There are some rabbits in Singapore Zoo. To feed them, Zookeeper bought $$$n$$$ carrots with lengths $$$a_1, a_2, a_3, \ldots, a_n$$$. However, rabbits are very fertile and multiply very quickly. Zookeeper now has $$$k$$$ rabbits and does not have enough carrots to feed all of them. To solve this problem, Zookeeper decided to cut the carrots into $$$k$$$ pieces. For some reason, all resulting carrot lengths must be positive integers.Big carrots are very difficult for rabbits to handle and eat, so the time needed to eat a carrot of size $$$x$$$ is $$$x^2$$$.Help Zookeeper split his carrots while minimizing the sum of time taken for rabbits to eat the carrots.

The first line contains two integers $$$n$$$ and $$$k$$$ $$$(1 \leq n \leq k \leq 10^5)$$$: the initial number of carrots and the number of rabbits. The next line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ $$$(1 \leq a_i \leq 10^6)$$$: lengths of carrots. It is guaranteed that the sum of $$$a_i$$$ is at least $$$k$$$.

Output one integer: the minimum sum of time taken for rabbits to eat carrots.

NoteFor the first test, the optimal sizes of carrots are $$$\{1,1,1,2,2,2\}$$$. The time taken is $$$1^2+1^2+1^2+2^2+2^2+2^2=15$$$For the second test, the optimal sizes of carrots are $$$\{4,5,5,5\}$$$. The time taken is $$$4^2+5^2+5^2+5^2=91$$$.

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b);
  if (b < a) return [];
  let arr = Array(b - a + 1)
  for (let i = a; i <= b; i++) arr[i - a] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return a;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  a = a || 0;
  b = b || (this.length - 1);
  let prev = a;
  for (let i = a; i <= b; i++) {
    if (i == b || fn(this[i], this[i + 1], i, this)) {
      arr.push(this.slice(prev, i + 1));
      prev = i + 1;
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
function inv(b, m) {
  for (var a = m, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + m) % m;
}

// let MOD = 1e9 + 7
// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[MOD % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }
// alpha = "abcdefghijklmnopqrstuvwxyz"

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
async function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, { min, max, ceil, floor, sqrt, abs, log2 } = Math,
    bi = BigInt, rand = n => Math.random() * n | 0;

  let [n, k] = $(2), a = $(n)
  let h = new Heap(n), res = 0n;
  a.forEach(v => {
    res += bi(v * v);
    let c = 2;
    let p = v / c | 0;
    let s = p * p * (c - v % c) + (p + 1) * (p + 1) * (v % c);
    h.push(s - v * v, { v: v, c: c, s: s })
  });
  // log(h);
  For(n + 1, k, i => {
    res += bi(h.h[1].key);
    let c = h.h[1].data.c + 1;
    let v = h.h[1].data.v;
    let p = v / c | 0;
    let s = p * p * (c - v % c) + (p + 1) * (p + 1) * (v % c);
    h.update(1, s - h.h[1].data.s, { v: v, c, s })
  })
  log(res+'')
}

class Heap {
  size; comp; h; // h = {key,data,i}[]
  constructor(MAX_LENGTH = 100, comp = (a, b) => a.key < b.key) {
    this.h = Array(MAX_LENGTH);
    this.size = 0;
    this.comp = comp;
  }
  swap(i, j) {
    this.h[i].i = j; this.h[j].i = i;
    [this.h[i], this.h[j]] = [this.h[j], this.h[i]];
  }
  upHeap(i) {
    let i2
    while (i > 1) {
      i2 = i >> 1;
      if (this.comp(this.h[i2], this.h[i])) break;
      this.swap(i, i2)
      i = i2;
    }
    return this.h[i];
  }
  downHeap(i) {
    let i2;
    while (1) {
      i2 = i << 1;
      if (i2 < this.size && this.comp(this.h[i2 | 1], this.h[i2])) i2 |= 1;
      if (i2 > this.size || this.comp(this.h[i], this.h[i2])) break;
      this.swap(i, i2)
      i = i2;
    }
    return this.h[i];
  }
  push(key, data) {
    this.h[++this.size] = { key, data, i: this.size };
    return this.upHeap(this.size);
  }
  pop() {
    this.swap(1, this.size);
    this.size--;
    this.downHeap(1);
    return this.h[this.size + 1];
  }
  update(i, key, data) {
    this.h[i].key = key;
    this.h[i].data = data;
    if (i > 1 && this.comp(this.h[i], this.h[i >> 1])) return this.upHeap(i);
    return this.downHeap(i);
  }
  remove(i) {
    this.swap(i, this.size);
    this.size--;
    if (i > 1 && this.comp(this.h[i], this.h[i >> 1])) this.upHeap(i);
    else this.downHeap(i);
    return this.h[this.size + 1];
  }
}

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b);
  if (b < a) return [];
  let arr = Array(b - a + 1)
  for (let i = a; i <= b; i++) arr[i - a] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return a;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  a = a || 0;
  b = b || (this.length - 1);
  let prev = a;
  for (let i = a; i <= b; i++) {
    if (i == b || fn(this[i], this[i + 1], i, this)) {
      arr.push(this.slice(prev, i + 1));
      prev = i + 1;
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
function inv(b, m) {
  for (var a = m, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + m) % m;
}

// let MOD = 1e9 + 7
// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[MOD % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }
// alpha = "abcdefghijklmnopqrstuvwxyz"

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
async function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, { min, max, ceil, floor, sqrt, abs, log2 } = Math,
    bi = BigInt, rand = n => Math.random() * n | 0;

  let [n, k] = $(2), a = $(n)
  let l = 1, r = a.max()[0], m;
  while (l < r) {
    let m = (l + r) / 2 | 0;
    let s = 0;
    For(n, i => {
      s += ceil(a[i] / m);
    })
    if (s <= k) r = m;
    else l = m + 1;
  }
  let res = 0;
  For(n, i => {
    let x = ceil(a[i] / l);
    let pn = a[i] / x | 0;
    let pdu = a[i] - pn * x;
    res += pn * pn * (x - pdu) + (pn + 1) * (pn + 1) * pdu;
  })
  log(res)
}

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b);
  if (b < a) return [];
  let arr = Array(b - a + 1)
  for (let i = a; i <= b; i++) arr[i - a] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return a;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  a = a || 0;
  b = b || (this.length - 1);
  let prev = a;
  for (let i = a; i <= b; i++) {
    if (i == b || fn(this[i], this[i + 1], i, this)) {
      arr.push(this.slice(prev, i + 1));
      prev = i + 1;
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
function inv(b, m) {
  for (var a = m, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + m) % m;
}

// let MOD = 1e9 + 7
// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[MOD % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }
// alpha = "abcdefghijklmnopqrstuvwxyz"

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
async function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, { min, max, ceil, floor, sqrt, abs, log2 } = Math,
    bi = BigInt, rand = n => Math.random() * n | 0;

  let [n, k] = $(2), a = $(n).sort(asc)
  let l = 1, r = a[n - 1], m;
  while (l < r) {
    let m = (l + r) / 2 | 0;
    let s = 0;
    For(n, i => {
      s += ceil(a[i] / m);
    })
    if (s <= k) r = m;
    else l = m + 1;
  }
  let res = 0;
  let sl = 0;
  For(n - 1, i => {
    let x = ceil(a[i] / l);
    let pn = a[i] / x | 0;
    let pdu = a[i] - pn * x;
    res += pn * pn * (x - pdu) + (pn + 1) * (pn + 1) * pdu;
    sl += x;
  })
  let x = k - sl;
  let pn = a[n - 1] / x | 0;
  let pdu = a[n - 1] - pn * x;
  res += pn * pn * (x - pdu) + (pn + 1) * (pn + 1) * pdu;
  log(res)
}

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b);
  if (b < a) return [];
  let arr = Array(b - a + 1)
  for (let i = a; i <= b; i++) arr[i - a] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return a;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  a = a || 0;
  b = b || (this.length - 1);
  let prev = a;
  for (let i = a; i <= b; i++) {
    if (i == b || fn(this[i], this[i + 1], i, this)) {
      arr.push(this.slice(prev, i + 1));
      prev = i + 1;
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
function inv(b, m) {
  for (var a = m, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + m) % m;
}

// let MOD = 1e9 + 7
// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[MOD % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }
// alpha = "abcdefghijklmnopqrstuvwxyz"

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
async function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, { min, max, ceil, floor, sqrt, abs, log2 } = Math,
    bi = BigInt, rand = n => Math.random() * n | 0;

  let [n, k] = $(2), a = $(n)
  let h = new Heap(n), res = 0;
  a.forEach(v => {
    res += v * v;
    let c = 2;
    let p = v / c | 0;
    let s = p * p * (c - v % c) + (p + 1) * (p + 1) * (v % c);
    h.push(s - v * v, { v: v, c: c, s: s })
  });
  // log(h);
  For(n + 1, k, i => {
    res += h.h[1].key;
    let c = h.h[1].data.c + 1;
    let v = h.h[1].data.v;
    let p = v / c | 0;
    let s = p * p * (c - v % c) + (p + 1) * (p + 1) * (v % c);
    h.update(1, s - h.h[1].data.s, { v: v, c, s })
  })
  log(res)
}

class Heap {
  size; comp; h; // h = {key,data,i}[]
  constructor(MAX_LENGTH = 100, comp = (a, b) => a.key < b.key) {
    this.h = Array(MAX_LENGTH);
    this.size = 0;
    this.comp = comp;
  }
  swap(i, j) {
    this.h[i].i = j; this.h[j].i = i;
    [this.h[i], this.h[j]] = [this.h[j], this.h[i]];
  }
  upHeap(i) {
    let i2
    while (i > 1) {
      i2 = i >> 1;
      if (this.comp(this.h[i2], this.h[i])) break;
      this.swap(i, i2)
      i = i2;
    }
    return this.h[i];
  }
  downHeap(i) {
    let i2;
    while (1) {
      i2 = i << 1;
      if (i2 < this.size && this.comp(this.h[i2 | 1], this.h[i2])) i2 |= 1;
      if (i2 > this.size || this.comp(this.h[i], this.h[i2])) break;
      this.swap(i, i2)
      i = i2;
    }
    return this.h[i];
  }
  push(key, data) {
    this.h[++this.size] = { key, data, i: this.size };
    return this.upHeap(this.size);
  }
  pop() {
    this.swap(1, this.size);
    this.size--;
    this.downHeap(1);
    return this.h[this.size + 1];
  }
  update(i, key, data) {
    this.h[i].key = key;
    this.h[i].data = data;
    if (i > 1 && this.comp(this.h[i], this.h[i >> 1])) return this.upHeap(i);
    return this.downHeap(i);
  }
  remove(i) {
    this.swap(i, this.size);
    this.size--;
    if (i > 1 && this.comp(this.h[i], this.h[i >> 1])) this.upHeap(i);
    else this.downHeap(i);
    return this.h[this.size + 1];
  }
}


For some time the program of rounding numbers that had been developed by the Codeforces participants during one of the previous rounds, helped the citizens of Far Far Away to convert numbers into a more easily readable format. However, as time went by, the economy of the Far Far Away developed and the scale of operations grew. So the King ordered to found the Bank of Far Far Away and very soon even the rounding didn't help to quickly determine even the order of the numbers involved in operations. Besides, rounding a number to an integer wasn't very convenient as a bank needed to operate with all numbers with accuracy of up to 0.01, and not up to an integer.The King issued yet another order: to introduce financial format to represent numbers denoting amounts of money. The formal rules of storing a number in the financial format are as follows:   A number contains the integer part and the fractional part. The two parts are separated with a character "." (decimal point).  To make digits in the integer part of a number easier to read, they are split into groups of three digits, starting from the least significant ones. The groups are separated with the character "," (comma). For example, if the integer part of a number equals 12345678, then it will be stored in the financial format as 12,345,678  In the financial format a number's fractional part should contain exactly two digits. So, if the initial number (the number that is converted into the financial format) contains less than two digits in the fractional part (or contains no digits at all), it is complemented with zeros until its length equals 2. If the fractional part contains more than two digits, the extra digits are simply discarded (they are not rounded: see sample tests).  When a number is stored in the financial format, the minus sign is not written. Instead, if the initial number had the minus sign, the result is written in round brackets.  Please keep in mind that the bank of Far Far Away operates using an exotic foreign currency — snakes ($), that's why right before the number in the financial format we should put the sign "$". If the number should be written in the brackets, then the snake sign should also be inside the brackets. For example, by the above given rules number 2012 will be stored in the financial format as "$2,012.00" and number -12345678.9 will be stored as "($12,345,678.90)".The merchants of Far Far Away visited you again and expressed much hope that you supply them with the program that can convert arbitrary numbers to the financial format. Can you help them?

The input contains a number that needs to be converted into financial format. The number's notation length does not exceed 100 characters, including (possible) signs "-" (minus) and "." (decimal point). The number's notation is correct, that is:    The number's notation only contains characters from the set {"0" – "9", "-", "."}.  The decimal point (if it is present) is unique and is preceded and followed by a non-zero quantity on decimal digits  A number cannot start with digit 0, except for a case when its whole integer part equals zero (in this case the integer parts is guaranteed to be a single zero: "0").  The minus sign (if it is present) is unique and stands in the very beginning of the number's notation  If a number is identically equal to 0 (that is, if it is written as, for example, "0" or "0.000"), than it is not preceded by the minus sign.  The input data contains no spaces.  The number's notation contains at least one decimal digit.

Print the number given in the input in the financial format by the rules described in the problem statement.

NotePay attention to the second and third sample tests. They show that the sign of a number in the financial format (and consequently, the presence or absence of brackets) is determined solely by the sign of the initial number. It does not depend on the sign of the number you got after translating the number to the financial format.


Vasya decided to go to the grocery store. He found in his wallet $$$a$$$ coins of $$$1$$$ burle and $$$b$$$ coins of $$$2$$$ burles. He does not yet know the total cost of all goods, so help him find out $$$s$$$ ($$$s > 0$$$): the minimum positive integer amount of money he cannot pay without change or pay at all using only his coins.For example, if $$$a=1$$$ and $$$b=1$$$ (he has one $$$1$$$-burle coin and one $$$2$$$-burle coin), then:  he can pay $$$1$$$ burle without change, paying with one $$$1$$$-burle coin,  he can pay $$$2$$$ burle without change, paying with one $$$2$$$-burle coin,  he can pay $$$3$$$ burle without change by paying with one $$$1$$$-burle coin and one $$$2$$$-burle coin,  he cannot pay $$$4$$$ burle without change (moreover, he cannot pay this amount at all). So for $$$a=1$$$ and $$$b=1$$$ the answer is $$$s=4$$$.

The first line of the input contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the test. The description of each test case consists of one line containing two integers $$$a_i$$$ and $$$b_i$$$ ($$$0 \le a_i, b_i \le 10^8$$$) — the number of $$$1$$$-burle coins and $$$2$$$-burles coins Vasya has respectively.

For each test case, on a separate line print one integer $$$s$$$ ($$$s > 0$$$): the minimum positive integer amount of money that Vasya cannot pay without change or pay at all.

Note  The first test case of the example is clarified into the main part of the statement.  In the second test case, Vasya has only $$$1$$$ burle coins, and he can collect either any amount from $$$1$$$ to $$$4$$$, but $$$5$$$ can't.  In the second test case, Vasya has only $$$2$$$ burle coins, and he cannot pay $$$1$$$ burle without change.  In the fourth test case you don't have any coins, and he can't even pay $$$1$$$ burle.

var t = parseInt(readline());

while(t--){
    var s = readline().split(' ');
	var a = parseInt(s[0]);
	var b = parseInt(s[1]);
	var res = b * 2 + a + 1;
	if(a == 0)res = 1;
	print(res);
}

var t = parseInt(readline());

while (t--) {
    // const [a, b] = readline().split(" ").map(function(x) { return parseInt(x); });
    // const [a, b] = readline().split(" ").map(x => parseInt(x));
    var ab = readline().split(' ');

    var a = parseInt(ab[0]);
    var b = parseInt(ab[1]);

    var r = a + 2 * b + 1;

    if (!a) {
        r = 1;
    }

    write(r);
    write('\n');
}

var test_cases = parseInt(readline());
var i;
for( i=0; i<test_cases; i++){
var coins = readline().split(" ");
var total_no=0;

if( parseInt(coins[0]) == 0 && parseInt(coins[1]) > 0){
	total_no =1;
	print(total_no);
}

else if (parseInt(coins[0]) == 0 && parseInt(coins[1]) == 0){
	total_no =1;
	print(total_no);
}

else if(parseInt(coins[0]) > 0 && parseInt(coins[1]) >= 0){
	total_no =  parseInt(coins[0]) + (parseInt(coins[1]) * 2)+1;
	print(total_no);
}
print("\n");
}

var t = readline();
for (var i=0 ; i < t ; i++){
    var inputs = readline().split(' ');
        a = inputs[0] , b = inputs[1];
        if(a == '0'){
            print(1);
        }
        else{
            print(parseInt(a) + (parseInt(b) * 2) + 1);
        }
}

var tests = parseInt(readline());
    for (var t=0; t < tests; t++) {
        var ab = readline().split(' ').map(x=>parseInt(x));
        var a = ab[0];
        var b = ab[1];
        if (a == 0) {
            print(1);
        } else {
            print(a + 2 * b + 1);
        }
    }

T = readline ()
while(T--){
   x = readline().split(' ').map(x => +x)
   a = x[0]
   b = x[1]

   if(a === 0)
      print(1)
   else
      print(a + b*2 +1)

}

var x = readline();

var res ="";
while(x--){

var arr = readline().split(' ');

res +=  arr[0] == 0 ?  1+'\n' : (+1 + +arr[0] + ( +arr[1] * 2 )) +'\n' ;
}
print(res);

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', function(inputStdin) {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function minSum(oneBurle,twoBurle){
    if(twoBurle===0){
        return oneBurle+1
    }
    else if(oneBurle===0){
        return 1
    }
    else{
        return (twoBurle*2) + oneBurle + 1
    }
}

function main() {

    const t = parseInt(readLine().trim(), 10);

    for (let tItr = 0; tItr < t; tItr++) {
        const vals = readLine().split(' ');

        const a = parseInt(vals[0], 10);
        const b = parseInt(vals[1], 10);
        const result = minSum(a,b);
        console.log(result)
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function main() {
    let t = readLine();
    t = parseInt(t);
    while(t--) {
        let line = readLine();
        line = line.split(" ");
        let n = parseInt(line[0]);
        let m = parseInt(line[1]);
       if(n!==0)
	   {console.log(n+2*m+1);}
		else console.log(1);

    }
}

const readline = require("readline");
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false,
});

let c = 0;

rl.on("line", (d) => {
  if (c === 0) {
    c++;
    return;
  }

  const [a, b] = d.split(" ").map(Number);
  const ans = a + b * 2 + 1;

  if (a === 0) {
    console.log(1);
  } else {
    console.log(ans);
  }
  c++;
});

rl.on("close", () => {});

process.stdin.resume(); process.stdin.setEncoding('utf-8'); let inputString = ''; let currentLine = 0; process.stdin.on('data', inputStdin => { inputString += inputStdin; }); process.stdin.on('end', _ => { inputString = inputString.trim().split('\n').map(string => { return string.trim(); }); main(); }); function readLine() { return inputString[currentLine++]; }
function main() {
  const N = parseInt(readLine());

  for (let i = 0; i < N; i++) {
    const [ar, br] = readLine().split(' ');
    const a = Number(ar);
    const b = Number(br);

    if (a) {
      console.log(a + b * 2 + 1);
    } else {
      console.log(1);
    }
  }
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const [a, b] = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(a, b)
    }
    console.log(output.join('\n'))
// })()
})

function solve(a, b) {
    const odd = a >= 1 ? (Math.floor((a - 1) / 2) + b) * 2 + 1 : -1
    const even = (Math.floor(a / 2) + b) * 2
// console.log(odd, even)

    let ans
    if (odd === even + 1 || even === odd + 1) {
        ans = Math.max(odd, even) + 1
    } else {
        ans = Math.min(odd, even) + 1
    }
    return Math.max(1, ans)
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', stdin => inputString += stdin);

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(s => s.trim());
    main();
});

function readline() {
    return inputString[currentLine++];
}

function output(x) {
    if (typeof x !== 'string') {
        x = x.toString();
    }
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    let N = readline();

    for (let test = 0; test < N; test++) {
        let [a, b] = readline().split(' ').map(Number);
        output(a === 0 ? 1 : b * 2 + a + 1);
    }
}

let q = '';
process.stdin.on('data', c => q += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = q.split(EOL);
    var n = lines[0];
    for(j = 1; j <= n; j++){
        var a = lines[j].split(' ').map(Number);
        var one = a[0];
        var two = a[1] * 2;
        if(one === 0){
            console.log(1);
        }else{
            console.log(one + two + 1);
        }
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n; j++){
        var a = lines[j].split(' ').map(Number)
        var one = a[0]
        var two = a[1] * 2
        if(one === 0){
            console.log(1)
        }else{
            console.log(one + two + 1)
        }
    }
});

process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  main();
});

function readLine() {
  return inputString[currentLine++];
}

function main() {
  let t = parseInt(readLine());

  for (let i = 0; i < t; i++) {
    let [a, b] = readLine().split(" ").map(Number);

    if (a == 0) {
      console.log(1);
    } else if (b == 0) {
      console.log(a + 1);
    } else {
      a += b * 2;
      console.log(a + 1);
    }
  }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
function readLine() {
    return inputString[currentLine++];
};
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
    // cmd(not powershell): node cp.js < input.txt
});

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        console.log(solve());
    }
}
function solve() {
    const [a, b] = readLine().split(" ").map(i => parseInt(i));
    if (a === 0 && b === 0) return 1;
    if (a === 0) return 1;
    return a + (2 * b) + 1;
}

const fs = require('fs')
const inputs = fs
  .readFileSync(0, 'utf-8')
  .split('\n')
  .map(line => line.trim().split(' ').map(Number))

const [n] = inputs[0]
const data = inputs.slice(1, n + 1)

main(n, data)
function main(n, data) {
  let res = []
  for (let [a, b] of data) {
    if (a === 0) res.push(1)
    else res.push(a + b * 2 + 1)
  }
  console.log(res.join('\n'))
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = nextLong();
		}else if(code == 'double'){
			ret[i] = nextDouble();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');} function nextDoubleArray(size){return nextArray(size, 'double');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());} function nextDouble(){return parseFloat(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var A = nextInt();
		var B = nextInt();
		if(A >= 1){
			myout(A + (B * 2) + 1);
		}else{
			myout(1);
		}
	}
}

'use strict'; /*jslint node:true, browser:true, es6:true*/
const print = console.log
const E = {};
const lines = []
if (!process.env.JEST_WORKER_ID){
  const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
  rl.on('line', line => {
      lines.push(line);
  });
  rl.on('close', main)
}
let rli = 0;
function readline() {
    return lines[rli++];
}

module.exports = E;

const ra = ()=>readline().split(' ').map(a=>+a)

const EPS = 1e-6;

const calc = (a, b)=>{
  if (a==0)
    return 1;
  return a+b*2+1;
};

function main() {
    let T = +readline();
    while (T--){
      let [a, b] = ra();
      print(calc(a, b))
    }
}

E.calc = calc;

var t = parseInt(readline());

while(t--){
    var s = readline().split(' ');
	var a = parseInt(s[0]);
	var b = parseInt(s[1]);
	var res = b * 2 + a + 1;
	if(a <= b){
	    res = a * 3 + 1;
	}
	print(res + '\n');
}

var t = parseInt(readline());

while (t--) {
    // const [a, b] = readline().split(" ").map(function(x) { return parseInt(x); });
    // const [a, b] = readline().split(" ").map(x => parseInt(x));
    var ab = readline().split(' ');

    var a = parseInt(ab[0]);
    var b = parseInt(ab[1]);

    write(a + 2 * b + 1);
    write('\n');
}

let minSum = function(oneBurle,twoBurle){
    if(twoBurle==0){
        return oneBurle+1;
    }
    else if(oneBurle==0){
        return 1;
    }
    else{
        return (twoBurle*2) + oneBurle + 1 ;
    }
};

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function main() {
    let t = readLine();
    t = parseInt(t);
    while(t--) {
        let line = readLine();
        line = line.split(" ");
        let n = parseInt(line[0]);
        let m = parseInt(line[1]);

		console.log(n+2*m+1);

    }
}

const readline = require("readline");
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false,
});

let c = 0;

rl.on("line", (d) => {
  if (c === 0) {
    c++;
    return;
  }

  const [a, b] = d.split(" ").map(Number);
  const ans = a + b * 2 + 1;
  console.log(ans);
  c++;
});

rl.on("close", () => {});

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const [a, b] = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(a, b)
    }
    console.log(output.join('\n'))
// })()
})

function solve(a, b) {
    return binarySearch(1, 1e9, x => {
        const two = Math.min(Math.floor(x / 2), b)
        return two * 2 + a >= x
    }) + 1
}
function binarySearch(l, r, fn) {
    while (l <= r) {
        const m = Math.floor((l + r) / 2)
        if (fn(m)) {
            l = m + 1
        } else {
            r = m - 1
        }
    }
    return r
}


Alice and Bob are playing a game. They start with a positive integer $$$n$$$ and take alternating turns doing operations on it. Each turn a player can subtract from $$$n$$$ one of its divisors that isn't $$$1$$$ or $$$n$$$. The player who cannot make a move on his/her turn loses. Alice always moves first.Note that they subtract a divisor of the current number in each turn.You are asked to find out who will win the game if both players play optimally.

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^9$$$) — the initial number.

For each test case output "Alice" if Alice will win the game or "Bob" if Bob will win, if both players play optimally.

NoteIn the first test case, the game ends immediately because Alice cannot make a move.In the second test case, Alice can subtract $$$2$$$ making $$$n = 2$$$, then Bob cannot make a move so Alice wins.In the third test case, Alice can subtract $$$3$$$ so that $$$n = 9$$$. Bob's only move is to subtract $$$3$$$ and make $$$n = 6$$$. Now, Alice can subtract $$$3$$$ again and $$$n = 3$$$. Then Bob cannot make a move, so Alice wins.

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let curLine = 0;

const readLine = () => standardInputString[curLine++];

const readArray = (splitter, mapFunc) => readLine()
  .split(splitter)
  .map(mapFunc);

const eratosphenSieve = (limiter = 1e5) => {
  const sieve = new Array(limiter)
    .fill(true);
  sieve[0] = sieve[1] = false;

  for (let num = 2; num < sieve.length; num += 1) {
    if (num) {
      let mod = 2;

      while (num * mod < sieve.length) {
        sieve[num * mod] = false;
        mod += 1;
      }
    }
  }

  const simpleNums = [];
  sieve
    .forEach((item, ix) => {
      item && simpleNums.push(ix);
    });

  return simpleNums;
};

process.stdin.on("data", rawData => {
  standardInputString += rawData;
});

process.stdin.on("end", _ => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map(line => {
      return line.trim();
    });

  main();
});

// https://codeforces.com/problemset/problem/1537/d

/**
 * Types of num n:
 * 1) odd
 *   - Has only odd dividers. After subtraction we obtain even number, since oddNum - oddNum = evenNum
 *   - Short: we can transit only to 3 state
 * 2) even which is power of 2
 *   - We can subtract half of number, since (n**2 % 2 === 0) and obtain another power of 2.
 *   - On the other hand we can subtract k*2, where k is a divider of n. In that case we obtain even number, which is not power of 2.
 *   - It is not power of 2, since n === k*2 * x (where x is power of 2) => n - k*2 === k*2 * x - k*2 => n - k*2 === (x - 1) * k*2. x is a power of 2 =>
 *   - => x - 1 is odd number.
 *   - Short: we can transit to 2 state of 3 state
 * 3) even
 *   - Since it is not power of 2 we have at least one odd divider => we can subtract it and get 1 state
 *   - We can subtract even number and change state to 3
 *
 * Our transitions between states:
 * 1 -> 3
 * 2 -> 2
 * 2 -> 3
 * 3 -> 1
 *
 * Profit of states:
 * 1) Our number is simple or it is 1 => Lose
 * 2) If we change state to 1 we lose => we should change state to 2 => if log(n) % 2 Win else Lose
 * 3) We can change state to 1 => Win
 */

const main = () => {
  const t = +readLine();

  for (let testCaseNum = 0; testCaseNum < t; testCaseNum++) {
    const n = +readLine();

    const binaryN = n.toString(2);
    const powerOfTwo = binaryN.length - 1;

    if (n % 2 === 1) {
      console.log("Bob");
    } else if (binaryN === Math.pow(2, powerOfTwo).toString(2)) {
      console.log(powerOfTwo % 2 === 0 ? "Alice" : "Bob");
    } else {
      console.log("Alice");
    }
  }
};

const lib = require('readline');
const rl = lib.createInterface({
    input: process.stdin,
    output: process.stdout
});

const getLine = (function () {
    const getLineGen = (async function* () {
        for await (const line of rl) {
            yield line;
        }
    })();
    return async () => ((await getLineGen.next()).value);
})();

let solve = async () => {
    /*const was = [];
    for(let i = 1; i <= 1000; i++) {
        was[i] = 1;
        for(let j = 2; j*j<=i; j++){
            if (i%j==0 && was[i-j] === 1) {
                was[i] = 0;
                break;
            }
            if (i%j ===0 && was[i-i/j] === 1) {
                was[i] = 0;
                break;
            }
        }
    }
    const was2=[];
    for(let i =2; i<=1000; i+=2)
        if (was[i]==1){
            was2.push(i);
        }
    console.log(was2.join(' '));*/
    const nsc = parseInt(await getLine());
    for(let sc = 0; sc < nsc; sc++) {
        let n = parseInt(await getLine());
        let pow = 0;
        while (n%2==0){
            n=n/2;
            pow++;
        }
        if (pow == 0 || (pow%2==1 && n===1)) {
            console.log('Bob');
        }
        else
            console.log('Alice');
    }
}

solve();

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let curLine = 0;

const readLine = () => standardInputString[curLine++];

const readArray = (splitter, mapFunc) => readLine()
  .split(splitter)
  .map(mapFunc);

const eratosphenSieve = (limiter = 1e5) => {
  const sieve = new Array(limiter)
    .fill(true);
  sieve[0] = sieve[1] = false;

  for (let num = 2; num < sieve.length; num += 1) {
    if (num) {
      let mod = 2;

      while (num * mod < sieve.length) {
        sieve[num * mod] = false;
        mod += 1;
      }
    }
  }

  const simpleNums = [];
  sieve
    .forEach((item, ix) => {
      item && simpleNums.push(ix);
    });

  return simpleNums;
};

process.stdin.on("data", rawData => {
  standardInputString += rawData;
});

process.stdin.on("end", _ => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map(line => {
      return line.trim();
    });

  main();
});

// https://codeforces.com/problemset/problem/1537/d

/**
 * Types of num n:
 * 1) odd
 *   - Has only odd dividers. After subtraction we obtain even number, since oddNum - oddNum = evenNum
 *   - Short: we can transit only to 3 state
 * 2) even which is power of 2
 *   - We can subtract half of number, since (n**2 % 2 === 0) and obtain another power of 2.
 *   - On the other hand we can subtract k*2, where k is a divider of n. In that case we obtain even number, which is not power of 2.
 *   - It is not power of 2, since n === k*2 * x (where x is power of 2) => n - k*2 === k*2 * x - k*2 => n - k*2 === (x - 1) * k*2. x is a power of 2 =>
 *   - => x - 1 is odd number.
 *   - Short: we can transit to 2 state of 3 state
 * 3) even
 *   - Since it is not power of 2 we have at least one odd divider => we can subtract it and get 1 state
 *   - We can subtract even number and change state to 3
 *
 * Our transitions between states:
 * 1 -> 3
 * 2 -> 2
 * 2 -> 3
 * 3 -> 1
 *
 * Profit of states:
 * 1) Our number is simple or it is 1 => Lose
 * 2) If we change state to 1 we lose => we should change state to 2 => if log(n) % 2 Win else Lose
 * 3) We can change state to 1 => Win
 */

const main = () => {
  const t = +readLine();

  for (let testCaseNum = 0; testCaseNum < t; testCaseNum++) {
    const n = +readLine();

    const binaryN = n.toString(2);
    const powerOfTwo = binaryN.length - 1;
    console.log(powerOfTwo, binaryN, Math.pow(2, powerOfTwo).toString(2));

    if (n % 2 === 1) {
      console.log("Bob");
    } else if (binaryN === Math.pow(2, powerOfTwo).toString(2)) {
      console.log(powerOfTwo % 2 === 0 ? "Alice" : "Bob");
    } else {
      console.log("Alice");
    }
  }
};

const lib = require('readline');
const rl = lib.createInterface({
    input: process.stdin,
    output: process.stdout
});

const getLine = (function () {
    const getLineGen = (async function* () {
        for await (const line of rl) {
            yield line;
        }
    })();
    return async () => ((await getLineGen.next()).value);
})();

let solve = async () => {
    const nsc = parseInt(await getLine());
    for(let sc = 0; sc < nsc; sc++) {
        let n = parseInt(await getLine());
        let pow = 0;
        while (n%2==0){
            n/=2;
            pow++;
        }
        if (pow = 0 || (pow%2==1 && n===1)) {
            console.log('Bob');
        }
        else
            console.log('Alice');
    }
}

solve();


You are given an integer $$$n$$$.You should find a list of pairs $$$(x_1, y_1)$$$, $$$(x_2, y_2)$$$, ..., $$$(x_q, y_q)$$$ ($$$1 \leq x_i, y_i \leq n$$$) satisfying the following condition.Let's consider some function $$$f: \mathbb{N} \times \mathbb{N} \to \mathbb{N}$$$ (we define $$$\mathbb{N}$$$ as the set of positive integers). In other words, $$$f$$$ is a function that returns a positive integer for a pair of positive integers.Let's make an array $$$a_1, a_2, \ldots, a_n$$$, where $$$a_i = i$$$ initially.You will perform $$$q$$$ operations, in $$$i$$$-th of them you will:   assign $$$t = f(a_{x_i}, a_{y_i})$$$ ($$$t$$$ is a temporary variable, it is used only for the next two assignments);  assign $$$a_{x_i} = t$$$;  assign $$$a_{y_i} = t$$$. In other words, you need to simultaneously change $$$a_{x_i}$$$ and $$$a_{y_i}$$$ to $$$f(a_{x_i}, a_{y_i})$$$. Note that during this process $$$f(p, q)$$$ is always the same for a fixed pair of $$$p$$$ and $$$q$$$.In the end, there should be at most two different numbers in the array $$$a$$$.It should be true for any function $$$f$$$.Find any possible list of pairs. The number of pairs should not exceed $$$5 \cdot 10^5$$$.

The single line contains a single integer $$$n$$$ ($$$1 \leq n \leq 15\,000$$$).

In the first line print $$$q$$$ ($$$0 \leq q \leq 5 \cdot 10^5$$$) — the number of pairs. In each of the next $$$q$$$ lines print two integers. In the $$$i$$$-th line print $$$x_i$$$, $$$y_i$$$ ($$$1 \leq x_i, y_i \leq n$$$). The condition described in the statement should be satisfied. If there exists multiple answers you can print any of them.

NoteIn the first example, after performing the only operation the array $$$a$$$ will be $$$[f(a_1, a_2), f(a_1, a_2), a_3]$$$. It will always have at most two different numbers.In the second example, after performing two operations the array $$$a$$$ will be $$$[f(a_1, a_2), f(a_1, a_2), f(a_3, a_4), f(a_3, a_4)]$$$. It will always have at most two different numbers.

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn, init) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b, fn);
  if (b < a) return [];
  let arr = Array(b - a + 1).fill(0);
  if (init) init(arr);
  for (let i = a; i <= b; i++) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.for = function (a, b, fn) {
  let res
  for (let i = a; i <= b; i++) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.forR = function (a, b, fn) {
  let res
  for (let i = a; i >= b; i--) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
let MOD = 998244353
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + MOD) % MOD;
}
// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[998244353 % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let n = $()

  let merge = (start, size) => {
    if (size < 2) return;
    if (size == 2) return out.push((start + 0) + ' ' + (start + 1));
    merge(start, size / 2)
    merge(start + size / 2, size / 2)
    For(size / 2, i => { out.push((start + i) + ' ' + (start + size / 2 + i)) })
  }
  let solve = (n) => {
    let n2 = 1 << Math.log2(n) | 0
    merge(1, n2)
    if (n - n2 + 1 > 1) merge(n - n2 + 1, n2)
  }
  solve(n)
  log(out.length)
  log(out.join('\n'))
}


You are given three positive (greater than zero) integers $$$c$$$, $$$d$$$ and $$$x$$$. You have to find the number of pairs of positive integers $$$(a, b)$$$ such that equality $$$c \cdot lcm(a, b) - d \cdot gcd(a, b) = x$$$ holds. Where $$$lcm(a, b)$$$ is the least common multiple of $$$a$$$ and $$$b$$$ and $$$gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Each test case consists of one line containing three integer $$$c$$$, $$$d$$$ and $$$x$$$ ($$$1 \le c, d, x \le 10^7$$$).

For each test case, print one integer — the number of pairs ($$$a, b$$$) such that the above equality holds.

let text = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', str => {
    if (str === '\r\n' || str === '\n') {
        process.stdin.emit('end');
    } else {
        text += str;
    }
});

process.stdin.on('end', () => {
    const input = text.trim().replace(/\r/g, '').split('\n');
    const total = +input[0];
    for (let i = 1; i <= total; i++) {
        console.log(solve(input[i]));
    }

    process.exit();
});

const max = 10 ** 7 * 2 + 1;
const record = new Array(max + 1).fill(1);

for (let i = 2; i < max; i++) {
    if (record[i] === 1) {
        record[i] = 2;
        for (let j = i * 2; j <= max; j += i) {
            record[j] <<= 1;
        }
    }
}
function solve(str) {
    const [c, d, x] = str.split(' ').map(ele => +ele);
    const end = Math.sqrt(x) >> 0;
    let result = 0;
    for (let i = 1; i < end; i++) {
        if (x % i === 0) {
            deal(x / i + d);
            deal(i + d);
        }
    }
    if (x % end === 0) {
        deal(x / end + d);
        if (x / end !== end) {
            deal(end + d);
        }
    }
    function deal(math) {
        if (math >= c && math % c === 0) {
            result += mathSum(math / c);
        }
    }
    function mathSum(number) {
        return record[number];
    }
    return result;
}


The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of them is a match between two participants. n·(n - 1) / 2 games were played during the tournament, and each participant had a match with each other participant. The rules of the game are quite simple — the participant who falls asleep first wins. The secretary made a record of each game in the form «xi yi», where xi and yi are the numbers of participants. The first number in each pair is a winner (i.e. xi is a winner and yi is a loser). There is no draws.Recently researches form the «Institute Of Sleep» have found that every person is characterized by a value pj — the speed of falling asleep. The person who has lower speed wins. Every person has its own value pj, constant during the life. It is known that all participants of the tournament have distinct speeds of falling asleep. Also it was found that the secretary made records about all the games except one. You are to find the result of the missing game.

The first line contains one integer n (3 ≤ n ≤ 50) — the number of participants. The following n·(n - 1) / 2 - 1 lines contain the results of the games. Each game is described in a single line by two integers xi, yi (1 ≤ xi, yi ≤ n, xi ≠ yi), where xi и yi are the numbers of the opponents in this game. It is known that during the tournament each of the n participants played n - 1 games, one game with each other participant.

Output two integers x and y — the missing record. If there are several solutions, output any of them.

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var n = parseInt(readline());
	var pairNum = n*(n-1)/2;

	var counts = [];
	for (var i = 0; i <= n; ++i) {
		counts.push({ win: 0, lose: 0 });
	}

	for (var i = 1; i < pairNum; ++i) {
		var pair = tokenizeIntegers(readline());
		counts[pair[0]].win += 1;
		counts[pair[1]].lose += 1;
	}

	var missing = [];
	for (var i = 1; i <= n; ++i) {
		if (counts[i].win + counts[i].lose != n-1) {
			missing.push(i);
		}
	}

	if (counts[missing[0]].win > counts[missing[1]].win) {
		print(missing[0]+" "+missing[1]);
	}
	else {
		print(missing[1]+" "+missing[0]);
	}
}

main();

'use strict'

const N = +readline()
let lll

let ps = []

while (lll = readline()) {
  lll = lll.split(' ').map(v => parseInt(v))
  const v = lll[0]
  const l = lll[1]
  if (!ps[v]) {ps[v] = {bt: [], wt: [], n: 0, i: v}}
  ps[v].bt.push(l)
  ps[v].n++
  if (!ps[l]) {ps[l] = {bt: [], wt: [], n: 0, i: l}}
  ps[l].wt.push(v)
  ps[l].n++
}

let min = Infinity

for (let i = 1; i < ps.length; i++) {
  min = Math.min(ps[i].n, min)
}

let ms = []

for (let i = 1; i < ps.length; i++) {
  if (ps[i].n == min) ms.push(ps[i])
}

let fv
for (let i = 1; i < ms[0].bt.length; i++) {
  if (~ms[1].wt.indexOf(ms[0].bt[i])) {
    fv = true;
    break
  }
}

print(fv ? ms[0].i + ' ' + ms[1].i : ms[1].i + ' ' + ms[0].i)

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var n = parseInt(readline());
	var pairNum = n*(n-1)/2;

	var counts = [];
	for (var i = 0; i <= n; ++i) {
		counts.push({ win: 0, lose: 0 });
	}

	for (var i = 1; i < pairNum; ++i) {
		var pair = tokenizeIntegers(readline());
		counts[pair[0]].win += 1;
		counts[pair[1]].lose += 1;
	}

	var missing = [];
	for (var i = 1; i <= n; ++i) {
		if (counts[i].win + counts[i].lose != n-1) {
			missing.push(i);
		}
	}

	if (missing[0].win > missing[1].win) {
		print(missing[0]+" "+missing[1]);
	}
	else {
		print(missing[1]+" "+missing[0]);
	}
}

main();

'use strict'

const N = +readline()
let lll

let ps = []

while (lll = readline()) {
  lll = lll.split(' ').map(v => parseInt(v))
  const v = lll[0]
  const l = lll[1]
  if (!ps[v]) {ps[v] = {bt: [], wt: [], n: 0, i: v}}
  ps[v].bt.push(l)
  ps[v].n++
  if (!ps[l]) {ps[l] = {bt: [], wt: [], n: 0, i: l}}
  ps[l].wt.push(v)
  ps[l].n++
}

let min = Infinity

for (let i = 1; i < 4; i++) {
  min = Math.min(ps[i].n, min)
}

let ms = []

for (let i = 1; i < ps.length; i++) {
  if (ps[i].n == min) ms.push(ps[i])
}

let fv
for (let i = 1; i < ms[0].bt.length; i++) {
  if (~ms[1].wt.indexOf(ms[0].bt[i])) {
    fv = true;
    break
  }
}

print(fv ? ms[0].i + ' ' + ms[1].i : ms[1].i + ' ' + ms[0].i)


Someone gave Alyona an array containing n positive integers a1, a2, ..., an. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not apply any operation to the array at all.Formally, after applying some operations Alyona will get an array of n positive integers b1, b2, ..., bn such that 1 ≤ bi ≤ ai for every 1 ≤ i ≤ n. Your task is to determine the maximum possible value of mex of this array.Mex of an array in this problem is the minimum positive integer that doesn't appear in this array. For example, mex of the array containing 1, 3 and 4 is equal to 2, while mex of the array containing 2, 3 and 2 is equal to 1.

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of elements in the Alyona's array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the elements of the array.

Print one positive integer — the maximum possible value of mex of the array after Alyona applies some (possibly none) operations.

NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements.

var n = Number(readline());
var array = readline().split(' ').map(Number);

array.sort(function(a, b) {return a - b});

// k is the new value for array[i];
var k = 1;

for (var i = 0; i < n; i++) {
	if (array[i] >= k) {
		array[i] = k;
		k ++;
	}
}

var mex = array[n - 1] + 1;

print(mex);

var print = this.print || require('lol-io').print; //print --> outputs result and adds (enter)
var write = this.write || require('lol-io').write; //write --> creates output.txt with output
var readline = this.readline || require('lol-io').readline; //readline --> reads unread line of input.txt

var ans = 1, arr, n;

n = Number(readline());
arr = readline().split(' ').map(Number).sort((a, b) => a - b);

for (i = 0; i < n; i++) {

    if (arr[i] >= ans) {

        ans++;
    }
}

print(ans);

readline()
k=1
for(i of readline().split(' ').sort((a,b)=>a-b))k+=i>=k
print(k)

l=+readline(),a=readline().split(' ').sort((a,b)=>a-b),k=1;
for(var i of a)if(+i>=k)++k;
print(k);

var n = parseInt(readline());
var input = readline().split(' ').map(function(item){return parseInt(item)}).sort(function(a, b){return a-b})
var gaps = input[0] - 1, repeat = 0;
for(var i = 1; i < input.length; i++){
	var diff = input[i] - input[i-1];
	if(diff === 0){
		if(gaps === 0){
			repeat++;
		} else {
			gaps--;
		}
	} else {
		gaps += diff - 1;
	}
}
var mex = n - repeat + 1;
print(mex);

		var arr = [],
			mex=1,
			quantity = readline().split(" ").map(function(x) { return parseInt(x); }),
			string = readline().split(" ").map(function(x) { return parseInt(x); });
		for (var i = 0; i < quantity; i++)
		{
			arr[i] = parseInt(string[i],10);
		}
		function compareNumeric(a, b)
		{
  			if (a > b) return 1;
  			if (a < b) return -1;
		}
		arr.sort(compareNumeric);
		for (var i = 0; i < arr.length; i++) {
			if (arr[i] >= mex)
				mex++;
		}
		print(mex);

var print = this.print || require('lol-io').print; //print --> outputs result and adds (enter)
var write = this.write || require('lol-io').write; //write --> creates output.txt with output
var readline = this.readline || require('lol-io').readline; //readline --> reads unread line of input.txt

var ans = 1, arr, n;

n = Number(readline());
arr = readline().split(' ').map(Number).sort();

for (i = 0; i < n; i++) {

    if (arr[i] >= ans) {

        ans++;
    }
}

print(ans);

var print = this.print || require('lol-io').print; //print --> outputs result and adds (enter)
var write = this.write || require('lol-io').write; //write --> creates output.txt with output
var readline = this.readline || require('lol-io').readline; //readline --> reads unread line of input.txt

var ans = 1, arr, n;

n = Number(readline());
arr = readline().split(' ').map(Number).sort();

for (i = 0; i < arr.length; i++) {

    if (arr[i] >= ans) {

        ans++;
    }
}

print(ans);

var n=+readline(),ar=readline().split(' '),i=0,k=1,l=ar.length;
for(i=l;i--;)ar[i]=+ar[i];
ar.sort();
for(i=0;i<l;++i)if(ar[i]>=k)++k;
print(k);

		var arr = [],
			mex=0,
			quantity = readline().split(" ").map(function(x) { return parseInt(x); }),
			string = readline().split(" ").map(function(x) { return parseInt(x); });
		for (var i = 0; i < quantity; i++)
		{
			arr[i] = parseInt(string[i],10);
		}
		function compareNumeric(a, b)
		{
  			if (a > b) return 1;
  			if (a < b) return -1;
		}
		arr.sort(compareNumeric);
		for (var i = 0; i < arr.length; i++) {
			if (arr[i] >= mex)
				mex++;
		}
		print(mex);

		var arr = [],
			mex=0,
			quantity = readline().split(" ").map(function(x) { return parseInt(x); }),
			string = readline().split(" ").map(function(x) { return parseInt(x); });
		for (var i = 0; i < quantity; i++)
		{
			arr[i] = parseInt(string[i],10);
		}
		function compareNumeric(a, b)
		{
  			if (a > b) return 1;
  			if (a < b) return -1;
		}
		arr.sort(compareNumeric);
		for (var i = 0; i <= arr.length; i++)
		{
			arr[0] = 1;
			while (arr[i] + 1 < arr[i+1])
			{
				if ((arr[i] + 1) < arr[i+1])
				{
					arr[i+1] = arr[i+1] - 1;
				}

			}
		}
		var max = 0;
		for (var i = 1; i < arr.length; i++) {
			if (arr[i] > arr[i-1])
			{
				max = arr[i];
			}
		}
		mex = max + 1;
		print(mex);

		var arr = [],
			mex=0,
			quantity = readline().split(" ").map(function(x) { return parseInt(x); }),
			string = readline().split(" ").map(function(x) { return parseInt(x); });
		for (var i = 0; i < quantity; i++)
		{
			arr[i] = parseInt(string[i],10);
		}
		function compareNumeric(a, b)
		{
  			if (a > b) return 1;
  			if (a < b) return -1;
		}
		arr.sort(compareNumeric);
		for (var i = 0; i <= arr.length; i++)
		{
			arr[0] = 1;
			while (arr[i] + 1 < arr[i+1])
			{
				if ((arr[i] + 1) < arr[i+1])
				{
					arr[i+1] = arr[i+1] - 1;
				}

			}
		}
		var max = 0;
		for (var i = 1; i < arr.length; i++) {
			if (arr[i] > arr[i-1])
			{
				max = arr[i];
			}
		}
		if (max == 1) {
		    mex = 1;
		}
		else mex = max + 1;
		print(mex);

		var arr = [],
			mex=0,
			quantity = readline().split(" ").map(function(x) { return parseInt(x); }),
			string = readline().split(" ").map(function(x) { return parseInt(x); });
		for (var i = 0; i < quantity; i++)
		{
			arr[i] = parseInt(string[i],10);
		}

		for (var i = 0; i <= arr.length; i++)
		{
			arr[0] = 1;
			while (arr[i] + 1 < arr[i+1])
			{
				if ((arr[i] + 1) < arr[i+1])
				{
					arr[i+1] = arr[i+1] - 1;
				}

			}
		}
		var max = 1;
		for (var i = 1; i < arr.length; i++) {
			if (arr[i] > arr[i-1])
			{
				max = arr[i];
			}
		}
		mex = max + 1;
		print(mex);


Real stupidity beats artificial intelligence every time.— Terry Pratchett, Hogfather, DiscworldYou are given a string $$$s$$$ of length $$$n$$$ and a number $$$k$$$. Let's denote by $$$rev(s)$$$ the reversed string $$$s$$$ (i.e. $$$rev(s) = s_n s_{n-1} ... s_1$$$). You can apply one of the two kinds of operations to the string: replace the string $$$s$$$ with $$$s + rev(s)$$$ replace the string $$$s$$$ with $$$rev(s) + s$$$How many different strings can you get as a result of performing exactly $$$k$$$ operations (possibly of different kinds) on the original string $$$s$$$?In this statement we denoted the concatenation of strings $$$s$$$ and $$$t$$$ as $$$s + t$$$. In other words, $$$s + t = s_1 s_2 ... s_n t_1 t_2 ... t_m$$$, where $$$n$$$ and $$$m$$$ are the lengths of strings $$$s$$$ and $$$t$$$ respectively.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — number of test cases. Next $$$2 \cdot t$$$ lines contain $$$t$$$ test cases: The first line of a test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 100$$$, $$$0 \le k \le 1000$$$) — the length of the string and the number of operations respectively. The second string of a test case contains one string $$$s$$$ of length $$$n$$$ consisting of lowercase Latin letters.

For each test case, print the answer (that is, the number of different strings that you can get after exactly $$$k$$$ operations) on a separate line. It can be shown that the answer does not exceed $$$10^9$$$ under the given constraints.

4

3 2

aab

3 3

aab

7 1

abacaba

2 0

ab

NoteIn the first test case of the example:After the first operation the string $$$s$$$ can become either aabbaa or baaaab. After the second operation there are 2 possibilities for $$$s$$$: aabbaaaabbaa and baaaabbaaaab.

/* Common Template Starts */
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
	inputString += inputStdin;
});

process.stdin.on("end", (_) => {
	inputString = inputString
		.trim()
		.split("\n")
		.map((string) => {
			return string.trim();
		});

	main();
});

function readline() {
	return inputString[currentLine++];
}
/* Common Template Ends */
function main() {
	const cases = +(readline()); // Test cases count
	for(let i = 0; i < cases; i++) {
		// console.log(`case ${i}`)
		const [strLen, k] = readline().split(" ").map((v) => parseInt(v));
		let strings;
		const s = readline();
		const rev = [...s].reverse().join("");
		const set = new Set();
		set.add(s + rev);
		set.add(rev + s);
		strings = set;
		// console.log(strings.get(0), strings.get(0).size);
		if(k === 0) console.log(1);
		else if(k === 1) console.log(strings.size);
		else console.log(strings.size);
		//else {
		//	for(let j = 1; j < k; j++) {
		//		const set = new Set();
		//		const ss = Array.from(strings);
		//		// console.log(ss);
		//		for(let l = 0; l < strings.size; l++) {
		//			const s = ss[l];
		//			const rev = [...s].reverse().join("");
		//			// console.log(s, rev);
		//			set.add(s + rev);
		//			set.add(rev + s);
		//		}
		//		strings = set;
		//		// console.log(strings.get(j));
		//	}
		//	console.log(strings.size); // output
		//}
		//strings.clear();
    }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', stdin => inputString += stdin);

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(s => s.trim());
    main();
});

function readline() {
    return inputString[currentLine++];
}

function output(x) {
    if (typeof x !== 'string') {
        x = x.toString();
    }
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    let N = readline();

    const isPalindrome = str => str === str.split('').reverse().join('');

    for (let test = 0; test < N; test++) {
        let [n, k] = readline().split(' ').map(Number);
        let s = readline();

        if (k === 0) {
            output(1);
            continue;
        }
        if (isPalindrome(s)) output(1); else output(2);

    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function main(){
	let t = parseInt(readLine())
	while(t--){
		let line = readLine().split(' ');
		let n = parseInt(line[0]);
		let k = parseInt(line[1]);
		let s = readLine();
		if(s == s.split('').reverse().join('') || k == 0){
			console.log(1);
		}
		else console.log(2);
	}
}

'use strict';
/* ================== */
process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

const readline = () => inputString[currentLine++];
const readline_arr = () => readline().split(' ').map((n) => parseInt(n, 10));
const print = (...txt) => process.stdout.write(`${txt}\n`)
/* ================== */

function main() {
  let t = parseInt(readline(), 10);
  while (t--) {
    solve();
  }
}

function solve() {
  const [l, op] = readline().split(' ').map((n) => parseInt(n, 10));
  const str = readline();

  let rev = '';
  for (let i = str.length - 1; i >= 0; i--) {
    rev += str[i];
  }

  if (str === rev || op === 0) print(1);
  else print(2);
}

'use strict';
/* ================== */
process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function print(...txt) {
  process.stdout.write(`${txt}\n`);
}
/* ================== */

function main() {
  let t = readline();
  while (t--) {
    solve();
  }
}

function solve() {
  const [l, op] = readline().split(' ').map((n) => parseInt(n, 10));
  const str = readline();

  let rev = '';
  for (let i = str.length - 1; i >= 0; i--) {
    rev += str[i];
  }

  if (str === rev || op === 0) print(1);
  else print(2);
}

var isPalin = function(s){
    var n = s.length;
    s = s.split('');
    for(l = 0; l < Math.floor(n / 2); l++){
        if(s[l] != s[n - l - 1]){
            return false;
        }
    }
    return true;
};
let y = '';
process.stdin.on('data', c => y += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = y.split(EOL);
	var t = lines[0];
	var n = 0, k = 0, s = 0;
	for(i = 1; i <= t * 2; i++){
	    if(i % 2 == 1){
	        s = lines[i].split(' ').map(Number);
	        n = s[0];
	        k = s[1];
	    }else{
	        s = lines[i];
            if(k === 0 || isPalin(s)){
                console.log(1);
            }else{
                console.log(2);
            }
	    }
	}
});

// Create readline interface
const readline = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

// Parse input
let t = null;
const nk = [];
const strings = [];
let i = 0;
readline.on('line', line => {
  if (t === null) {
    t = Number(line);
  } else {
    i++;
    if (i % 2) {
      nk.push(line.split(' ').map(Number));
    } else {
      strings.push(line.trim());
    }
  }
});

const isPalindrome = str => str === [...str].reverse().join('');

// Main program
readline.on('close', () => {
  for (let i = 0; i < t; i++) {
    const [n, k] = nk[i];
    const str = strings[i];
    if (k === 0) {
      console.log(1);
    } else {
      if (isPalindrome(str)) {
        console.log(1);
      } else {
        console.log(2);
      }
    }
  }
});

process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  const testCases = readline();
  // let isPalindrome = true;

  for (let i = 0; i < testCases; i++) {
    let [size, k] = readline().split(" ");
    let s = readline();
    // console.log(k, s);
    if (k === "0") {
      console.log(1);
    } else {
      let mid = Math.floor(s.length / 2);
      let isPalindrome = true;
      for (let i = 0; i < mid; i++) {
        if (s[i] !== s[s.length - 1 - i]) {
          isPalindrome = false;
          break;
        }
      }
      console.log(isPalindrome ? 1 : 2);
    }
  }

  // return isPalindrome ? k : 2 * k;
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', stdin => inputString += stdin);

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(s => s.trim());
    main();
});

function readline() {
    return inputString[currentLine++];
}

function output(x) {
    if (typeof x !== 'string') {
        x = x.toString();
    }
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    let N = readline();

    const isPalindrome = str => str === str.split('').reverse().join('');

    for (let test = 0; test < N; test++) {
        let [n, k] = readline().split(' ').map(Number);
        let s = readline();

        if (k === 0) {
            output(1);
            continue;
        }
        if (isPalindrome(s)) output(k); else output(2);

    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function main(){
	let t = parseInt(readLine())
	while(t--){
		let line = readLine().split(' ');
		let n = parseInt(line[0]);
		let k = parseInt(line[1]);
		let ans = 1;
		let s = readLine();
		if(s == s.reverse){
			console.log(ans);
			continue;
		}
		k = parseInt(k/2);
		console.log((ans<<k));
	}
}


It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the i-th accumulator has ai units of energy. Energy can be transferred from one accumulator to the other. Every time x units of energy are transferred (x is not necessarily an integer) k percent of it is lost. That is, if x units were transferred from one accumulator to the other, amount of energy in the first one decreased by x units and in other increased by  units.Your task is to help Petya find what maximum equal amount of energy can be stored in each accumulator after the transfers.

First line of the input contains two integers n and k (1 ≤ n ≤ 10000, 0 ≤ k ≤ 99) — number of accumulators and the percent of energy that is lost during transfers. Next line contains n integers a1, a2, ... , an — amounts of energy in the first, second, .., n-th accumulator respectively (0 ≤ ai ≤ 1000, 1 ≤ i ≤ n).

Output maximum possible amount of energy that can remain in each of accumulators after the transfers of energy. The absolute or relative error in the answer should not exceed 10 - 6.

'use strict'

const {EOL} = require('os')

let ipt = ''
process.stdin.on('data', s => ipt += s)
process.stdin.on('end', () => {
  const ils = ipt.split(EOL).slice(0, -1)
  let [n, k] = ils[0].split(' ').map(v => parseInt(v))
  k = 1 - k / 100
  const A = ils[1].split(' ').map(v => parseInt(v))

  let t = A.reduce((s, v) => s + v, 0) / A.length
  let s = t
  let b
  do {
    if (b > 0) {
      t += s
    } else if (b < 0) {
      t -= s
    }
    b = 0
    for (let i = 0; i < A.length; i++) {
      if (A[i] > t) b += (A[i] - t) * k
      else if (A[i] < t) b -= t - A[i]
    }
    s /= 2
  } while (Math.abs(b) > 0.000001)

  console.log(t)
})


Let's call an array of non-negative integers $$$a_1, a_2, \ldots, a_n$$$ a $$$k$$$-extension for some non-negative integer $$$k$$$ if for all possible pairs of indices $$$1 \leq i, j \leq n$$$ the inequality $$$k \cdot |i - j| \leq min(a_i, a_j)$$$ is satisfied. The expansion coefficient of the array $$$a$$$ is the maximal integer $$$k$$$ such that the array $$$a$$$ is a $$$k$$$-extension. Any array is a 0-expansion, so the expansion coefficient always exists.You are given an array of non-negative integers $$$a_1, a_2, \ldots, a_n$$$. Find its expansion coefficient.

The first line contains one positive integer $$$n$$$ — the number of elements in the array $$$a$$$ ($$$2 \leq n \leq 300\,000$$$). The next line contains $$$n$$$ non-negative integers $$$a_1, a_2, \ldots, a_n$$$, separated by spaces ($$$0 \leq a_i \leq 10^9$$$).

Print one non-negative integer — expansion coefficient of the array $$$a_1, a_2, \ldots, a_n$$$.

NoteIn the first test, the expansion coefficient of the array $$$[6, 4, 5, 5]$$$ is equal to $$$1$$$ because $$$|i-j| \leq min(a_i, a_j)$$$, because all elements of the array satisfy $$$a_i \geq 3$$$. On the other hand, this array isn't a $$$2$$$-extension, because $$$6 = 2 \cdot |1 - 4| \leq min(a_1, a_4) = 5$$$ is false.In the second test, the expansion coefficient of the array $$$[0, 1, 2]$$$ is equal to $$$0$$$ because this array is not a $$$1$$$-extension, but it is $$$0$$$-extension.

(function () {
    var read = {
        number: function () {
            return +readline();
        },
        arr: function (divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function (divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    }

    var n = read.number();
    var a = read.arrNumber(' ');

    var min = Infinity;

    for(var i = 0; i < n; i++) {

        var l = i;
        var r = n - 1 - i;
        var res = Math.floor(a[i] / (l > r ? l : r));
        if(res < min) {
            min =res;
        }
    }

    print(min);

}());

const input = require('fs')
    .readFileSync(0, 'ascii')
    .split('\n')
    .filter(line => !/^\s*$/.test(line))
    .map(l => l.split(' ').map(w => parseInt(w)));
const [[n], a] = input;

function max_k(x, i) {
    let l = Infinity, r = Infinity;
    if (i > 0)
        l = x / i;
    if (i < n - 1)
        r = x / (n - 1 - i);
    return Math.floor(Math.min(l, r));
}

function min(xs) {
    r = xs[0];
    for (x of xs) {
        if (x < r)
            r = x;
    }
    return r;
}

console.log(min(a.map(max_k)));