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

using namespace std;

typedef long long ll;



const int N = 100005;

int n, m, k;

vector<int> fr[N], bl[N];

int cc[N], sz[N];

bool vis[N];



void dfs(int u, int c) {

	vis[u] = 1;

	cc[u] = c;

	sz[c]++;

	for(auto& v : fr[u]) {

		if(!vis[v])

			dfs(v, c);

	}

}



int main() {

	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	cin >> n >> m >> k;

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

		int a, b; cin >> a >> b;

		fr[a].push_back(b);

		fr[b].push_back(a);

	}

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

		int a, b; cin >> a >> b;

		bl[a].push_back(b);

		bl[b].push_back(a);

	}



	int idx = 0;

	memset(vis, 0, sizeof vis);

	memset(sz, 0, sizeof sz);

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

		if(!vis[i])

			dfs(i, ++idx);

	}



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

		int ans = sz[cc[i]] - fr[i].size() - 1;

		for(auto& v : bl[i]) {

			if(cc[v] == cc[i]) ans--;

		}

		cout << ans << " ";

	}

	cout << '\n';



	return 0;

}

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

using namespace std;

typedef long long ll;

const int N=1e5+5;



int father[N],sum[N],ans[N];

int n,m,k,x,y;



int Findfather(int x){

    return father[x]==x?x:father[x]=Findfather(father[x]);

}



void Union(int a,int b){

    a=Findfather(a),b=Findfather(b);

    if(a!=b) father[b]=a,sum[a]+=sum[b];

}



void init(){

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

        father[i]=i,sum[i]=1;

}



int main(){

    scanf("%d%d%d",&n,&m,&k);

    init();

    while(m--){

        scanf("%d%d",&x,&y);

        ans[x]++,ans[y]++;

        Union(x,y);

    }

    while(k--){

        scanf("%d%d",&x,&y);

        if(Findfather(x)==Findfather(y)) ans[x]++,ans[y]++;

    }

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

        printf("%d ",sum[Findfather(i)]-ans[i]-1);

    }

    return 0;

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

#include<iostream>



#define INF 2100000000



using namespace std;



int minix(int a,int b,int c){

	if(b>=a && c>=a){

		return a;

	}

	if(a>=b && c>=b){

		return b;

	}

	if(b>=c && a>=c){

		return c;

	}

}



int main(){

	int n;

	int masu[1002][1002];

	int ura[1002][1002];

	char str[1002];

	while(1){

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

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

				masu[i][j]=0;

			}

		}

		scanf("%d",&n);

		if(n==0){

			break;

		}

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

			scanf("%s",str);

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

				if(str[j-1]=='.'){

					ura[i][j]=0;

				}else{

					ura[i][j]=1;

				}

			}

		}

		

		int maxi=0;

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

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

				if(ura[i][j]==0){

					masu[i][j]=minix(masu[i-1][j],masu[i][j-1],masu[i-1][j-1])+1;

					maxi=max(masu[i][j],maxi);

				}

			}

		}

		

		printf("%d\n",maxi);

	}

}

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

#include<iostream>



#define INF 2100000000



using namespace std;



int minix(int a,int b,int c){

	if(b>=a && c>=a){

		return a;

	}

	if(a>=b && c>=b){

		return b;

	}

	if(b>=c && a>=c){

		return c;

	}

}



int main(){

	int n;

	int masu[1002][1002];

	int ura[1002][1002];

	char str[1002];

	while(1){

		scanf("%d",&n);

		if(n==0){

			break;

		}

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

			scanf("%s",str);

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

				if(str[j-1]=='.'){

					ura[i][j]=0;

				}else{

					ura[i][j]=1;

				}

			}

		}

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

			masu[i][0]=masu[0][i]=0;

		}

		int maxi=0;

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

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

				if(ura[i][j]==0){

					masu[i][j]=minix(masu[i-1][j],masu[i][j-1],masu[i-1][j-1])+1;

					maxi=max(masu[i][j],maxi);

				}else{

					masu[i][j]=0;

				}

			}

		}

		

		printf("%d\n",maxi);

	}

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

#include<iostream>



#define INF 2100000000



using namespace std;



int minix(int a,int b,int c){

	if(b>=a && c>=a){

		return a;

	}

	if(a>=b && c>=b){

		return b;

	}

	if(b>=c && a>=c){

		return c;

	}

}



int main(){

	int n;

	int masu[1002][1002];

	int ura[1002][1002];

	char str[1002];

	while(1){

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

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

				masu[i][j]=0;

			}

		}

		scanf("%d",&n);

		if(n==0){

			break;

		}

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

			scanf("%s",str);

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

				if(str[j-1]=='.'){

					ura[i][j]=0;

				}else{

					ura[i][j]=1;

				}

			}

		}

		

		int maxi=0;

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

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

				if(ura[i][j]==0){

					masu[i][j]=minix(masu[i-1][j],masu[i][j-1],masu[i-1][j-1])+1;

					maxi=max(masu[i][j],maxi);

				}

			}

		}

		

		printf("%d\n",maxi);

	}

}

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

#include<iostream>



#define INF 2100000000



using namespace std;



int minix(int a,int b,int c){

	if(b>=a && c>=a){

		return a;

	}

	if(a>=b && c>=b){

		return b;

	}

	if(b>=c && a>=c){

		return c;

	}

}



int main(){

	int n,maxi,i,j;

	int masu[1002][1002];

	int ura[1002][1002];

	char str[1002];

	while(1){

		scanf("%d",&n);

		if(n==0){

			break;

		}

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

			scanf("%s",str);

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

				if(str[j-1]=='.'){

					ura[i][j]=0;

				}else{

					ura[i][j]=1;

				}

			}

		}

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

			masu[i][0]=masu[0][i]=0;

		}

		maxi=0;

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

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

				if(ura[i][j]==0){

					masu[i][j]=minix(masu[i-1][j],masu[i][j-1],masu[i-1][j-1])+1;

					maxi=max(masu[i][j],maxi);

				}else{

					masu[i][j]=0;

				}

			}

		}

		

		printf("%d\n",maxi);

	}

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

using namespace std;

#define print printf("==================\n")

#define ll long long

#define pi acos(-1.0)

#define eps 1e-16

#define max3(a,b,c) max(a,max(b,c))

const ll INF = 1 << 30;

#define mod 1000000007

typedef pair<double, double  > payar;

typedef struct

{

    ll  x, y;

} point;

priority_queue<payar, vector<payar>,  greater<payar> > pq; ///accending

vector< pair<double,payar  > > vpp;

vector < payar >  vp;

char ara[1006][1006];

ll dp[1006][1005];

int n, m ;

ll cal(int i, int j )

{

    if(i>n or j>m )

        return 0;

    if(i==n and j==m)

        return 1;

    if(ara[i][j]=='#')

        return 0 ;

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

        return dp[i][j]%mod;

    return dp[i][j]= (cal(i+1,j)%mod+cal(i,j+1)%mod)%mod;





}

int main()

{





    cin>>n>>m;

    memset(dp,-1,sizeof dp);

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

    {

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

        {

            cin>>ara[i][j];

        }

    }

    cout<<cal(1,1);



    return  0 ;

}


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



using namespace std;

 

typedef long long ll;

typedef long double ld;

typedef unsigned long long ull;

 

#define nl '\n'

 

#define y1 aza_ibagaliev

 

#define f first

#define s second

	

#define ed end()

#define bg begin()

#define rbg rbegin()

 

#define rv reverse

#define mp make_pair

#define pb push_back

#define ppb pop_back

#define ppf pop_front

 

#define sz size()

#define all(x) x.bg, x.ed

 

#define pll pair < ll, ll >

#define pii pair < int, int >

 

#define sqr(x) ((x) * 1ll * (x))

#define sqrd(x) ((x) * 1.0 * (x))

 

#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

 

#define rnl cout << "----------------------------------------" << nl

 

#define bit __builtin_popcount

 

inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}

        	

const int ppr = 257;

const ll INF = 2e18;

const int inf = 2e9;

const int mod = 1e9 + 7;

const int N = 1e5 + 123;

const ld pi = 3.1741592653589793238462643;

 

const int dx[] = {1, 0, -1, 0};

const int dy[] = {0, 1, 0, -1};



int n, m, dp[1005][1005];

char c[1005][1005];



main() {             	

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

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



//	srand(time(NULL));



	cin >> n >> m;



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

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

			cin >> c[i][j];



	dp[1][1] = 1;



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

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

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

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

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

		}



	cout << dp[n][m];

	        	



    return 0;                                        

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

using namespace std;

#define print printf("==================\n")

#define ll long long

#define pi acos(-1.0)

#define eps 1e-16

#define max3(a,b,c) max(a,max(b,c))

const ll INF = 1 << 30;

#define mod 1000000007

typedef pair<double, double  > payar;

typedef struct

{

    ll  x, y;

} point;

priority_queue<payar, vector<payar>,  greater<payar> > pq; ///accending

vector< pair<double,payar  > > vpp;

vector < payar >  vp;

char ara[1006][1006];

ll dp[1006][1005];

int n, m ;

ll cal(int i, int j )

{

    if(i>n or j>m )

        return 0;

    if(i==n and j==m)

        return 1;

    if(ara[i][j]=='#')

        return 0 ;

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

        return dp[i][j]%mod;

    return dp[i][j]= (cal(i+1,j)%mod+cal(i,j+1)%mod)%mod;





}

int main()

{





    cin>>n>>m;

    memset(dp,-1,sizeof dp);

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

    {

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

        {

            cin>>ara[i][j];

        }

    }

    cout<<cal(1,1);



    return  0 ;

}


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



#define Solved int main()

#define pb push_back

#define mp make_pair

#define F first

#define S second

#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define forn(i, n) for(int i = 1; i <= n; i++)

#define rep(i, x, y) for(int i = x; i <= y; i++)

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

#define pii pair<int, int>

#define ll long long

#define ull unsigned long long

#define ld long double

#define mii map<int, int>

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

#define lb lower_bound

#define ub upper_bound

using namespace std;



inline ll bip(ll x,ll n,ll mod){ll res=1;while(n){if(n&1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}



const int maxn = 1e9;

const ll inf = 1e18;

//const int mod = 998244353;

const int mod = 1e9 + 7;

const int N = 1e5 + 10;



int n, m, dp[1010][1010];

char a[1010][1010];



void solve() {

    cin >> n >> m;



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

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

            cin >> a[i][j];



    dp[1][1] = 1;

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

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

            if (i + j == 2) continue;



            if (a[i - 1][j] != '#') dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;

            if (a[i][j - 1] != '#') dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;

        }

    }

    cout << dp[n][m];

}



Solved {

    SpeedForce;

	int tt = 1;

    //cin >> tt;

	while (tt--) {

		solve();

		cout << '\n';

	}



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

using namespace std;

#define print printf("==================\n")

#define ll long long

#define pi acos(-1.0)

#define eps 1e-16

#define max3(a,b,c) max(a,max(b,c))

const ll INF = 1 << 30;

#define mod 1000000007

typedef pair<double, double  > payar;

typedef struct

{

    ll  x, y;

} point;

priority_queue<payar, vector<payar>,  greater<payar> > pq; ///accending

vector< pair<double,payar  > > vpp;

vector < payar >  vp;

char ara[1006][1006];

ll dp[1006][1005];

int n, m ;

ll cal(int i, int j )

{

    if(i>n or j>m )

        return 0;

    if(i==n and j==m)

        return 1;

    if(ara[i][j]=='#')

        return 0 ;

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

        return dp[i][j]%mod;

    return dp[i][j]= (cal(i+1,j)%mod+cal(i,j+1)%mod)%mod;





}

int main()

{





    cin>>n>>m;

    memset(dp,-1,sizeof dp);

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

    {

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

        {

            cin>>ara[i][j];

        }

    }

    cout<<cal(1,1);



    return  0 ;

}


// Faster C++ solution for the same problem (measured speedup: 1.8411385723003177x):
#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

#include<unordered_map>

#include<unordered_set>	

using namespace std;

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

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

#define clr(v, d)		memset(v, d, sizeof(v))

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

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

typedef long long         ll;

const double EPS = (1e-7);

int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }

#define pb					push_back

#define P(x)				cout<<#x<<" = { "<<x<<" }\n"

clock_t T;

#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl

void GOAT()

{

	std::ios_base::sync_with_stdio(0);

	cin.tie(NULL);

	cout.tie(NULL);

#ifndef ONLINE_JUDGE

	freopen("in.txt", "r", stdin);

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

#else

#endif



}

int r, c;

char grid[1007][1007];

int mem[1007][1007];

bool valid(int i, int j)

{

	return (i < r && j < c);

}

const int m = 1e9 + 7;

int solve(int i, int j)

{

	if (i == r - 1 && j == c - 1)return 1;

	int& ret = mem[i][j];

	if (~ret)return ret;

	ret = 0;

	if (valid(i, j + 1) && grid[i][j + 1] != '#')ret=((ret%m)+(solve(i, j + 1)%m))%m;

	if (valid(i + 1, j) && grid[i + 1][j] != '#')ret = ((ret % m) + (solve(i+1, j) % m)) % m;

	return ret%m;

}

int main() {

	//GOAT();

	

		clr(mem, -1);

		cin >> r >> c;

		for (int i = 0; i < r; i++)

		{

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

			{

				cin>>grid[i][j];

			}

		}

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

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

using namespace std;

#define print printf("==================\n")

#define ll long long

#define pi acos(-1.0)

#define eps 1e-16

#define max3(a,b,c) max(a,max(b,c))

const ll INF = 1 << 30;

#define mod 1000000007

typedef pair<double, double  > payar;

typedef struct

{

    ll  x, y;

} point;

priority_queue<payar, vector<payar>,  greater<payar> > pq; ///accending

vector< pair<double,payar  > > vpp;

vector < payar >  vp;

char ara[1006][1006];

ll dp[1006][1005];

int n, m ;

ll cal(int i, int j )

{

    if(i>n or j>m )

        return 0;

    if(i==n and j==m)

        return 1;

    if(ara[i][j]=='#')

        return 0 ;

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

        return dp[i][j]%mod;

    return dp[i][j]= (cal(i+1,j)%mod+cal(i,j+1)%mod)%mod;





}

int main()

{





    cin>>n>>m;

    memset(dp,-1,sizeof dp);

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

    {

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

        {

            cin>>ara[i][j];

        }

    }

    cout<<cal(1,1);



    return  0 ;

}


// Faster C++ solution for the same problem (measured speedup: 9.377067603040448x):
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;

using namespace std;

const int N = 1e3 + 5;

const int mod = 1e9 + 7;

int h , w;

int dp[N][N];

char a[N][N];

int main() {

    abdelrahman010

    cin >> h >> w;

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

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

            cin >> a[i][j];

    dp[0][1] = 1;

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

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

            int &ans = dp[i][j];

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

                ans = 0;

                continue;

            }

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

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

        }

    cout << dp[h][w];

    return 0;

}
// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

#include<unordered_map>

#include<unordered_set>	

using namespace std;

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

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

#define clr(v, d)		memset(v, d, sizeof(v))

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

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

typedef long long         ll;

const double EPS = (1e-7);

int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }

#define pb					push_back

#define P(x)				cout<<#x<<" = { "<<x<<" }\n"

clock_t T;

#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl

void GOAT()

{

	std::ios_base::sync_with_stdio(0);

	cin.tie(NULL);

	cout.tie(NULL);

#ifndef ONLINE_JUDGE

	freopen("in.txt", "r", stdin);

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

#else

#endif



}

int r, c;

char grid[1007][1007];

int mem[1007][1007];

bool valid(int i, int j)

{

	return (i < r && j < c);

}

const int m = 1e9 + 7;

int solve(int i, int j)

{

	if (i == r - 1 && j == c - 1)return 1;

	int& ret = mem[i][j];

	if (~ret)return ret;

	ret = 0;

	if (valid(i, j + 1) && grid[i][j + 1] != '#')ret=((ret%m)+(solve(i, j + 1)%m))%m;

	if (valid(i + 1, j) && grid[i + 1][j] != '#')ret = ((ret % m) + (solve(i+1, j) % m)) % m;

	return ret%m;

}

int main() {

	//GOAT();

	

		clr(mem, -1);

		cin >> r >> c;

		for (int i = 0; i < r; i++)

		{

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

			{

				cin>>grid[i][j];

			}

		}

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

}

// Faster C++ solution for the same problem (measured speedup: 5.093080849055671x):
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;

using namespace std;

const int N = 1e3 + 5;

const int mod = 1e9 + 7;

int h , w;

int dp[N][N];

char a[N][N];

int main() {

    abdelrahman010

    cin >> h >> w;

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

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

            cin >> a[i][j];

    dp[0][1] = 1;

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

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

            int &ans = dp[i][j];

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

                ans = 0;

                continue;

            }

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

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

        }

    cout << dp[h][w];

    return 0;

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

using namespace std;

#define print printf("==================\n")

#define ll long long

#define pi acos(-1.0)

#define eps 1e-16

#define max3(a,b,c) max(a,max(b,c))

const ll INF = 1 << 30;

#define mod 1000000007

typedef pair<double, double  > payar;

typedef struct

{

    ll  x, y;

} point;

priority_queue<payar, vector<payar>,  greater<payar> > pq; ///accending

vector< pair<double,payar  > > vpp;

vector < payar >  vp;

char ara[1006][1006];

ll dp[1006][1005];

int n, m ;

ll cal(int i, int j )

{

    if(i>n or j>m )

        return 0;

    if(i==n and j==m)

        return 1;

    if(ara[i][j]=='#')

        return 0 ;

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

        return dp[i][j]%mod;

    return dp[i][j]= (cal(i+1,j)%mod+cal(i,j+1)%mod)%mod;





}

int main()

{





    cin>>n>>m;

    memset(dp,-1,sizeof dp);

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

    {

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

        {

            cin>>ara[i][j];

        }

    }

    cout<<cal(1,1);



    return  0 ;

}


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



int mod = 1000000007;

int dp[1001][1001];



int main()

{

	int n, m;

	std::cin >> n >> m;

	char c;

	std::cin >> c;

	dp[0][0] = 1;

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

	{

		std::cin >> c;

		if (c == '.')

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

	}

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

	{

		std::cin >> c;

		if (c == '.')

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

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

		{

			std::cin >> c;

			if (c == '.')

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

		}

	}

	std::cout << dp[n - 1][m - 1] << '\n';

	return 0;

}
// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

#include<unordered_map>

#include<unordered_set>	

using namespace std;

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

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

#define clr(v, d)		memset(v, d, sizeof(v))

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

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

typedef long long         ll;

const double EPS = (1e-7);

int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }

#define pb					push_back

#define P(x)				cout<<#x<<" = { "<<x<<" }\n"

clock_t T;

#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl

void GOAT()

{

	std::ios_base::sync_with_stdio(0);

	cin.tie(NULL);

	cout.tie(NULL);

#ifndef ONLINE_JUDGE

	freopen("in.txt", "r", stdin);

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

#else

#endif



}

int r, c;

char grid[1007][1007];

int mem[1007][1007];

bool valid(int i, int j)

{

	return (i < r && j < c);

}

const int m = 1e9 + 7;

int solve(int i, int j)

{

	if (i == r - 1 && j == c - 1)return 1;

	int& ret = mem[i][j];

	if (~ret)return ret;

	ret = 0;

	if (valid(i, j + 1) && grid[i][j + 1] != '#')ret=((ret%m)+(solve(i, j + 1)%m))%m;

	if (valid(i + 1, j) && grid[i + 1][j] != '#')ret = ((ret % m) + (solve(i+1, j) % m)) % m;

	return ret%m;

}

int main() {

	//GOAT();

	

		clr(mem, -1);

		cin >> r >> c;

		for (int i = 0; i < r; i++)

		{

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

			{

				cin>>grid[i][j];

			}

		}

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

}

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



int mod = 1000000007;

int dp[1001][1001];



int main()

{

	int n, m;

	std::cin >> n >> m;

	char c;

	std::cin >> c;

	dp[0][0] = 1;

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

	{

		std::cin >> c;

		if (c == '.')

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

	}

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

	{

		std::cin >> c;

		if (c == '.')

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

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

		{

			std::cin >> c;

			if (c == '.')

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

		}

	}

	std::cout << dp[n - 1][m - 1] << '\n';

	return 0;

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

using namespace std;

#define print printf("==================\n")

#define ll long long

#define pi acos(-1.0)

#define eps 1e-16

#define max3(a,b,c) max(a,max(b,c))

const ll INF = 1 << 30;

#define mod 1000000007

typedef pair<double, double  > payar;

typedef struct

{

    ll  x, y;

} point;

priority_queue<payar, vector<payar>,  greater<payar> > pq; ///accending

vector< pair<double,payar  > > vpp;

vector < payar >  vp;

char ara[1006][1006];

ll dp[1006][1005];

int n, m ;

ll cal(int i, int j )

{

    if(i>n or j>m )

        return 0;

    if(i==n and j==m)

        return 1;

    if(ara[i][j]=='#')

        return 0 ;

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

        return dp[i][j]%mod;

    return dp[i][j]= (cal(i+1,j)%mod+cal(i,j+1)%mod)%mod;





}

int main()

{





    cin>>n>>m;

    memset(dp,-1,sizeof dp);

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

    {

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

        {

            cin>>ara[i][j];

        }

    }

    cout<<cal(1,1);



    return  0 ;

}


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



using namespace std;

typedef long long ll;



const int N = 1007, M = 1e9 + 7;



char mat[N][N];





int memo[N][N];

int n, m;



int solve(int i, int j) {

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

    if(i >= n or j >= m) return 0;



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

    

    int & st = memo[i][j];

    if(st == -1) {

        st = solve(i+1, j) + solve(i, j+1);

        st %= M;

    }

    return st;

}



int main() {

    memset(memo, -1, sizeof memo);

    cin >> n >> m;



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

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

            cin >> mat[i][j];

        }

    }



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

}