A penguin Rocher has $$$n$$$ sticks. He has exactly one stick with length $$$i$$$ for all $$$1 \le i \le n$$$.He can connect some sticks. If he connects two sticks that have lengths $$$a$$$ and $$$b$$$, he gets one stick with length $$$a + b$$$. Two sticks, that were used in the operation disappear from his set and the new connected stick appears in his set and can be used for the next connections.He wants to create the maximum number of sticks that have the same length. It is not necessary to make all sticks have the same length, some sticks can have the other length. How many sticks with the equal length he can create?

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain descriptions of test cases. For each test case, the only line contains a single integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$).

For each test case, print a single integer  — the answer to the problem.

NoteIn the third case, he can connect two sticks with lengths $$$1$$$ and $$$2$$$ and he will get one stick with length $$$3$$$. So, he will have two sticks with lengths $$$3$$$.In the fourth case, he can connect two sticks with lengths $$$1$$$ and $$$3$$$ and he will get one stick with length $$$4$$$. After that, he will have three sticks with lengths $$$\{2, 4, 4\}$$$, so two sticks have the same length, and one stick has the other length.

package main

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

var in *bufio.Reader
var out *bufio.Writer

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

func main() {
	out = bufio.NewWriterSize(os.Stdout, 8192)
	defer out.Flush()
	if false {
		file, err := os.Open("in.txt")
		if err != nil {
			log.Fatal(err)
		}
		in = bufio.NewReaderSize(file, 8192)
	} else {
		in = bufio.NewReaderSize(os.Stdin, 8192)
	}

	var t, n int
	scanf("%d", &t)

	for ; t > 0; t-- {
		scanf("\n%d", &n)
		printf("%d\n", (n+1)/2)
	}
}

package main

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

func main() {
	var t, n int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		fmt.Printf("%.0f\n", math.Ceil(float64(n)/2))
	}
}

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-- {
		var n int64
		fmt.Fscan(in, &n)
		fmt.Fprintln(out, (n+1)/2)
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input, _ := reader.ReadString('\n')
	trimmedInput := strings.TrimSpace(input)
	testCases, _ := strconv.Atoi(trimmedInput)

	for testCases > 0 {
		input, _ = reader.ReadString('\n')
		trimmedInput = strings.TrimSpace(input)
		number, _ := strconv.Atoi(trimmedInput)
		fmt.Println((number / 2) + (number % 2))
		testCases--
	}

}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		fmt.Println(solve(n))
	}
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(n int) int {
	return (n + 1) / 2
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		var s int
		fmt.Scanf("%d\n", &s)
		fmt.Println((s + 1) / 2)
	}
}

// https://codeforces.com/contest/1365/problem/A
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input *bufio.Reader

func main() {
	var T int

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		fmt.Println(solver())
	}
}

func solver() int {
	var n int
	fmt.Fscan(input, &n)
	if n == 1 { return 1}
	if n % 2 == 0 { return (n  / 2)	 }
	return (n - 3) / 2 + 2
}

package main

import "fmt"

func even(n uint) uint {
	return n / 2
}

func odd(n uint) uint {
	return (n + 1) / 2
}

func test() {
	var n uint
	fmt.Scan(&n)

	if n%2 == 0 {
		fmt.Println(even(n))
	} else {
		fmt.Println(odd(n))
	}
}

func main() {
	var t uint
	fmt.Scan(&t)

	for t != 0 {
		test()
		t--
	}
}

package main

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

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		// n:= reader.NextInt64()
		a:=reader.NextInt64()
		sol(a)
	}
}

func sol(a int64) {
	var val int64
	if(a%2!=0){
		val = (a/2) + 1;
	}else{
	val = (a/2)
	}
	writer.Printf("%d\n",val)
}

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

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

type BufferedWriter interface {
	Printf(format string, a ...interface{})
	Flush()
}

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
	fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
	impl.Writer.Flush()
}

type WordScanner interface {
	NextInt() int
	NextInt64() int64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt() int {
	impl.Scan()
	bb := impl.Bytes()
	i := 0
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextInt64() int64 {
	impl.Scan()
	bb := impl.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}

package main
import "fmt"
func main() {
	var t int
	var n int
	fmt.Scanln(&t)
	for ; t > 0; t-- {
	    fmt.Scanln(&n)
		fmt.Println(((n - 1)/2) + 1)
	}
}

/*
URL:
https://codeforces.com/contest/1371/problem/A
*/

package main

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

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

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

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

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

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

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

const (
	// General purpose
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

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

var (
	t int

	n int
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		n = ReadInt()

		solve()
	}
}

func solve() {
	ans := (n-1)/2 + 1
	fmt.Println(ans)
}

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

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

var (
	// ReadString returns a WORD string.
	ReadString 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()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

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

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

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

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

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

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

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

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

// 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
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// 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)
}

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

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

package main

import "fmt"

func main() {
	var n, t int
	fmt.Scan(&t)
	for i := 1; i <= t; i++ {
		fmt.Scan(&n)
		quo := n / 2
		rem := n % 2
		temp := quo + rem
		fmt.Println(temp)
	}
}

package main

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

var DEBUG = true

func main() {
	defer Flush()

	T := readi()
	for t := 0; t < T; t++ {
		n := readi()
		println((n + 1) / 2)

	}

}

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func dbgf(f string, args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintf(os.Stderr, f, args...)
}

func dbg(args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

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

func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minf(a, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

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

func maxll(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxf(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

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

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func absf(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

package main
import (
        "fmt"
        "os"
        "bufio"
)
func main(){
    var t, n int
    in := bufio.NewReader(os.Stdin)
    out := bufio.NewWriter(os.Stdout)
    defer out.Flush()
    fmt.Fscan(in, &t)
    for ; t > 0; t-- {
        fmt.Fscan(in, &n)
        fmt.Fprintln(out, n/2 + n%2)
    }
}

package main

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

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

	var t int

	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(r, &n)

		if n&1 == 0 {
			fmt.Fprintln(w, n/2)
			continue
		}

		fmt.Fprintln(w, (n/2)+1)
	}
}

package main

import("fmt")

func main(){
	var t int32
	var n int32

	fmt.Scan(&t)

	for ;t>0;t-- {
		fmt.Scan(&n)

		if n%2 == 0 {
			fmt.Println(n/2)
		} else {
			fmt.Println(n/2 + 1)
		}
	}
}

package main

import "fmt"

func main() {
	var tc int
	fmt.Scanf("%d\n", &tc)
	for ; tc > 0; tc-- {
		var x int
		fmt.Scanf("%d\n", &x)
		fmt.Println((x+1)/2)
	}
}

package main

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

func main() {
	sc := NewScanner()
	t := sc.NextInt()
	for i := 0; i < t; i++ {
		N := sc.NextInt()
		fmt.Println((N + 1) / 2)
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

func main() {
	defer writer.Flush()
	t := NextInt()
	for t > 0 {
		t--
		n := NextInt()
		Println((n+1)/2)
	}
}

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

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

func Println(data interface{}) {
	writer.WriteString(fmt.Sprintf("%v\n", data))
}

func Print(data interface{}) {
	writer.WriteString(fmt.Sprintf("%v", data))
}

func Next() string {
	sc.Scan()
	return sc.Text()
}

func NextInt() int {
	i, err := strconv.Atoi(Next())
	if err != nil {
		panic(err)
	}
	return i
}

func NextInt64() int64 {
	i64, err := strconv.ParseInt(Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i64
}

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

package main

import "fmt"

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

	for testCases > 0 {
		var number int
		fmt.Scanf("%d", &number)
		fmt.Println((number / 2) + (number % 2))
		testCases--
	}
}

package main

import "fmt"

func maxSticks(tc int) {
	var number int
	for tc > 0 {
		fmt.Scanf("%d", &number)
		quotient := number / 2
		reminder := number % 2
		fmt.Println(quotient + reminder)
		tc--
	}
}

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

// https://codeforces.com/contest/1365/problem/A
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input *bufio.Reader

func main() {
	var T int

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		fmt.Println(solver())
	}
}

func solver() int {
	var n int
	fmt.Fscan(input, &n)
	if n == 1 { return 1}
	if n == 3 { return 2}
	return (n  / 2)
}

package main
import (
        "fmt"
        "os"
        "bufio"
)
func main(){
    var t, n int
    in := bufio.NewReader(os.Stdin)
    out := bufio.NewWriter(os.Stdout)
    defer out.Flush()
    fmt.Fscan(in, &t)
    for ; t > 0; t-- {
        fmt.Fscan(in, &n)
        if n == 1 || n == 2 {
            fmt.Fprintln(out, 1)
        } else if n == 3 {
            fmt.Fprintln(out, 2)
        } else {
            fmt.Fprintln(out, n/2)
        }
    }
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdin)
	defer w.Flush()

	var t int

	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(r, &n)

		if n&1 == 0 {
			fmt.Fprintln(w, n/2)
			continue
		}

		fmt.Fprintln(w, (n/2)+1)
	}
}

package main

import "fmt"

func main() {
	var tc int
	fmt.Scanf("%d", &tc)
	for ; tc > 0; tc-- {
		var x int
		fmt.Scanf("%d", &x)
		fmt.Println((x + 1) / 2)
	}
}


You went to the store, selling $$$n$$$ types of chocolates. There are $$$a_i$$$ chocolates of type $$$i$$$ in stock.You have unlimited amount of cash (so you are not restricted by any prices) and want to buy as many chocolates as possible. However if you buy $$$x_i$$$ chocolates of type $$$i$$$ (clearly, $$$0 \le x_i \le a_i$$$), then for all $$$1 \le j < i$$$ at least one of the following must hold:  $$$x_j = 0$$$ (you bought zero chocolates of type $$$j$$$) $$$x_j < x_i$$$ (you bought less chocolates of type $$$j$$$ than of type $$$i$$$) For example, the array $$$x = [0, 0, 1, 2, 10]$$$ satisfies the requirement above (assuming that all $$$a_i \ge x_i$$$), while arrays $$$x = [0, 1, 0]$$$, $$$x = [5, 5]$$$ and $$$x = [3, 2]$$$ don't.Calculate the maximum number of chocolates you can buy.

The first line contains an integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$), denoting the number of types of chocolate. The next line contains $$$n$$$ integers $$$a_i$$$ ($$$1 \le a_i \le 10^9$$$), denoting the number of chocolates of each type.

Print the maximum number of chocolates you can buy.

NoteIn the first example, it is optimal to buy: $$$0 + 0 + 1 + 3 + 6$$$ chocolates.In the second example, it is optimal to buy: $$$1 + 2 + 3 + 4 + 10$$$ chocolates.In the third example, it is optimal to buy: $$$0 + 0 + 0 + 1$$$ chocolates.

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	n := 0;
	fmt.Fscanf(in, "%d\n", &n);

    var slice = make([]int, 223456);
	for i:=0; i < n; i++ {
        a := 0;
        fmt.Fscanf(in, "%d", &a);
        slice[i] = a;
	}
    var ans int64 = 0;
    var cur = slice[n-1];
    ans = int64(cur);
    for i := 1; i < n; i++ {
        if cur > slice[n-1-i] {
            cur = slice[n-1-i];
        } else {
            cur = cur - 1;
        }
        if cur == -1 {
            break;
        }
        ans += int64(cur);
    }
	fmt.Println(ans);
}

package main

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

func main() {
	buf := bufio.NewReader(os.Stdin)

	var n int
	fmt.Fscanf(buf, "%d\n", &n)
	mat := make([]int,n+1)
	for i:=0;i < n;i++{
		fmt.Fscanf(buf, "%d", &mat[i])
	}
	fmt.Fscanf(buf, "\n")
	var ans int64 = int64(mat[n-1])
	var pre int = mat[n-1]
	for i:=n-2;pre>0&&i >=0 ;i--{
		if mat[i] >= pre{
			ans += int64(pre-1)
			pre--
		}else{
			ans += int64(mat[i])
			pre = mat[i]
		}
	}
	fmt.Printf("%d\n",ans)

}

package main

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

func main()  {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n int
	var x int
	a := make([]int,0)
	fmt.Fscanln(in,&n)
	for i := 0 ;i  < n ;i++{
		fmt.Fscan(in,&x)
		a = append(a,x)
	}
	var ans int64
	ans = int64(a[n - 1])
	curr := a[n - 1]
	for i := n - 2 ;i  >= 0; i--{
		if(curr > a[i]){
			curr = a[i]
			ans += int64(a[i])
		}else{
			if(curr - 1 >= 0){
				ans += int64(curr - 1)
				curr = min1(curr - 1 , a[i])
			}
		}
	}
	fmt.Fprint(out,ans)

}
func min1(x1,x2 int) int  {
	if(x1 < x2){
		return x1
	}else{
		return x2
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &a[i])
	}
	ans := int64(a[n-1])
	cur := a[n-1] - 1
	for i := n - 2; i >= 0; i-- {
		if cur <= 0 {
			break
		}
		if a[i] < cur {
			cur = a[i]
		}
		ans += int64(cur)
		cur--
	}
	fmt.Fprintf(out, "%d\n", ans)
	return
}

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

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

package main

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

func main() {
	var n int
	fmt.Scanln(&n)
	r := bufio.NewReader(os.Stdin)
	line, err := r.ReadString('\n')
	if err != nil {
		fmt.Println(err)
	}
	sum, err := parseInts(line, n)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(sum)
}

func parseInts(s string, l int) (uint64, error) {
	var (
		fields = strings.Fields(s)
		sum, prev, v uint64
		err    error
	)
	prev, _ = strconv.ParseUint(fields[l-1], 10, 32)
	sum += prev
	for i := l - 2; i >= 0; i-- {
		v, err = strconv.ParseUint(fields[i], 10, 32)
		if err != nil {
			return 0, err
		}
		if prev == 0{
			break
		}
		if prev > v{
			prev = v
		} else{
			prev = prev - 1
		}
		sum += prev
    }
	return sum, nil
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)

	var n int

	fmt.Fscan(reader, &n)

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &arr[i])
	}

	for i := n - 2; i >= 0; i-- {
		arr[i] = max(0, min(arr[i], arr[i+1]-1))
	}

	var count int64
	for _, vl := range arr {
		count += int64(vl)
	}

	fmt.Println(count)
}

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

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

package main

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

func main()  {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n int
	var x int
	a := make([]int,0)
	fmt.Fscanln(in,&n)
	for i := 0 ;i  < n ;i++{
		fmt.Fscan(in,&x)
		a = append(a,x)
	}
	ans := a[n - 1]
	curr := a[n - 1]
	for i := n - 2 ;i  >= 0; i--{
		if(curr > a[i]){
			curr = a[i]
			ans += a[i]
		}else{
			if(curr - 1 >= 0){
				ans += curr - 1
				curr = min(curr - 1 , a[i])
			}

		}
	}
	fmt.Fprint(out,ans)

}
func min(x1,x2 int) int  {
	if(x1 < x2){
		return x1
	}else{
		return x2
	}
}

package main

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

func main()  {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n int
	var x int
	a := make([]int,0)
	fmt.Fscanln(in,&n)
	for i := 0 ;i  < n ;i++{
		fmt.Fscan(in,&x)
		a = append(a,x)
	}
	ans := a[n - 1]
	curr := a[n - 1]
	for i := n - 2 ;i  >= 0; i--{
		if(curr > a[i]){
			curr = a[i]
			ans += a[i]
		}else{
			if(curr - 1 >= 0){
				ans += curr - 1
				curr -= 1
			}

		}
	}
	fmt.Fprint(out,ans)

}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &a[i])
	}
	ans := int64(a[n-1])
	cur := a[n-1] - 1
	for i := n - 2; i >= 0; i-- {
		if cur <= 0 {
			break
		}
		if a[i] < cur-1 {
			cur = a[i]
		}
		ans += int64(cur)
		cur--
	}
	fmt.Fprintf(out, "%d\n", ans)
	return
}

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

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &a[i])
	}
	ans := int64(0)

	queue := []int{}
	for i := 0; i < n; i++ {
		queue = append(queue, a[i])
		for j := len(queue) - 2; j >= 0; j-- {
			if queue[j] >= queue[j+1] {
				queue[j] = queue[j+1] - 1
			}
		}
		for len(queue) > 0 && queue[0] <= 0 {
			queue = queue[1:]
		}
		cur := int64(0)
		for j := 0; j < len(queue); j++ {
			cur += int64(queue[j])
		}
		if cur > ans {
			ans = cur
		}
	}
	fmt.Fprintf(out, "%d\n", ans)
	return
}

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

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

package main

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

func main() {
	var n int
	fmt.Scanln(&n)
	r := bufio.NewReader(os.Stdin)
	line, err := r.ReadString('\n')
	if err != nil {
		fmt.Println(err)
	}
	sum, err := parseInts(line, n)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(sum)
}

func parseInts(s string, l int) (int, error) {
	var (
		fields = strings.Fields(s)
		sum, prev, v int
		err    error
	)
	prev, _ = strconv.Atoi(fields[l-1])
	sum += prev
	for i := l - 2; i >= 0; i-- {
		v, err = strconv.Atoi(fields[i])
		if err != nil {
			return 0, err
		}
		if prev == 0{
			break
		}
		if prev > v{
			prev = v
		} else{
			prev = prev - 1
		}
		sum += prev
    }
	return sum, nil
}

package main

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

func main() {
	var n int
	fmt.Scanln(&n)
	r := bufio.NewReader(os.Stdin)
	line, err := r.ReadString('\n')
	if err != nil {
		fmt.Println(err)
	}
	sum, err := parseInts(line, n)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(sum)
}

func parseInts(s string, l int) (int, error) {
	var (
		fields = strings.Fields(s)
		sum, prev, v int
		err    error
	)
	for i := l - 1; i >= 0; i-- {
		v, err = strconv.Atoi(fields[i])
		if err != nil {
			return 0, err
		}
		if i == l - 1{
			prev = v
			sum += v
			continue
		}
		if prev > v{
			prev = v
			sum += v
		} else{
			if prev > 0{
				prev = prev - 1
			}
			sum += prev
		}
	}
	return sum, nil
}


Little town Nsk consists of n junctions connected by m bidirectional roads. Each road connects two distinct junctions and no two roads connect the same pair of junctions. It is possible to get from any junction to any other junction by these roads. The distance between two junctions is equal to the minimum possible number of roads on a path between them.In order to improve the transportation system, the city council asks mayor to build one new road. The problem is that the mayor has just bought a wonderful new car and he really enjoys a ride from his home, located near junction s to work located near junction t. Thus, he wants to build a new road in such a way that the distance between these two junctions won't decrease. You are assigned a task to compute the number of pairs of junctions that are not connected by the road, such that if the new road between these two junctions is built the distance between s and t won't decrease.

The firt line of the input contains integers n, m, s and t (2 ≤ n ≤ 1000, 1 ≤ m ≤ 1000, 1 ≤ s, t ≤ n, s ≠ t) — the number of junctions and the number of roads in Nsk, as well as the indices of junctions where mayors home and work are located respectively. The i-th of the following m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi), meaning that this road connects junctions ui and vi directly. It is guaranteed that there is a path between any two junctions and no two roads connect the same pair of junctions.

Print one integer — the number of pairs of junctions not connected by a direct road, such that building a road between these two junctions won't decrease the distance between junctions s and t.

package main

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

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

	var n, m, v, w, start, end, ans int
	Fscan(in, &n, &m, &start, &end)
	start--
	end--
	g := make([][]int, n)
	for i := 0; i < m; i++ {
		Fscan(in, &v, &w)
		v--
		w--
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	bfs := func(st int) []int {
		depths := make([]int, n)
		vis := make([]bool, n)
		vis[st] = true
		type pair struct{ v, dep int }
		q := []pair{{st, 0}}
		for len(q) > 0 {
			var p pair
			p, q = q[0], q[1:]
			depths[p.v] = p.dep
			for _, w := range g[p.v] {
				if !vis[w] {
					vis[w] = true
					q = append(q, pair{w, p.dep + 1})
				}
			}
		}
		return depths
	}
	stDepths, edDepths := bfs(start), bfs(end)
	minDis := stDepths[end]
	for v, gi := range g {
		sort.Ints(gi)
		j := 0
		for w := range g {
			if j == len(gi) || w < gi[j] {
				if w > v && stDepths[v]+edDepths[w]+1 >= minDis && stDepths[w]+edDepths[v]+1 >= minDis {
					ans++
				}
			} else {
				j++
			}
		}
	}
	Fprint(out, ans)
}

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

package main

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

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

	var n, m, v, w, start, end, ans int
	Fscan(in, &n, &m, &start, &end)
	start--
	end--
	g := make([][]int, n)
	for i := 0; i < m; i++ {
		Fscan(in, &v, &w)
		v--
		w--
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	bfs := func(st int) []int {
		depths := make([]int, n)
		vis := make([]bool, n)
		vis[st] = true
		queue := []int{st}
		for len(queue) > 0 {
			v, queue = queue[0], queue[1:]
			for _, w := range g[v] {
				if !vis[w] {
					vis[w] = true
					depths[w] = depths[v] + 1
					queue = append(queue, w)
				}
			}
		}
		return depths
	}
	stDepths, edDepths := bfs(start), bfs(end)
	minDis := stDepths[end]
	for v, gi := range g {
		sort.Ints(gi)
		j := 0
		for w := range g {
			if j == len(gi) || w < gi[j] {
				if w > v && stDepths[v]+edDepths[w]+1 >= minDis && stDepths[w]+edDepths[v]+1 >= minDis {
					ans++
				}
			} else {
				j++
			}
		}
	}
	Fprint(out, ans)
}

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

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n, m, s, t int
	fmt.Fscan(reader, &n, &m, &s, &t)
	g := make([][]int, n+1)
	for i := 0; i < m; i++ {
		var x, y int
		fmt.Fscan(reader, &x, &y)
		g[x] = append(g[x], y)
		g[y] = append(g[y], x)
	}
	gao(n, m, s, t, g)
}

func gao(n, m, s, t int, g [][]int) {
	distS := bfs(n, m, s, g)
	distT := bfs(n, m, t, g)
	minDist := distS[t]

	ans := 0
	for x := 1; x <= n; x++ {
		has := make(map[int]bool)
		for _, y := range g[x] {
			has[y] = true
		}
		for y := x + 1; y <= n; y++ {
			if !has[y] {
				dec := false
				// Choice 1: s -> x -> y -> t
				if distS[x]+1+distT[y] < minDist {
					dec = true
				}
				// Choice 2: s -> y -> x -> t
				if distS[y]+1+distT[x] < minDist {
					dec = true
				}
				if !dec {
					ans++
				}
			}
		}
	}

	fmt.Println(ans)
}

func bfs(n, m, beg int, g [][]int) []int {
	dist := make([]int, n+1)
	const maxdist = 10000
	for i := 1; i <= n; i++ {
		dist[i] = maxdist
	}

	dist[beg] = 0
	que := []int{beg}
	for len(que) > 0 {
		x := que[0]
		que = que[1:]
		for _, y := range g[x] {
			if dist[x]+1 < dist[y] {
				dist[y] = dist[x] + 1
				que = append(que, y)
			}
		}
	}
	return dist
}

package main

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

var scanner = bufio.NewScanner(os.Stdin)

func scanNum() int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}

func main() {
	scanner.Split(bufio.ScanWords)
	n, r, x, y := scanNum(), scanNum(), scanNum(), scanNum()
	adjMap := map[int]map[int]bool{}
	for i := 0; i < r; i++ {
		u, v := scanNum(), scanNum()
		if adjMap[u] == nil {
			adjMap[u] = map[int]bool{}
		}
		if adjMap[v] == nil {
			adjMap[v] = map[int]bool{}
		}
		adjMap[u][v], adjMap[v][u] = true, true
	}

	bfs := func(i int, s []int) {
		q, v := []int{i}, map[int]bool{i: true}
		for len(q) > 0 {
			task, distance := q[0], s[q[0]]
			q = q[1:]
			for item := range adjMap[task] {
				if !v[item] {
					v[item] = true
					s[item] = distance + 1
					q = append(q, item)
				}
			}
		}
	}
	sX, sY := make([]int, n+1), make([]int, n+1)
	sX[x], sY[y] = 0, 0
	bfs(x, sX)
	bfs(y, sY)

	sum, shortest := 0, sX[x]+sY[x]
	for i := 1; i < n; i++ {
		for j := i + 1; j <= n; j++ {
			if adjMap[i][j] {
				continue
			}
			// If the relax result generate a shorter path then the current one,
			// it creates an "bad" case.
			iX, iY := sX[i], sY[i]
			if sX[j] < iX {
				iX = sX[j] + 1
			}
			if sY[j] < iY {
				iY = sY[j] + 1
			}
			if (iX + iY) >= shortest {
				sum++
			}
		}
	}
	fmt.Println(sum)
}

package main

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

const (
	MaxN = 1024
)

var n, m, s, t int
var a [MaxN][MaxN]bool
var ds, dt [MaxN]int

func bfs(start int, dist *[MaxN]int) {
	var visited [MaxN]bool
	q := []int{start}
	visited[start] = true

	for len(q) > 0 {
		top := q[0]
		q = q[1:]

		for i := 1; i <= n; i++ {
			if a[top][i] && !visited[i] {
				q = append(q, i)
				dist[i] = dist[top] + 1
				visited[i] = true
			}
		}
	}
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d %d %d\n", &n, &m, &s, &t)
	for i := 0; i < m; i++ {
		var t1, t2 int
		fmt.Fscanf(buf, "%d %d\n", &t1, &t2)
		a[t1][t2] = true
		a[t2][t1] = true
	}

	bfs(s, &ds)
	bfs(t, &dt)

	ans := 0
	for i := 1; i <= n; i++ {
		for j := i + 1; j <= n; j++ {
			if !a[i][j] && ds[i] + dt[j] + 1 >= ds[t] && ds[j] + dt[i] + 1 >= ds[t] {
				ans++
			}
		}
	}
	fmt.Printf("%d\n", ans)
}

package main

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

const (
	MaxN = 1024
)

var n, m, s, t int
var a [MaxN][MaxN]bool
var ds, dt [MaxN]int

func bfs(start int, dist *[MaxN]int) {
	var visited [MaxN]bool
	q := []int{start}

	for len(q) > 0 {
		t := q[0]
		q = q[1:]
		visited[t] = true

		for i := 1; i <= n; i++ {
			if a[t][i] && !visited[i] {
				q = append(q, i)
				dist[i] = dist[t] + 1
			}
		}
	}
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d %d %d\n", &n, &m, &s, &t)
	for i := 0; i < m; i++ {
		var t1, t2 int
		fmt.Fscanf(buf, "%d %d\n", &t1, &t2)
		a[t1][t2] = true
		a[t2][t1] = true
	}

	bfs(s, &ds)
	bfs(t, &dt)

	ans := 0
	for i := 1; i <= n; i++ {
		for j := i + 1; j <= n; j++ {
			if !a[i][j] && ds[i] + dt[j] + 1 >= ds[t] && ds[j] + dt[i] +1 >= ds[t] {
				ans++
			}
		}
	}
	fmt.Printf("%d\n", ans)
}

package main

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

const (
	MaxN = 1024
)

var n, m, s, t int
var a [MaxN][MaxN]bool
var ds, dt [MaxN]int

func bfs(start int, dist *[MaxN]int) {
	var visited [MaxN]bool
	q := []int{start}

	for len(q) > 0 {
		t := q[0]
		q = q[1:]
		visited[t] = true

		for i := 1; i <= n; i++ {
			if a[t][i] && !visited[i] {
				q = append(q, i)
				dist[i] = dist[t] + 1
			}
		}
	}
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d %d %d\n", &n, &m, &s, &t)
	for i := 0; i < m; i++ {
		var t1, t2 int
		fmt.Fscanf(buf, "%d %d\n", &t1, &t2)
		a[t1][t2] = true
		a[t2][t1] = true
	}

	bfs(s, &ds)
	bfs(t, &dt)

	ans := 0
	for i := 1; i <= n; i++ {
		for j := i + 1; j <= n; j++ {
			if !a[i][j] && ds[i] + dt[j] + 1 >= ds[t] {
				ans++
			}
		}
	}
	fmt.Printf("%d\n", ans)
}


You are given an array $$$a$$$ consisting of $$$n$$$ non-negative integers. You have to choose a non-negative integer $$$x$$$ and form a new array $$$b$$$ of size $$$n$$$ according to the following rule: for all $$$i$$$ from $$$1$$$ to $$$n$$$, $$$b_i = a_i \oplus x$$$ ($$$\oplus$$$ denotes the operation bitwise XOR).An inversion in the $$$b$$$ array is a pair of integers $$$i$$$ and $$$j$$$ such that $$$1 \le i < j \le n$$$ and $$$b_i > b_j$$$.You should choose $$$x$$$ in such a way that the number of inversions in $$$b$$$ is minimized. If there are several options for $$$x$$$ — output the smallest one.

First line contains a single integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the number of elements in $$$a$$$. Second line contains $$$n$$$ space-separated integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$0 \le a_i \le 10^9$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$.

Output two integers: the minimum possible number of inversions in $$$b$$$, and the minimum possible value of $$$x$$$, which achieves those number of inversions.

NoteIn the first sample it is optimal to leave the array as it is by choosing $$$x = 0$$$.In the second sample the selection of $$$x = 14$$$ results in $$$b$$$: $$$[4, 9, 7, 4, 9, 11, 11, 13, 11]$$$. It has $$$4$$$ inversions:  $$$i = 2$$$, $$$j = 3$$$;  $$$i = 2$$$, $$$j = 4$$$;  $$$i = 3$$$, $$$j = 4$$$;  $$$i = 8$$$, $$$j = 9$$$. In the third sample the selection of $$$x = 8$$$ results in $$$b$$$: $$$[0, 2, 11]$$$. It has no inversions.

package main

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

var in *bufio.Reader
var out *bufio.Writer

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

func scan(a ...interface{}) (n int, err error) {
	return fmt.Fscan(in, a...)
}

var err error

func next() (n string) {
	scan(&n)
	return n
}

func nextInt() (n int) {
	scan(&n)
	return n
}

func nextLong() (n int64) {
	scan(&n)
	return n
}

func nextDouble() (n float64) {
	scan(&n)
	return n
}

func Max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

var res [30][2]int64

func solve() {
	n := nextInt()
	arr := make([]int, n)
	for i := range arr {
		arr[i] = nextInt()
	}
	recurse(arr, 29)
	ans := 0
	var tot int64
	for i, v := range res {
		if v[1] < v[0] {
			ans += 1 << i
			tot += v[1]
		} else {
			tot += v[0]
		}
	}
	printf("%d %d\n", tot, ans)
}

func recurse(arr []int, bit int) {
	if bit < 0 || len(arr) == 0 {
		return
	}
	var a, b int64 = 0, 0
	var x, y []int

	for _, v := range arr {
		if v&(1<<bit) == 0 {
			a++
			res[bit][0] += b
			x = append(x, v)
		} else {
			b++
			res[bit][1] += a
			y = append(y, v)
		}
	}
	recurse(x, bit-1)
	recurse(y, bit-1)
}

func main() {
	in = bufio.NewReaderSize(os.Stdin, 8192)
	out = bufio.NewWriterSize(os.Stdout, 8192)
	name := "in"
	file1, err := os.Open(name + ".in")
	if err == nil {
		in = bufio.NewReaderSize(file1, 8192)
	}
	// file2, err := os.Create(name + ".out")
	// if err != nil {
	// 	log.Fatal(err)
	// }
	// out = bufio.NewWriterSize(file2, 8192)
	defer out.Flush()
	// start := time.Now()

	// for t, i := nextInt(), 1; t > 0; t, i = t-1, i+1 {
	// printf("Case #%d:\n", i)
	solve()
	// }

	// printf("%v\n", time.Now().Sub(start))
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1416C(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n int
	Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}

	x := 0
	group := [][]int{a}
	for i := 29; i >= 0; i-- {
		g := group
		group = nil
		s := [2]int64{}
		for _, a := range g {
			b := [2][]int{}
			c := [2]int64{}
			for _, v := range a {
				w := v >> i & 1
				b[w] = append(b[w], v)
				s[w] += c[w^1]
				c[w]++
			}
			for _, a := range b {
				if len(a) > 0 {
					group = append(group, a)
				}
			}
		}
		if s[0] > s[1] {
			x |= 1 << i
		}
	}
	for i, v := range a {
		a[i] = v ^ x
	}

	b := append([]int(nil), a...)
	sort.Ints(b)
	k := 1
	kth := map[int]int{b[0]: k}
	for i := 1; i < n; i++ {
		if b[i] != b[i-1] {
			k++
			kth[b[i]] = k
		}
	}
	tree := make([]int, k+1)
	add := func(i int) {
		for ; i <= k; i += i & -i {
			tree[i]++
		}
	}
	sum := func(i int) (res int) {
		for ; i > 0; i &= i - 1 {
			res += tree[i]
		}
		return
	}
	c := int64(0)
	for i, v := range a {
		v = kth[v]
		c += int64(i - sum(v))
		add(v)
	}
	Fprintln(out, c, x)
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1416C(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	min := func(a, b int64) int64 {
		if a < b {
			return a
		}
		return b
	}
	var n int
	Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}

	cnt, x := int64(0), 0
	group := [][]int{a}
	for i := 29; i >= 0; i-- {
		g := group
		group = nil
		s := [2]int64{}
		for _, a := range g {
			b := [2][]int{}
			c := [2]int64{}
			for _, v := range a {
				w := v >> i & 1
				b[w] = append(b[w], v)
				s[w] += c[w^1]
				c[w]++
			}
			for _, a := range b {
				if len(a) > 0 {
					group = append(group, a)
				}
			}
		}
		cnt += min(s[0], s[1])
		if s[0] > s[1] {
			x |= 1 << i
		}
	}
	Fprintln(out, cnt, x)
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1416C(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n int
	Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}

	x := 0
	set := [][]int{a}
	for i := 29; i >= 0; i-- {
		newSet := [][]int{}
		var c10, c01 int64
		for _, a := range set {
			b := make([][]int, 2)
			var c0, c1 int64
			for _, v := range a {
				w := v >> i & 1
				b[w] = append(b[w], v)
				if w > 0 {
					c1++
					c01 += c0
				} else {
					c0++
					c10 += c1
				}
			}
			for _, a := range b {
				if len(a) > 0 {
					newSet = append(newSet, a)
				}
			}
		}
		if c01 < c10 {
			x |= 1 << i
		}
		set = newSet
	}
	for i, v := range a {
		a[i] = v ^ x
	}

	b := append([]int(nil), a...)
	sort.Ints(b)
	k := 1
	kth := map[int]int{b[0]: k}
	for i := 1; i < n; i++ {
		if b[i] != b[i-1] {
			k++
			kth[b[i]] = k
		}
	}
	tree := make([]int, k+1)
	add := func(i int) {
		for ; i <= k; i += i & -i {
			tree[i]++
		}
	}
	sum := func(i int) (res int) {
		for ; i > 0; i &= i - 1 {
			res += tree[i]
		}
		return
	}
	cnt := int64(0)
	for i, v := range a {
		v = kth[v]
		cnt += int64(i - sum(v))
		add(v)
	}
	Fprintln(out, cnt, x)
}

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

//Author: devACE
package main

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

func inv(bit_array *[]int64)int64{
	var ct0 int64 = 0
	var count int64= 0
	for i:=len(*bit_array)-1;i>=0;i--{
		if (*bit_array)[i]==1{
			count += ct0
		}else{
			ct0+=1
		}
	}

	return count
}

func f(v *[]int64, dp *[][]int64, arr []int64, lev int64){
	if lev<0 || len(arr)==0{
		return
	}

	bit_array0 := []int64{}
	bit_array1 := []int64{}

	for _,i := range(arr){
		bit_array0 = append(bit_array0,((*v)[i]>>lev)&1)
		bit_array1 = append(bit_array1,(((*v)[i]>>lev)&1)^1)
	}

	count0 := inv(&bit_array0)
	count1 := inv(&bit_array1)

	(*dp)[lev][0] += count0
	(*dp)[lev][1] += count1

	arr0 := []int64{}
	arr1 := []int64{}

	for _,i := range(arr){
		if (((*v)[i]>>lev)&1)==1 {
			arr1 = append(arr1,i)
		}else{
			arr0 = append(arr0,i)
		}
	}

	f(v,dp,arr0,lev-1)
	f(v,dp,arr1,lev-1)

	return

}

func Numbers(s string)[]int64{ //Converts a list of strings into list of integer
	a := []int64{}
	for _,val := range strings.Fields(s){
		int_val,conversion_err := strconv.Atoi(val)
		if conversion_err == nil{
			a = append(a,int64(int_val))
		}
	}
	return a
}

func main(){

	// var line1,line2 []int64 //Reading Input
	// scanner := bufio.NewScanner(os.Stdin)
	// for i:=0;i<2 && scanner.Scan(); i++{
	// 	if i==0{
	// 		line1 = Numbers(scanner.Text())
	// 	}else{
	// 		line2 = Numbers(scanner.Text())
	// 	}
	// }

	in := bufio.NewReader(os.Stdin)
	var n int64
	Fscan(in, &n)
	v := make([]int64, n)
	for i := range v {
		Fscan(in, &v[i])
	}

	// var (
	// 	n int64
	// 	v []int64
	// )

	// n = line1[0]
	// v = line2

	dp := make([][]int64,32) //Creating 32 slices
	for i:=0;i<32;i++{
		dp[i] = make([]int64,2)
	}

	arr := make([]int64,n)

	for i:=int64(0);i<n;i++{
		arr[i]=int64(i)
	}

	f(&v,&dp,arr,31)

	var ans,x int64 = 0,0
	for i:=0;i<32;i++{
		if dp[i][1]<dp[i][0]{
			ans += dp[i][1]
			x |= (1<<i)
		}else{
			ans += dp[i][0]
		}
	}

	fmt.Printf("%d %d\n",ans,x)
}


A new pack of n t-shirts came to a shop. Each of the t-shirts is characterized by three integers pi, ai and bi, where pi is the price of the i-th t-shirt, ai is front color of the i-th t-shirt and bi is back color of the i-th t-shirt. All values pi are distinct, and values ai and bi are integers from 1 to 3.m buyers will come to the shop. Each of them wants to buy exactly one t-shirt. For the j-th buyer we know his favorite color cj.A buyer agrees to buy a t-shirt, if at least one side (front or back) is painted in his favorite color. Among all t-shirts that have colors acceptable to this buyer he will choose the cheapest one. If there are no such t-shirts, the buyer won't buy anything. Assume that the buyers come one by one, and each buyer is served only after the previous one is served.You are to compute the prices each buyer will pay for t-shirts.

The first line contains single integer n (1 ≤ n ≤ 200 000) — the number of t-shirts. The following line contains sequence of integers p1, p2, ..., pn (1 ≤ pi ≤ 1 000 000 000), where pi equals to the price of the i-th t-shirt. The following line contains sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 3), where ai equals to the front color of the i-th t-shirt. The following line contains sequence of integers b1, b2, ..., bn (1 ≤ bi ≤ 3), where bi equals to the back color of the i-th t-shirt. The next line contains single integer m (1 ≤ m ≤ 200 000) — the number of buyers.  The following line contains sequence c1, c2, ..., cm (1 ≤ cj ≤ 3), where cj equals to the favorite color of the j-th buyer. The buyers will come to the shop in the order they are given in the input. Each buyer is served only after the previous one is served.

Print to the first line m integers — the j-th integer should be equal to the price of the t-shirt which the j-th buyer will buy. If the j-th buyer won't buy anything, print -1.

package main

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

var in = bufio.NewScanner(os.Stdin)

func readInt() int {
	if !in.Scan() {
		panic(in.Err())
	}
	res := 0
	for _, b := range in.Bytes() {
		res = res*10 + int(b-'0')
	}
	return res
}

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

	n := readInt()
	var col [4][]int
	p := make([]int, n)
	for i := range p {
		p[i] = readInt()
	}
	for _, p := range p {
		a := readInt()
		col[a] = append(col[a], p)
	}
	for _, p := range p {
		b := readInt()
		col[b] = append(col[b], p)
	}
	for _, c := range col {
		sort.Ints(c)
	}

	paid := make(map[int]bool)
	m := readInt()
	for i := 0; i < m; i++ {
		c := readInt()
		buy := -1
		for len(col[c]) > 0 {
			first := col[c][0]
			col[c] = col[c][1:]
			if !paid[first] {
				buy = first
				paid[first] = true
				break
			}
		}
		if i + 1 == m {
			fmt.Fprintln(out, buy)
		} else {
			fmt.Fprint(out, buy, " ")
		}
	}
}


There are $$$n$$$ people sitting in a circle, numbered from $$$1$$$ to $$$n$$$ in the order in which they are seated. That is, for all $$$i$$$ from $$$1$$$ to $$$n-1$$$, the people with id $$$i$$$ and $$$i+1$$$ are adjacent. People with id $$$n$$$ and $$$1$$$ are adjacent as well.The person with id $$$1$$$ initially has a ball. He picks a positive integer $$$k$$$ at most $$$n$$$, and passes the ball to his $$$k$$$-th neighbour in the direction of increasing ids, that person passes the ball to his $$$k$$$-th neighbour in the same direction, and so on until the person with the id $$$1$$$ gets the ball back. When he gets it back, people do not pass the ball any more.For instance, if $$$n = 6$$$ and $$$k = 4$$$, the ball is passed in order $$$[1, 5, 3, 1]$$$. Consider the set of all people that touched the ball. The fun value of the game is the sum of the ids of people that touched it. In the above example, the fun value would be $$$1 + 5 + 3 = 9$$$.Find and report the set of possible fun values for all choices of positive integer $$$k$$$. It can be shown that under the constraints of the problem, the ball always gets back to the $$$1$$$-st player after finitely many steps, and there are no more than $$$10^5$$$ possible fun values for given $$$n$$$.

The only line consists of a single integer $$$n$$$ ($$$2 \leq n \leq 10^9$$$) — the number of people playing with the ball.

Suppose the set of all fun values is $$$f_1, f_2, \dots, f_m$$$. Output a single line containing $$$m$$$ space separated integers $$$f_1$$$ through $$$f_m$$$ in increasing order.

NoteIn the first sample, we've already shown that picking $$$k = 4$$$ yields fun value $$$9$$$, as does $$$k = 2$$$. Picking $$$k = 6$$$ results in fun value of $$$1$$$. For $$$k = 3$$$ we get fun value $$$5$$$ and with $$$k = 1$$$ or $$$k = 5$$$ we get $$$21$$$.   In the second sample, the values $$$1$$$, $$$10$$$, $$$28$$$, $$$64$$$ and $$$136$$$ are achieved for instance for $$$k = 16$$$, $$$8$$$, $$$4$$$, $$$10$$$ and $$$11$$$, respectively.

// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Mon Dec 31 01:14:12 2018
//
package main

import (
	"fmt"
	"sort"
)

func calcDivisors(n int64) []int64 {
	ret := []int64{1}
	for i := int64(2); i*i <= n; i++ {
		if n%i == 0 {
			ret = append(ret, i)
			if n/i != i {
				ret = append(ret, n/i)
			}
		}
	}

	if n != 1 {
		ret = append(ret, n)
	}

	return ret
}

func main() {
	var n int64
	fmt.Scan(&n)

	divisors := calcDivisors(n)
	ans := make([]int64, 0)
	for i := range divisors {
		d := divisors[i]
		num := n / d
		ans = append(ans, num+num*(num-1)*d/2)
	}
	sort.Slice(ans, func(i, j int) bool {
		return ans[i] < ans[j]
	})

	for i := range ans {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Print(ans[i])
	}

	fmt.Println()
}

/*
URL:
https://codeforces.com/problemset/problem/1091/C
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

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

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

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

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

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

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

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

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

var (
	n int
)

func main() {
	n = ReadInt()

	D := divisor(n)
	answers := []int64{}
	for i := 0; i < len(D); i++ {
		d := D[i]
		ans := int64(0)
		// for j := int64(1); j <= int64(n); j += int64(d) {
		// 	ans += j
		// }
		x := int64((n-1)/d) + 1
		ans = ArithmeticSequenceSum(1, int64(d), x)

		answers = append(answers, ans)
	}

	sort.Slice(answers, func(i, j int) bool { return answers[i] < answers[j] })
	fmt.Println(PrintInts64Line(answers...))
}

// ArithmeticSequenceSum returns a sum of an arithmetic sequence.
// a: 初項, d: 公差, n: 項数
func ArithmeticSequenceSum(a, d, n int64) int64 {
	return (2*a + (n-1)*d) * n / 2
}

// 約数の列挙: O(sqrt(n))
func divisor(n int) []int {
	res := []int{}

	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i != (n / i) {
				res = append(res, (n / i))
			}
		}
	}

	return res
}

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

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

var (
	// ReadString returns a WORD string.
	ReadString 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()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

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

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

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

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

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

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

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

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

// 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
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// 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)
}

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

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1091C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	doDivisors := func(n int, do func(d int)) {
		for d := 1; d*d <= n; d++ {
			if n%d == 0 {
				do(d)
				if d*d < n {
					do(n / d)
				}
			}
		}
		return
	}

	var n int
	Fscan(in, &n)
	ans := []int64{}
	doDivisors(n, func(d int) { ans = append(ans, int64(n-d+2)*int64(n/d)/2) })
	sort.Slice(ans, func(i, j int) bool { return ans[i] < ans[j] })
	for _, v := range ans {
		Fprint(out, v, " ")
	}
}

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

package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var n int64
	fmt.Scan(&n)

	divisors := findDivisors(n)

	var ans []int64
	for _, v := range divisors {
		ans = append(ans, calculateSum(n, v))
	}

	for i := len(ans) - 1; i >= 0; i-- {
		fmt.Print(ans[i])
		if i > 0 {
			fmt.Print(" ")
		}
	}
	fmt.Println()
}

func findDivisors(n int64) []int64 {
	sqrtn := int64(math.Sqrt(float64(n))) + 2
	var divisors []int64
	for x := int64(1); x < sqrtn; x++ {
		if n%x != 0 {
			continue
		}
		divisors = append(divisors, x)
		if x != n/x {
			divisors = append(divisors, n/x)
		}
	}
	sort.Slice(divisors, func(i, j int) bool { return divisors[i] < divisors[j] })
	divisors = uniqueSlice(divisors)
	return divisors
}

func uniqueSlice(slice []int64) []int64 {
	var uniquedSlice []int64
	for i, _ := range slice {
		if i == 0 || slice[i-1] != slice[i] {
			uniquedSlice = append(uniquedSlice, slice[i])
		}
	}
	return uniquedSlice
}

func calculateSum(n, k int64) int64 {
	number := n / k
	last := 1 + (number-1)*k
	return (1 + last) * number / 2
}

// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Mon Dec 31 01:14:12 2018
//
package main

import (
	"fmt"
	"sort"
)

func calcDivisors(n int) []int {
	ret := []int{1}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			ret = append(ret, i)
			if n/i != i {
				ret = append(ret, n/i)
			}
		}
	}

	if n != 1 {
		ret = append(ret, n)
	}

	return ret
}

func main() {
	var n int
	fmt.Scan(&n)

	divisors := calcDivisors(n)
	ans := make([]int, 0)
	for i := range divisors {
		d := divisors[i]
		num := n / d
		ans = append(ans, num+num*(num-1)*d/2)
	}
	sort.Ints(ans)

	for i := range ans {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Print(ans[i])
	}

	fmt.Println()
}

// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Mon Dec 31 01:14:12 2018
//
package main

import (
	"fmt"
	"sort"
)

func calcDivisors(n int) []int {
	ret := make([]int, 0)
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			ret = append(ret, i)
			if i != 1 && n/i != i {
				ret = append(ret, n/i)
			}
		}
	}
	ret = append(ret, n)
	return ret
}

func main() {
	var n int
	fmt.Scan(&n)

	divisors := calcDivisors(n)
	ans := make([]int, 0)
	for i := range divisors {
		d := divisors[i]
		num := n / d
		ans = append(ans, num+num*(num-1)*d/2)
	}
	sort.Ints(ans)

	for i := range ans {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Print(ans[i])
	}

	fmt.Println()
}

// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Mon Dec 31 01:14:12 2018
//
package main

import (
	"fmt"
	"sort"
)

func calcDivisors(n int) []int {
	ret := make([]int, 0)
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			ret = append(ret, i)
		}
	}
	ret = append(ret, n)
	return ret
}

func main() {
	var n int
	fmt.Scan(&n)

	divisors := calcDivisors(n)
	ans := make([]int, 0)
	for i := range divisors {
		d := divisors[i]
		num := n / d
		ans = append(ans, num+num*(num-1)*d/2)
	}
	sort.Ints(ans)

	for i := range ans {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Print(ans[i])
	}

	fmt.Println()
}


You are given a matrix $$$a$$$ consisting of positive integers. It has $$$n$$$ rows and $$$m$$$ columns.Construct a matrix $$$b$$$ consisting of positive integers. It should have the same size as $$$a$$$, and the following conditions should be met:   $$$1 \le b_{i,j} \le 10^6$$$;  $$$b_{i,j}$$$ is a multiple of $$$a_{i,j}$$$;  the absolute value of the difference between numbers in any adjacent pair of cells (two cells that share the same side) in $$$b$$$ is equal to $$$k^4$$$ for some integer $$$k \ge 1$$$ ($$$k$$$ is not necessarily the same for all pairs, it is own for each pair). We can show that the answer always exists.

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n,m \le 500$$$). Each of the following $$$n$$$ lines contains $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line is $$$a_{i,j}$$$ ($$$1 \le a_{i,j} \le 16$$$).

The output should contain $$$n$$$ lines each containing $$$m$$$ integers. The $$$j$$$-th integer in the $$$i$$$-th line should be $$$b_{i,j}$$$.

NoteIn the first example, the matrix $$$a$$$ can be used as the matrix $$$b$$$, because the absolute value of the difference between numbers in any adjacent pair of cells is $$$1 = 1^4$$$.In the third example:   $$$327$$$ is a multiple of $$$3$$$, $$$583$$$ is a multiple of $$$11$$$, $$$408$$$ is a multiple of $$$12$$$, $$$664$$$ is a multiple of $$$8$$$;  $$$|408 - 327| = 3^4$$$, $$$|583 - 327| = 4^4$$$, $$$|664 - 408| = 4^4$$$, $$$|664 - 583| = 3^4$$$.

package main

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

var (
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sint64s(n int64) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = sint64()
	}
	return a
}

func sstring() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	if a < 0 {
		a *= -1
	}
	return a
}

func lcm(a, b int64) int64 {
	if a == 0 || b == 0 {
		panic("invalid input")
	}
	ret := a / gcd(a, b) * b
	if ret < 0 {
		ret *= -1
	}
	return ret
}

func main() {
	defer writer.Flush()
	n, m := sint64(), sint64()
	a := make([][]int64, n)
	for i := range a {
		a[i] = sint64s(m)
	}
	res := sol(n, m, a)
	for i := range res {
		for j := range res[i] {
			printf("%d ", res[i][j])
		}
		printf("\n")
	}
}

var lcm16 = func() int64 {
	ret := int64(1)
	for i := int64(1); i <= 16; i++ {
		ret = lcm(ret, i)
	}
	return ret
}()

func sol(n, m int64, a [][]int64) [][]int64 {
	ret := make([][]int64, n)
	for i := range ret {
		ret[i] = make([]int64, m)
		for j := range ret[i] {
			if (i+j)&1 == 0 {
				ret[i][j] = lcm16
			} else {
				ret[i][j] = lcm16 + pow4(a[i][j])
			}
		}
	}
	return ret
}

func pow4(n int64) int64 {
	return n * n * n * n
}

package main

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

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

	var n, m, v int
	Fscan(in, &n, &m)
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if Fscan(in, &v); (i+j)&1 > 0 {
				Fprint(out, 720720-v*v*v*v, " ")
			} else {
				Fprint(out, "720720 ")
			}
		}
		Fprintln(out)
	}
}

package main

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

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

	var n, m, v int
	Fscan(in, &n, &m)
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			Fscan(in, &v)
			if (i+j)&1 > 0 {
				Fprint(out, 720720-v*v*v*v, " ")
			} else {
				Fprint(out, "720720 ")
			}
		}
		Fprintln(out)
	}
}

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

package main

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

const (
	LCM int = 720720
	MOD int = 1e9+7
	NL byte = byte('\n')
	SP byte = byte(' ')
)

var (
	in *bufio.Scanner
	out *bufio.Writer

	n, m int
	a [500][500]int
)

func main() {
	initBuffer()
	var t int = 1
	// t = getInt()
	for i := 0; i < t; i++ {
		solve()
	}
	// test()
	out.Flush()
}

func solve() {
	initialize()
	input()
	count()
	output()
}

func initialize() {

}

func input() {
	n = getInt()
	m = getInt()
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			a[i][j] = getInt()
		}
	}
}

func count() {
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if (i + j) % 2 == 1 {
				a[i][j] *= a[i][j]
				a[i][j] *= a[i][j]
				a[i][j] += LCM
			} else {
				a[i][j] = LCM
			}
		}
	}
}

func output() {
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			out.Write(intToBytes(a[i][j]))
			out.WriteByte(SP)
		}
		out.WriteByte(NL)
	}
}

func test() {
	fmt.Print()
}

func initBuffer() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer([]byte{}, 4 * 1024 * 1024)
	in.Split(scanWords)
	out = bufio.NewWriter(os.Stdout)
}

func scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}
	i := bytes.IndexByte(data, '\n')
	j := bytes.IndexByte(data, ' ')
	ind := min(i, j)
	if ind < 0 {
		ind = max(i, j)
	}
	if ind >= 0 {
		return ind + 1, dropCR(data[0:ind]), nil
	}
	if atEOF {
		return len(data), dropCR(data), nil
	}
	return 0, nil, nil
}

func dropCR(data []byte) []byte {
	if len(data) > 0 && data[len(data)-1] == '\r' {
		return data[:len(data)-1]
	}
	return data
}

func getFloat() float64 {
	in.Scan()
	b := in.Bytes()
	var isNeg bool
	if b[0] == '-' {
		isNeg = true
		b = b[1:]
	}
	var res1 int64
	for i := 0; i < len(b); i++ {
		if b[i] == '.' {
			b = b[i+1:]
			break
		}
		res1 *= 10
		res1 += int64(b[i]) - 48
		if i == len(b) - 1 {
			b = b[:0]
		}
	}
	var res2 float64
	for i := len(b); i > 0; i-- {
		res2 += float64(b[i-1]) - 48
		res2 /= 10
	}
	if isNeg {
		res1 *= -1
		res2 *= -1
	}
	return float64(res1) + res2
}

func getInt() int {
	return int(getInt64())
}

func getInt64() int64 {
	in.Scan()
	b := in.Bytes()
	var isNeg bool
	if b[0] == '-' {
		isNeg = true
		b = b[1:]
	}
	var res int64
	for i := 0; i < len(b); i++ {
		res *= 10
		res += int64(b[i]) - 48
	}
	if isNeg {
		res *= -1
	}
	return res
}

func getString() string {
	in.Scan()
	return in.Text()
}

func intToBytes(n int) []byte {
	return int64ToBytes(int64(n))
}

func int64ToBytes(n int64) []byte {
	var res [65]byte
	var isNeg bool
	if n < 0 {
		isNeg = true
		n = -n
	}
	var l int = 65
	for n > 0 {
		l--
		res[l] = byte(n % 10 + 48)
		n /= 10
	}
	if l == 65 {
		l--
		res[l] = byte(48)
	}
	if isNeg {
		l--
		res[l] = byte(45)
	}
	return res[l:]
}

func bsLower(arr []int, n int) int {
	var minN, midN, maxN int
	maxN = len(arr)
	for maxN - 1 > minN {
		midN = (minN + maxN) / 2
		if arr[midN] < n {
			minN = midN
		} else {
			maxN = midN
		}
	}
	if arr[minN] >= n {
		return minN
	}
	return maxN
}

func bsLower64(arr []int64, n int64) int {
	var minN, midN, maxN int
	maxN = len(arr)
	for maxN - 1 > minN {
		midN = (minN + maxN) / 2
		if arr[midN] < n {
			minN = midN
		} else {
			maxN = midN
		}
	}
	if arr[minN] >= n {
		return minN
	}
	return maxN
}

func bsUpper(arr []int, n int) int {
	var minN, midN, maxN int
	maxN = len(arr)
	for maxN - 1 > minN {
		midN = (minN + maxN) / 2
		if arr[midN] <= n {
			minN = midN
		} else {
			maxN = midN
		}
	}
	if arr[minN] > n {
		return minN
	}
	return maxN
}

func bsUpper64(arr []int64, n int64) int {
	var minN, midN, maxN int
	maxN = len(arr)
	for maxN - 1 > minN {
		midN = (minN + maxN) / 2
		if arr[midN] <= n {
			minN = midN
		} else {
			maxN = midN
		}
	}
	if arr[minN] > n {
		return minN
	}
	return maxN
}

func max(n1, n2 int) int {
	return int(max64(int64(n1), int64(n2)))
}

func max64(n1, n2 int64) int64 {
	if n1 > n2 {
		return n1
	}
	return n2
}

func min(n1, n2 int) int {
	return int(min64(int64(n1), int64(n2)))
}

func min64(n1, n2 int64) int64 {
	if n1 < n2 {
		return n1
	}
	return n2
}

func yes(res, isUpperCase bool) bool {
	var arr [4]string = [4]string{"No", "Yes", "NO", "YES"}
	var ind int
	if res == true {
		ind = 1
	}
	if isUpperCase == true {
		ind += 2
	}
	out.WriteString(arr[ind])
	out.WriteByte(NL)
	return res
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)

	var buf bytes.Buffer

	n, m := readTwoNums(reader)

	A := make([][]int, n)
	for i := 0; i < n; i++ {
		A[i] = readNNums(reader, m)
	}
	solve(A)

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			buf.WriteString(fmt.Sprintf("%d ", A[i][j]))
		}
		buf.WriteByte('\n')
	}
	fmt.Print(buf.String())
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

const H = 720720 // lcm(1, 2, 3,... 16)

func solve(A [][]int) {
	for i := 0; i < len(A); i++ {
		for j := 0; j < len(A[i]); j++ {
			if (i+j)&1 == 0 {
				A[i][j] = H
			} else {
				A[i][j] = H + pow4(A[i][j])
			}
		}
	}
}

func pow4(a int) int {
	return a * a * a * a
}

package main

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

func primeFactors(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i <= x; i++ {
		if x%i != 0 {
			continue
		}
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	return res
}

func main() {
	maxFactors := make(map[int]int)

	for i := 2; i <= 16; i++ {
		factors := primeFactors(i)
		for i, c := range factors {
			if maxFactors[i] < c {
				maxFactors[i] = c
			}
		}
	}
	var mul int = 1
	for i, c := range maxFactors {
		for j := 0; j < c; j++ {
			mul *= i
		}
	}
	input := bufio.NewReader(os.Stdin)
	var m, n int
	fmt.Fscanln(input, &m, &n)
	for i := 0; i < m; i++ {
		for j := 0; j < n; j++ {
			var data int
			fmt.Fscan(input, &data)
			res := mul
			if (i+j)%2 == 1 {
				res += data * data * data * data
			}
			if j != n-1 {
				fmt.Printf("%d ", res)
			} else {
				fmt.Printf("%d\n", res)
				fmt.Fscanf(input, "\n")
			}
		}
	}
}

package main

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

const maxn int = 510

var a [maxn][maxn]int64

func gcd(a, b int64) int64 {
	if b == 0 {
		return a
	} else {
		return gcd(b, a%b)
	}
}
func lcm(a, b int64) int64 {
	return (a * b) / gcd(a, b)
}
func main() {

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

	var LCM int64 = 1
	for i := 1; i <= 16; i++ {
		LCM = lcm(LCM, int64(i))
	}
	var m, n int

	Fscan(in, &m, &n)

	for i := 0; i < m; i++ {
		for j := 0; j < n; j++ {
			Fscan(in, &a[i][j])
			if (i+j)%2 == 1 {
				Fprint(out, LCM, " ")
			} else {
				Fprint(out, a[i][j]*a[i][j]*a[i][j]*a[i][j]+LCM, " ")
			}

		}
		Fprintln(out)
	}

}

package main

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

var (
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sint64s(n int64) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = sint64()
	}
	return a
}

func sstring() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	if a < 0 {
		a *= -1
	}
	return a
}

func lcm(a, b int64) int64 {
	if a == 0 || b == 0 {
		panic("invalid input")
	}
	ret := a / gcd(a, b) * b
	if ret < 0 {
		ret *= -1
	}
	return ret
}

func main() {
	defer writer.Flush()
	n, m := sint64(), sint64()
	a := make([][]int64, n)
	for i := range a {
		a[i] = sint64s(m)
	}
	res := sol(n, m, a)
	for i := range res {
		for j := range res[i] {
			printf("%d ", res[i][j])
		}
		printf("\n")
	}
}

var lcm16 = func() int64 {
	ret := int64(1)
	for i := int64(1); i <= 16; i++ {
		ret = lcm(ret, i)
	}
	return ret
}()

func sol(n, m int64, a [][]int64) [][]int64 {
	w := lcm16
	x := lcm16 + pow4(2)
	y := lcm16 + pow4(3)
	z := lcm16 + pow4(4)
	ret := make([][]int64, n)
	for i := range ret {
		ret[i] = make([]int64, m)
		for j := range ret[i] {
			if i&1 == 0 && j&1 == 0 {
				ret[i][j] = w
			}
			if i&1 == 0 && j&1 == 1 {
				ret[i][j] = x
			}
			if i&1 == 1 && j&1 == 0 {
				ret[i][j] = y
			}
			if i&1 == 1 && j&1 == 1 {
				ret[i][j] = z
			}
		}
	}
	return ret
}

func pow4(n int64) int64 {
	return n * n * n * n
}