malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n;   char s[105][105];   char t[105];   bool judge1() {     int i = 0;     for (; i < n; i++) t[i] =  E ;     t[i] =   0 ;     for (int i = 0; i < n; i++)       if (strcmp(t, s[i]) == 0) return 1;     return 0;   }   bool judge2() {     for (int i = 0; i < n; i++) {       int F = 1;       for (int j = 0; j < n; j++)         if (s[j][i] !=  E ) {           F = 0;           break;         }       if (F) return 1;     }     return 0;   }   int main() {     while (~scanf( %d , &n)) {       for (int i = 0; i < n; i++) scanf( %s , s[i]);       if (judge1() && judge2()) {         cout << -1 << endl;         continue;       }       if (judge1()) {         for (int i = 0; i < n; i++) {           for (int j = 0; j < n; j++)             if (s[j][i] ==  . ) {               cout << j + 1 <<     << i + 1 << endl;               break;             }         }       } else         for (int i = 0; i < n; i++) {           int l = strlen(s[i]);           for (int j = 0; j < l; j++)             if (s[i][j] ==  . ) {               cout << i + 1 <<     << j + 1 << endl;               break;             }         }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   #pragma GCC optimization( unroll-loops )   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   void __print(int x) { cout << x; }   void __print(long x) { cout << x; }   void __print(long long x) { cout << x; }   void __print(unsigned x) { cout << x; }   void __print(unsigned long x) { cout << x; }   void __print(unsigned long long x) { cout << x; }   void __print(float x) { cout << x; }   void __print(double x) { cout << x; }   void __print(long double x) { cout << x; }   void __print(char x) { cout <<      << x <<     ; }   void __print(const char *x) { cout <<     << x <<    ; }   void __print(const string &x) { cout <<     << x <<    ; }   void __print(bool x) { cout << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cout <<  { ;     __print(x.first);     cout <<  , ;     __print(x.second);     cout <<  } ;   }   template <typename T>   void __print(const T &x) {     int first = 0;     cout <<  { ;     for (auto &i : x) cout << (first++ ?  ,  :   ), __print(i);     cout <<  } ;   }   void _print() { cout <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cout <<  ,  ;     _print(v...);   }   template <class T>   void remdup(vector<T> &v) {     sort((v).begin(), (v).end());     v.erase(unique((v).begin(), (v).end()), end(v));   }   template <typename T>   struct cmp {     bool operator()(const T &p1, const T &p2) {}   };   const long long N = 2e5 + 100;   const long long mod = 1e9 + 7;   const long long X = 2e5 + 100;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     ;     string s;     cin >> s;     long long ans = 0, wait = 0, m = 0;     for (auto &it : s) {       if (it ==  M ) {         m++;         if (wait) wait--;       } else {         if (m) {           ans = max(ans, m + wait);           wait++;         }       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int MOD = 1e9 + 7;   long long int t;   string s;   long long int n;   long long int dp[100][2501];   long long int adp[100][2501];   long long int l, r, sm;   void solve() {     cin >> s;     n = s.length() - 1;     sm = 0;     for (auto it : s) sm += it -  a ;     l = adp[n][sm] - 1;     if (l < 0) l += MOD;     cout << l << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     for (int i = 0; i < 26; i++) adp[0][i] = dp[0][i] = 1;     for (int i = 1; i <= 2500; i++) {       dp[0][i] += dp[0][i - 1];       dp[0][i] %= MOD;     }     for (int i = 1; i < 100; i++) {       for (int j = 0; j <= 2500; j++) {         l = r = 0;         if (j - 26 >= 0) l = dp[i - 1][j - 26];         r = dp[i - 1][j];         dp[i][j] = r - l;         if (dp[i][j] < 0) dp[i][j] += MOD;         dp[i][j] %= MOD;         adp[i][j] = dp[i][j];         if (j != 0) {           dp[i][j] += dp[i][j - 1];           dp[i][j] %= MOD;         }       }     }     t = 1;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     for (int tc = 1; tc <= t; tc++) {       int n;       cin >> n;       pair<pair<int, int>, int> arr[2 * n - 1];       for (int i = 0; i < 2 * n - 1; i++) {         cin >> arr[i].first.first >> arr[i].first.second;         arr[i].second = i;       }       sort(arr, arr + 2 * n - 1);       long long odd = 0, even = 0;       for (int i = 0; i < 2 * n - 1; i++) {         if (i & 1)           even += arr[i].first.second;         else           odd += arr[i].first.second;       }       if (odd >= even) {         cout <<  YES n ;         int ans[n];         for (int i = 0; i < 2 * n - 1; i += 2) ans[i / 2] = arr[i].second + 1;         sort(ans, ans + n);         for (int i = 0; i < n - 1; i++) cout << ans[i] <<    ;         cout << ans[n - 1] <<   n ;       } else {         cout <<  YES n ;         int ans[n];         for (int i = 1; i < 2 * n - 1; i += 2) ans[i / 2] = arr[i].second + 1;         ans[n - 1] = arr[2 * n - 2].second + 1;         sort(ans, ans + n);         for (int i = 0; i < n - 1; i++) cout << ans[i] <<    ;         cout << ans[n - 1] <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   pair<int, pair<int, int> > tup[100000 * 2 + 10];   multiset<int> st;   int L[100000 * 2 + 10], R[100000 * 2 + 10], sl[100000 * 2 + 10],       sr[100000 * 2 + 10];   int main() {     int m, n, r, l, t;     scanf( %d%d , &m, &n);     int flag = 0;     for (int i = 1; i <= n; i++) {       scanf( %d%d%d , &l, &r, &t);       tup[i] = make_pair(l, make_pair(t, 0));       tup[i + n] = make_pair(r, make_pair(t, 1));     }     n *= 2;     sort(tup + 1, tup + n + 1);     int lasty = -1, o = 0;     for (int i = 1; i <= n; i++) {       int cury = tup[i].first;       if (lasty != -1 && cury != lasty && st.size()) {         if (st.empty()) {           printf( empty n );           return 0;         }         int curt = *st.begin();         L[++o] = curt - lasty;         R[o] = curt - cury;       }       lasty = cury;       if (tup[i].second.second)         st.erase(st.lower_bound(tup[i].second.first));       else         st.insert(tup[i].second.first);     }     if (flag) {       printf( o:%d n , o);       return 0;     }     sort(L + 1, L + o + 1);     sort(R + 1, R + o + 1);     for (int i = 1; i <= o; i++)       sl[i] = sl[i - 1] + L[i], sr[i] = sr[i - 1] + R[i];     while (m--) {       scanf( %d , &t);       l = lower_bound(L + 1, L + o + 1, t) - L - 1;       r = lower_bound(R + 1, R + o + 1, t) - R - 1;       printf( %d n , (int)((r - l) * (long long)t - sr[r] + sl[l]));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       string s[n];       map<string, int> m;       set<string> k;       int count = 0;       for (int i = 0; i < n; i++) {         cin >> s[i];         k.insert(s[i]);       }       for (int i = 0; i < n; i++) {         if (m[s[i]] >= 1) {           count++;           int j = 0;           while (k.find(s[i]) != k.end()) {             s[i][3] = j +  0 ;             j++;           }         }         m[s[i]]++;         k.insert(s[i]);       }       cout << count << endl;       for (int i = 0; i < n; i++) cout << s[i] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     int t;     cin >> t;     while (t--) {       int a, b, c, d;       cin >> a >> b >> c >> d;       cout << max(a + b, c + d) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:268435456 )   using namespace std;   long long _gcd(long long a, long long b) {     if (b == 0) return a;     _gcd(b, a % b);   }   int main() {     int n, m, k, a[20500][10], res[20500] = {0}, b[20500][10] = {0};     cin >> n >> m >> k;     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) cin >> a[i][j];     for (int i = 0; i < k; ++i) {       int l, r;       cin >> l >> r;       l--;       r--;       b[0][r]++;       b[l][r]--;       b[l + 1][r]++;       b[n][r]--;     }     for (int i = 0; i < m; ++i) {       for (int j = 1; j < n; ++j) b[j][i] += b[j - 1][i];     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j)         if (a[i][j] == 1) res[i] += b[i][j];     }     for (int i = 0; i < n; ++i) cout << res[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   const long double eps = 1e-9;   const int inf = 1e+9;   const double pi = acos(-1.0);   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long xabs(long long a) { return a > 0 ? a : -a; }   map<int, vector<string>> s;   int sm[9][2] = {{0, 1},  {0, -1}, {1, 0},   {-1, 0}, {1, 1},                   {1, -1}, {-1, 1}, {-1, -1}, {0, 0}};   void dfs(int x, int y, int t) {     if (t == 9) {       cout <<  WIN ;       exit(0);     }     if (s[t][x][y] ==  S ) return;     for (int i = 0; i < 9; i++) {       int xx = x + sm[i][0];       int yy = y + sm[i][1];       if (xx >= 0 && xx < 8 && yy >= 0 && yy < 8 && s[t][xx][yy] !=  S )         dfs(xx, yy, t + 1);     }   }   int main() {     for (int i = 0; i < 8; i++) {       string t;       cin >> t;       s[0].push_back(t);     }     for (int i = 1; i <= 8; i++) {       string r =  ........ ;       s[i].push_back(r);       for (int k = 0; k < 7; k++) {         s[i].push_back(s[i - 1][k]);       }     }     dfs(7, 0, 0);     cout <<  LOSE ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T, class U>   void maximize(T &x, U y) {     if (x < y) x = y;   }   template <class T, class U>   void minimize(T &x, U y) {     if (x > y) x = y;   }   template <class T>   T Abs(T x) {     return (x < (T)0 ? -x : x);   }   namespace task {   const int N = 2e5 + 5;   const int maxVal = 5e5;   vector<int> prime;   vector<vector<int> > p;   int e[maxVal + 5];   int cnt[maxVal + 5];   bool inshelf[N];   int a[N];   int n, q;   void solve() {     cin >> n >> q;     for (int i = 1; i <= n; ++i) {       cin >> a[i];     }     iota(e, e + 1 + maxVal, 0);     for (int i = 2; i <= maxVal; ++i) {       if (e[i] == i) {         prime.emplace_back(i);       }       for (int j = 0; j < (int)((prime).size()) and i * prime[j] <= maxVal; ++j) {         e[i * prime[j]] = prime[j];         if (i % prime[j] == 0) {           break;         }       }     }     p.resize(n + 2, vector<int>());     for (int i = 1; i <= n; ++i) {       int tmp = a[i];       for (int k = e[tmp]; k > 1 and tmp > 1; k = e[tmp]) {         while (tmp % k == 0) {           tmp /= k;         }         p[i].emplace_back(k);       }     }     int cur = 0;     long long ans = 0;     while (q--) {       int x;       cin >> x;       long long subs = 0;       int k = (inshelf[x] ? -1 : 1);       for (int mask = 1; mask < ((1LL) << ((int)((p[x]).size()))); ++mask) {         int mul = 1;         for (int i = 0; i < (int)((p[x]).size()); ++i) {           if ((((mask) >> (i)) & 1)) {             mul *= p[x][i];           }         }         subs += 1LL * ((__builtin_popcount(mask) & 1) ? 1 : -1) * 1LL * cnt[mul];       }       if (!inshelf[x]) {         ans += cur - subs;         inshelf[x] = true;         ++cur;       } else {         ans -= cur - (a[x] == 1 ? 1 : subs);         inshelf[x] = false;         --cur;       }       cout << ans <<   n ;       for (int mask = 1; mask < ((1LL) << ((int)((p[x]).size()))); ++mask) {         int mul = 1;         for (int i = 0; i < (int)((p[x]).size()); ++i) {           if ((((mask) >> (i)) & 1)) {             mul *= p[x][i];           }         }         cnt[mul] += k;       }     }   }   }  // namespace task   int main(void) {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     task::solve();   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int mod = 1e9 + 7;   const int maxn = 55;   int st[maxn];   struct E {     int u, v, w, cost;     int nxt;   } edge[500009];   int gtot = 0, head[maxn * 100];   void addedge(int u, int v, int w, int cost) {     edge[gtot].v = v;     edge[gtot].w = w;     edge[gtot].cost = cost;     edge[gtot].nxt = head[u];     head[u] = gtot++;     edge[gtot].v = u;     edge[gtot].w = 0;     edge[gtot].cost = -cost;     edge[gtot].nxt = head[v];     head[v] = gtot++;   }   int dis[maxn * 100], path[500009], vis[maxn * 100], pre[maxn * 100];   bool spfa(int s, int t) {     memset(pre, -1, sizeof(pre));     memset(dis, inf, sizeof(dis));     memset(vis, 0, sizeof(vis));     queue<int> que;     que.push(s);     vis[s] = 1;     dis[s] = 0;     while (!que.empty()) {       int u = que.front();       que.pop();       vis[u] = 0;       for (int i = head[u]; ~i; i = edge[i].nxt) {         int v = edge[i].v, val = edge[i].w, cost = edge[i].cost;         if (val > 0 && dis[v] > dis[u] + cost) {           dis[v] = dis[u] + cost;           pre[v] = u;           path[v] = i;           if (vis[v] == 0) {             vis[v] = 1;             que.push(v);           }         }       }     }     return pre[t] != -1;   }   int mcmf(int s, int t) {     int flow = 0, cost = 0;     while (spfa(s, t)) {       int f = inf;       for (int i = t; i != s; i = pre[i]) {         f = min(f, edge[path[i]].w);       }       flow += f;       cost += f * dis[t];       for (int i = t; i != s; i = pre[i]) {         edge[path[i]].w -= f;         edge[path[i] ^ 1].w += f;       }     }     return cost;   }   int main() {     memset(head, -1, sizeof(head));     gtot = 0;     int n, m, k, c, d;     scanf( %d%d%d%d%d , &n, &m, &k, &c, &d);     for (int i = 1; i <= k; i++) {       int x;       scanf( %d , &x);       st[x]++;     }     int s = 0, t = 100 * n + 1;     for (int i = 1; i <= n; i++) {       for (int j = 2; j <= 100; j++) {         addedge((i - 1) * 100 + j - 1, (i - 1) * 100 + j, inf, c);       }     }     for (int i = 2; i <= n; i++) {       if (st[i]) addedge(s, (i - 1) * 100 + 1, st[i], 0);     }     for (int i = 1; i <= 100; i++) addedge(i, t, inf, 0);     for (int i = 1; i <= m; i++) {       int u, v;       scanf( %d%d , &u, &v);       for (int j = 2; j <= 100; j++) {         for (int k = 1; k <= 20; k++) {           addedge((u - 1) * 100 + j - 1, (v - 1) * 100 + j, 1,                   (k * k - (k - 1) * (k - 1)) * d + c);           addedge((v - 1) * 100 + j - 1, (u - 1) * 100 + j, 1,                   (k * k - (k - 1) * (k - 1)) * d + c);         }       }     }     printf( %d n , mcmf(s, t));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, t = 1, c1, c2;   vector<vector<long long>> adj;   vector<vector<long long>> g;   vector<bool> visited;   void DFS(long long v) {     visited[v] = true;     g[t].push_back(v);     for (auto i : adj[v])       if (!visited[i]) DFS(i);   }   long long number_of_components() {     for (long long v = 1; v <= n; v++)       if (!visited[v]) {         DFS(v);         if (g[t].size() > 3) {           cout <<  -1 ;           return -1;         }         if (g[t].size() == 1) c1++;         if (g[t].size() == 2) c2++;         t++;       }   }   void solve() {     long long m, x, y, j = 0, h = 1;     cin >> n >> m;     adj.resize(n + 1);     g.resize(n + 1);     visited.assign(n + 1, false);     for (long long i = 1; i <= m; i++) {       cin >> x >> y;       adj[x].push_back(y);       adj[y].push_back(x);     }     long long z = number_of_components();     if (z == -1) return;     if (c2 > c1) {       cout <<  -1 ;       return;     }     if ((c1 - c2) % 3 != 0) {       cout << -1;       return;     }     for (long long i = 1; i <= t; i++) {       if (g[i].size() == 3) {         for (auto v : g[i]) cout << v <<    ;         cout <<   n ;       }       if (g[i].size() == 2) {         for (auto v : g[i]) cout << v <<    ;         for (j = h; j <= t; j++)           if (g[j].size() == 1) {             cout << g[j][0];             break;           }         h = j + 1;         cout <<   n ;       }     }     for (long long i = j + 1; i <= t; i++) {       if (g[i].size() == 1) cout << g[i][0] <<    ;       if ((j - i) % 3 == 0) cout <<   n ;     }   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     solve();     cerr <<  time taken :   << (float)clock() / CLOCKS_PER_SEC <<   secs  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, d, h;   int main() {     cin >> n >> d >> h;     if (d - h > h) {       cout <<  -1  << endl;       return 0;     }     if (h == 1 && d == 1 && n > 2) {       cout <<  -1  << endl;       return 0;     }     for (int i = 2; i <= h + 1; i++) {       cout << i - 1 <<     << i << endl;     }     int j = 1;     for (int i = h + 2; i <= d + 1; i++) {       if (i > h + 2) j = i - 1;       cout << j <<     << i << endl;     }     for (int i = d + 2; i <= n; i++) {       cout << h <<     << i << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, k;   char s[200005];   vector<long long> cnt[3][202];   vector<pair<long long, long long> > res;   int main() {     long long i, j;     scanf( %lld , &n);     scanf( %s , &s);     for (i = 0; i <= n - 1; i++) {       cnt[1][s[i]].push_back(i + 1);     }     scanf( %s , &s);     for (i = 0; i <= n - 1; i++) {       cnt[2][s[i]].push_back(i + 1);     }     for (i =  a ; i <=  z ; i++) {       while (cnt[1][i].size() && cnt[2][i].size()) {         res.push_back(make_pair(cnt[1][i].back(), cnt[2][i].back()));         cnt[1][i].pop_back(), cnt[2][i].pop_back();       }     }     for (i =  a ; i <=  z ; i++) {       while (cnt[2][i].size() && cnt[1][ ? ].size()) {         res.push_back(make_pair(cnt[1][ ? ].back(), cnt[2][i].back()));         cnt[1][ ? ].pop_back(), cnt[2][i].pop_back();       }     }     for (i =  a ; i <=  z ; i++) {       while (cnt[1][i].size() && cnt[2][ ? ].size()) {         res.push_back(make_pair(cnt[1][i].back(), cnt[2][ ? ].back()));         cnt[2][ ? ].pop_back(), cnt[1][i].pop_back();       }     }     while (cnt[1][ ? ].size() && cnt[2][ ? ].size()) {       res.push_back(make_pair(cnt[1][ ? ].back(), cnt[2][ ? ].back()));       cnt[2][ ? ].pop_back(), cnt[1][ ? ].pop_back();     }     long long d = res.size();     printf( %lld n , d);     for (i = 0; i <= d - 1; i++) {       printf( %lld %lld n , res[i].first, res[i].second);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int x[2000][10], y[2000][10];   double Ab(int x) {     if (x >= 0) return x;     return -x;   };   double q(double x) { return x * x; };   double d(int i, int j) {     double X, Y;     if (x[i][0] == x[i][1] && y[j][0] == y[j][1]) {       Y = min(Ab(y[i][0] - y[j][0]), Ab(y[i][1] - y[j][0]));       if (y[j][0] <= y[i][1] && y[j][0] >= y[i][0]) Y = 0;       X = min(Ab(x[j][0] - x[i][0]), Ab(x[j][1] - x[i][0]));       if (x[i][0] <= x[j][1] && x[i][0] >= x[j][0]) X = 0;     } else if (x[j][0] == x[j][1] && y[i][0] == y[i][1]) {       Y = min(Ab(y[i][0] - y[j][0]), Ab(y[i][1] - y[j][1]));       if (y[i][0] <= y[j][1] && y[i][0] >= y[j][0]) Y = 0;       X = min(Ab(x[j][0] - x[i][0]), Ab(x[j][1] - x[i][1]));       if (x[j][0] <= x[i][1] && x[j][0] >= x[i][0]) X = 0;     } else if (x[i][0] == x[i][1]) {       X = Ab(x[i][0] - x[j][0]);       Y = min(min(Ab(y[i][1] - y[j][0]), Ab(y[i][1] - y[j][1])),               min(Ab(y[i][0] - y[j][0]), Ab(y[i][0] - y[j][1])));       if (y[i][1] <= y[j][1] && y[i][1] >= y[j][0]) Y = 0;       if (y[i][0] <= y[j][1] && y[i][0] >= y[j][0]) Y = 0;     } else {       Y = Ab(y[i][0] - y[j][0]);       X = min(min(Ab(x[i][1] - x[j][0]), Ab(x[i][1] - x[j][1])),               min(Ab(x[i][0] - x[j][0]), Ab(x[i][0] - x[j][1])));       if (x[i][1] <= x[j][1] && x[i][1] >= x[j][0]) X = 0;       if (x[i][0] <= x[j][1] && x[i][0] >= x[j][0]) X = 0;     }     return (sqrt(q(X) + q(Y)));   };   int main() {     double a, b;     cin >> a >> b;     int xk, yk;     scanf( %d%d%d%d , &x[0][0], &y[0][0], &xk, &yk);     x[0][1] = x[0][0];     y[0][1] = y[0][0];     int n;     scanf( %d , &n);     x[n + 1][0] = xk;     y[n + 1][0] = yk;     x[n + 1][1] = xk;     y[n + 1][1] = yk;     for (int i = 1; i <= n; i++) {       scanf( %d%d%d%d , &x[i][0], &y[i][0], &x[i][1], &y[i][1]);       if (y[i][0] > y[i][1]) swap(y[i][0], y[i][1]);       if (x[i][0] > x[i][1]) swap(x[i][0], x[i][1]);     }     queue<pair<int, int> > q;     q.push(make_pair(0, 0));     bool was[2000];     for (int i = 0; i <= n + 1; i++) was[i] = false;     was[0] = true;     double ans = -1;     while (!q.empty()) {       pair<int, int> A = q.front();       q.pop();       int i = A.first;       int k = A.second;       if (d(n + 1, i) - a <= 1e-7) {         double X = d(n + 1, i) + (a + b) * k;         if (ans == -1)           ans = X;         else           ans = min(ans, X);       }       for (int j = 0; j <= n; j++) {         if (was[j]) continue;         if (d(i, j) - a > 1e-7) continue;         q.push(make_pair(j, k + 1));         was[j] = true;       }     }     cout << fixed << setprecision(10);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2010;   char mp[N][N];   int n, m, cnt1, cnt2, in[N][N];   int xx[6] = {0, 0, 1, 0, -1};   int yy[6] = {0, 1, 0, -1, 0};   queue<pair<long long, long long> > q;   int main() {     int n, m;     while (cin >> n >> m) {       memset(in, 0, sizeof in);       for (int i = 1; i <= n; i++) {         scanf( %s , mp[i] + 1);       }       cnt1 = cnt2 = 0;       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= m; j++)           if (mp[i][j] ==  . ) {             cnt1++;             for (int k = 1; k <= 4; k++)               if (mp[i + xx[k]][j + yy[k]] ==  . ) in[i][j]++;             if (in[i][j] == 1) {               q.push(pair<long long, long long>(i, j));             }           }       }       while (!q.empty()) {         pair<long long, long long> u = q.front();         q.pop();         int x = u.first, y = u.second, tx, ty, i;         for (i = 1; i <= 4; i++) {           tx = x + xx[i];           ty = y + yy[i];           if (mp[tx][ty] ==  . ) {             cnt2 += 2;             if (i == 1) mp[x][y] =  < , mp[tx][ty] =  > ;             if (i == 2) mp[x][y] =  ^ , mp[tx][ty] =  v ;             if (i == 3) mp[x][y] =  > , mp[tx][ty] =  < ;             if (i == 4) mp[x][y] =  v , mp[tx][ty] =  ^ ;             break;           }         }         if (i == 5) continue;         x = tx, y = ty;         for (int i = 1; i <= 4; i++) {           tx = x + xx[i];           ty = y + yy[i];           if (mp[tx][ty] ==  . ) {             in[tx][ty]--;             if (in[tx][ty] == 1) {               q.push(pair<long long, long long>(tx, ty));             }           }         }       }       if (cnt1 < cnt2) {         cout << cnt1 <<     << cnt2 << endl;         for (int i = 1; i <= n; i++) {           printf( %s n , mp[i] + 1);         }         break;       }       if (cnt1 != cnt2) {         printf( Not unique n );         continue;       }       for (int i = 1; i <= n; i++) {         printf( %s n , mp[i] + 1);       }     }   }