malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int M = 1e9 + 7;   int main() {     long long int i, t, a = 0, k, b = 0, j = 0, l = 0, n, m, r = 0, c = 0, ct = 0,                         pos = 0, neg = 0, flag = 0, x, y, space, maxi,                         ans = 999999, ans2 = -100, avg, sum = 0;     double d;     long long int ar1[100005] = {0}, ar2[100005] = {0};     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     long long int ch, temp = 0;     vector<long long int> v;     string st, st2, st3;     stack<char> s;     vector<pair<string, string> > vp;     queue<pair<long long int, long long int> > q;     cin >> n;     cout << 2 * n - 1 <<     << 2 << endl << 1 <<     << 2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   set<int> s[300000];   int ans[300000];   bool vis[300000];   int nr[500000];   int main() {     int n, m;     scanf( %d %d , &n, &m);     priority_queue<pair<int, int> > pq;     for (int i = 0; i <= 2 * m; i++) nr[i] = -1;     for (int i = 0; i < n; i++) {       int k, x;       scanf( %d , &k);       while (k--) {         scanf( %d , &x);         nr[x + m] = i;         s[i].insert(x);       }       pq.push(make_pair(-s[i].size(), i));     }     while (!pq.empty()) {       int k = pq.top().second;       pq.pop();       if (vis[k]) continue;       vis[k] = true;       if (s[k].empty()) {         puts( NO );         return 0;       }       int x = *s[k].begin();       if (x > 0) ans[x] = 1;       if (nr[m - x] != -1) {         s[nr[m - x]].erase(-x);         pq.push(make_pair(-s[nr[m - x]].size(), nr[m - x]));       }     }     puts( YES );     for (int i = 1; i <= m; i++) printf( %d , ans[i]);     puts(  );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     if (m == 3 && n >= 5)       cout << -1 << endl;     else {       if (m == 3 && n == 4)         puts( -1 0 n1 0 n0 2 n0 1 );       else {         for (int i = 1; i <= m; i++) cout << i <<     << i * i + 343231 << endl;         n -= m;         for (int i = 1; i <= n; i++)           cout << i <<     << -(i * i + 343231) << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int s[n];     int f[10] = {0};     for (int i = 0; i < n; i++) {       cin >> s[i];     }     int tmp;     for (int j = 0; j < m; j++) {       cin >> tmp;       f[tmp] = 1;     }     int emp = 1;     for (int i = 0; i < n; i++) {       if (f[s[i]] == 1) {         emp = 0;         cout << s[i] <<    ;       }     }     if (emp == 1) cout <<   n ;   }
#include <bits/stdc++.h>   const int maxn = 3e5 + 3;   int n, a[maxn], b[maxn], m, l[maxn], r[maxn];   void solve() {     scanf( %d , &n);     m = 0;     for (int i = 0; i < n; ++i) {       scanf( %d , a + i);       b[m++] = a[i];     }     std::sort(b, b + m);     m = std::unique(b, b + m) - b;     for (int i = 0; i < n; ++i) {       a[i] = std::lower_bound(b, b + m, a[i]) - b;     }     std::fill(l, l + m, 0x7fffffff);     std::fill(r, r + m, 0x80000000);     for (int i = 0; i < n; ++i) {       l[a[i]] = std::min(l[a[i]], i);       r[a[i]] = std::max(r[a[i]], i);     }     int ans = m - 1;     for (int i = 0, j; i < m; i = j) {       for (j = i + 1; j < m && r[j - 1] < l[j]; ++j)         ;       ans = std::min(ans, i + (m - j));     }     printf( %d n , ans);   }   int main() {     int t;     scanf( %d , &t);     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int Q = 9, R = 5, B = 3, N = 3, P = 1, q = 9, r = 5, b = 3, n = 3, p = 1;     int sum2 = 0, Sum2 = 0;     char c[64];     for (int i = 0; i < 64; i++) {       cin >> c[i];     }     for (int i = 0; i < 64; i++) {       switch (c[i]) {         case  q :           sum2 += q;           break;         case  r :           sum2 += r;           break;         case  b :           sum2 += b;           break;         case  n :           sum2 += n;           break;         case  p :           sum2 += p;           break;         case  Q :           Sum2 += Q;           break;         case  R :           Sum2 += R;           break;         case  B :           Sum2 += B;           break;         case  N :           Sum2 += N;           break;         case  P :           Sum2 += P;           break;       }     }     if (sum2 > Sum2)       cout <<  Black ;     else if (sum2 < Sum2)       cout <<  White ;     else       cout <<  Draw ;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e9 + 10;   const long long MN = 5e2 + 10;   long long n, m, a[MN], b[MN];   vector<pair<long long, char> > ans;   long long lz = 0;   bool fl = false;   void fail() {     cout <<  NO n ;     exit(0);   }   long long get(long long l, long long r) {     long long mx = *max_element(a + l, a + r + 1);     if (a[l] == mx) {       fl = true;       long long ret = l;       for (; a[ret] == mx; ++ret)         ;       return ret - 1;     }     long long ret = l;     for (; a[ret] != mx; ++ret)       ;     return ret;   }   int32_t main() {     ios_base ::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n;     for (long long i = 0; i < n; ++i) cin >> a[i];     cin >> m;     for (long long i = 0; i < m; ++i) cin >> b[i];     long long cur = 0;     long long p = 0;     long long lst = 0;     for (long long i = 0; i < n; ++i) {       cur += a[i];       if (cur == b[p] && p < m) {         if (i == lst) {           ++p, cur = 0, lst = i + 1;           continue;         }         if (*max_element(a + lst, a + i + 1) == *min_element(a + lst, a + i + 1))           fail();         ++p;         fl = false;         long long ind = get(lst, i);         if (fl) {           for (long long j = 0; j < (i - ind); ++j)             ans.push_back(make_pair(ind - lz,  R ));           for (long long j = ind - 1; j >= lst; --j) {             ans.push_back(make_pair(ind - lz,  L ));             ++lz;           }           lz += (i - ind);         } else {           for (long long j = ind - 1; j >= lst; --j) {             ans.push_back(make_pair(ind - lz,  L ));             ++lz;           }           for (long long j = 0; j < (i - ind); ++j)             ans.push_back(make_pair(ind - lz,  R ));           lz += i - ind;         }         cur = 0;         lst = i + 1;       }     }     if (cur || p < m) fail();     cout <<  YES n ;     for (auto v : ans) cout << v.first + 1 <<     << v.second << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int gcd(long long int a, long long int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long int lcm(long long int a, long long int b) {     return a * b / gcd(a, b);   }   long long int fexp(long long int a, long long int b) {     long long int ans = 1;     while (b) {       if (b & 1) ans = ans * a % 998244353;       b /= 2;       a = a * a % 998244353;     }     return ans;   }   long long int inverse(long long int a, long long int p) {     return fexp(a, p - 2);   }   void solve() {     string s;     cin >> s;     long long int n = (long long int)s.size();     long long int ans = 1e9 + 5;     set<long long int> st;     long long int cnt = 0;     vector<long long int> vec(4, 0);     long long int fir = s[0] -  0 , num = 0;     for (long long int i = 0; i < n; i++) {       cnt = 0;       long long int idx = s[i] -  0 ;       if (idx == fir && i != num) {         vec[fir] = 1;         st.insert(idx);         fir = s[i - 1] -  0 ;         continue;       }       st.insert(idx);       vec[idx]++;       if ((long long int)st.size() == 3) {         cnt = vec[s[i - 1] -  0 ] + 2;         ans = min(ans, cnt);         st.erase(fir);         vec[fir] = 0;         vec[s[i - 1] -  0 ] = 1;         fir = s[i - 1] -  0 ;         num = i - 1;       }     }     if (ans == 1e9 + 5) {       cout << 0 <<   n ;       return;     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2005;   vector<pair<int, int> > v[N * N];   bool flag[N * N], a[N][N], vis[N][N];   pair<int, int> dis[N * N];   int id[N][N], q[N * N], ID, n, m, r, c, sx, sy, ans;   char s[N];   void bfs(int r, int c) {     int L = 0, R = 0;     q[R++] = id[r][c];     flag[id[r][c]] = true;     dis[id[r][c]] = make_pair(0, 0);     while (L < R) {       int u = q[L++], sz = v[u].size();       for (int i = 0; i < sz; i++) {         int x = v[u][i].first, y = v[u][i].second;         if (y > 1 && a[x][y - 1] && !flag[id[x][y - 1]]) {           q[R++] = id[x][y - 1];           flag[id[x][y - 1]] = true;           dis[id[x][y - 1]] = make_pair(dis[u].first + 1, dis[u].second);         }         if (y < m && a[x][y + 1] && !flag[id[x][y + 1]]) {           q[R++] = id[x][y + 1];           flag[id[x][y + 1]] = true;           dis[id[x][y + 1]] = make_pair(dis[u].first, dis[u].second + 1);         }       }     }   }   void dfs(int x, int y, int z) {     vis[x][y] = true;     id[x][y] = z;     v[z].push_back(make_pair(x, y));     if (x > 1 && a[x - 1][y] && !vis[x - 1][y]) dfs(x - 1, y, z);     if (x < n && a[x + 1][y] && !vis[x + 1][y]) dfs(x + 1, y, z);   }   int main() {     memset(dis, 0x3f, sizeof(dis));     scanf( %d%d%d%d%d%d , &n, &m, &r, &c, &sx, &sy);     for (int i = 1; i <= n; i++) {       scanf( %s , s + 1);       for (int j = 1; j <= m; j++) a[i][j] = (s[j] ==  . );     }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         if (a[i][j] && !vis[i][j]) ID++, dfs(i, j, ID);     bfs(r, c);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         if (a[i][j]) {           int u = id[i][j];           if (dis[u].first <= sx && dis[u].second <= sy) ans++;         }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using P = pair<int, int>;   const long long MOD = 1000000007;   const long long INF = 1LL << 60;   const int INT_INF = 1000000000;   int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};   void solve() {     int n;     cin >> n;     vector<ll> a(n);     for (auto &ai : a) cin >> ai;     bool positive;     if (a[0] < 0)       positive = false;     else       positive = true;     ll sum = 0;     ll tmp = a[0];     for (int i = 1; i < n; i++) {       if (positive) {         if (a[i] > 0) {           tmp = max(tmp, a[i]);         } else {           sum += tmp;           tmp = a[i];           positive = false;         }       } else {         if (a[i] > 0) {           sum += tmp;           tmp = a[i];           positive = true;         } else {           tmp = max(tmp, a[i]);         }       }     }     sum += tmp;     cout << sum << endl;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int t;     cin >> t;     for (int i = 0; i < t; i++) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) {     if (a == 0) {       return b;     }     return gcd(b % a, a);   }   int idx[200001] = {0};   vector<int> g[160];   int dp[160][100001] = {0};   int len[160][200001] = {0};   int nless(vector<int>& v, int val) {     if (!(int)v.size()) return 0;     if (v[0] > val) return 0;     int l = 0, r = (int)v.size() - 1;     while (r - l + 1 > 2) {       int x = (l + r) / 2;       if (v[x] > val) {         r = x;       } else {         l = x;       }     }     if (r - l + 1 == 2) {       if (v[r] <= val) {         return r + 1;       } else {         return l + 1;       }     }     if (r - l + 1 == 1) {       return l + 1;     }   }   void solve() {     int n;     cin >> n;     vector<int> v(n);     for (int j = 0; j < n; j++) cin >> v[j];     int num = 1;     vector<int> factors;     factors.push_back(1);     for (int j = 2; j <= sqrt(n); j++) {       if (n % j == 0) {         factors.push_back(j);         num++;         if (j * j != n) {           factors.push_back(n / j);           num++;         }       }     }     sort(factors.begin(), factors.end());     for (int j = 0; j < (int)factors.size(); j++) {       idx[factors[j]] = j;     }     for (int j = 1; j < n; j++) {       g[idx[gcd(j, n)]].push_back(j);     }     for (int j = n - 1; j >= 0; j--) {       for (int i = 0; i < num; i++) {         dp[i][j % factors[i]] = max(dp[i][j % factors[i]], v[j]);       }     }     for (int j = n - 1; j >= 0; j--) {       for (int i = 0; i < num; i++) {         len[i][j] = (v[j] == dp[i][j % factors[i]]) * (1 + len[i][j + 1]);       }     }     for (int j = n - 1; j >= 0; j--) {       for (int i = 0; i < num; i++) {         len[i][j] = min(             n - 1, (v[j] == dp[i][j % factors[i]]) * (1 + len[i][(j + 1) % n]));       }     }     long long int ans = 0;     for (int j = 0; j < n; j++) {       for (int i = 0; i < num; i++) {         int cnt = nless(g[i], len[i][j]);         ans += cnt;       }     }     cout << ans <<   n ;     return;   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     int t;     t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2 * 1000 + 5;   const long long INF = 1000ll * 1000 * 1000 * 1000 * 1000 * 1000;   int n, k, dp[maxn], a[maxn];   bool check(long long x) {     for (int i = 1; i <= n; i++) {       dp[i] = i - 1;       for (int j = 1; j < i; j++) {         if (abs(a[i] - a[j]) <= (i - j) * x)           dp[i] = min(dp[i], dp[j] + i - j - 1);         if (dp[i] + n - i <= k) return true;       }     }     return false;   }   int main() {     cin >> n >> k;     for (int i = 1; i <= n; i++) cin >> a[i];     if (n == 1) {       cout << 0 << endl;       return 0;     }     long long l = -1, r = INF + 1, mid;     while (r - l > 1) {       mid = (l + r) >> 1;       if (check(mid))         r = mid;       else         l = mid;     }     cout << r << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int arr[n];     int i = 0;     int cnt[101] = {0};     for (int i = 0; i < n; i++) {       cin >> arr[i];       cnt[arr[i]]++;     }     int a = -1, b = -1;     for (int i = 0; i <= 100; i++) {       if (cnt[i] == n / 2) {         if (a == -1)           a = i;         else           b = i;       }     }     if (a != -1 && b != -1) {       cout <<  YES n ;       cout << a <<     << b;     } else       cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   const int MAXN = 2020;   int n, m;   int mp[MAXN][MAXN], realx[MAXN], realy[MAXN], cntx, cnty;   char dir[MAXN];   int len[MAXN];   void unique(int *real, int &cnt) {     std::sort(real, real + cnt);     int t2 = 1;     for (int t1 = 1; t1 < cnt; t1++)       if (real[t1] ^ real[t1 - 1]) real[t2++] = real[t1];     cnt = t2;   }   inline bool legal(int x, int y) {     return x >= 0 && x <= cntx && y >= 0 && y <= cnty;   }   void dfs(int x, int y) {     mp[x][y] = -1;     if (legal(x + 1, y) && !mp[x + 1][y]) dfs(x + 1, y);     if (legal(x - 1, y) && !mp[x - 1][y]) dfs(x - 1, y);     if (legal(x, y + 1) && !mp[x][y + 1]) dfs(x, y + 1);     if (legal(x, y - 1) && !mp[x][y - 1]) dfs(x, y - 1);   }   int main() {     scanf( %d , &n);     register int nowx = 0, nowy = 0;     for (int i = 1; i <= n; i++) {       scanf( %s%d , dir + i, len + i);       switch (dir[i]) {         case  L :           realx[cntx++] = nowx + 1;           realx[cntx++] = nowx -= len[i];           realy[cnty++] = nowy;           realy[cnty++] = nowy + 1;           break;         case  R :           realx[cntx++] = nowx;           realx[cntx++] = (nowx += len[i]) + 1;           realy[cnty++] = nowy;           realy[cnty++] = nowy + 1;           break;         case  U :           realy[cnty++] = nowy;           realy[cnty++] = (nowy += len[i]) + 1;           realx[cntx++] = nowx;           realx[cntx++] = nowx + 1;           break;         case  D :           realy[cnty++] = nowy + 1;           realy[cnty++] = nowy -= len[i];           realx[cntx++] = nowx;           realx[cntx++] = nowx + 1;           break;       }     }     unique(realx, cntx);     unique(realy, cnty);     int curx = std::upper_bound(realx, realx + cntx, nowx = 0) - realx,         cury = std::upper_bound(realy, realy + cnty, nowy = 0) - realy, nxt;     for (int i = 1; i <= n; i++) {       switch (dir[i]) {         case  L :           nxt = std::upper_bound(realx, realx + cntx, nowx -= len[i]) - realx;           while (curx > nxt) mp[curx--][cury] = 1;           break;         case  R :           nxt = std::upper_bound(realx, realx + cntx, nowx += len[i]) - realx;           while (curx < nxt) mp[curx++][cury] = 1;           break;         case  U :           nxt = std::upper_bound(realy, realy + cnty, nowy += len[i]) - realy;           while (cury < nxt) mp[curx][cury++] = 1;           break;         case  D :           nxt = std::upper_bound(realy, realy + cnty, nowy -= len[i]) - realy;           while (cury > nxt) mp[curx][cury--] = 1;           break;       }     }     mp[curx][cury] = 1;     for (int i = 0; i <= cntx; i++) {       if (!mp[i][cnty]) dfs(i, cnty);       if (!mp[i][0]) dfs(i, 0);     }     for (int i = 1; i < cnty; i++) {       if (!mp[cntx][i]) dfs(cntx, i);       if (!mp[0][i]) dfs(0, i);     }     long long ans = 0;     for (int i = 1; i <= cntx; i++)       for (int j = 1; j <= cnty; j++)         if (~mp[i][j])           ans += 1ll * (realx[i] - realx[i - 1]) * (realy[j] - realy[j - 1]);     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char func(char c) {     if (c >=  A  && c <=  Z ) c = tolower(c);     if (c ==  o )       c =  0 ;     else if (c ==  l  || c ==  i )       c =  1 ;     return c;   }   int main() {     string s;     int n;     cin >> s >> n;     for (int i = 0; i < n; i++) {       string str;       cin >> str;       if (str.size() != s.size()) continue;       bool ok = true;       for (int j = 0; j < s.size(); j++) {         if (func(s[j]) != func(str[j])) {           ok = false;           break;         }       }       if (ok) {         cout <<  No ;         return 0;       }     }     cout <<  Yes ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long P = (long long)1e9 + 7;   int n, k;   int a[2];   long long c[60][60];   long long cnt[60][60];   int dp[60][60];   struct rmdr {     int i, j;     bool operator<(const rmdr& a) const {       if (50 * i + 100 * j != 50 * a.i + 100 * a.j)         return 50 * i + 100 * j < 50 * a.i + 100 * a.j;       return i > a.i;     }   };   rmdr r[100010];   int sz = 0;   int main() {     cin >> n >> k;     a[0] = a[1] = 0;     for (int i = 0; i < int(n); ++i) {       int tmp;       cin >> tmp;       if (tmp == 50)         a[0]++;       else         a[1]++;     }     memset(c, 0, sizeof(c));     c[0][0] = 1;     for (int i = int(1); i < int(n + 1); ++i) {       c[i][0] = 1;       for (int j = int(1); j < int(i + 1); ++j)         c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % P;     }     memset(cnt, 0, sizeof(cnt));     for (int i = 0; i < int(a[0] + 1); ++i)       for (int j = 0; j < int(a[1] + 1); ++j) dp[i][j] = 100500;     dp[0][0] = 0;     cnt[0][0] = 1;     for (int i = 0; i < int(a[0] + 1); ++i)       for (int j = 0; j < int(a[1] + 1); ++j) {         if (i == 0 && j == 0) continue;         r[sz].i = i, r[sz].j = j;         sz++;       }     sort(r, r + sz);     for (int z = 0; z < int(sz); ++z) {       int i = r[z].i, j = r[z].j;       if (50 * i + 100 * j <= k) {         dp[i][j] = 1;         cnt[i][j] = 1;         continue;       }       for (int i1 = 0; i1 < int(i + 1); ++i1)         for (int j1 = 0; j1 < int(j + 1); ++j1) {           if (i1 == 0 && j1 == 0) continue;           if (50 * i1 + 100 * j1 > k) break;           for (int i2 = 0; i2 < int(a[0] - i + i1 + 1); ++i2)             for (int j2 = 0; j2 < int(a[1] - j + j1 + 1); ++j2) {               if (i2 == 0 && j2 == 0) continue;               if (50 * i2 + 100 * j2 > k) break;               if (dp[i][j] >= dp[i - i1 + i2][j - j1 + j2] + 2) {                 long long tmp = (cnt[i - i1 + i2][j - j1 + j2] * c[i][i1]) % P;                 tmp = (tmp * c[j][j1]) % P;                 tmp = (tmp * c[a[0] - i + i1][i2]) % P;                 tmp = (tmp * c[a[1] - j + j1][j2]) % P;                 if (dp[i][j] > dp[i - i1 + i2][j - j1 + j2] + 2) {                   dp[i][j] = dp[i - i1 + i2][j - j1 + j2] + 2;                   cnt[i][j] = tmp;                 } else                   cnt[i][j] = (cnt[i][j] + tmp) % P;               }             }         }     }     if (dp[a[0]][a[1]] == 100500) {       printf( -1 n0 n );     } else {       printf( %d n%d n , dp[a[0]][a[1]], int(cnt[a[0]][a[1]]));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e5 + 5;   const long long inf = -1;   const long long m = 1e6;   vector<long long> prime;   bool sieve[m + 2];   void primeSieve() {     memset(sieve, true, sizeof(sieve));     sieve[0] = sieve[1] = false;     prime.push_back(2);     for (long long i = 4; i <= m; i += 2) sieve[i] = false;     long long sqrtn = sqrt(m);     for (long long i = 3; i <= sqrtn; i += 2) {       if (sieve[i]) {         for (long long j = i * i; j <= m; j += 2 * i) sieve[j] = false;       }     }     for (long long i = 3; i <= m; i += 2)       if (sieve[i]) prime.push_back(i);   }   map<pair<long long, long long>, long long> use;   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     primeSieve();     long long n, m, i;     cin >> n >> m;     long long pos =         upper_bound(prime.begin(), prime.end(), n - 2) - prime.begin();     long long need = prime[pos] - (n - 2);     vector<pair<long long, pair<long long, long long>>> v;     long long x = 1;     for (i = 1; i < n; i++) {       if (i + 1 == n) x = need;       v.push_back(make_pair(i, make_pair(i + 1, x)));       use[make_pair(i, i + 1)] = 1;     }     long long sum = (n - 2) + need;     m -= (n - 1);     for (i = 1; i < n; i++) {       if (m == 0) break;       for (long long j = i + 1; j <= n; j++) {         if (m == 0) break;         if (!use[make_pair(i, j)] and m) {           v.push_back(make_pair(i, make_pair(j, mod)));           m--;           use[make_pair(i, j)] = 1;         }       }     }     cout << sum <<     << sum << endl;     for (auto p : v) {       cout << p.first <<     << (p.second).first <<     << (p.second).second            << endl;     }   }