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$$$.

/*
URL:
https://codeforces.com/contest/1428/problem/E
*/

package main

import (
	"bufio"
	"container/heap"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	n, k int
	A    []int64
)

func main() {
	defer stdout.Flush()

	n, k = readi2()
	A = readlls(n)

	pq := NewCarrotPQ()
	for _, a := range A {
		l, p := a, int64(1)
		dec := F(l, p) - F(l, p+1)
		pq.push(&Carrot{pri: dec, l: l, p: p})
	}

	plus := k - n
	for i := 0; i < plus; i++ {
		c := pq.pop()

		c.p++
		l, p := c.l, c.p
		dec := F(l, p) - F(l, p+1)
		c.pri = dec
		pq.push(c)
	}

	ans := int64(0)
	for pq.Len() > 0 {
		c := pq.pop()

		l, p := c.l, c.p
		ans += F(l, p)
	}

	fmt.Println(ans)
}

func F(l, p int64) int64 {
	w := l / p
	p2 := l % p
	p1 := p - p2

	return p1*w*w + p2*(w+1)*(w+1)
}

type Carrot struct {
	pri int64
	l   int64
	p   int64
}
type CarrotPQ []*Carrot

// Interfaces
func NewCarrotPQ() *CarrotPQ {
	temp := make(CarrotPQ, 0)
	pq := &temp
	heap.Init(pq)

	return pq
}
func (pq *CarrotPQ) push(target *Carrot) {
	heap.Push(pq, target)
}
func (pq *CarrotPQ) pop() *Carrot {
	return heap.Pop(pq).(*Carrot)
}

func (pq CarrotPQ) Len() int           { return len(pq) }
func (pq CarrotPQ) Less(i, j int) bool { return pq[i].pri > pq[j].pri } // <: ASC, >: DESC
func (pq CarrotPQ) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}
func (pq *CarrotPQ) Push(x interface{}) {
	item := x.(*Carrot)
	*pq = append(*pq, item)
}
func (pq *CarrotPQ) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

/*******************************************************************/

/********** common constants **********/

const (
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPH_N  = 26
	INF_I64 = math.MaxInt64
	INF_B60 = 1 << 60
	INF_I32 = math.MaxInt32
	INF_B30 = 1 << 30
	NIL     = -1
	EPS     = 1e-10
)

/********** bufio setting **********/

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	reads = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

// mod can calculate a right residual whether value is positive or negative.
func mod(val, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// chmin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func chmin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// chmax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func chmax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// sum returns multiple integers sum.
func sum(integers ...int) int {
	var s int
	s = 0

	for _, i := range integers {
		s += i
	}

	return s
}

// abs is integer version of math.Abs
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// pow is integer version of math.Pow
// pow calculate a power by Binary Power (二分累乗法(O(log e))).
func pow(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := pow(a, halfE)
		return half * half
	}

	return a * pow(a, e-1)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := reads()
//i := readi()
//X := readis(n)
//S := readrs()
//a := readf()
//A := readfs(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*********** Input ***********/

var (
	// reads returns a WORD string.
	reads  func() string
	stdout *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// readi returns an integer.
func readi() int {
	return int(_readInt64())
}
func readi2() (int, int) {
	return int(_readInt64()), int(_readInt64())
}
func readi3() (int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64())
}
func readi4() (int, int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())
}

// readll returns as integer as int64.
func readll() int64 {
	return _readInt64()
}
func readll2() (int64, int64) {
	return _readInt64(), _readInt64()
}
func readll3() (int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64()
}
func readll4() (int64, int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64(), _readInt64()
}

func _readInt64() int64 {
	i, err := strconv.ParseInt(reads(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// readis returns an integer slice that has n integers.
func readis(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readi()
	}
	return b
}

// readlls returns as int64 slice that has n integers.
func readlls(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = readll()
	}
	return b
}

// readf returns an float64.
func readf() float64 {
	return float64(_readFloat64())
}

func _readFloat64() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func readfs(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = readf()
	}
	return b
}

// readrs returns a rune slice.
func readrs() []rune {
	return []rune(reads())
}

/*********** Output ***********/

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// Printf is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func printf(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*********** Debugging ***********/

// debugf is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func debugf(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
)

var reader = bufio.NewReader(os.Stdin)

type Seg struct {
	parts, value int
}

func (s *Seg) oneMore() int64 {
	oldCost := s.cost()
	s.parts++
	newCost := s.cost()
	s.parts--
	return oldCost - newCost
}

func (s *Seg) cost() int64 {
	nBigger := s.value % s.parts
	nSmaller := s.parts - nBigger
	smallerSize := s.value / s.parts

	var biggerCost int64 = int64(smallerSize+1) * int64(smallerSize+1)
	var smallerCost int64 = int64(smallerSize) * int64(smallerSize)

	return int64(nBigger)*biggerCost + int64(nSmaller)*smallerCost
}

type IntHeap []*Seg

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i].oneMore() > h[j].oneMore() }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(*Seg))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	old[n-1] = nil
	*h = old[0 : n-1]
	return x
}

func main() {
	var n, k int
	fmt.Fscan(reader, &n, &k)

	h := &IntHeap{}
	heap.Init(h)
	for i := 0; i < n; i++ {
		var a int
		fmt.Fscan(reader, &a)
		heap.Push(h, &Seg{parts: 1, value: a})
	}

	for i := 0; i < k-n; i++ {
		max := heap.Pop(h).(*Seg)
		max.parts++
		heap.Push(h, max)
	}

	var sum int64
	for i := 0; i < h.Len(); i++ {
		el := (*h)[i]
		sum += el.cost()
	}

	fmt.Println(sum)
}

/*
URL:
https://codeforces.com/contest/1428/problem/E
*/

package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	n, k int
	A    []int64
)

func main() {
	defer stdout.Flush()

	n, k = readi2()
	A = readlls(n)

	pq := NewCarrotPQ()
	for _, a := range A {
		pq.push(&Carrot{pri: int(a), length: a})
	}

	plus := k - n
	for i := 0; i < plus; i++ {
		c := pq.pop()
		var al, bl int64
		if c.length%2 == 0 {
			al, bl = c.length/2, c.length/2
		} else {
			al, bl = c.length/2+1, c.length/2
		}

		pq.push(&Carrot{pri: int(al), length: al})
		pq.push(&Carrot{pri: int(bl), length: bl})
	}

	ans := int64(0)
	for pq.Len() > 0 {
		c := pq.pop()
		val := c.length

		ans += val * val
	}

	fmt.Println(ans)
}

type Carrot struct {
	pri    int
	length int64
}
type CarrotPQ []*Carrot

// Interfaces
func NewCarrotPQ() *CarrotPQ {
	temp := make(CarrotPQ, 0)
	pq := &temp
	heap.Init(pq)

	return pq
}
func (pq *CarrotPQ) push(target *Carrot) {
	heap.Push(pq, target)
}
func (pq *CarrotPQ) pop() *Carrot {
	return heap.Pop(pq).(*Carrot)
}

func (pq CarrotPQ) Len() int           { return len(pq) }
func (pq CarrotPQ) Less(i, j int) bool { return pq[i].pri > pq[j].pri } // <: ASC, >: DESC
func (pq CarrotPQ) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}
func (pq *CarrotPQ) Push(x interface{}) {
	item := x.(*Carrot)
	*pq = append(*pq, item)
}
func (pq *CarrotPQ) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

/*******************************************************************/

/********** common constants **********/

const (
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPH_N  = 26
	INF_I64 = math.MaxInt64
	INF_B60 = 1 << 60
	INF_I32 = math.MaxInt32
	INF_B30 = 1 << 30
	NIL     = -1
	EPS     = 1e-10
)

/********** bufio setting **********/

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	reads = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

// mod can calculate a right residual whether value is positive or negative.
func mod(val, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// chmin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func chmin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// chmax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func chmax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// sum returns multiple integers sum.
func sum(integers ...int) int {
	var s int
	s = 0

	for _, i := range integers {
		s += i
	}

	return s
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := reads()
//i := readi()
//X := readis(n)
//S := readrs()
//a := readf()
//A := readfs(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*********** Input ***********/

var (
	// reads returns a WORD string.
	reads  func() string
	stdout *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// readi returns an integer.
func readi() int {
	return int(_readInt64())
}
func readi2() (int, int) {
	return int(_readInt64()), int(_readInt64())
}
func readi3() (int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64())
}
func readi4() (int, int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())
}

// readll returns as integer as int64.
func readll() int64 {
	return _readInt64()
}
func readll2() (int64, int64) {
	return _readInt64(), _readInt64()
}
func readll3() (int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64()
}
func readll4() (int64, int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64(), _readInt64()
}

func _readInt64() int64 {
	i, err := strconv.ParseInt(reads(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// readis returns an integer slice that has n integers.
func readis(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readi()
	}
	return b
}

// readlls returns as int64 slice that has n integers.
func readlls(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = readll()
	}
	return b
}

// readf returns an float64.
func readf() float64 {
	return float64(_readFloat64())
}

func _readFloat64() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func readfs(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = readf()
	}
	return b
}

// readrs returns a rune slice.
func readrs() []rune {
	return []rune(reads())
}

/*********** Output ***********/

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// Printf is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func printf(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*********** Debugging ***********/

// debugf is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func debugf(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

/*
URL:
https://codeforces.com/contest/1428/problem/E
*/

package main

import (
	"bufio"
	"container/heap"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	n, k int
	A    []int64
)

func main() {
	defer stdout.Flush()

	n, k = readi2()
	A = readlls(n)

	pq := NewCarrotPQ()
	for _, a := range A {
		l, p := a, int64(1)
		dec := F(l, p) - F(l, p+1)
		pq.push(&Carrot{pri: dec, l: l, p: p})
	}

	plus := k - n
	for i := 0; i < plus; i++ {
		c := pq.pop()

		l, p := c.l, c.p
		dec := F(l, p) - F(l, p+1)
		c.p++
		c.pri = dec
		pq.push(c)
	}

	ans := int64(0)
	for pq.Len() > 0 {
		c := pq.pop()

		l, p := c.l, c.p
		ans += F(l, p)
	}

	fmt.Println(ans)
}

func F(l, p int64) int64 {
	w := l / p
	p2 := l % p
	p1 := p - p2

	return p1*w*w + p2*(w+1)*(w+1)
}

type Carrot struct {
	pri int64
	l   int64
	p   int64
}
type CarrotPQ []*Carrot

// Interfaces
func NewCarrotPQ() *CarrotPQ {
	temp := make(CarrotPQ, 0)
	pq := &temp
	heap.Init(pq)

	return pq
}
func (pq *CarrotPQ) push(target *Carrot) {
	heap.Push(pq, target)
}
func (pq *CarrotPQ) pop() *Carrot {
	return heap.Pop(pq).(*Carrot)
}

func (pq CarrotPQ) Len() int           { return len(pq) }
func (pq CarrotPQ) Less(i, j int) bool { return pq[i].pri > pq[j].pri } // <: ASC, >: DESC
func (pq CarrotPQ) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}
func (pq *CarrotPQ) Push(x interface{}) {
	item := x.(*Carrot)
	*pq = append(*pq, item)
}
func (pq *CarrotPQ) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

/*******************************************************************/

/********** common constants **********/

const (
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPH_N  = 26
	INF_I64 = math.MaxInt64
	INF_B60 = 1 << 60
	INF_I32 = math.MaxInt32
	INF_B30 = 1 << 30
	NIL     = -1
	EPS     = 1e-10
)

/********** bufio setting **********/

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	reads = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

// mod can calculate a right residual whether value is positive or negative.
func mod(val, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// chmin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func chmin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// chmax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func chmax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// sum returns multiple integers sum.
func sum(integers ...int) int {
	var s int
	s = 0

	for _, i := range integers {
		s += i
	}

	return s
}

// abs is integer version of math.Abs
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// pow is integer version of math.Pow
// pow calculate a power by Binary Power (二分累乗法(O(log e))).
func pow(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := pow(a, halfE)
		return half * half
	}

	return a * pow(a, e-1)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := reads()
//i := readi()
//X := readis(n)
//S := readrs()
//a := readf()
//A := readfs(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*********** Input ***********/

var (
	// reads returns a WORD string.
	reads  func() string
	stdout *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// readi returns an integer.
func readi() int {
	return int(_readInt64())
}
func readi2() (int, int) {
	return int(_readInt64()), int(_readInt64())
}
func readi3() (int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64())
}
func readi4() (int, int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())
}

// readll returns as integer as int64.
func readll() int64 {
	return _readInt64()
}
func readll2() (int64, int64) {
	return _readInt64(), _readInt64()
}
func readll3() (int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64()
}
func readll4() (int64, int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64(), _readInt64()
}

func _readInt64() int64 {
	i, err := strconv.ParseInt(reads(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// readis returns an integer slice that has n integers.
func readis(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readi()
	}
	return b
}

// readlls returns as int64 slice that has n integers.
func readlls(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = readll()
	}
	return b
}

// readf returns an float64.
func readf() float64 {
	return float64(_readFloat64())
}

func _readFloat64() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func readfs(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = readf()
	}
	return b
}

// readrs returns a rune slice.
func readrs() []rune {
	return []rune(reads())
}

/*********** Output ***********/

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// Printf is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func printf(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*********** Debugging ***********/

// debugf is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func debugf(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

/*
URL:
https://codeforces.com/contest/1428/problem/E
*/

package main

import (
	"bufio"
	"container/heap"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	n, k int
	A    []int64
)

func main() {
	defer stdout.Flush()

	n, k = readi2()
	A = readlls(n)

	pq := NewCarrotPQ()
	for _, a := range A {
		l, p := a, int64(1)
		dec := F(l, p) - F(l, p+1)
		pq.push(&Carrot{pri: dec, l: l, p: p})
	}

	plus := k - n
	for i := 0; i < plus; i++ {
		c := pq.pop()

		l, p := c.l, c.p
		c.p++
		dec := F(l, p) - F(l, p+1)
		c.pri = dec
		pq.push(c)
	}

	ans := int64(0)
	for pq.Len() > 0 {
		c := pq.pop()

		l, p := c.l, c.p
		ans += F(l, p)
	}

	fmt.Println(ans)
}

func F(l, p int64) int64 {
	w := l / p
	p2 := l % p
	p1 := p - p2

	return p1*w*w + p2*(w+1)*(w+1)
}

type Carrot struct {
	pri int64
	l   int64
	p   int64
}
type CarrotPQ []*Carrot

// Interfaces
func NewCarrotPQ() *CarrotPQ {
	temp := make(CarrotPQ, 0)
	pq := &temp
	heap.Init(pq)

	return pq
}
func (pq *CarrotPQ) push(target *Carrot) {
	heap.Push(pq, target)
}
func (pq *CarrotPQ) pop() *Carrot {
	return heap.Pop(pq).(*Carrot)
}

func (pq CarrotPQ) Len() int           { return len(pq) }
func (pq CarrotPQ) Less(i, j int) bool { return pq[i].pri > pq[j].pri } // <: ASC, >: DESC
func (pq CarrotPQ) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}
func (pq *CarrotPQ) Push(x interface{}) {
	item := x.(*Carrot)
	*pq = append(*pq, item)
}
func (pq *CarrotPQ) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

/*******************************************************************/

/********** common constants **********/

const (
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPH_N  = 26
	INF_I64 = math.MaxInt64
	INF_B60 = 1 << 60
	INF_I32 = math.MaxInt32
	INF_B30 = 1 << 30
	NIL     = -1
	EPS     = 1e-10
)

/********** bufio setting **********/

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	reads = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

// mod can calculate a right residual whether value is positive or negative.
func mod(val, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// chmin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func chmin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// chmax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func chmax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// sum returns multiple integers sum.
func sum(integers ...int) int {
	var s int
	s = 0

	for _, i := range integers {
		s += i
	}

	return s
}

// abs is integer version of math.Abs
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// pow is integer version of math.Pow
// pow calculate a power by Binary Power (二分累乗法(O(log e))).
func pow(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := pow(a, halfE)
		return half * half
	}

	return a * pow(a, e-1)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := reads()
//i := readi()
//X := readis(n)
//S := readrs()
//a := readf()
//A := readfs(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*********** Input ***********/

var (
	// reads returns a WORD string.
	reads  func() string
	stdout *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// readi returns an integer.
func readi() int {
	return int(_readInt64())
}
func readi2() (int, int) {
	return int(_readInt64()), int(_readInt64())
}
func readi3() (int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64())
}
func readi4() (int, int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())
}

// readll returns as integer as int64.
func readll() int64 {
	return _readInt64()
}
func readll2() (int64, int64) {
	return _readInt64(), _readInt64()
}
func readll3() (int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64()
}
func readll4() (int64, int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64(), _readInt64()
}

func _readInt64() int64 {
	i, err := strconv.ParseInt(reads(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// readis returns an integer slice that has n integers.
func readis(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readi()
	}
	return b
}

// readlls returns as int64 slice that has n integers.
func readlls(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = readll()
	}
	return b
}

// readf returns an float64.
func readf() float64 {
	return float64(_readFloat64())
}

func _readFloat64() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func readfs(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = readf()
	}
	return b
}

// readrs returns a rune slice.
func readrs() []rune {
	return []rune(reads())
}

/*********** Output ***********/

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// Printf is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func printf(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*********** Debugging ***********/

// debugf is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func debugf(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
)

var reader = bufio.NewReader(os.Stdin)

type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func main() {
	var n, k int
	fmt.Fscan(reader, &n, &k)

	h := &IntHeap{}
	heap.Init(h)
	for i := 0; i < n; i++ {
		var a int
		fmt.Fscan(reader, &a)
		heap.Push(h, a)
	}

	for i := 0; i < k-n; i++ {
		max := heap.Pop(h).(int)
		half := max / 2

		heap.Push(h, half)
		heap.Push(h, max-half)
	}

	var sum int64
	for h.Len() > 0 {
		el := heap.Pop(h).(int)
		sum += int64(el * el)
	}

	fmt.Println(sum)
}

package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
)

var reader = bufio.NewReader(os.Stdin)

type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func main() {
	var n, k int
	fmt.Fscan(reader, &n, &k)

	h := &IntHeap{}
	heap.Init(h)
	for i := 0; i < n; i++ {
		var a int
		fmt.Fscan(reader, &a)
		heap.Push(h, a)
	}

	for i := 0; i < k-n; i++ {
		max := heap.Pop(h).(int)
		half := max / 2

		heap.Push(h, half)
		heap.Push(h, max-half)
	}

	var sum int64
	for h.Len() > 0 {
		el := heap.Pop(h).(int)
		sum += int64(el) * int64(el)
	}

	fmt.Println(sum)
}


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.

package main

import "os"
import "bufio"

func main(){
	var s string
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	s = r.Text()
	dot := len(s)
	for i:=0; i<len(s); i++ {
		if string(s[i]) == "." {
			dot = i
		}
	}
	if string(s[0]) == "-" {
		w.WriteString("($")
	} else {
		w.WriteString("$"+string(s[0]))
	}
	for i:=1; i<dot; i++ {
		if (dot - i) % 3 == 0 && !(i == 1 && string(s[0]) == "-") {
			w.WriteString(",")
		}
		w.WriteString(string(s[i]))
	}
	if len(s)-dot == 0 {
		w.WriteString(".00")
	} else if len(s)-dot == 2 {
		w.WriteString("."+string(s[dot+1])+"0")
	} else if len(s)-dot > 2 {
		w.WriteString("."+string(s[dot+1])+string(s[dot+2]))
	}
	if string(s[0]) == "-" {
		w.WriteString(")")
	}
	w.WriteString("\n")
	w.Flush()
}

package main

import (
  "os"
  "bufio"
  "strconv"
  "strings"
)

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  s := getS()
  negative := false
  if s[0] == '-' {
    negative = true
    s = s[1:len(s)]
  }
  parts := strings.Split(s, ".")
  whole, fraction := parts[0], "0"
  if len(parts) == 2 {
    fraction = parts[1]
  }

  if negative {
    writer.WriteString("(")
  }
  writer.WriteString("$")

  offset := (3 - len(whole)%3) % 3
  for i := 0; i < len(whole); i++ {
    if offset == 3 {
      writer.WriteString(",")
      offset = 0
    }
    writer.WriteByte(whole[i])
    offset++
  }

  writer.WriteString(".")
  writer.WriteByte(fraction[0])
  if len(fraction) == 1 {
    writer.WriteString("0")
  } else {
    writer.WriteByte(fraction[1])
  }

  if negative {
    writer.WriteString(")")
  }
    writer.WriteString("\n")
}


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.

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	for i := read(); i > 0; i-- {
	    a, b := read(), read()
	    if a != 0 {
	        Fprintln(out, a+2*b+1)
	    } else {
	        Fprintln(out, 1)
	    }
	}
}

func main() {
	run(os.Stdin, os.Stdout)
}

package main

import "fmt"

func solve() {
	var a, b int
	fmt.Scan(&a, &b)
	if a == 0 {
		// fmt.Println(1)
		fmt.Printf("1\n")
	} else {
		// fmt.Println(2*b + a + 1)
		fmt.Printf("%d\n", 2*b+a+1)
	}
}

func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		t--
		solve()
	}
}

package main

import "fmt"

func solve() {
	var a, b int
	fmt.Scan(&a, &b)
	if a == 0 {
		fmt.Println(1)
	} else {
		fmt.Println(2*b + a + 1)
	}
}

func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		t--
		solve()
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, a, b int
	fmt.Scanf("%d\n", &t)
	for ; t > 0; t-- {
		fmt.Scanf("%d %d\n", &a, &b)
		if a == 0 {
			fmt.Printf("%d\n", 1)
		} else {
			fmt.Printf("%d\n", b*2+a+1)
		}
	}
}

// a == b == 2
// (a) (b) (ab) (bb) (abb) (aabb)
// a > b
// a=6 b=3
// (a) (b) (ab) (bb) (abb) (bbb) (abbb) (aabbb) (aaabbb) (aaaabb) (aaaaabb) (aaaaaabb)
// a=6 b=5
// (a) (b) (ab) (bb) (abb) (bbb) (abbb) (bbbb) (abbbb) (bbbbb) (abbbbb) (aabbbbb) (aaabbbbb) (aaaabbbbb) (aaaaabbbbb) (aaaaaabbbbb)
// a < b
// a=3 b=6
// (a) (b) (ab) (bb) (abb) (bbb) (abbb) (bbbb) (abbbb) (bbbbb) (abbbbb) (bbbbbb) (abbbbbb) (aabbbbbb) (aaabbbbbb)

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		a, b := 0, 0
		scan(&a, &b)
		if a == 0 {
			printf("1\n")
		} else {
			printf("%d\n", a+b*2+1)
		}
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b int
		_, _ = fmt.Scan(&a, &b)
		if a == 0 {
			fmt.Println(1)
		} else {
			fmt.Println(a + b*2 + 1)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, a, b int;
	fmt.Scan(&n);

	for ; n > 0 ; n-- {
		fmt.Scan(&a, &b)
		if a == 0 {
			fmt.Println(1)
		} else {
			fmt.Println(a + 2*b + 1)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, a, b int64
	_, _ = fmt.Scan(&n)
	for ; n > 0; n -= 1 {
		_, _ = fmt.Scan(&a, &b)
		if a > 0 {
			fmt.Println(a + 2*b + 1)
		} else {
			fmt.Println(1)
		}
	}

}

package main

// Problem description URL https://atcoder.jp/contests/abc236/tasks/abc240_a

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }

type pair struct {
	Color int
	Size  int
}

var (
	n   = 0
	res []int
	s   *list.List
	cur = 0
)

func solve() {
	scan(&n)
	for n != 0 {
		n--
		a, b := 0, 0
		scan(&a, &b)
		if(a == 0){
			printf("1\n")
		}else {
			printf("%d\n", b*2+(a+1))
		}
	}
}

func main() {
	defer out.Flush()
	solve()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve(scanner *bufio.Scanner, t int) {
	for i := 0; i < t; i++ {
		scanner.Scan()
		a, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		b, _ := strconv.Atoi(scanner.Text())

		lowerBound := a + 1
		upperBound := a + 2*b + 1
		ans := upperBound

		for lowerBound <= upperBound {
			m := lowerBound + (upperBound-lowerBound)/2
			if !canDo(a, b, m) {
				ans = m
				upperBound = m - 1
			} else {
				lowerBound = m + 1
			}
		}
		fmt.Println(ans)
	}
}

func canDo(a, b, num int) bool {
	n := num / 2
	if n <= b && a > 0 {
		return true
	}
	if n > b && a >= num-2*b {
		return true
	}
	return false
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())

	solve(scanner, t)

}

package main

import (
	"bufio"
	"fmt"
	"os"
)

type Problem struct {
	Language   string
	Code       string
	OriginProb string
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		var a, b int64
		fmt.Fscan(in, &a, &b)
		if a > 0 {
			fmt.Fprintln(out, a+2*b+1)
		} else {
			fmt.Fprintln(out, 1)
		}

		t--
	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		var a, b int64
		fmt.Fscan(in, &a, &b)
		if a > 0 {
			fmt.Fprintln(out, a+2*b+1)
		} else {
			fmt.Fprintln(out, 1)
		}
		t--
	}

}

package main

import ("fmt")

func solve(){
	var a,b int
	fmt.Scan(&a,&b)

	if (a==0) {
       fmt.Println(1)
	}else{
		fmt.Println(2*b+a+1)
	}

}
func main() {
	var tc int
    fmt.Scan(&tc)
	// fmt.Print(tc)
	for i:=0;i<tc;i++{
		solve()
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func solve(cin *scanner, cout *writer, cerr *writer) {
	a, b := cin.NextInt(), cin.NextInt()
	if a > 0 {
		cout.Println(b + b + a + 1)
	} else {
		cout.Println(1)
	}
}

func main() {
	cin := NewScanner(os.Stdin)
	cout, cerr := NewWriter(os.Stdout), NewWriter(os.Stderr)
	defer cout.Flush()
	defer cerr.Flush()
	t := cin.NextInt()
	// t := 1
	for ti := 0; ti < t; ti++ {
		solve(cin, cout, cerr)
	}
}

// Template Bolierplate {{{
type scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 1024*1024)
	return &scanner{s}
}

func (i *scanner) Next() string {
	i.Scan()
	return i.Text()
}

func (i *scanner) Nexts(n int) []string {
	res := make([]string, n)
	for j := range res {
		res[j] = i.Next()
	}
	return res
}

func (i *scanner) NextInt() int {
	v, _ := strconv.Atoi(i.Next())
	return v
}

func (i *scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(i.Next(), 10, 64)
	return v
}

func (i *scanner) NextInts(n int) []int {
	res := make([]int, n)
	for j := range res {
		res[j] = i.NextInt()
	}
	return res
}

func (i *scanner) NextInt64s(n int) []int64 {
	res := make([]int64, n)
	for j := range res {
		res[j] = i.NextInt64()
	}
	return res
}

type writer struct {
	w *bufio.Writer
}

func NewWriter(w io.Writer) *writer {
	return &writer{bufio.NewWriter(w)}
}

func (i *writer) Print(a ...interface{}) {
	fmt.Fprint(i.w, a...)
}

func (i *writer) Println(a ...interface{}) {
	fmt.Fprintln(i.w, a...)
}

func (i *writer) Printf(format string, a ...interface{}) {
	fmt.Fprintf(i.w, format, a...)
}

func (i *writer) Flush() {
	i.w.Flush()
}

// }}}

// vim: fdm=marker

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var (
		t int
		a int
		b int
	)
	fmt.Scanf("%d\n", &t)
	scanner := bufio.NewScanner(os.Stdin)
	for i := 0; i < t; i++ {
		scanner.Scan()
		sl := strings.Split(scanner.Text(), " ")
		a, _ = strconv.Atoi(sl[0])
		b, _ = strconv.Atoi(sl[1])
		if a == 0 {
			fmt.Println(1)
		} else {
			fmt.Println(a + b*2 + 1)
		}
	}
}

package main
import(
    "fmt"
)
func main(){
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var a,b int
		fmt.Scan(&a,&b)
		if a == 0 {
			fmt.Println(1)
		}else{
			fmt.Println(2*b+a+1)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main(){
	cin := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(cin, &t)
	for t > 0 {
		var a, b int
		fmt.Fscan(cin, &a, &b)
		ans := 0
		switch {
		case a == 0:
			ans = 1
		case a > 0:
			ans = 2*b + a + 1
		}
		fmt.Println(ans)
		 t -= 1
	}
}

package main

import "fmt"

func execute(OneCoin, TwoCoin int) int {

	if OneCoin == 0 && TwoCoin == 0 {
		return 1
	}
	if OneCoin == 0 {
		return 1
	}

	if TwoCoin == 0 {
		return 1 + OneCoin
	}

	return 2*TwoCoin + OneCoin + 1

}

func main() {

	var testcase int
	fmt.Scan(&testcase)
	// hehe :)
	var OneCoin int
	var TwoCoin int
	for i := 0; i < testcase; i++ {
		fmt.Scan(&OneCoin, &TwoCoin)
		fmt.Println(execute(OneCoin, TwoCoin))
	}
}

package main

import (
	"fmt"
)

func main() {
	var testCases int
	fmt.Scanf("%d\n", &testCases)

	for i := 0; i < int(testCases); i++ {
		var a, b int
		fmt.Scanf("%d %d\n", &a, &b)
		if a == 0 {
			fmt.Println(1)
			continue
		}
		maximum := ((b * 2) + a) + 1
		fmt.Println(maximum)
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	run(os.Stdin, os.Stdout)
}

func run(r io.Reader, w io.Writer) {
	in := bufio.NewReader(r)
	out := bufio.NewWriter(w)

	defer out.Flush()

	var t, x, y int
	for fmt.Fscan(in, &t); t > 0; t-- {
		fmt.Fscan(in, &x, &y)
		if x == 0 {
			fmt.Fprintln(out, 1)
		} else {
			fmt.Fprintln(out, x+2*y+1)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func solve(r *bufio.Reader) {
	var a, b int
	fmt.Fscan(r, &a, &b)
	if a == 0 {
		fmt.Println(1)
	} else {
		fmt.Println(a + 2*b + 1)
	}
}
func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(r, &n)
	for i := 0; i < n; i++ {
		solve(r)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	sc *bufio.Scanner
	wr *bufio.Writer
)

func init() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	wr = bufio.NewWriter(os.Stdout)
}

func scanInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func main() {
	defer wr.Flush()

	for T := scanInt(); T > 0; T-- {
		a, b := scanInt(), scanInt()
		if a == 0 {
			fmt.Fprintln(wr, 1)
		} else {
			fmt.Fprintln(wr, a+b*2+1)
		}
	}
}

package main

import "fmt"

func main() {
	var t int

	fmt.Scan(&t)

	for ; t > 0 ; t--  {
		var a,b int
		fmt.Scan(&a,&b)
		if(a == 0){
			fmt.Print(1,"\n")
		} else{
			fmt.Print(2 * b + a + 1,"\n")
		}
	}

}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1660A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, a, b int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &a, &b)
		if a == 0 {
			Fprintln(out, 1)
		} else {
			Fprintln(out, a+b*2+1)
		}
	}
}

func main() { CF1660A(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"os"
)

const mod = 998244353
const mx = 3000

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	var a,b int
	fmt.Fscan(in,&a,&b)
	if a == 0{
		fmt.Fprintln(out,1)
		return
	}
	fmt.Fprintln(out,a + b * 2 + 1)
}

func abs(a,b int)int{
	if a > b{
		return a - b
	}
	return b - a
}
func sum(a,b int64)int64{
	return (b + a) * (b - a + 1) / 2
}

func max(a,b int)int{
	if a > b{
		return a
	}
	return b
}
func min(a,b int)int{
	if a > b{
		return b
	}
	return a
}
func gcd(a,b int)int{
	if a % b == 0{
		return b
	}
	return gcd(b,a%b)
}

func main() {
	stdin := os.Stdin
	stdout := os.Stdout
	in := bufio.NewReader(stdin)
	out := bufio.NewWriter(stdout)
	n := 1
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		solve(in, out)
	}
}

package main

import (
	"fmt"
)

func main() {
	var T, a, b int
	fmt.Scan(&T)
	for ; T > 0; T-- {
		fmt.Scan(&a, &b)
		if a == 0 {
			fmt.Println(1)
		} else {
			fmt.Println(b*2 + a + 1)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type CF1660A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1660A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1660A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1660A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1660A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1660A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1660A
Date: 2/04/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1660/A
Problem: CF1660A
**/
func (in *CF1660A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		a, b := in.NextInt(), in.NextInt()
		if a == 0 {
			fmt.Println(1)
		} else {
			fmt.Println((b * 2) + a + 1)
		}
	}
}

func NewCF1660A(r *bufio.Reader) *CF1660A {
	return &CF1660A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1660A(bufio.NewReader(os.Stdin)).Run()
}

package main

import (
  "bufio"
  "fmt"
  "os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
  defer writer.Flush()
  var t int
  for scanf("%d\n", &t) ; t > 0 ; t-- {
    var a, b int
    scanf("%d %d\n", &a, &b)
    if a != 0 {
      printf("%d\n", a + b * 2 + 1)
    } else {
      printf("1\n")
    }
  }
}

package main

import "fmt"

func solve() {

	var a, b int
	fmt.Scanf("%d %d\n", &a, &b)

	if a == 0 && b > 0 {
		fmt.Println(1)
		return
	} else if b == 0 && a > 0 {
		fmt.Println(a + 1)
		return
	}

	payA := a
	payB := b * 2

	total := payA + payB

	fmt.Println(total + 1)
}

func main() {

	var t int
	fmt.Scanf("%d\n", &t)

	for t > 0 {
		solve()
		t--
	}
}

package main

import (
	"fmt"
)

func main() {
	a := 1
	b := 2
	var n int
	var nC1, nC2 int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nC1)
		fmt.Scan(&nC2)
		if nC1 == 0 {
			fmt.Println(1)
			continue
		}

		sm := nC1*a + nC2*b
		sm += 1
		fmt.Println(sm)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		line := scanner.Text()

		fields := strings.Fields(line)

		if len(fields) == 1 {
			continue
		} else if len(fields) == 0 {
			break
		}

		a, err := strconv.Atoi(fields[0])
		if err != nil {
			panic(err)
		}
		b, err := strconv.Atoi(fields[1])
		if err != nil {
			panic(err)
		}

		fmt.Println(firstChange(a, b))
	}

}

func firstChange(a int, b int) int {
	if a == 0 {
		return 1
	} else {
		return a*1 + b*2 + 1
	}
}

package main

import (
	"bufio"
	. "fmt"
	"os"
)

const (
	INF = 3e5 + 10
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var t int
	Fscan(in, &t)

	for i := 0; i < t; i++ {
		var a, b int64

		Fscan(in, &a, &b)

		var ans int64

		if a == 0 {
			ans = 1
		} else {
			ans = a + b*2 + 1
		}
		Fprintln(out, ans)

	}

}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

/*

 */

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var a, b int
	scanf("%d %d\n", &a, &b)

	ans := a + 2*b + 1

	if a == 0 {
		ans = 1
	}

	fmt.Fprintln(writer, ans)
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div > 0 {
		quot++
	} else if num%div < 0 {
		quot--
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	return nums[minIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func minIdx(nums ...int) int {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return minNumIdx
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	return nums[maxIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func maxIdx(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	defer out.Flush()
	var t int
	fmt.Fscanf(in, "%d\n", &t)
	for t := t; t > 0; t-- {
		var a, b int
		fmt.Fscanf(in, "%d%d\n", &a, &b)
		res := b*2 + a + 1

		if a == 0 {
			res = 1
		}

		fmt.Fprintln(out, res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var a, b int
		fmt.Fscan(in, &a, &b)

		if a == 0 {
			fmt.Fprintln(out, 1)
		} else if b == 0 {
			fmt.Fprintln(out, a+1)
		} else {
			fmt.Fprintln(out, b*2+a+1)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in,out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t:=0
	fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		var m,n int
		fmt.Fscan(in, &m,&n)
		if m ==0{
			fmt.Fprintln(out, 1)
		}else {
			fmt.Fprintln(out, m+n*2+1)
		}
	}
}

func max(a, b int) int {
	if a >b{
		return a
	}
	return b
}
func min(a, b int) int {
	if a <b{
		return a
	}
	return b
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	for i := read(); i >= 0; i-- {
	    a, b := read(), read()
	    if a != 0 {
	        Fprintln(out, a+2*b+1)
	    } else {
	        Fprintln(out, 1)
	    }
	}
}

func main() {
	run(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	for i := read(); i >= 0; i-- {
	    a, b := read(), read()
	    Fprintln(out, a+2*b+1)
	}
}

func main() {
	run(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	a, b:= read(), read()
	Fprintln(out, a + 2*b + 1)
}

func main() {
	run(os.Stdin, os.Stdout)
}

package main

import "fmt"

func solve() {
	var a, b int
	// fmt.Scan(&a, &b)
	fmt.Scanf("%d%d", &a, &b)
	if a == 0 {
		fmt.Println(1)
	} else {
		fmt.Println(2*b + a + 1)
	}
}

func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		t--
		solve()
	}
}

package main

import "fmt"

func solve() {
	var a, b int
	// fmt.Scan(&a, &b)
	fmt.Scanf("%d%d", &a, &b)
	if a == 0 {
		// fmt.Println(1)
		fmt.Printf("1\n")
	} else {
		// fmt.Println(2*b + a + 1)
		fmt.Printf("%d\n", 2*b+a+1)
	}
}

func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		t--
		solve()
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, a, b int
	fmt.Scanf("%d", &t)
	for ; t > 0; t-- {
		fmt.Scanf("%d %d", &a, &b)
		if a == 0 {
			fmt.Printf("%d\n", 1)
		} else {
			fmt.Printf("%d\n", b*2+a+1)
		}
	}
}

// a == b == 2
// (a) (b) (ab) (bb) (abb) (aabb)
// a > b
// a=6 b=3
// (a) (b) (ab) (bb) (abb) (bbb) (abbb) (aabbb) (aaabbb) (aaaabb) (aaaaabb) (aaaaaabb)
// a=6 b=5
// (a) (b) (ab) (bb) (abb) (bbb) (abbb) (bbbb) (abbbb) (bbbbb) (abbbbb) (aabbbbb) (aaabbbbb) (aaaabbbbb) (aaaaabbbbb) (aaaaaabbbbb)
// a < b
// a=3 b=6
// (a) (b) (ab) (bb) (abb) (bbb) (abbb) (bbbb) (abbbb) (bbbbb) (abbbbb) (bbbbbb) (abbbbbb) (aabbbbbb) (aaabbbbbb)

package main

import (
	"fmt"
)

func main() {
	var t, a, b int
	fmt.Scanf("%d", &t)
	for ; t > 0; t-- {
		fmt.Scanf("%d %d", &a, &b)
		fmt.Printf("%d\n", Calculation(a, b))
	}
}

func Calculation(a, b int) int {
	if a == 0 {
		return 1
	}
	return b*2 + a + 1
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// a == b == 2
// (a) (b) (ab) (bb) (abb) (aabb)
// a > b
// a=6 b=3
// (a) (b) (ab) (bb) (abb) (bbb) (abbb) (aabbb) (aaabbb) (aaaabb) (aaaaabb) (aaaaaabb)
// a=6 b=5
// (a) (b) (ab) (bb) (abb) (bbb) (abbb) (bbbb) (abbbb) (bbbbb) (abbbbb) (aabbbbb) (aaabbbbb) (aaaabbbbb) (aaaaabbbbb) (aaaaaabbbbb)
// a < b
// a=3 b=6
// (a) (b) (ab) (bb) (abb) (bbb) (abbb) (bbbb) (abbbb) (bbbbb) (abbbbb) (bbbbbb) (abbbbbb) (aabbbbbb) (aaabbbbbb)

package main

import (
	"fmt"
)

func main() {
	var n, a, b int;
	fmt.Scanf("%d", &n);

	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d", &a, &b)
		fmt.Println(a + 2*b + 1)
	}
}

package main

import (
	"fmt"
)

func main() {
	var a, b int64
	_, _ = fmt.Scan(&a, &b)
	if a > 0 {
		fmt.Print(a + 2*b + 1)
	} else {
		fmt.Print(1)
	}
}

package main

// Problem description URL https://atcoder.jp/contests/abc236/tasks/abc240_a

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }

type pair struct {
	Color int
	Size  int
}

var (
	n   = 0
	res []int
	s   *list.List
	cur = 0
)

func solve() {
	scan(&n)
	for n != 0 {
		n--
		a, b := 0, 0
		scan(&a, &b)
		if(a == 0){
			printf("1\n")
		}else {
			printf("%lld\n", b*2+(a+1))
		}
	}
}

func main() {
	defer out.Flush()
	solve()
}

package main

import ("fmt")

func solve(){
	var a,b int
	fmt.Scan(&a,&b)

	if (a==0) {
       fmt.Println(1)
	}else{
		fmt.Println(2*b+a+1)
	}

}
func main() {
	var tc int
    fmt.Scan(&tc)
	fmt.Print(tc)
	for i:=0;i<tc;i++{
		solve()
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func solve(cin *scanner, cout *writer, cerr *writer) {
	a, b := cin.NextInt(), cin.NextInt()
	cout.Println(b + b + a + 1)
}

func main() {
	cin := NewScanner(os.Stdin)
	cout, cerr := NewWriter(os.Stdout), NewWriter(os.Stderr)
	defer cout.Flush()
	defer cerr.Flush()
	t := cin.NextInt()
	// t := 1
	for ti := 0; ti < t; ti++ {
		solve(cin, cout, cerr)
	}
}

// Template Bolierplate {{{
type scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 1024*1024)
	return &scanner{s}
}

func (i *scanner) Next() string {
	i.Scan()
	return i.Text()
}

func (i *scanner) Nexts(n int) []string {
	res := make([]string, n)
	for j := range res {
		res[j] = i.Next()
	}
	return res
}

func (i *scanner) NextInt() int {
	v, _ := strconv.Atoi(i.Next())
	return v
}

func (i *scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(i.Next(), 10, 64)
	return v
}

func (i *scanner) NextInts(n int) []int {
	res := make([]int, n)
	for j := range res {
		res[j] = i.NextInt()
	}
	return res
}

func (i *scanner) NextInt64s(n int) []int64 {
	res := make([]int64, n)
	for j := range res {
		res[j] = i.NextInt64()
	}
	return res
}

type writer struct {
	w *bufio.Writer
}

func NewWriter(w io.Writer) *writer {
	return &writer{bufio.NewWriter(w)}
}

func (i *writer) Print(a ...interface{}) {
	fmt.Fprint(i.w, a...)
}

func (i *writer) Println(a ...interface{}) {
	fmt.Fprintln(i.w, a...)
}

func (i *writer) Printf(format string, a ...interface{}) {
	fmt.Fprintf(i.w, format, a...)
}

func (i *writer) Flush() {
	i.w.Flush()
}

// }}}

// vim: fdm=marker


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.

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	pow := [35]int{}
	pow[0]=1
	for i:=1;i<=31;i++{
		if i==1{
			pow[i]=2
		}else{
			pow[i]=pow[i-1]*2
		}
	}
	for u:=1;u<=t;u++{
		var n int
		fmt.Fscan(in,&n)
		if n%2==0{
			flag := false
			for i:=0;i<=31;i++{
				if n==pow[i]{
					flag= true
				}
			}
			if flag{
				cnt := 0
				for n>1{
					n/=2
					cnt++
				}
				if cnt%2==0{
					fmt.Fprintln(out,"Alice")
				}else{
					fmt.Fprintln(out,"Bob")
				}
			}else{
				fmt.Fprintln(out,"Alice")
			}
		}else{
			fmt.Fprintln(out,"Bob")
		}
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"math/bits"
	"os"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		if n&(n-1) == 0 && bits.Len(uint(n))&1 == 0 {
			Fprintln(out, "Bob")
			return
		}
		if n&1==0 {
			Fprintln(out, "Alice")
		} else {
			Fprintln(out, "Bob")
		}
	}

	T := 1
	Fscan(in, &T)
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

func main() { run(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"math/bits"
	"os"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		if n&(n-1) == 0 && bits.Len(uint(n))&1 == 0 {
			Fprintln(out, "Bob")
			return
		}
		if n&1==0 {
			Fprintln(out, "Alice")
		} else {
			Fprintln(out, "Bob")
		}
	}

	T := 1
	Fscan(in, &T) //
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

func main() { run(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"os"
)

var in *bufio.Reader

func solve() {
	var n int
	fmt.Fscan(in, &n)

	if n%2 == 1 {
		fmt.Println("Bob")
		return
	}

	x := n
	cnt := 0
	for x > 1 {
		x >>= 1
		cnt++
	}
	x <<= cnt
	if x != n {
		fmt.Println("Alice")
	} else {
		if cnt%2 == 0 {
			fmt.Println("Alice")
		} else {
			fmt.Println("Bob")
		}
	}
}

func main() {
	in = bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		solve()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var in *bufio.Reader

func solve() {
	var n int
	fmt.Fscan(in, &n)

	if n%2 == 1 {
		fmt.Println("Bob")
		return
	}

	x := n
	cnt := 0
	for x > 0 {
		x >>= 1
		cnt++
	}
	x = 1
	x <<= cnt - 1
	if x != n {
		fmt.Println("Alice")
	} else {
		if cnt%2 == 1 {
			fmt.Println("Alice")
		} else {
			fmt.Println("Bob")
		}
	}
}

func main() {
	in = bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		solve()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

// Math

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var t int
	fmt.Fscan(reader, &t)

	var n int
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		if n&1 == 1 {
			fmt.Fprintln(writer, "Bob")
			continue
		}
		cnt := 0
		for ; n&1 == 0; n >>= 1 {
			cnt++
		}
		if n > 1 || cnt&1 == 0 {
			fmt.Fprintln(writer, "Alice")
		} else {
			fmt.Fprintln(writer, "Bob")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
)

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)

	mn := make(map[int]bool)
	for i := 1; i < 32; i+=2 {
		mn[1<<i]=true
	}

	for t := io.ReadInt(); t > 0; t-- {
		s := io.ReadInt()
		if s % 2 == 0 && mn[s] == false {
			io.Println("Alice")
		} else {
			io.Println("Bob")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	pow := [35]int{}
	pow[0]=1
	for i:=1;i<=31;i++{
		if i==1{
			pow[i]=2
		}else{
			pow[i]=pow[i-1]*2
		}
	}
	for u:=1;u<=t;u++{
		var n int
		fmt.Fscan(in,&n)
		if n%2==0{
			x := n/2
			flag := false
			for i:=0;i<=31;i++{
				if pow[i]==x&&x!=2{
					flag = true
				}
			}
			if flag{
				fmt.Fprintln(out,"Bob")
			}else{
				fmt.Fprintln(out,"Alice")
			}
		}else{
			fmt.Fprintln(out,"Bob")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for u:=1;u<=t;u++{
		var n int
		fmt.Fscan(in,&n)
		if n%2==0{
			fmt.Fprintln(out,"Alice")
		}else{
			fmt.Fprintln(out,"Bob")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var t int
	fmt.Fscan(reader, &t)

	var n int
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		if canWin(n) {
			fmt.Fprintln(writer, "Alice")
		} else {
			fmt.Fprintln(writer, "Bob")
		}
	}
}

func canWin(n int) bool {
	ok := false
LOOP:
	for i := 2; i*i <= n; i++ {
		if n%i > 0 {
			continue
		} else if i&1 == 0 {
			ok = true
			break LOOP
		}
		for ; n%i == 0; n /= i {
		}
	}
	return ok
}


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.

package main

import (
	"bufio"
	. "fmt"
	"math/bits"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var f func(l, r int)
	f = func(l, r int) {
		if r-l == 1 {
			Fprintln(out, l, r)
			return
		}
		m := (l + r) / 2
		f(l, m)
		f(m+1, r)
		for i := l; i <= m; i++ {
			Fprintln(out, i, m+i-l+1)
		}
	}
	var n int
	Scan(&n)
	if n == 1 {
		Fprint(out, 0)
		return
	}
	d := bits.Len(uint(n)) - 1
	m := 1 << d
	Fprintln(out, d*m)
	f(1, m)
	f(n-m+1, n)
}


You've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at least k other nodes of this graph. Your task is to find in the given graph a simple cycle of length of at least k + 1.A simple cycle of length d (d > 1) in graph G is a sequence of distinct graph nodes v1, v2, ..., vd such, that nodes v1 and vd are connected by an edge of the graph, also for any integer i (1 ≤ i < d) nodes vi and vi + 1 are connected by an edge of the graph.

The first line contains three integers n, m, k (3 ≤ n, m ≤ 105; 2 ≤ k ≤ n - 1) — the number of the nodes of the graph, the number of the graph's edges and the lower limit on the degree of the graph node. Next m lines contain pairs of integers. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi) — the indexes of the graph nodes that are connected by the i-th edge.  It is guaranteed that the given graph doesn't contain any multiple edges or self-loops. It is guaranteed that each node of the graph is connected by the edges with at least k other nodes of the graph.

In the first line print integer r (r ≥ k + 1) — the length of the found cycle. In the next line print r distinct integers v1, v2, ..., vr (1 ≤ vi ≤ n) — the found simple cycle. It is guaranteed that the answer exists. If there are multiple correct answers, you are allowed to print any of them.

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF263D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, m, k, v, w, end, st int
	Fscan(in, &n, &m, &k)
	g := make([][]int, n+1)
	for ; m > 0; m-- {
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	fa := make([]int, n+1)
	dep := make([]int, n+1)
	var f func(v, p, d int) bool
	f = func(v, p, d int) bool {
		fa[v] = p
		dep[v] = d
		for _, w := range g[v] {
			if dep[w] == 0 && f(w, v, d+1) {
				return true
			}
			if dep[w] > 0 && d-dep[w] >= k {
				end, st = v, w
				return true
			}
		}
		return false
	}
	f(1, 0, 1)

	ans := []interface{}{st}
	for v := end; v != st; v = fa[v] {
		ans = append(ans, v)
	}
	Fprintln(out, len(ans))
	Fprint(out, ans...)
}

func main() { CF263D(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF263D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, m, k, v, w, end, st int
	Fscan(in, &n, &m, &k)
	g := make([][]int, n+1)
	for ; m > 0; m-- {
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	fa := make([]int, n+1)
	dep := make([]int, n+1)
	var f func(v, p, d int) bool
	f = func(v, p, d int) bool {
		fa[v] = p
		dep[v] = d
		for _, w := range g[v] {
			if dep[w] == 0 {
				if f(w, v, d+1) {
					return true
				}
			} else if d-dep[w] >= k {
				end, st = v, w
				return true
			}
		}
		return false
	}
	f(1, 0, 1)

	ans := []interface{}{st}
	for v := end; v != st; v = fa[v] {
		ans = append(ans, v)
	}
	Fprintln(out, len(ans))
	Fprint(out, ans...)
}

func main() { CF263D(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF263D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, m, k, v, w, end int
	Fscan(in, &n, &m, &k)
	g := make([][]int, n+1)
	for ; m > 0; m-- {
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	vis := make([]bool, n+1)
	fa := make([]int, n+1)
	var f func(v, p, d int) bool
	f = func(v, p, d int) bool {
		vis[v] = true
		fa[v] = p
		if d >= k {
			for _, w := range g[v] {
				if w == 1 {
					end = v
					return true
				}
			}
		}
		for _, w := range g[v] {
			if !vis[w] && f(w, v, d+1) {
				return true
			}
		}
		return false
	}
	f(1, 0, 0)

	ans := []interface{}{1}
	for v := end; v > 1; v = fa[v] {
		ans = append(ans, v)
	}
	Fprintln(out, len(ans))
	Fprint(out, ans...)
}

func main() { CF263D(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF263D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, m, k, v, w, end int
	Fscan(in, &n, &m, &k)
	g := make([][]int, n+1)
	for ; m > 0; m-- {
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	vis := make([]bool, n+1)
	fa := make([]int, n+1)
	var f func(v, p, d int) bool
	f = func(v, p, d int) bool {
		vis[v] = true
		fa[v] = p
		if d >= k {
			for _, w := range g[v] {
				if w == 1 {
					end = v
					return true
				}
			}
		}
		for _, w := range g[v] {
			if !vis[w] {
				if f(w, v, d+1) {
					return true
				}
			}
		}
		return false
	}
	f(1, 0, 0)

	ans := []interface{}{}
	for v := end; v > 0; v = fa[v] {
		ans = append(ans, v)
	}
	Fprintln(out, len(ans))
	Fprint(out, ans...)
}

func main() { CF263D(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF263D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, m, k, v, w, end int
	Fscan(in, &n, &m, &k)
	g := make([][]int, n+1)
	for ; m > 0; m-- {
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	vis := make([]bool, n+1)
	fa := make([]int, n+1)
	var f func(v, p, d int) bool
	f = func(v, p, d int) bool {
		vis[v] = true
		fa[v] = p
		if d == k {
			for _, w := range g[v] {
				if w == 1 {
					end = v
					return true
				}
			}
		}
		for _, w := range g[v] {
			if !vis[w] {
				if f(w, v, d+1) {
					return true
				}
			}
		}
		return false
	}
	f(1, 0, 0)

	ans := []interface{}{}
	for v := end; v > 0; v = fa[v] {
		ans = append(ans, v)
	}
	Fprintln(out, len(ans))
	Fprint(out, ans...)
}

func main() { CF263D(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF263D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, m, k, v, w, end int
	Fscan(in, &n, &m, &k)
	g := make([][]int, n+1)
	for ; m > 0; m-- {
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	vis := make([]bool, n+1)
	fa := make([]int, n+1)
	var f func(v, p, d int) bool
	f = func(v, p, d int) bool {
		vis[v] = true
		fa[v] = p
		if d >= k {
			for _, w := range g[v] {
				if w == 1 {
					end = v
					return true
				}
			}
		}
		for _, w := range g[v] {
			if !vis[w] && f(w, v, d+1) {
				return true
			}
		}
		return false
	}
	f(1, 0, 0)

	ans := []interface{}{}
	for v := end; v > 1; v = fa[v] {
		ans = append(ans, v)
	}
	ans = append(ans, 1)
	Fprintln(out, len(ans))
	Fprint(out, ans...)
}

func main() { CF263D(os.Stdin, os.Stdout) }


Ayoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols "0" and "1"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to "1".More formally, $$$f(s)$$$ is equal to the number of pairs of integers $$$(l, r)$$$, such that $$$1 \leq l \leq r \leq |s|$$$ (where $$$|s|$$$ is equal to the length of string $$$s$$$), such that at least one of the symbols $$$s_l, s_{l+1}, \ldots, s_r$$$ is equal to "1". For example, if $$$s = $$$"01010" then $$$f(s) = 12$$$, because there are $$$12$$$ such pairs $$$(l, r)$$$: $$$(1, 2), (1, 3), (1, 4), (1, 5), (2, 2), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 4), (4, 5)$$$.Ayoub also thinks that he is smarter than Mahmoud so he gave him two integers $$$n$$$ and $$$m$$$ and asked him this problem. For all binary strings $$$s$$$ of length $$$n$$$ which contains exactly $$$m$$$ symbols equal to "1", find the maximum value of $$$f(s)$$$.Mahmoud couldn't solve the problem so he asked you for help. Can you help him?

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$)  — the number of test cases. The description of the test cases follows. The only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 10^{9}$$$, $$$0 \leq m \leq n$$$) — the length of the string and the number of symbols equal to "1" in it.

For every test case print one integer number — the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to "1".

NoteIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to "1". These strings are: $$$s_1 = $$$"100", $$$s_2 = $$$"010", $$$s_3 = $$$"001". The values of $$$f$$$ for them are: $$$f(s_1) = 3, f(s_2) = 4, f(s_3) = 3$$$, so the maximum value is $$$4$$$ and the answer is $$$4$$$.In the second test case, the string $$$s$$$ with the maximum value is "101".In the third test case, the string $$$s$$$ with the maximum value is "111".In the fourth test case, the only string $$$s$$$ of length $$$4$$$, which has exactly $$$0$$$ symbols, equal to "1" is "0000" and the value of $$$f$$$ for that string is $$$0$$$, so the answer is $$$0$$$.In the fifth test case, the string $$$s$$$ with the maximum value is "01010" and it is described as an example in the problem statement.

package main

import (
	"fmt"
	"bufio"
	"os"
)

func main() {
	var t int
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	fmt.Fscanf(in, "%d\n", &t)
	var n, m int64
	for i := 0; i < t; i++ {
		fmt.Fscanf(in, "%d %d\n", &n, &m)
		var result int64 = (n * (n + 1))/2
		var z int64 =  n - m
		var k int64 = z/(m + 1)
		result -= (m + 1) * k * (k + 1) / 2
		result -= (z % (m + 1)) * (k + 1)
		fmt.Fprintf(out, "%v\n", result)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

type node struct {
	diff int
	time int
}

type ByTime []node

func (a ByTime) Len() int           { return len(a) }
func (a ByTime) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByTime) Less(i, j int) bool { return a[i].time < a[j].time }

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n, m := int64(0), int64(0)
		fmt.Fscanf(in, "%d %d\n", &n, &m)
		remainingN := n - m
		parts := m + 1
		eachPartNum := remainingN / parts
		a := remainingN % parts
		ans := (1 + n) * n / 2
		//fmt.Println(ans, remainingN, parts, eachPartNum, a)
		ans -= a * (eachPartNum + 1 + 1) * (eachPartNum + 1) / 2
		ans -= (parts - a) * (eachPartNum + 1) * eachPartNum / 2
		fmt.Fprintf(out, "%d\n", ans)
	}
	return
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	return scanner.Bytes()
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

type state struct {
	i   int
	res int
}

var dp [11][11]state

func solve(n, m int) int64 {
	// var s state
	for nn := 1; nn <= n; nn++ {
		for mm := 1; mm <= m; mm++ {
			for i := 1; i <= nn; i++ {
				if dp[nn][mm].res < dp[nn-i][mm-1].res+i*(nn-i+1) {
					dp[nn][mm].res = dp[nn-i][mm-1].res + i*(nn-i+1)
					dp[nn][mm].i = i
				}
			}
		}
	}
	return int64(dp[n][m].res)
}

func form(n, b, q int) int64 {
	if q <= 0 {
		return int64(0)
	}
	return int64(b) * (int64(n+1)*int64(q) - int64(q)*int64(q+1)/int64(2)*int64(b))
}

func solveFaster(n, m int) int64 {
	A := 1 + (n-m)/(m+1)
	B := A + 1
	cntB := (n - m) % (m + 1)
	cntA := (m + 1) - cntB
	// fmt.Fprintln(os.Stderr, A, B, cntA, cntB, n, m)
	res := form(n, B, cntB-1)
	// fmt.Fprintln(os.Stderr, res)
	res += form(n-B*cntB, A, cntA-1)
	// fmt.Fprintln(os.Stderr, res)
	if cntB > 0 && cntA > 0 {
		res += int64(B) * int64(n-B*cntB+1)
	}

	// n - baseLen * ()
	// for n > 0 && m > 0 {
	// 	i := 1 + (n-m)/(m+1)
	// 	res += i * (n - i + 1)
	// 	n -= i
	// 	m--
	// }
	return res
}

func main() {
	f := os.Stdin
	out := os.Stdout
	// f, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(f, 1000010)
	// solve(1000, 1000)
	// for nn := 0; nn <= 1000; nn++ {
	// 	for mm := 0; mm <= nn; mm++ {
	// 		fr := solveFaster(nn, mm)
	// 		if dp[nn][mm].res != int(fr) {
	// 			fmt.Fprintln(out, "n=", nn, "m=", mm, "i=", dp[nn][mm].i, dp[nn][mm].res, "fr=", fr)
	// 		}
	// 		// fmt.Fprint(out, dp[i][j].i, " ")
	// 	}
	// 	// fmt.Fprintln(out)
	// }

	// dp = make([][100]state, 100)

	// fmt.Fprintln(out, solveFaster(100, 50))
	T := NextInt()

	for t := 0; t < T; t++ {
		n := NextInt()
		m := NextInt()
		fmt.Fprintln(out, solveFaster(n, m))
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	tests := scanInt()
	for t := 0; t < tests; t++ {
		n := scanInt64()
		m := scanInt64()

		c0 := (n-m)/(m+1)
		cnt1 := (n-m)%(m+1)
		cnt0 := m+1-cnt1

		ans := cnt1*(c0+2)*(n+1)-(c0+2)*(c0+2)*cnt1*(cnt1+1)/2
		ans += (c0+1)*(cnt0*(n+1-(c0+2)*cnt1)-(c0+1)*cnt0*(cnt0+1)/2)
		fmt.Println(ans)
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func() (ans int64) {
		var n, ones int64
		Fscan(in, &n, &ones)

		if ones == 0 {
			return
		}

		zeros := n - ones
		segZero, plus1Cnt := zeros/(ones+1), zeros%(ones+1)
		segZeroCnt := ones + 1 - plus1Cnt
		//if segZero == 0 {
		//	return n*ones - (ones-1)*ones/2
		//}

		//if segZero == 0 {
		//	return n*ones-(ones-1)*ones/2
		//}

		//a := segZero +1
		//b := n- segZero
		//c := segZero +1
		//d := (ones-1)*ones/2
		//ans += a*(ones*b-c*d)

		ans += (segZero + 1) * (n*segZeroCnt - segZero*(segZeroCnt+1)*segZeroCnt/2 - (segZeroCnt-1)*segZeroCnt/2)
		if plus1Cnt > 0 {
			n -= (segZero + 1) * segZeroCnt

			segZeroCnt = plus1Cnt
			segZero++
			ans += (segZero + 1) * (n*segZeroCnt - segZero*(segZeroCnt+1)*segZeroCnt/2 - (segZeroCnt-1)*segZeroCnt/2)

		}

		return
	}

	var t int
	Fscan(in, &t)
	for _case := 1; _case <= t; _case++ {
		if _case == 6 {
			//println()

		}
		Fprintln(out, solve())
	}
}

func main() { run(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	var t int
	var n, m int64
	fmt.Fscanln(in, &t)
	for t > 0 {
		fmt.Fscanln(in, &n, &m)

		zero := n - m
		div := m + 1

		k := (zero / div)
		l := (zero % div)

		res := n*(n+1)/2 - (k*(k+1)/2*(div-l) + (k+1)*(k+2)/2*l)
		fmt.Fprintln(out, res)
		t--
	}
	out.Flush()
}

package main

import (
	"fmt"
)

func solve() {
	var n, m int64
	fmt.Scan(&n)
	fmt.Scan(&m)
	fmt.Println(n, m)
	var result int64 = (n * (n + 1))/2
	var z int64 =  n - m
	var k int64 = z/(m + 1)
    result -= (m + 1) * k * (k + 1) / 2
    result -= (z % (m + 1)) * (k + 1)
    fmt.Println(result)
}

func main() {
	var testcases uint32
	fmt.Scan(&testcases)
	for testcases != 0 {
		solve()
		testcases--
	}
}

package main

import (
    "fmt"
)

func main() {
	var testcases uint32
	fmt.Scanf("%d", &testcases)
	for testcases > 0 {
		var n, m int64
		// defer writer.Flush()
		fmt.Scanf("%d %d", &n, &m)
		var result int64 = (n * (n + 1))/2
		var z int64 =  n - m
		var k int64 = z/(m + 1)
		result -= (m + 1) * k * (k + 1) / 2
		result -= (z % (m + 1)) * (k + 1)
		fmt.Printf("%v\n", result)
		testcases --
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func() (ans int64) {
		var n, ones int64
		Fscan(in, &n, &ones)

		if ones == 0 {
			return
		}

		zeros := n-ones
		full,_ := zeros/(ones+1), zeros%(ones+1)
		a := full+1
		b := n-full
		c := full+1
		d := (ones-1)*ones/2
		ans = a*(ones*b-c*d)
		return
	}

	var t int
	Fscan(in, &t)
	for _case := 1; _case <= t; _case++ {
		if _case == 5 {
			//println()

		}
		Fprintln(out, solve())
	}
}

func main() { run(os.Stdin, os.Stdout) }