malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long blk = 300;   struct data {     long long l, r, i;     data() { l = r = i = 0; }     data(long long v1, long long v2, long long v3) {       l = v1;       r = v2;       i = v3;     }     bool operator<(const data &x) const {       if (l / blk != x.l / blk)         return (l / blk < x.l / blk);       else         return (r < x.r);     }   };   long long num[100005], num2[100005];   data query[100005];   long long freq[1048600], freq2[1048600];   long long output[100005];   int main() {     long long a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t;     scanf( %lld %lld %lld , &a, &b, &c);     num[0] = 0;     for (i = 1; i <= a; i++) {       scanf( %lld , &num[i]);       num2[i] = num[i];       num[i] ^= num[i - 1];     }     for (i = a - 1; i >= 1; i--) num2[i] ^= num2[i + 1];     for (i = 1; i <= b; i++) {       scanf( %lld %lld , &d, &e);       query[i] = data(d, e, i);     }     sort(query + 1, query + b + 1);     memset(freq, 0, sizeof(freq));     l = 1;     r = 0;     long long ans = 0;     num[a + 1] = 0;     freq[0]++;     freq2[num2[1]]++;     for (i = 1; i <= b; i++) {       freq2[num2[r + 1]]--;       while (r < query[i].r) {         r++;         ans += freq[c ^ num[r]];         freq[num[r]]++;         freq2[num2[r]]++;       }       while (r > query[i].r) {         freq[num[r]]--;         freq2[num2[r]]--;         ans -= freq[c ^ num[r]];         r--;       }       freq2[num2[r + 1]]++;       freq[num[l - 1]]--;       while (l < query[i].l) {         freq2[num2[l]]--;         freq[num[l]]--;         ans -= freq2[c ^ num2[l]];         l++;       }       while (l > query[i].l) {         l--;         ans += freq2[c ^ num2[l]];         freq2[num2[l]]++;         freq[num[l]]++;       }       freq[num[l - 1]]++;       output[query[i].i] = ans;     }     for (i = 1; i <= b; i++) {       printf( %lld n , output[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int tam = 100010;   const int MOD = 1000000007;   const int MOD1 = 998244353;   const double EPS = 1e-9;   const double PI = acos(-1);   int ar[3000000];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     for (int i = 0; i < n; i++) ar[i] = i + 1;     for (int i = 2; i < n + 1; i++) {       for (int j = (n + i - 2) - (n % i == 0 ? i : n % i); j > i - 3; j -= i) {         ar[min(n + i - 2, j + i)] = ar[j];       }     }     for (int i = n - 1; i < 2 * n - 1; i++) {       if (i > n - 1) cout <<    ;       cout << ar[i];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string str;     int n;     cin >> n >> str;     bool flag = true;     int fs = 0, ss = 0;     for (int i = 0; i < n; i++) {       if (str[i] !=  4  && str[i] !=  7 ) {         flag = false;       }     }     for (int i = 0; i < n / 2; i++) {       fs += str[i] -  0 ;     }     for (int i = n / 2; i < n; i++) {       ss += str[i] -  0 ;     }     if (fs != ss) flag = false;     if (flag)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   inline int gi() {     register int x = 0, f = 0;     register char ch = getchar();     while (!isdigit(ch)) f ^= ch ==  - , ch = getchar();     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return f ? -x : x;   }   std::set<std::pair<int, int> > st[100010];   std::bitset<200010> bit, I, B, C;   inline bool nmd(int n, int g) {     for (int i = 1; i < n; ++i)       for (auto j : st[i]) {         int a = j.first, b = j.second;         a = (a + g - 1) % n + 1, b = (b + g - 1) % n + 1;         if (st[i].find({a, b}) == st[i].end() &&             st[i].find({b, a}) == st[i].end())           return 0;       }     puts( Yes );     exit(0);   }   int main() {     long long n = gi(), m = gi(), a, b, c;     for (int i = 1; i <= m; ++i) {       a = gi(), b = gi();       if (a > b) std::swap(a, b);       c = std::min(b - a, a + n - b);       if (b - a != c) std::swap(a, b);       if (c * 2 == n)         st[c].insert({b, a}), st[c].insert({a, b});       else         st[c].insert({a, b});     }     for (int i = 1; i * i <= n; ++i)       if (n % i == 0) {         nmd(n, i);         if (i * i != n && i != 1) nmd(n, n / i);       }     puts( No );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 1e5 + 5;   const int M = 1e6;   const long long INF = (long long)(1e18);   const int inf = 1e9;   const long long MOD = 1000000007LL;   long long n, m;   long long a[MAX_N];   long long ans[MAX_N];   long long suff[MAX_N];   void solve() {}   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     long long s = 0LL;     for (long long i = 1; i <= m; i++) {       cin >> a[i];       s += a[i];     }     bool ok = true;     for (long long i = 1; i <= m; i++) {       if (i - 1 + a[i] > n) {         ok = false;         break;       }     }     if (s < n || !ok) {       cout << -1;       return 0;     }     for (long long i = m; i >= 1; i--) {       suff[i] = suff[i + 1] + a[i];       ans[i] = max(i, n - suff[i] + 1);     }     for (long long i = 1; i <= m; i++) {       cout << ans[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, k;     cin >> n >> k;     long long ans = 0;     for (int i = 0; i < k && n >= 2; i++) {       ans += n - 1 + n - 2;       n -= 2;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   char src[2002], tar[2002];   int ans[2002 * 4], n;   int get(int l, int r, char ch) {     for (int i = l; i <= r; i++)       if (src[i] == ch) return i;     return -1;   }   void reverse(int l, int r) {     for (int i = l; i < r - i + l; i++) swap(src[i], src[r - i + l]);   }   void doswap(int la, int lb) {     reverse(la + lb + 1, n);     reverse(1, n);     reverse(2, n);   }   void work() {     int step = 0;     for (int i = n; i >= 1; i--) {       int p = get(n - i + 1, n, tar[i]);       if (p == -1) {         puts( -1 );         return;       } else {         ans[++step] = n;         ans[++step] = p - 1;         ans[++step] = 1;         doswap(n - i, p - n + i - 1);       }     }     printf( %d n , step);     for (int i = 1; i <= step; i++) printf( %d  , ans[i]);     putchar(  n );   }   int main() {     scanf( %d , &n);     scanf( %s , src + 1);     scanf( %s , tar + 1);     work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100100;   int main() {     ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     int t;     cin >> t;     for (int hh = 1; hh <= t; hh++) {       int a, b, c, r, aa, bb;       cin >> aa >> bb >> c >> r;       int r1, r2;       r1 = c - r;       r2 = c + r;       a = min(aa, bb);       b = max(aa, bb);       if (a >= r2) {         cout << b - a << endl;         continue;       }       if (b <= r1) {         cout << b - a << endl;         continue;       }       if (a >= r1 && b <= r2) {         cout << 0 << endl;         continue;       }       if (a < r1 && b > r2) {         cout << r1 - a + b - r2 << endl;         continue;       }       if (a < r1 && b <= r2) {         cout << r1 - a << endl;         continue;       }       if (a >= r1 && b > r2) {         cout << b - r2 << endl;         continue;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mxn = 300001;   int n;   long long a[mxn], dp[mxn];   map<int, int> first[mxn];   void answer() {     cin >> n;     long long ret = 0;     for (int i = 1; i <= n; i++) {       cin >> a[i];       first[i].clear();       if (first[i - 1].count(a[i])) {         int x = first[i - 1][a[i]];         ret += (dp[i] = (x ? dp[x - 1] : 0) + 1);         swap(first[i], first[x - 1]);         first[i][a[x - 1]] = x - 1;       } else {         dp[i] = 0;       }       first[i][a[i]] = i;     }     cout << ret <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int t;     cin >> t;     for (int i = 0; i < t; i++) answer();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     vector<int> a(n);     int prev = -1;     bool invalid = false;     for (int i = 0; i < n; i++) {       cin >> a[i];       invalid = (prev > a[i]) || (a[i] > i + 1);       prev = a[i];     }     if (invalid) {       cout << -1 << endl;       return;     }     int mex = a.back();     vector<int> ans(n);     bool first = true;     for (int i = 0, cnt = 0; i < n; i++) {       if (first && i == mex) {         first = false;         cnt++;       }       ans[i] = cnt++;     }     for (int i = n - 1; ~i; i--) {       if (ans[a[i]] == a[i]) {         swap(ans[a[i]], ans[i + 1]);       }     }     for (int i = 0; i < n; i++) {       cout << ans[i] <<    n [i + 1 == n];     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = (1 << 20) + 50;   const int MAXLOG = 21;   long long int a[MAXN];   long long int data[MAXLOG][MAXN];   long long int answer[2][MAXN];   long long int n;   void build(int s = 0, int e = (1 << n), int h = 0) {     if (e - s < 2) {       data[h][s] = a[s];       return;     }     int mid = (s + e) / 2;     build(s, mid, h + 1);     build(mid, e, h + 1);     merge(data[h + 1] + s, data[h + 1] + mid, data[h + 1] + mid, data[h + 1] + e,           data[h] + s);     for (int i = s; i < mid; i++) {       long long int now = lower_bound(data[h + 1] + mid, data[h + 1] + e, a[i]) -                           (data[h + 1] + mid);       answer[0][h] += now;     }     for (int i = mid; i < e; i++) {       long long int now = lower_bound(data[h + 1] + s, data[h + 1] + mid, a[i]) -                           (data[h + 1] + s);       answer[1][h] += now;     }   }   int main() {     scanf( %I64d , &n);     for (int i = 0; i < (1 << n); i++) {       scanf( %I64d , a + i);     }     build();     long long int q;     scanf( %I64d , &q);     while (q--) {       long long int ans = 0;       long long int cur;       scanf( %I64d , &cur);       for (int i = n - cur; i < n; ++i) {         swap(answer[0][i], answer[1][i]);       }       for (int i = 0; i < n; i++) {         ans += answer[0][i];       }       printf( %I64d n , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   int n, a[N], cnt[N], sum[N];   vector<int> pos[N];   set<int> S;   int main() {     scanf( %d , &n);     for (int i = (1); i <= (n); ++i)       scanf( %d , &a[i]), ++cnt[a[i]], pos[a[i]].push_back(i);     int tt = 0, mx = 0;     for (int i = (1); i <= (n); ++i) {       if (cnt[i] > cnt[mx]) {         mx = i;         tt = 0;       }       if (cnt[i] == cnt[mx]) {         ++tt;       }     }     if (tt > 1) {       printf( %d n , n);       return 0;     }     for (int i = (1); i <= (n + 1); ++i)       sum[i] = sum[i - 1] + (a[i] == mx), a[i] == mx && (S.insert(i), 0);     int ans = 0;     for (int i = (1); i <= (n); ++i)       if (i != mx && ((int)(pos[i]).size())) {         vector<int> v;         for (auto x : pos[i]) {           {             auto it = S.lower_bound(x);             if (it != S.begin()) {               v.push_back(*prev(it));               S.erase(prev(it));             }             if (it != S.end()) {               v.push_back(*it);               S.erase(*it);             }           }           {             auto it = S.lower_bound(x);             if (it != S.begin()) {               v.push_back(*prev(it));               S.erase(prev(it));             }             if (it != S.end()) {               v.push_back(*it);               S.erase(*it);             }           }         }         vector<int> t(v);         for (auto x : pos[i]) v.push_back(x);         {           auto it = S.lower_bound(*min_element(v.begin(), v.end()));           if (it != S.begin()) {             --it;             v.push_back(*it);           }           v.push_back(0);           it = S.upper_bound(*max_element(v.begin(), v.end()));           if (it != S.end()) {             v.push_back(*it);           }           v.push_back(n + 1);         }         sort(v.begin(), v.end());         map<int, int> fi;         fi[sum[v[0]]] = v[0];         int s = 0;         for (int j = (1); j <= (((int)(v).size()) - 1); ++j) {           if (fi.count(sum[v[j] - 1] + s)) {             ans = max(ans, v[j] - 1 - fi[sum[v[j] - 1] + s]);           }           if (a[v[j]] == i) --s;           if (!fi.count(sum[v[j]] + s)) fi[sum[v[j]] + s] = v[j];         }         for (auto x : t) S.insert(x);       }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   long long a[1 << 24], dp[1 << 24], b[2];   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> a[1 << i];     cin >> k;     for (int i = 0; i < k; i++) cin >> b[i];     for (int i = 1; i < (1 << n); i++) {       long long s = 0;       int t = i;       while (t) {         s += (a[t & (-t)]);         t -= t & (-t);       }       for (int j = 0; j < k; j++) {         if (s == b[j]) {           dp[i] = -1;           break;         }       }     }     dp[0] = 1;     for (int i = 1; i < (1 << n); i++) {       if (dp[i] == -1) {         dp[i] = 0;         continue;       }       for (int j = 0; j < n; j++) {         if (1 & (i >> j)) {           dp[i] += dp[i ^ (1 << j)];         }       }       if (dp[i] >= 1000000007ll) dp[i] %= 1000000007ll;     }     cout << dp[(1 << n) - 1] << endl;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( O3 )   #pragma GCC optimize( no-stack-protector )   #pragma GCC optimize( unroll-loops )   #pragma GCC optimize( fast-math )   #pragma GCC target( sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native )   mt19937 rng(time(NULL));   const int inf = 1e9 + 100;   const long long linf = 2e18;   const long long maxn = 2e5 + 100;   const int mod = 1e9 + 7;   vector<int> g[maxn];   int c[maxn];   bool f = 1;   void dfs(int v, int cl) {     c[v] = cl;     for (int i : g[v]) {       if (c[i] == 0)         dfs(i, cl == 1 ? 2 : 1);       else if (c[i] == cl)         f = 0;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, m;     cin >> n >> m;     vector<pair<int, int> > ans(m);     for (int i = 0; i < m; ++i) {       cin >> ans[i].first >> ans[i].second;       g[ans[i].first - 1].push_back(ans[i].second - 1);       g[ans[i].second - 1].push_back(ans[i].first - 1);     }     for (int i = 0; i < n; ++i)       if (!c[i]) dfs(i, 1);     if (f) {       cout <<  YES n ;       for (auto i : ans) {         if (c[i.first - 1] == 2)           cout << 1;         else           cout << 0;       }     } else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void wldd() {     long long n, a, b;     cin >> n >> a >> b;     b = b % n;     long long sum = 0;     if (b < 0) {       sum = n + a + b;     } else {       sum = a + b;     }     if (sum % n == 0)       cout << n <<   n ;     else       cout << abs(sum % n) <<   n ;   }   int32_t main() {     wldd();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int sgn(double x) { return (x > 1e-8) - (x < -1e-8); }   int count_bit(int x) { return x == 0 ? 0 : count_bit(x >> 1) + (x & 1); }   template <class T>   inline void to_min(T &a, const T b) {     if (b < a) a = b;   }   template <class T>   inline void to_max(T &a, const T b) {     if (b > a) a = b;   }   const int maxn = 200000 + 10;   int n, a[3], w[maxn];   bool used[maxn];   int rearray(int n) {     int newn = 0;     for (int i = 0; i < (n); ++i) {       if (!used[i]) {         w[newn++] = w[i];       }     }     return newn;   }   int solve() {     int r = a[2] + a[1] + a[0];     if (r < w[n - 1]) {       return -1;     }     int ret = 0;     int l = a[2] + a[1];     while (n >= 0 && w[n - 1] > l) {       ++ret;       --n;     }     r = l;     l = a[2] + a[0];     memset(used, 0, sizeof(used));     int max_idx = upper_bound(w, w + n, a[0]) - w - 1;     while (n >= 0 && w[n - 1] > l) {       ++ret;       --n;       if (max_idx >= 0) {         used[max_idx--] = true;       }     }     n = rearray(n);     r = l;     l = max(a[2], a[1] + a[0]);     memset(used, 0, sizeof(used));     max_idx = upper_bound(w, w + n, a[1]) - w - 1;     while (n >= 0 && w[n - 1] > l) {       ++ret;       --n;       if (max_idx >= 0) {         used[max_idx--] = true;       }     }     n = rearray(n);     if (a[1] + a[0] > a[2]) {       r = a[1] + a[0];       l = a[2];       memset(used, 0, sizeof(used));       max_idx = upper_bound(w, w + n, a[2]) - w - 1;       while (n >= 0 && w[n - 1] > l) {         ++ret;         --n;         if (max_idx >= 0) {           used[max_idx--] = true;         }       }       n = rearray(n);     }     memset(used, 0, sizeof(used));     int idx_3 = n - 1;     int idx_2 = upper_bound(w, w + n, a[1]) - w;     int idx_1 = upper_bound(w, w + n, a[1]) - w - 1;     int idx_0 = 0;     while (true) {       while (idx_3 >= 0 && used[idx_3]) --idx_3;       if (idx_3 < 0) break;       used[idx_3--] = true;       ++ret;       if (idx_1 >= idx_0) {         while (idx_1 >= idx_0 && used[idx_1]) --idx_1;         if (idx_1 >= idx_0) {           used[idx_1--] = true;         }         while (idx_0 <= idx_1 && w[idx_0] <= a[0] && used[idx_0]) ++idx_0;         if (idx_0 <= idx_1 && w[idx_0] <= a[0]) {           used[idx_0++] = true;         }       } else {         if (!used[idx_2] && w[idx_2] <= a[0] + a[1]) {           used[idx_2++] = true;         }       }     }     return ret;   }   int main() {     ios::sync_with_stdio(false);     cout << fixed << setprecision(8);     cin >> n;     for (int i = 0; i < (3); ++i) {       cin >> a[i];     }     sort(a, a + 3);     for (int i = 0; i < (n); ++i) {       cin >> w[i];     }     sort(w, w + n);     cout << solve() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int main() {     scanf( %d , &n);     printf( +------------------------+ n );     printf( | );     if (n >= 1)       printf( O. );     else       printf( #. );     for (int i = 2; i <= 11; i++)       if ((i - 2) * 3 + 4 + 1 <= n)         printf( O. );       else         printf( #. );     printf( |D|) n );     printf( | );     if (n >= 2)       printf( O. );     else       printf( #. );     for (int i = 2; i <= 11; i++)       if ((i - 2) * 3 + 4 + 2 <= n)         printf( O. );       else         printf( #. );     printf( |.| n );     if (n >= 3)       printf( |O.......................| n );     else       printf( |#.......................| n );     printf( | );     if (n >= 4)       printf( O. );     else       printf( #. );     for (int i = 2; i <= 11; i++)       if ((i - 2) * 3 + 4 + 3 <= n)         printf( O. );       else         printf( #. );     printf( |.|) n );     printf( +------------------------+ n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, x, y;     int a[1005], b[1005], c[1005], d[1005];     cin >> n >> m >> x >> y;     for (int i = 1; i <= m; i++) {       cin >> a[i] >> b[i] >> c[i] >> d[i];     }     int dp[1005][11];     int temp, i, j, k, t;     for (int i = 0; i <= n; i++) {       dp[i][0] = 0;     }     for (i = 1; i <= n; i++) {       for (j = 1; j <= m; j++) {         temp = -1;         t = a[j] / b[j];         for (k = 0; k <= t; k++)           if (k * c[j] <= i) {             temp = max(temp, dp[i - k * c[j]][j - 1] + k * d[j]);           }         dp[i][j] = temp;       }     }     int Max = -1;     for (int l = 0; l <= n; l++) {       Max = max(Max, dp[l][m] + ((n - l) / x) * y);     }     cout << Max << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     long long x;     int c;     friend bool operator<(node x, node y) { return x.x < y.x; }   } a[400001];   long long leftdata[400001], rightdata[400001];   int n;   long long ans;   long long max1, max2, l1, r1, ttt;   void work1() {     long long tans;     l1 = 0;     for (int i = 1; i <= n; ++i)       if (a[i].c == 0) {         tans = ans;         if (l1 != 0) ans += a[i].x - l1;         l1 = a[i].x;       }     l1 = 0;     for (int i = 1; i <= n; ++i)       if (a[i].c == 1) {         tans = ans;         if (l1 != 0) ans += a[i].x - l1;         l1 = a[i].x;       }     cout << ans << endl;   }   void work2() {     long long tans;     long long f1 = 0, f2 = 0;     int sum = 0;     for (int i = 1; i <= n; ++i) {       if (a[i].c == 2) {         max2 = max(a[i].x - r1, max2);         max1 = max(a[i].x - l1, max1);         sum++;         if (sum == 1) {           tans = ans;           if (f1 != 0) ans = ans + a[i].x - f1;           if (f2 != 0) ans = ans + a[i].x - f2;         } else {           long long t1 = a[i].x + a[i].x - ttt - ttt;           long long t2 =               (a[i].x + a[i].x - ttt - ttt) - max1 + (a[i].x - ttt) - max2;           long long yzc = min(t1, t2);           ans = ans + yzc;         }         l1 = r1 = ttt = a[i].x;         max1 = 0;         max2 = 0;       } else if (a[i].c == 0) {         if (f1 == 0) f1 = a[i].x;         if (max1 < a[i].x - l1) max1 = a[i].x - l1;         l1 = a[i].x;       } else {         if (f2 == 0) f2 = a[i].x;         if (max2 < a[i].x - r1) max2 = a[i].x - r1;         r1 = a[i].x;       }     }     f1 = 0;     f2 = 0;     for (int i = n; i >= 1; --i) {       if (a[i].c == 2) {         tans = ans;         if (f1 != 0) ans = ans + f1 - a[i].x;         if (f2 != 0) ans = ans + f2 - a[i].x;         break;       } else if (a[i].c == 0) {         if (f1 == 0) f1 = a[i].x;       } else {         tans = ans;         if (f2 == 0) f2 = a[i].x;       }     }     cout << ans << endl;   }   int main() {     scanf( %d , &n);     char tmp[123];     int sumx = 0;     for (int i = 1; i <= n; ++i) {       long long x;       scanf( %lld , &x);       scanf( %s , tmp);       a[i].x = x;       if (tmp[0] ==  R )         a[i].c = 0;       else if (tmp[0] ==  B )         a[i].c = 1;       else         a[i].c = 2, sumx++;     }     sort(a + 1, a + n + 1);     ans = max1 = max2 = l1 = r1 = ttt = 0;     if (sumx == 0)       work1();     else       work2();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, d, h;   vector<pair<int, int> > ans;   int main() {     ios::sync_with_stdio(0);     cin >> n >> d >> h;     if (2 * h < d || (d == 1 && n > 2)) {       cout << -1 <<   n ;       return 0;     }     for (int i = 2; i <= h + 1; i++) ans.push_back(make_pair(i - 1, i));     int idx = 1;     bool done = false;     for (int i = h + 2; i <= d + 1; i++) {       ans.push_back(make_pair(idx, i));       done = true;       idx = i;     }     if (done)       idx = 1;     else       idx = 2;     for (int i = d + 2; i <= n; i++) ans.push_back(make_pair(idx, i));     for (int i = 0; i < ans.size(); i++)       cout << ans[i].first <<     << ans[i].second <<   n ;     return 0;   }