inlineintread(){ int s = 0, x = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') x = -x; ch = getchar(); } while (isdigit(ch)) { s = s * 10 + ch - '0'; ch = getchar(); } return s * x; }
int n;
intmain(){ int T = read(); while (T --> 0) { n = read(); for (int a = 0; a <= n; a += 3) { for (int b = 0; a + b <= n; b += 5) { int c = n - a - b; if (c % 7 == 0) { printf("%d %d %d\n", a / 3, b / 5, c / 7); goto suc; } } } puts("-1"); suc: continue; } return0; }
inlineintread(){ int s = 0, x = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') x = -x; ch = getchar(); } while (isdigit(ch)) { s = s * 10 + ch - '0'; ch = getchar(); } return s * x; }
constint MAXN = 200000 + 10;
int n, k, aa[MAXN];
intmain(){ int T = read(); while (T --> 0) { n = read(); k = read(); for (int i = 1; i <= n; ++i) { aa[i] = read(); } std::sort(aa + 1, aa + 1 + n, std::greater<int>()); longlongint ans = 0; for (int i = 1; i <= k + 1; ++i) ans += 1ll * aa[i]; printf("%lld\n", ans); } return0; }
inlineintread(){ int s = 0, x = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') x = -x; ch = getchar(); } while (isdigit(ch)) { s = s * 10 + ch - '0'; ch = getchar(); } return s * x; }
int n; std::priority_queue<int> st; std::vector<std::pair<int, int> > op;
intmain(){ int T = read(); while (T --> 0) { n = read(); for (int i = 1; i <= n; ++i) { st.push(i); } for (int i = 1; i <= n - 1; ++i) { auto mxn = st.top(); st.pop(); auto tmxn = st.top(); st.pop(); st.push((mxn + tmxn + 1) >> 1); op.push_back({mxn, tmxn}); } printf("%d\n", st.top()); while (!st.empty()) st.pop(); for (auto v : op) { printf("%d %d\n", v.first, v.second); } op.clear(); } return0; }