malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   map<string, int> m1, m2;   void go(string s, map<string, int>& mp) {     if (mp.find(s) != mp.end()) {       return;     }     mp[s] = 1;     if (s[0] ==  X ) {       string s1 = s;       string s2 = s;       swap(s1[0], s1[1]);       swap(s2[0], s2[2]);       go(s1, mp);       go(s2, mp);     } else if (s[1] ==  X ) {       string s1 = s;       string s2 = s;       swap(s1[1], s1[0]);       swap(s2[1], s2[3]);       go(s1, mp);       go(s2, mp);     } else if (s[3] ==  X ) {       string s1 = s;       string s2 = s;       swap(s1[3], s1[1]);       swap(s2[3], s2[2]);       go(s1, mp);       go(s2, mp);     } else {       string s1 = s;       string s2 = s;       swap(s1[2], s1[0]);       swap(s2[2], s2[3]);       go(s1, mp);       go(s2, mp);     }   }   int main() {     string tmp;     string a;     cin >> a;     cin >> tmp;     a += tmp;     string b;     cin >> b;     cin >> tmp;     b += tmp;     go(a, m1);     go(b, m2);     int done = 0;     for (auto it : m1) {       if (m2[it.first]) {         done = 1;         cout <<  YES  << endl;         break;       }     }     if (!done) {       cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long p[2001];   long long find_size(long long x) {     if (p[x] == -1) return 1;     return 1 + find_size(p[x]);   }   void solve() {     long long n;     cin >> n;     for (long long i = 0; i < n; i++) {       long long x;       cin >> x;       if (x > 0) x--;       p[i] = x;     }     long long ans = 1;     for (long long i = 0; i < n; i++) {       ans = max(ans, find_size(i));     }     cout << ans << endl;   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   const int mod = 1e9 + 7;   int a[N];   long long fac[30];   long long sum[N];   long long Contor(int* a, int n) {     long long res = 0;     for (int i = 1; i <= n; i++) {       int cnt = 0;       for (int j = i + 1; j <= n; j++)         if (a[i] > a[j]) cnt++;       res += cnt * fac[n - i];     }     return res;   }   void ReContor(int* a, int n, long long k, int ed) {     int vis[30] = {0};     for (int i = 1; i <= n; i++) {       int cnt = k / fac[n - i], j;       for (j = 1; j <= n; j++)         if (!vis[j]) {           if (!cnt) break;           cnt--;         }       vis[j] = 1;       a[i] = ed + j;       k %= fac[n - i];     }   }   void init() {     fac[0] = 1;     for (int i = 1; i <= 20; i++) fac[i] = fac[i - 1] * i;   }   int main() {     init();     int n, q;     scanf( %d%d , &n, &q);     for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + i;     int m = 15, ed = n - 15;     if (n < 15) m = n, ed = 0;     for (int i = 1; i <= m; i++) a[i] = ed + i;     long long cnt = 0;     while (q--) {       int op;       scanf( %d , &op);       if (op == 1) {         int l, r;         scanf( %d%d , &l, &r);         printf( %lld n , sum[r] - sum[l - 1]);       } else {         int x;         scanf( %d , &x);         cnt += x;         ReContor(a, m, cnt, ed);         for (int i = 1; i <= m; i++) sum[ed + i] = sum[ed + i - 1] + a[i];         for (int i = 1; i <= m; i++) a[i] = ed + i;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1111111111;   const long long MOD = 1e9 + 7;   int pref[5001][5001];   int nxt[5001][5001];   int dp(int i, int j) {     int x;     if (i > 0) {       x = pref[i][j] - pref[i - 1][j];     } else {       x = pref[0][j];     }     x %= MOD;     if (x < 0) {       x += MOD;     }     return x;   }   int digits[5001];   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     string x;     cin >> x;     for (int i = 1; i <= n; i++) {       digits[i] = x.at(i - 1) -  0 ;     }     for (int i = 0; i < 5001; i++) {       for (int j = 0; j < 5001; j++) {         if (j == 0) {           pref[j][i] = 0;         } else if (i == 0) {           pref[j][i] = 0;         } else {           pref[j][i] = 1;         }       }     }     for (int i = n; i >= 1; i--) {       for (int j = n; j >= i; j--) {         if (digits[i] == digits[j]) {           if (j == n) {             nxt[i][j] = INF;           } else {             nxt[i][j] = nxt[i + 1][j + 1] + 1;           }         } else {           nxt[i][j] = 0;         }       }     }     int a;     int next;     for (int b = 2; b <= n; b++) {       for (int c = b; c <= n; c++) {         if (digits[b] == 0) {           pref[b][c] = pref[b - 1][c];         } else {           a = max(1, 2 * b - c);           pref[b][c] = (pref[b - 1][c] % MOD + pref[b - 1][b - 1] % MOD -                         pref[a - 1][b - 1] % MOD) %                        MOD;           if (2 * b - c - 1 > 0) {             a = 2 * b - c - 1;             next = nxt[a][b];             if (next < INF) {               if (next + a < b && next + b <= c &&                   digits[next + a] < digits[next + b]) {                 pref[b][c] += dp(a, b - 1);                 pref[b][c] %= MOD;               }             }           }         }       }     }     int ans = 0;     for (int i = 1; i <= n; i++) {       ans += dp(i, n);       ans %= MOD;     }     if (ans < 0) {       ans += MOD;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-10;   const int inf = 0x3f3f3f3f, N = 1e7;   using namespace std;   int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }   char s[10];   int d(char c) { return c -  0 ; }   int main() {     while (~scanf( %s , s)) {       long long x = d(s[0]) * 10000 + d(s[2]) * 1000 + d(s[4]) * 100 +                     d(s[3]) * 10 + d(s[1]);       long long ans = x;       for (int i = 1; i < 5; i++) ans = ans * x % 100000;       printf( %05d , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   vector<int> g[100005];   int vis[100005];   vector<vector<int> > r;   bool dfs(int x, int f) {     vis[x] = 1;     int k = -1;     for (int y : g[x]) {       if (y == f) continue;       if (vis[y] > 0 || !vis[y] && !dfs(y, x)) {         if (k < 0)           k = y;         else           r.push_back({k, x, y}), k = -1;       }     }     vis[x] = -1;     if (k >= 0) {       r.push_back({k, x, f});       return true;     }     return false;   }   int main() {     scanf( %d%d , &n, &m);     for (int _ = 0, ThxDem = m; _ < ThxDem; ++_) {       int x, y;       scanf( %d%d , &x, &y);       x--;       y--;       g[x].push_back(y);       g[y].push_back(x);     }     for (int i = 0, ThxDem = n; i < ThxDem; ++i)       if (!vis[i] && dfs(i, -1)) {         puts( No solution );         return 0;       }     for (auto v : r) printf( %d %d %d n , v[0] + 1, v[1] + 1, v[2] + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   ostream& operator<<(ostream& os, const array<T, 2>& a) {     for (T e : a) {       os << e <<    ;     };     return os;   }   inline void lol(const function<void(int)>& fun, const array<int, 2>& f,                   const array<int, 2>& s) {     if (f == s) {       return;     }     for (int i = 0; i < 2; ++i) {       for (int j = 0; j < 2; ++j) {         if (f[i] == s[j]) {           fun(f[i]);         }       }     }   }   inline int common(const array<int, 2>& f, const array<int, 2>& s) {     for (int i = 0; i < 2; ++i) {       for (int j = 0; j < 2; ++j) {         if (f[i] == s[j]) {           return f[i];         }       }     }   }   bool ok(const vector<array<int, 2>>& a, const array<int, 2>& f) {     unordered_set<int> s;     for (auto& p : a) {       lol([&](int x) { s.emplace(x); }, p, f);     }     return s.size() == 1;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     vector<array<int, 2>> first(n), second(m);     for (int i = 0; i < n; ++i) {       cin >> first[i][0] >> first[i][1];       if (first[i][0] > first[i][1]) {         swap(first[i][0], first[i][1]);       }     }     for (int i = 0; i < m; ++i) {       cin >> second[i][0] >> second[i][1];       if (second[i][0] > second[i][1]) {         swap(second[i][0], second[i][1]);       }     }     unordered_set<int> candidates;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         lol([&](int x) { candidates.emplace(x); }, first[i], second[j]);       }     }     if (candidates.size() == 1) {       cout << *candidates.begin() <<   n ;       return 0;     }     bool they_know = true;     for (auto& f : first) {       vector<array<int, 2>> v;       for (auto& s : second) {         lol([&](int x) { v.emplace_back(s); }, f, s);       }       if (v.empty()) {         continue;       }       int chosen = common(f, v.front());       for (int i = 1; i < v.size(); ++i) {         if (chosen != common(f, v[i])) {           they_know = false;           break;         }       }       for (int i = 0; i < v.size(); ++i) {         if (!ok(first, v[i])) {           they_know = false;           break;         }       }       if (!they_know) {         break;       }     }     if (they_know) {       cout <<  0 n ;     } else {       cout <<  -1 n ;     }     return 0;   }
#include <bits/stdc++.h>   int n, m, k;   std::set<int> r;   std::set<std::pair<int, int> > e;   std::string getAnswer(bool b) {     if (b != 0)       return  possible ;     else       return  impossible ;   }   bool check(int x, int y) {     if (x > y) std::swap(x, y);     return e.find(std::make_pair(x, y)) == e.end();   }   void dfs(int x) {     std::vector<int> s;     for (auto now : r) {       if (check(x, now)) {         s.push_back(now);       }     }     for (auto now : s) {       r.erase(now);     }     for (auto now : s) {       dfs(now);     }   }   int main() {     std::cin >> n >> m >> k;     for (int i = 1; i <= m; i++) {       int x, y;       static int deg = 0;       std::cin >> x >> y;       if (x > y) std::swap(x, y);       e.insert(std::make_pair(x, y));       if (x == 1 && ++deg > n - k - 1) {         return puts(getAnswer(false).c_str()), 0;       }     }     for (int i = 2; i <= n; i++) {       r.insert(i);     }     int nBlock = 0;     for (int i = 2; i <= n; i++) {       if (check(1, i) && r.find(i) != r.end()) {         nBlock++;         r.erase(i);         dfs(i);       }     }     std::cout << getAnswer(nBlock <= k && r.empty()) << std::endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long tt = 1;     while (tt--) {       long long n;       cin >> n;       long long arr[n + 1];       for (long long i = 0; i < n; i++) cin >> arr[i];       arr[n] = arr[n - 1];       long long mx = -1;       long long ans = INT_MAX;       for (long long i = 0; i < n; i++) {         mx = max(arr[i], arr[i + 1]);         ans = min(ans, mx);       }       cout << min({ans, arr[0], arr[n]});       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007;   int N;   char A[2020];   char B[2020];   long long D[2020][4040];   long long E[2020][4040];   int main() {     int tc;     scanf( %d , &tc);     while (tc--) {       scanf( %d , &N);       scanf( %s , A + 1);       scanf( %s , B + 1);       for (int i = 0; i <= N + 1; i++)         for (int j = 0; j <= N + N; j++) D[i][j] = E[i][j] = 0;       D[0][N] = 1;       for (int i = 1; i <= N; i++) {         for (int j = 0; j <= N + N; j++) {           for (int k = 0; k < 2; k++) {             if (A[i] !=  ?  && A[i] != k +  0 ) continue;             for (int l = 0; l < 2; l++) {               if (B[i] !=  ?  && B[i] != l +  0 ) continue;               int tj = (i & 1 ? j + l - k : j - l + k);               if (tj < 0 || tj > N + N) continue;               D[i][tj] = (D[i][tj] + D[i - 1][j]) % MOD;             }           }         }       }       E[N + 1][N] = 1;       for (int i = N; i >= 1; i--) {         for (int j = 0; j <= N + N; j++) {           for (int k = 0; k < 2; k++) {             if (A[i] !=  ?  && A[i] != k +  0 ) continue;             for (int l = 0; l < 2; l++) {               if (B[i] !=  ?  && B[i] != l +  0 ) continue;               int tj = (~i & 1 ? j + l - k : j - l + k);               if (tj < 0 || tj > N + N) continue;               E[i][tj] = (E[i][tj] + E[i + 1][j]) % MOD;             }           }         }       }       long long ans = 0;       for (int i = 1; i < N; i++) {         for (int j = 0; j <= N + N; j++) {           ans = (ans + abs(j - N) * D[i][j] % MOD * E[i + 1][j]) % MOD;         }       }       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct st {     int x, p;   };   bool myfun(st a, st b) { return a.x < b.x; }   int main() {     int i, sum = 0, c = 0, n, k;     st a[110];     cin >> n >> k;     for (i = 0; i < n; ++i) {       a[i].p = i + 1;       cin >> a[i].x;     }     sort(a, a + n, myfun);     for (i = 0; i < n; ++i) {       sum += a[i].x;       if (sum > k) break;       c++;     }     cout << c <<   n ;     for (i = 0; i < c; ++i) cout << a[i].p <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   constexpr long long maxn = 2e5 + 5, inf = 0x3f3f3f3f;   vector<long long> e[maxn];   long long n, m, k, c[maxn], ans;   void dfs(long long u, long long fa) {     for (auto v : e[u]) {       if (v == fa) continue;       dfs(v, u);       c[u] += c[v];       ans += min(c[v], k - c[v]);     }   }   signed main() {     cin >> n >> k;     k *= 2;     for (long long i = 1; i <= k; i++) {       long long x;       cin >> x;       c[x] = 1;     }     for (long long i = 1; i < n; i++) {       long long u, v;       cin >> u >> v;       e[u].push_back(v);       e[v].push_back(u);     }     dfs(1, 1);     cout << ans;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   using namespace std;   long long seg[5000000];   long long scn[5000000];   void update(long long pos, long long x, long long l = 0, long long r = 300000,               long long ind = 1) {     if (l == r && l == pos)       seg[ind] = x, scn[ind] = x > 0;     else if (l > pos || r < pos)       return;     else if (l != r) {       update(pos, x, l, (l + r) / 2, ind * 2);       update(pos, x, (l + r) / 2 + 1, r, ind * 2 + 1);       seg[ind] = seg[ind * 2] + seg[ind * 2 + 1];       scn[ind] = scn[ind * 2] + scn[ind * 2 + 1];     }   }   long long query(long long light, long long l = 0, long long r = 300000,                   long long ind = 1) {     if (l == r || scn[ind] == light) return seg[ind];     if (scn[ind * 2] >= light)       return query(light, l, (l + r) / 2, ind * 2);     else       return seg[ind * 2] +              query(light - scn[ind * 2], (l + r) / 2 + 1, r, ind * 2 + 1);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long n;     cin >> n;     pair<long long, long long> a[n];     set<long long> all;     for (long long i = 0; i < n; i++) {       cin >> a[i].first >> a[i].second;       if (a[i].second > 0) {         all.insert(-a[i].second);       }     }     map<long long, long long> mapper;     long long cnt = 1;     for (auto v : all) {       mapper[-v] = cnt++;     }     cnt = 0;     set<long long> light;     for (long long i = 0; i < n; i++) {       if (a[i].first && a[i].second > 0)         light.insert(a[i].second);       else if (a[i].first && a[i].second < 0)         light.erase(-a[i].second);       if (a[i].second > 0)         update(mapper[a[i].second], a[i].second), cnt++;       else if (a[i].second < 0)         update(mapper[-a[i].second], 0), cnt--;       long long ans = seg[1];       if (light.size()) update(mapper[(*light.begin())], 0);       if (cnt == (long long)light.size())         ans += query((long long)light.size() - 1);       else         ans += query(light.size());       if (light.size()) update(mapper[(*light.begin())], (*light.begin()));       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   void sol() {     long long int n, k;     cin >> n >> k;     if (n == k)       cout << -1 <<   n ;     else {       long long int ar[n];       for (long long int i = 0; i < k; i++) {         ar[n - 1 - i] = n - i;       }       ar[n - 1 - k] = 1;       for (long long int i = 2; i <= n - k; i++) cout << i <<    ;       for (long long int i = n - 1 - k; i < n; i++) cout << ar[i] <<    ;     }   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int t = 1;     while (t--) {       sol();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int mod = 1e9 + 7;   bool prime[1000001] = {true};   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, m;     cin >> n >> m;     vector<int> arr(m);     if (m == 0) {       cout <<  YES ;       return 0;     }     for (int i = 0; i < m; i++) {       cin >> arr[i];     }     sort(arr.begin(), arr.end());     if (arr[0] == 1 || arr[m - 1] == n) {       cout <<  NO ;       return 0;     } else {       for (int i = 0; i < m - 1; i++) {         if (i < m - 2 && arr[i] + 1 == arr[i + 1] &&             arr[i + 1] + 1 == arr[i + 2]) {           cout <<  NO ;           return 0;         }       }       cout <<  YES ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, ar[100010], flag = 1, cnt = 1;     char s[100010];     scanf( %d , &n);     getchar();     for (int i = 1; i <= n; i++) scanf( %c , &s[i]);     for (int i = 1; i <= n; i++) scanf( %d , &ar[i]);     for (int i = 1; i <= n; i++) {       if (s[cnt] ==  > )         cnt += ar[cnt];       else         cnt -= ar[cnt];       if (cnt > n || cnt < 1) {         printf( FINITE n );         flag = 0;         break;       }     }     if (flag) printf( INFINITE n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   long long qsm(long long a, int b) {     a %= mod;     long long ret = 1;     while (b) {       if (b & 1) ret = ret * a % mod;       b >>= 1;       a = a * a % mod;     }     return ret;   }   long long a[220000], b[220000], f[220000];   int main() {     long long n;     scanf( %lld , &n);     for (int i = 0; i < n; i++) scanf( %lld , &a[i]), b[i] = a[i];     if (n == 1) {       printf( %lld n , a[0]);       return 0;     }     if (n & 1) {       n--;       int o = 0;       for (int i = 0; i < n; i++) {         if (!o)           b[i] = (a[i] + a[i + 1]) % mod;         else           b[i] = (a[i] - a[i + 1]) % mod;         o ^= 1;       }     }     f[0] = 1;     long long m = n / 2 - 1;     for (int i = 1; i <= m; i++) f[i] = f[i - 1] * i % mod;     long long ans1 = 0, ans2 = 0;     for (int i = 0; i <= m; i++) {       ans1 = (ans1 + f[m] * qsm(f[i] * f[m - i], mod - 2) % mod * b[i * 2]) % mod;       ans2 = (ans2 + f[m] * qsm(f[i] * f[m - i], mod - 2) % mod * b[i * 2 + 1]) %              mod;     }     long long ans;     if ((n * (n - 1) / 2) & 1)       ans = ((ans1 + ans2) % mod + mod) % mod;     else       ans = ((ans1 - ans2) % mod + mod) % mod;     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using vi = vector<int>;   using vvi = vector<vi>;   using ii = pair<int, int>;   using vii = vector<ii>;   using l = long long;   using vl = vector<l>;   using vvl = vector<vl>;   using ll = pair<l, l>;   using vll = vector<ll>;   using vvll = vector<vll>;   using lu = unsigned long long;   using vb = vector<bool>;   using vvb = vector<vb>;   using vd = vector<double>;   using vvd = vector<vd>;   const int INF = numeric_limits<int>::max();   const double EPS = 1e-10;   const l e5 = 100000, e6 = 1000000, e7 = 10000000, e9 = 1000000000;   struct node;   struct edge;   using pnode = shared_ptr<node>;   using graph = vector<pnode>;   struct node {     bool visited = false;     vector<pnode> adjusted;     char letter =  x ;     l same = 0;   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     l n, m;     while (cin >> n >> m) {       graph g(n);       for (auto &u : g) {         u = make_shared<node>();       }       for (l i = 0; i < m; i++) {         l a, b;         cin >> a >> b;         a--;         b--;         g[a]->adjusted.push_back(g[b]);         g[b]->adjusted.push_back(g[a]);       }       bool ok = true;       for (auto u : g) {         if (u->adjusted.size() == n - 1) {           u->letter =  b ;           u->visited = true;         }       }       char x =  a ;       for (auto u : g) {         if (u->visited) continue;         if (x ==  x ) {           ok = false;           break;         }         queue<pnode> q;         q.emplace(u);         l marked = 0;         u->visited = true;         u->letter = x;         marked++;         while (!q.empty()) {           auto v = q.front();           q.pop();           for (auto r : v->adjusted) {             if (!r->visited || r->letter == v->letter) v->same++;             if (r->visited) continue;             r->visited = true;             r->letter = x;             marked++;             q.emplace(r);           }         }         for (auto v : g) {           if (v->letter != x) continue;           if (v->same != marked - 1) ok = false;         }         if (!ok) break;         if (x ==  a ) {           x =  c ;         } else {           x =  x ;         }       }       if (ok) {         cout <<  Yes  << endl;         for (auto u : g) cout << u->letter;         cout << endl;       } else {         cout <<  No  << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, ans = 1;     cin >> n;     vector<vector<int>> graph(n + 1);     vector<bool> visit(n + 1);     vector<int> color(n + 1);     for (int i = 1; i < n; i++) {       int a, b;       cin >> a >> b;       graph[a].push_back(b);       graph[b].push_back(a);     }     queue<pair<int, int>> q;     color[1] = 1;     visit[1] = 1;     int curC = 2;     for (auto i : graph[1]) {       visit[i] = 1;       color[i] = curC;       ans = max(ans, color[i]);       curC++;       q.push({1, i});     }     while (!q.empty()) {       int kakek = q.front().first, bapak = q.front().second;       q.pop();       curC = 1;       for (auto i : graph[bapak]) {         if (!visit[i]) {           visit[i] = 1;           while (curC == color[bapak] || curC == color[kakek]) curC++;           color[i] = curC;           ans = max(ans, color[i]);           curC++;           q.push({bapak, i});         }       }     }     cout << ans <<   n ;     for (int i = 1; i <= n; i++) cout << color[i] <<    ;     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int a[105][105];   int main() {     int n, m, q;     cin >> n >> m >> q;     vector<pair<pair<int, int>, pair<int, int> > > t(q);     for (int i = 0; i < q; ++i) {       cin >> t[i].first.first >> t[i].first.second;       if (t[i].first.first == 3) cin >> t[i].second.first >> t[i].second.second;     }     while (q > 0) {       --q;       if (t[q].first.first == 1) {         int r = t[q].first.second;         --r;         int x = a[r][m - 1];         for (int j = m - 1; j > 0; --j) a[r][j] = a[r][j - 1];         a[r][0] = x;       } else if (t[q].first.first == 2) {         int r = t[q].first.second;         --r;         int x = a[n - 1][r];         for (int i = n - 1; i > 0; --i) a[i][r] = a[i - 1][r];         a[0][r] = x;       } else {         int x, y, v;         x = t[q].first.second, y = t[q].second.first, v = t[q].second.second;         --x, --y;         a[x][y] = v;       }     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) cout << a[i][j] <<    ;       cout << endl;     }   }