func_code_string: #include <bits/stdc++.h>   using namespace std;   long long con[2][2005][2005] = {0};   long long add[2][2005][2005] = {0};   long long can[2][2005][2005] = {0};   long long MOD = 1e9 + 7;   char all[2005][2005];   long long how[2][2005][2005];   int main() {     long long N, M, i, j, k, t = 0, l, r;     scanf( %lld %lld , &N, &M);     for (i = 0; i < N; i++) scanf( %s , all[i]);     t = 0;     for (i = 0; i < M; i++)       if (all[0][i] ==  R ) t++;     for (i = 1; i < M - t; i++) add[0][0][i] = con[0][0][i] = 1;     t = 0;     for (i = 0; i < N; i++)       if (all[i][0] ==  R ) t++;     for (i = 1; i < N - t; i++) add[1][i][0] = con[1][i][0] = 1;     for (i = 0; i < N; i++) {       how[0][i][M] = 0;       for (j = M - 1; j >= 0; j--)         how[0][i][j] = how[0][i][j + 1] + (all[i][j] ==  R );     }     for (i = 0; i < M; i++) {       how[1][N][i] = 0;       for (j = N - 1; j >= 0; j--)         how[1][j][i] = how[1][j + 1][i] + (all[j][i] ==  R );     }     for (i = 1; i < N; i++) {       for (j = 1; j < M; j++) {         t = 0;         l = 0;         r = N + 1;         while ((r - l) > 1) {           if (how[1][(r + l) / 2][j] >= N - i)             l = (r + l) / 2;           else             r = (r + l) / 2;         }         if (l >= i)           con[1][i][j] = 0;         else           con[1][i][j] += (add[0][i - 1][j] - add[0][l][j] + con[0][l][j] + MOD);         con[1][i][j] %= MOD;         add[1][i][j] = (add[1][i][j - 1] + con[1][i][j]) % MOD;         t = 0;         l = 0;         r = M + 1;         while ((r - l) > 1) {           if (how[0][i][(r + l) / 2] >= M - j)             l = (r + l) / 2;           else             r = (r + l) / 2;         }         if (l >= j)           con[0][i][j] = 0;         else           con[0][i][j] += (add[1][i][j - 1] - add[1][i][l] + con[1][i][l] + MOD);         con[0][i][j] %= MOD;         add[0][i][j] = (add[0][i - 1][j] + con[0][i][j]) % MOD;       }     }     if (N == 1 && M == 1)       printf( 1 n );     else       printf( %lld n , (con[0][N - 1][M - 1] + con[1][N - 1][M - 1]) % MOD);     return 0;   }   