malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long mod = (1e9 + 7);   const long long inf = (1e18 + 3);   const long long N = 1e7 + 5;   void no() {     cout <<  -1 ;     exit(0);   }   void yes() {     cout <<  YES ;     exit(0);   }   long long powmod(long long a, long long b) {     long long res = 1;     a %= mod;     assert(b >= 0);     for (; b; b >>= 1) {       if (b & 1) res = res * a % mod;       a = a * a % mod;     }     return res;   }   long long inv(long long a) { return powmod(a, mod - 2); }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long mul(long long a, long long b) { return a * b % mod; }   long long add(long long a, long long b) { return (a + b) % mod; }   long long sub(long long a, long long b) { return (a - b + mod) % mod; }   int main() {     string s;     cin >> s;     long long cnt = 1, res = 0;     for (auto i : s) {       if (i ==  a )         cnt <<= 1, cnt %= mod;       else         res = add(res, cnt - 1);     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool checkC(int n) {     for (int i = 2; i * i <= n; i++) {       if (n % i == 0) return 1;     }     return 0;   }   void per(string s, int i, int &num, string &ans) {     if (i == s.length()) {       if (num != 0 && checkC(num)) {         int x = num;         int d = 0;         while (x != 0) {           x /= 10;           d++;         }         if (d > 0) {           if (d < ans.length() || ans.length() == 0) ans = to_string(num);         }       }     } else {       int k = num;       num = num * 10 + (s[i] -  0 );       per(s, i + 1, num, ans);       num = k;       per(s, i + 1, num, ans);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int test;     cin >> test;     while (test--) {       int k;       cin >> k;       string s;       cin >> s;       vector<int> c(10, 0);       int ans = -1;       for (int i = 0; i < k; i++) {         int vl = s[i] -  0 ;         if (vl == 1 || vl == 4 || vl == 6 || vl == 8 || vl == 9) {           ans = vl;           break;         }         c[vl]++;       }       if (ans != -1) {         cout <<  1 n ;         cout << ans <<   n ;       } else {         if (c[2] >= 2) {           cout <<  2 n ;           cout <<  22 n ;         } else if (c[3] >= 2) {           cout <<  2 n ;           cout <<  33 n ;         } else if (c[5] >= 2) {           cout <<  2 n ;           cout <<  55 n ;         } else if (c[7] >= 2) {           cout <<  2 n ;           cout <<  77 n ;         } else {           string pa =   ;           int num = 0;           per(s, 0, num, pa);           cout << pa.length() <<   n ;           cout << pa <<   n ;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 500010;   const int inf = 2147483647;   const double pi = acos(-1.0);   int read() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return x * f;   }   int n, m, k, a[Maxn];   long long ans, rest;   bool del[Maxn];   struct Edge {     int x, y;   } e[Maxn];   int fa[Maxn << 1], dep[Maxn << 1];   int findfa(int x) { return ((fa[x] == x) ? x : findfa(fa[x])); }   int top = 0, sta[Maxn << 1], o, fa1[Maxn << 1], dep1[Maxn << 1];   void merge(int x, int y) {     int fx = findfa(x), fy = findfa(y);     if (dep[fx] < dep[fy]) swap(fx, fy);     sta[++top] = fy;     fa1[top] = fa[fy], dep1[top] = dep[fx];     fa[fy] = fx;     dep[fx] = max(dep[fx], dep[fy] + 1);   }   void resume() {     while (top > o) {       int fy = sta[top];       dep[fa[fy]] = dep1[top];       fa[fy] = fa1[top];       --top;     }   }   vector<pair<int, int> > g[Maxn];   int tot = 0;   map<int, map<int, int> > mp;   int main() {     memset(dep, 0, sizeof(dep));     memset(del, false, sizeof(del));     n = read(), m = read(), k = read();     ans = (long long)k * (k - 1ll) / 2ll;     rest = k - 1;     for (int i = 1; i <= n; i++) a[i] = read();     for (int i = 1; i <= m; i++) e[i].x = read(), e[i].y = read();     for (int i = 1; i <= n * 2; i++) fa[i] = i;     for (int i = 1; i <= m; i++)       if (!del[a[e[i].x]] && a[e[i].x] == a[e[i].y]) {         int fx = findfa(e[i].x), fy = findfa(e[i].y);         if (fx == fy)           del[a[e[i].x]] = true, ans -= rest, rest--;         else           merge(e[i].x, e[i].y + n), merge(e[i].y, e[i].x + n);       }     o = top;     for (int i = 1; i <= m; i++)       if (a[e[i].x] != a[e[i].y] && !del[a[e[i].x]] && !del[a[e[i].y]]) {         int cx = a[e[i].x], cy = a[e[i].y];         if (cx > cy) swap(cx, cy);         if (!mp[cx][cy]) mp[cx][cy] = ++tot;         g[mp[cx][cy]].push_back(make_pair(e[i].x, e[i].y));       }     for (int i = 1; i <= tot; i++) {       for (int j = 0; j < g[i].size(); j++) {         int x = g[i][j].first, y = g[i][j].second;         int fx = findfa(x), fy = findfa(y);         if (fx == fy) {           ans--;           break;         }         merge(x, y + n);         merge(y, x + n);       }       resume();     }     printf( %lld , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b, c, l;     cin >> a >> b >> c >> l;     long long cnt = (l + 1) * (l + 2) * (l + 3) / 6;     for (int i = 0; i <= l; i++) {       long long x = min(l - i, c + i - a - b);       if (x < 0) continue;       cnt -= (x + 1) * (x + 2) / 2;     }     for (int i = 0; i <= l; i++) {       long long x = min(l - i, b + i - a - c);       if (x < 0) continue;       cnt -= (x + 1) * (x + 2) / 2;     }     for (int i = 0; i <= l; i++) {       long long x = min(l - i, a + i - b - c);       if (x < 0) continue;       cnt -= (x + 1) * (x + 2) / 2;     }     cout << cnt << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000007;   const long long INFLL = 1000000000000000007;   const long long MOD = 998244353;   bool comp(long long a, long long b) { return a > b; }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int n, k;     cin >> n >> k;     vector<long long> v;     for (int i = 0; i < n; i++) {       long long x;       cin >> x;       v.push_back(x);     }     long long ans = 0, ans1 = 1, licz = -INFLL;     for (int i = 0; i < n; i++) {       if (v[i] <= n - k)         licz++;       else {         if (licz > 0) ans1 *= (licz + 1);         ans1 %= MOD;         ans += v[i];         licz = 0;       }     }     cout << ans <<     << ans1;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   using namespace std;   const int MOD = 1e9 + 7;   const long long INF = 1e18;   long long add(long long a, long long b) {     a = a % MOD;     b = b % MOD;     return (a + b) % MOD;   }   long long sub(long long a, long long b) {     a = a % MOD;     b = b % MOD;     return (a - b + MOD) % MOD;   }   long long mul(long long a, long long b) {     a = a % MOD;     b = b % MOD;     return ((a * b) % MOD + MOD) % MOD;   }   long long mod_pow(long long n, long long x) {     int res = 1;     while (x > 0) {       if (x % 2 == 1) res = (res * n) % MOD;       n = (n * n) % MOD;       x /= 2;     }     return res;   }   void solve() {     string t, order =   ;     cin >> t;     map<char, int> m;     int n = 0;     for (int i = t.size() - 1; i >= 0; i--) {       if (m[t[i]] == 0) {         order = t[i] + order;       }       m[t[i]]++;     }     for (int i = 0; i < order.size(); i++) {       m[order[i]] /= (i + 1);       n += m[order[i]];     }     string s = t.substr(0, n);     string sc = s;     bool temp = true;     int ind = n;     for (int i = 0; i < order.size(); i++) {       string temp =   ;       for (int j = 0; j < s.size(); j++) {         if (s[j] == order[i]) continue;         temp += s[j];       }       s = temp;       for (int j = 0; j < s.size(); j++) {         if (ind == t.size() || t[ind] != s[j]) {           cout <<  -1 n ;           return;         }         ind++;       }     }     if (ind != t.size()) temp = false;     if (temp) {       cout << sc <<     << order <<   n ;     } else {       cout <<  -1 n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int tc = 1;     cin >> tc;     while (tc--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   void c_p_c() {}   int main(int argc, char const *argv[]) {     c_p_c();     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int n;     string arr;     cin >> n >> arr;     int cnt = 0;     if (n == 1) {       cout << cnt << endl;       cout << arr << endl;       return 0;     }     for (int i = 1; i < n; i++) {       if (arr[i] == arr[i - 1] && arr[i] == arr[i + 1]) {         cnt++;         if (arr[i] ==  R )           arr[i] =  G ;         else if (arr[i] ==  G )           arr[i] =  R ;         else {           arr[i] =  G ;         }         i++;       } else if (arr[i] == arr[i - 1]) {         cnt++;         if (arr[i] ==  R  && arr[i + 1] ==  B ) {           arr[i] =  G ;           i++;         } else if (arr[i] ==  R  && arr[i + 1] ==  G ) {           arr[i] =  B ;           i++;         } else if (arr[i] ==  G  && arr[i + 1] ==  R ) {           arr[i] =  B ;           i++;         } else if (arr[i] ==  G  && arr[i + 1] ==  B ) {           arr[i] =  R ;           i++;         } else if (arr[i] ==  B  && arr[i + 1] ==  G ) {           arr[i] =  R ;           i++;         } else if (arr[i] ==  B  && arr[i + 1] ==  R ) {           arr[i] =  G ;           i++;         } else {           if (arr[i - 1] ==  R )             arr[i] =  G ;           else if (arr[i - 1] ==  G )             arr[i] =  R ;           else             arr[i] =  R ;         }       }     }     cout << cnt << endl;     cout << arr << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long infll = powl(2, 62) - 1;   const long long mod = pow(10, 9) + 7;   int64_t extGcd(int64_t a, int64_t b, int64_t& x, int64_t& y) {     if (!a) {       x = 0;       y = 1;       return b;     }     int64_t x1, y1;     int64_t d = extGcd(b % a, a, x1, y1);     x = y1 - (b / a) * x1;     y = x1;     return d;   }   inline long long addMod(long long a, long long b, long long m = mod) {     return ((int64_t)a + b) % m;   }   inline long long mulMod(long long a, long long b, long long m = mod) {     return ((int64_t)a * b) % m;   }   inline long long divMod(long long a, long long b, long long m = mod) {     int64_t x, y;     int64_t g = extGcd(b, m, x, y);     if (g != 1) {       cerr <<  Bad gcd!  << endl;       for (;;)         ;     }     x = (x % m + m) % m;     return mulMod(a, x, m);   }   const long long factRange = 1000000;   long long fact[factRange];   inline void precalcFactorials() {     fact[0] = 1;     for (long long i = 1; i < factRange; i++) {       fact[i] = mulMod(fact[i - 1], i);     }   }   inline long long F(long long n) { return (n < 0) ? 0 : fact[n]; }   inline long long C(long long n, long long k) {     return divMod(F(n), mulMod(F(n - k), F(k)));   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     precalcFactorials();     string bracket;     cin >> bracket;     vector<long long> open(bracket.size()), close(bracket.size());     long long count = 0;     for (long long i = 0; i < (long long)(bracket.size()); ++i) {       if (bracket[i] ==  ( ) count++;       open[i] = count;     }     count = 0;     for (long long i = (long long)(bracket.size()) - 1; i >= 0; --i) {       if (bracket[i] ==  ) ) count++;       close[i] = count;     }     long long ans = 0;     for (long long i = 0; i < (long long)(bracket.size()); ++i) {       if (bracket[i] !=  (  || close[i] == 0) continue;       if (bracket[i] ==  ( ) {         ans += C(open[i] + close[i] - 1, open[i]);         ans %= mod;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void Input_Preparing() {}   void Processing() {     int a, b;     cin >> a >> b;     cout << min(a, b) <<     << (max(a, b) - min(a, b)) / 2;   }   int main() {     std::cin.tie(0)->sync_with_stdio(0);     ;     Processing();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int l[(100000 + 10)], size = 0;   int fa[(100000 + 10)], son[(100000 + 10)], n, x, spec, specp;   bool b[(100000 + 10)] = {0}, f[(100000 + 10)] = {0};   int main() {     scanf( %d%d , &n, &x);     for (int i = 1; i <= n; i++) scanf( %d , &fa[i]);     for (int i = 1; i <= n; i++)       if (fa[i]) son[fa[i]] = i;     for (int i = 1; i <= n; i++)       if (fa[i] == 0) {         int tot = 1, j = i;         bool flag = b[x];         b[i] = 1;         j = i;         if (i == x) spec = 1;         while (son[j]) {           b[son[j]] = 1, tot++, j = son[j];           if (j == x) spec = tot;         }         if (b[x] == flag)           l[++size] = tot;         else           specp = spec;       }     f[0] = 1;     for (int i = 1; i <= size; i++) {       for (int j = n; j >= 0; j--) {         if (f[j]) f[j + l[i]] = 1;       }     }     for (int j = 0; j < n + 1; j++)       if (f[j]) cout << j + specp << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string to_string(string s) { return     + s +    ; }   string to_string(const char* s) { return to_string((string)s); }   template <typename A, typename B>   string to_string(pair<A, B> p) {     return  (  + to_string(p.first) +  ,   + to_string(p.second) +  ) ;   }   template <typename A>   string to_string(A v) {     bool first = true;     string res =  { ;     for (const auto& x : v) {       if (!first) {         res +=  ,  ;       }       first = false;       res += to_string(x);     }     res +=  } ;     return res;   }   void debug_out() { cerr << endl; }   template <typename Head, typename... Tail>   void debug_out(Head H, Tail... T) {     cerr <<     << to_string(H);     debug_out(T...);   }   const long double eps = 1e-12;   const int N = 2e6 + 9;   long long ans[N];   pair<pair<int, int>, int> a[N];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> a[i].first.first;       a[i].second = i;     }     for (int i = 0; i < n; i++) {       cin >> a[i].first.second;       a[i].first.second *= -1;     }     sort(a, a + n);     multiset<int> ss;     for (int i = 0; i < n; i++) {       42;       int j = 0;       auto it = ss.begin();       ans[a[i].second] = a[i].first.second;       while (j < m && it != ss.end()) {         ans[a[i].second] += (*it);         it++;         j++;       }       ss.insert(a[i].first.second);     }     for (int i = 0; i < n; i++) cout << -ans[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[200001];   int main() {     int n, w;     cin >> n >> w;     for (int i = 0; i < 2 * n; i++) {       cin >> a[i];     }     sort(a, a + 2 * n);     double x = min((double)a[0], (double)a[n] / 2);     double ans = min((double)w, (double)3 * n * x);     cout.precision(10);     cout << fixed;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   const int mod = 1e9 + 7;   void solve() {     long long v1, v2, t, d;     cin >> v1 >> v2 >> t >> d;     long long ans = 0;     for (int i = 0; i < t; i++) ans += min(v1 + d * i, v2 + (t - i - 1) * d);     cout << ans << endl;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     for (long long i = 0; i < n; i++) {       for (long long j = 0; j < n; j++) {         if (i % 2 == 0 && j % 2 == 0 || i % 2 == 1 && j % 2 == 1)           cout <<  W ;         else           cout <<  B ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<long long, long long> > v(3000);   int main() {     std::ios::sync_with_stdio(false);     long long n, x1, y1, x2, y2, x, y;     cin >> n;     cin >> x1 >> y1 >> x2 >> y2;     long long d1, d2;     for (long long i = (long long)(0); i <= (long long)(n - 1); i++) {       cin >> x >> y;       v[i].first = abs(x - x1) * abs(x - x1) + abs(y - y1) * abs(y - y1);       v[i].second = abs(x - x2) * abs(x - x2) + abs(y - y2) * abs(y - y2);     }     v.push_back(make_pair(0, 0));     long long ans = LLONG_MAX;     for (long long i = (long long)(0); i <= (long long)(n); i++) {       long long d1 = v[i].first;       long long d2 = 0;       for (long long j = (long long)(0); j <= (long long)(n); j++) {         if (v[j].first > d1) d2 = max(v[j].second, d2);       }       ans = min(ans, d1 + d2);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int rbq[505][505];   int score[505];   int main() {     int n, m, q;     while (~scanf( %d%d%d , &n, &m, &q)) {       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= m; j++) {           scanf( %d , &rbq[i][j]);         }       }       for (int i = 1; i <= n; i++) {         int max = 0;         for (int j = 1; j <= m; j++) {           int count = 0;           while (j <= m && rbq[i][j] == 1) {             j++;             count++;           }           if (count > max) max = count;         }         score[i] = max;       }       for (int i = 0; i < q; i++) {         int r, l;         scanf( %d%d , &r, &l);         if (rbq[r][l] == 0)           rbq[r][l] = 1;         else           rbq[r][l] = 0;         int max = 0;         for (int j = 1; j <= m; j++) {           int count = 0;           while (j <= m && rbq[r][j] == 1) {             j++;             count++;           }           if (count > max) max = count;         }         score[r] = max;         int max_score = 0;         for (int j = 1; j <= n; j++) {           if (score[j] > max_score) max_score = score[j];         }         printf( %d n , max_score);       }     }     return 0;   }
#include <bits/stdc++.h>   #define f(c,a,b) for(int c=a; c<=b; c++)   #define N 5000010   #define pii pair<int,int>   #define mp make_pair   #define fi first   #define se second   #define sl (u<<1)   #define sr ((u<<1)+1)   #define pb push_back      using namespace std;   typedef double db;   typedef long long ll;   struct node{    int u,v,x;    bool operator < (const node& a) const{ return x<a.x; }   }b[N];   int k[N];      bool ask(int i,int j){    cout<< ?  <<i<<   <<j<<endl;    string ans;    cin>>ans;    if(ans== Yes ) return true; else return false;   }      int main(){    // freopen( owo.in , r ,stdin);    // ios::sync_with_stdio(false);    // cin.tie(nullptr);    int n;    cin >> n;    f(i,1,n) cin>>k[i];    int id=0;    f(i,1,n){     f(j,i+1,n){      b[++id] = (node){ i,j,abs(k[i]-k[j]) };     }    }    sort(b+1,b+id+1);    for(int i=id; i>=1; i--) {     int ti=b[i].u, tj=b[i].v;     if(k[ti]>k[tj]) {      if(ask(ti,tj)){       cout<< !  <<ti<<   <<tj<<endl;       return 0;      }     }else{      if(ask(tj,ti)){       cout<< !  <<ti<<   <<tj<<endl;       return 0;      }      }    }    cout<< !  <<0<<   <<0<<endl;    return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 512345, lgN = 20, rootN = 1123;   const double eps = 1e-11;   vector<int> cities;   int root = -1;   int dp[N];   bool visited[N], rem[N];   vector<int> adj[N];   void dfsTree(int v) {     int sum = 0;     auto it = lower_bound(cities.begin(), cities.end(), v);     if (it < cities.end() && *it == v) ++sum;     for (int i = 0; i < adj[v].size(); ++i) {       int u = adj[v][i];       if (visited[u]) continue;       visited[u] = true;       dfsTree(u);       sum += dp[u];     }     if (sum == 0)       rem[v] = true;     else if (sum == cities.size() && root == -1)       root = v;     else if (sum == cities.size())       rem[v] = true;     dp[v] = sum;   }   pair<int, int> bfsDistance(int src) {     memset(visited, false, sizeof visited);     queue<pair<int, int> > q;     q.push(make_pair(src, 0));     visited[src] = true;     pair<int, int> ret = make_pair(src, 0);     while (!q.empty()) {       int v = q.front().first, dist = q.front().second;       q.pop();       if (dist > ret.second || (dist == ret.second && v < ret.first))         ret = make_pair(v, dist);       for (int i = 0; i < adj[v].size(); ++i) {         int u = adj[v][i];         if (visited[u] || rem[u]) continue;         visited[u] = true;         q.push(make_pair(u, dist + 1));       }     }     return ret;   }   int main() {     int n, c;     scanf( %d %d , &n, &c);     int u, v;     for (int i = 1; i < n; ++i) {       scanf( %d %d , &u, &v);       adj[u].push_back(v), adj[v].push_back(u);     }     cities.resize(c);     for (int i = 0; i < cities.size(); ++i) scanf( %d , &cities[i]);     sort(cities.begin(), cities.end());     visited[1] = true;     dfsTree(1);     pair<int, int> x = bfsDistance(root);     pair<int, int> y = bfsDistance(x.first);     printf( %d n , min(x.first, y.first));     int ct = 0;     for (int i = 1; i <= n; ++i)       if (!rem[i]) ++ct;     int ans = 2 * (ct - 1) - y.second;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int f[200010], fi[200010];   const int MOD = 1e9 + 7;   int add(long long a, long long b) { return (a + b) % MOD; }   int mul(long long a, long long b) { return (a * b) % MOD; }   int fp(long long a, int b) {     if (b == 0) return 1;     int tp = fp(a, b >> 1);     tp = mul(tp, tp);     if (b & 1)       return mul(tp, a);     else       return tp;   }   int comb(int n, int k) {     if (k > n) return 0;     return mul(f[n], mul(fi[n - k], fi[k]));   }   int h, w, n, dp[2010];   vector<pair<int, int> > v;   int main() {     f[0] = fi[0] = 1;     for (int i = 1; i <= 200002; i++) {       f[i] = mul(i, f[i - 1]);       fi[i] = fp(f[i], MOD - 2);     }     scanf( %d%d%d , &h, &w, &n);     v.resize(n);     for (int i = 0; i < n; i++) {       scanf( %d%d , &v[i].first, &v[i].second);     }     sort(v.begin(), v.end());     v.emplace_back(h, w);     for (int i = 0; i <= n; i++) {       dp[i] = comb(v[i].first + v[i].second - 2, v[i].first - 1);       for (int j = 0; j < i; j++) {         if (v[j].first <= v[i].first && v[j].second <= v[i].second) {           dp[i] =               add(dp[i],                   -mul(comb(v[i].first + v[i].second - (v[j].first + v[j].second),                             v[i].first - v[j].first),                        dp[j]));           if (dp[i] < 0) dp[i] += MOD;         }       }     }     printf( %d n , dp[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<string> grid;   int main() {     int n;     cin >> n;     string line =   ;     for (int i = 0; i < n; i++) {       cin >> line;       grid.push_back(line);     }     bool rowblock = false;     bool colblock = false;     for (int i = 0; i < n; i++) {       bool found = false;       for (int j = 0; j < n; j++) {         if (grid[i][j] ==  . ) {           found = true;         }       }       if (!found) {         rowblock = true;       }     }     for (int j = 0; j < n; j++) {       bool found = false;       for (int i = 0; i < n; i++) {         if (grid[i][j] ==  . ) {           found = true;         }       }       if (!found) {         colblock = true;       }     }     if (rowblock && colblock) {       cout << -1 << endl;       return 0;     }     if (rowblock == false) {       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           if (grid[i][j] ==  . ) {             cout << i + 1 <<     << j + 1 << endl;             break;           }         }       }     } else {       for (int j = 0; j < n; j++) {         for (int i = 0; i < n; i++) {           if (grid[i][j] ==  . ) {             cout << i + 1 <<     << j + 1 << endl;             break;           }         }       }     }     return 0;   }