In number world, two different numbers are friends if they have a lot in common, but also each one has unique perks.More precisely, two different numbers $$$a$$$ and $$$b$$$ are friends if $$$gcd(a,b)$$$, $$$\frac{a}{gcd(a,b)}$$$, $$$\frac{b}{gcd(a,b)}$$$ can form sides of a triangle.Three numbers $$$a$$$, $$$b$$$ and $$$c$$$ can form sides of a triangle if $$$a + b > c$$$, $$$b + c > a$$$ and $$$c + a > b$$$.In a group of numbers, a number is lonely if it doesn't have any friends in that group.Given a group of numbers containing all numbers from $$$1, 2, 3, ..., n$$$, how many numbers in that group are lonely?

The first line contains a single integer $$$t$$$ $$$(1 \leq t \leq 10^6)$$$ - number of test cases. On next line there are $$$t$$$ numbers, $$$n_i$$$ $$$(1 \leq n_i \leq 10^6)$$$ - meaning that in case $$$i$$$ you should solve for numbers $$$1, 2, 3, ..., n_i$$$.

For each test case, print the answer on separate lines: number of lonely numbers in group $$$1, 2, 3, ..., n_i$$$.

NoteFor first test case, $$$1$$$ is the only number and therefore lonely.For second test case where $$$n=5$$$, numbers $$$1$$$, $$$3$$$ and $$$5$$$ are lonely.For third test case where $$$n=10$$$, numbers $$$1$$$, $$$5$$$ and $$$7$$$ are lonely.

package main

import (
	"io"
	"io/ioutil"
	"os"
)

const _N int = 1e6 + 1

func processInput(in io.Reader) (int, []int) {
	buf, _ := ioutil.ReadAll(in)

	var i, l, n int
	l = len(buf)

	for ; buf[i] >= '0' && buf[i] <= '9'; i++ {
		n = (n * 10) + int(buf[i]&15)
	}

	ints := make([]int, n)
	for j := 0; j < n; j++ {
		for ; buf[i] < '0' || buf[i] > '9'; i++ {
		}

		for ; i < l && buf[i] >= '0' && buf[i] <= '9'; i++ {
			ints[j] = (ints[j] * 10) + int(buf[i]&15)
		}
	}

	return n, ints
}

const _B int = 1024 * 1024

type buffer struct {
	i    int
	size int
	arr  []byte
}

var output = &buffer{
	size: _B,
	arr:  make([]byte, _B),
}

func (o *buffer) print(out io.Writer, x int) {
	b := make([]byte, 8)
	i := 0

	for x > 0 {
		b[i] = byte(x%10) + '0'
		x /= 10
		i++
	}

	for j := i - 1; j >= 0; j-- {
		o.arr[o.i] = b[j]
		o.i++
	}

	o.arr[o.i] = '\n'
	o.i++

	if o.i >= (o.size/100)*95 {
		o.flush(out)
	}
}

func (o *buffer) flush(out io.Writer) {
	if o.i > 0 {
		out.Write(o.arr[:o.i])
		o.i = 0
	}
}

// Solution implements main logic to solve CF 1423 K
func Solution(in io.Reader, out io.Writer) {
	n, ints := processInput(in)

	primes := make([]bool, _N)
	for i := 1; i < _N; i++ {
		primes[i] = true
	}

	for p := 2; p*p < _N; p++ {
		if !primes[p] {
			continue
		}

		for i := p + p; i < _N; i += p {
			primes[i] = false
		}
	}

	countLonelyUpTo := make([]int, _N)
	p := 2
	counter := 0

	for i := 1; i < _N; i++ {
		if primes[i] {
			counter++
		}

		if p*p == i {
			counter--

			for p++; !primes[p]; p++ {
			}
		}

		countLonelyUpTo[i] = counter
	}

	for i := 0; i < n; i++ {
		x := ints[i]
		ans := countLonelyUpTo[x]

		output.print(out, ans)
	}

	output.flush(out)
}

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

package main

import (
	"io"
	"io/ioutil"
	"os"
)

const _N int = 1e6 + 1

func processInput(in io.Reader) (int, []int) {
	buf, _ := ioutil.ReadAll(in)

	var i, l, n int
	l = len(buf)

	for ; buf[i] >= '0' && buf[i] <= '9'; i++ {
		n = (n * 10) + int(buf[i]&15)
	}

	ints := make([]int, n)
	for j := 0; j < n; j++ {
		for ; buf[i] < '0' || buf[i] > '9'; i++ {
		}

		for ; i < l && buf[i] >= '0' && buf[i] <= '9'; i++ {
			ints[j] = (ints[j] * 10) + int(buf[i]&15)
		}
	}

	return n, ints
}

const _B int = 512 * 1024

type buffer struct {
	i    int
	size int
	arr  []byte
}

var output = &buffer{
	size: _B,
	arr:  make([]byte, _B),
}

func (o *buffer) print(out io.Writer, x int) {
	b := make([]byte, 8)
	i := 0

	for x > 0 {
		b[i] = byte(x%10) + '0'
		x /= 10
		i++
	}

	for j := i - 1; j >= 0; j-- {
		o.arr[o.i] = b[j]
		o.i++
	}

	o.arr[o.i] = '\n'
	o.i++

	if o.i >= (o.size/100)*95 {
		o.flush(out)
	}
}

func (o *buffer) flush(out io.Writer) {
	if o.i > 0 {
		out.Write(o.arr[:o.i])
		o.i = 0
	}
}

// Solution implements main logic to solve CF 1423 K
func Solution(in io.Reader, out io.Writer) {
	n, ints := processInput(in)

	primes := make([]bool, _N)
	for i := 1; i < _N; i++ {
		primes[i] = true
	}

	for p := 2; p*p < _N; p++ {
		if !primes[p] {
			continue
		}

		for i := p + p; i < _N; i += p {
			primes[i] = false
		}
	}

	countLonelyUpTo := make([]int, _N)
	p := 2
	counter := 0

	for i := 1; i < _N; i++ {
		if primes[i] {
			counter++
		}

		if p*p == i {
			counter--

			for p++; !primes[p]; p++ {
			}
		}

		countLonelyUpTo[i] = counter
	}

	for i := 0; i < n; i++ {
		x := ints[i]
		ans := countLonelyUpTo[x]

		output.print(out, ans)
	}

	output.flush(out)
}

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

package main

import (
	"io"
	"io/ioutil"
	"os"
)

const _N int = 1e6 + 1

func processInput(in io.Reader) (int, []int) {
	buf, _ := ioutil.ReadAll(in)

	var i, l, n int
	l = len(buf)

	for ; buf[i] >= '0' && buf[i] <= '9'; i++ {
		n = (n * 10) + int(buf[i]&15)
	}

	ints := make([]int, n)
	for j := 0; j < n; j++ {
		for ; buf[i] < '0' || buf[i] > '9'; i++ {
		}

		for ; i < l && buf[i] >= '0' && buf[i] <= '9'; i++ {
			ints[j] = (ints[j] * 10) + int(buf[i]&15)
		}
	}

	return n, ints
}

const _B int = 16 * 1024

type buffer struct {
	i    int
	size int
	arr  []byte
}

var output = &buffer{
	size: _B,
	arr:  make([]byte, _B),
}

func (o *buffer) print(out io.Writer, x int) {
	b := make([]byte, 10)
	i := 0

	for x > 0 {
		b[i] = byte(x%10) + '0'
		x /= 10
		i++
	}

	for j := i - 1; j >= 0; j-- {
		o.arr[o.i] = b[j]
		o.i++
	}

	o.arr[o.i] = '\n'
	o.i++

	if o.i >= (o.size/100)*95 {
		o.flush(out)
	}
}

func (o *buffer) flush(out io.Writer) {
	if o.i > 0 {
		out.Write(o.arr[:o.i])
		o.i = 0
	}
}

// Solution1 implements main logic to solve CF 1423 K
func Solution1(in io.Reader, out io.Writer) {
	n, ints := processInput(in)

	primes := make([]bool, _N)
	for i := 1; i < _N; i++ {
		primes[i] = true
	}

	for p := 2; p*p < _N; p++ {
		if !primes[p] {
			continue
		}

		for i := p + p; i < _N; i += p {
			primes[i] = false
		}
	}

	countLonelyUpTo := make([]int, _N)
	p := 2
	counter := 0

	for i := 1; i < _N; i++ {
		if primes[i] {
			counter++
		}

		if p*p == i {
			counter--

			for p++; !primes[p]; p++ {
			}
		}

		countLonelyUpTo[i] = counter
	}

	for i := 0; i < n; i++ {
		x := ints[i]
		ans := countLonelyUpTo[x]

		output.print(out, ans)
	}

	output.flush(out)
}

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

package main

import (
	"io"
	"io/ioutil"
	"os"
)

const _N int = 1e6 + 1

func processInput(in io.Reader) (int, []int) {
	buf, _ := ioutil.ReadAll(in)

	var i, l, n int
	l = len(buf)

	for ; buf[i] >= '0' && buf[i] <= '9'; i++ {
		n = (n * 10) + int(buf[i]&15)
	}

	ints := make([]int, n)
	for j := 0; j < n; j++ {
		for ; buf[i] < '0' || buf[i] > '9'; i++ {
		}

		for ; i < l && buf[i] >= '0' && buf[i] <= '9'; i++ {
			ints[j] = (ints[j] * 10) + int(buf[i]&15)
		}
	}

	return n, ints
}

// Any of (128K, 512k, 1M) gives the better output performance (ACC in 124ms)
const _B int = 216 * 1024

type buffer struct {
	i    int
	size int
	arr  []byte
}

var output = &buffer{
	size: _B,
	arr:  make([]byte, _B),
}

func (o *buffer) print(out io.Writer, x int) {
	b := make([]byte, 8)
	i := 0

	for x > 0 {
		b[i] = byte(x%10) + '0'
		x /= 10
		i++
	}

	for j := i - 1; j >= 0; j-- {
		o.arr[o.i] = b[j]
		o.i++
	}

	o.arr[o.i] = '\n'
	o.i++

	if o.i >= (o.size/100)*95 {
		o.flush(out)
	}
}

func (o *buffer) flush(out io.Writer) {
	if o.i > 0 {
		out.Write(o.arr[:o.i])
		o.i = 0
	}
}

// Solution implements main logic to solve CF 1423 K
func Solution(in io.Reader, out io.Writer) {
	n, ints := processInput(in)

	primes := make([]bool, _N)
	for i := 1; i < _N; i++ {
		primes[i] = true
	}

	for p := 2; p*p < _N; p++ {
		if !primes[p] {
			continue
		}

		for i := p + p; i < _N; i += p {
			primes[i] = false
		}
	}

	countLonelyUpTo := make([]int, _N)
	p := 2
	counter := 0

	for i := 1; i < _N; i++ {
		if primes[i] {
			counter++
		}

		if p*p == i {
			counter--

			for p++; !primes[p]; p++ {
			}
		}

		countLonelyUpTo[i] = counter
	}

	for i := 0; i < n; i++ {
		x := ints[i]
		ans := countLonelyUpTo[x]

		output.print(out, ans)
	}

	output.flush(out)
}

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

package main

import (
	"io"
	"io/ioutil"
	"os"
)

const _N int = 1e6 + 1

func processInput(in io.Reader) (int, []int) {
	buf, _ := ioutil.ReadAll(in)

	var i, l, n int
	l = len(buf)

	for ; buf[i] >= '0' && buf[i] <= '9'; i++ {
		n = (n * 10) + int(buf[i]&15)
	}

	ints := make([]int, n)
	for j := 0; j < n; j++ {
		for ; buf[i] < '0' || buf[i] > '9'; i++ {
		}

		for ; i < l && buf[i] >= '0' && buf[i] <= '9'; i++ {
			ints[j] = (ints[j] * 10) + int(buf[i]&15)
		}
	}

	return n, ints
}

const _B int = 8e6

type buffer struct {
	i    int
	size int
	arr  []byte
}

var output = &buffer{
	size: _B,
	arr:  make([]byte, _B),
}

func (o *buffer) print(out io.Writer, x int) {
	b := make([]byte, 8)
	i := 0

	for x > 0 {
		b[i] = byte(x%10) + '0'
		x /= 10
		i++
	}

	for j := i - 1; j >= 0; j-- {
		o.arr[o.i] = b[j]
		o.i++
	}

	o.arr[o.i] = '\n'
	o.i++

	// if o.i >= (o.size/100)*95 {
	// 	o.flush(out)
	// }
}

func (o *buffer) flush(out io.Writer) {
	if o.i > 0 {
		out.Write(o.arr[:o.i])
		o.i = 0
	}
}

// Solution implements main logic to solve CF 1423 K
func Solution(in io.Reader, out io.Writer) {
	n, ints := processInput(in)

	primes := make([]bool, _N)
	for i := 1; i < _N; i++ {
		primes[i] = true
	}

	for p := 2; p*p < _N; p++ {
		if !primes[p] {
			continue
		}

		for i := p + p; i < _N; i += p {
			primes[i] = false
		}
	}

	countLonelyUpTo := make([]int, _N)
	p := 2
	counter := 0

	for i := 1; i < _N; i++ {
		if primes[i] {
			counter++
		}

		if p*p == i {
			counter--

			for p++; !primes[p]; p++ {
			}
		}

		countLonelyUpTo[i] = counter
	}

	for i := 0; i < n; i++ {
		x := ints[i]
		ans := countLonelyUpTo[x]

		output.print(out, ans)
	}

	output.flush(out)
}

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

package main

import (
	"io"
	"io/ioutil"
	"os"
)

const _N int = 1e6 + 1

func processInput(in io.Reader) (int, []int) {
	buf, _ := ioutil.ReadAll(in)

	var i, l, n int
	l = len(buf)

	for ; buf[i] >= '0' && buf[i] <= '9'; i++ {
		n = (n * 10) + int(buf[i]&15)
	}

	ints := make([]int, n)
	for j := 0; j < n; j++ {
		for ; buf[i] < '0' || buf[i] > '9'; i++ {
		}

		for ; i < l && buf[i] >= '0' && buf[i] <= '9'; i++ {
			ints[j] = (ints[j] * 10) + int(buf[i]&15)
		}
	}

	return n, ints
}

const _B int = 128 * 1024

type buffer struct {
	i    int
	size int
	arr  []byte
}

var output = &buffer{
	size: _B,
	arr:  make([]byte, _B),
}

func (o *buffer) print(out io.Writer, x int) {
	b := make([]byte, 8)
	i := 0

	for x > 0 {
		b[i] = byte(x%10) + '0'
		x /= 10
		i++
	}

	for j := i - 1; j >= 0; j-- {
		o.arr[o.i] = b[j]
		o.i++
	}

	o.arr[o.i] = '\n'
	o.i++

	if o.i >= (o.size/100)*95 {
		o.flush(out)
	}
}

func (o *buffer) flush(out io.Writer) {
	if o.i > 0 {
		out.Write(o.arr[:o.i])
		o.i = 0
	}
}

// Solution implements main logic to solve CF 1423 K
func Solution(in io.Reader, out io.Writer) {
	n, ints := processInput(in)

	primes := make([]bool, _N)
	for i := 1; i < _N; i++ {
		primes[i] = true
	}

	for p := 2; p*p < _N; p++ {
		if !primes[p] {
			continue
		}

		for i := p + p; i < _N; i += p {
			primes[i] = false
		}
	}

	countLonelyUpTo := make([]int, _N)
	p := 2
	counter := 0

	for i := 1; i < _N; i++ {
		if primes[i] {
			counter++
		}

		if p*p == i {
			counter--

			for p++; !primes[p]; p++ {
			}
		}

		countLonelyUpTo[i] = counter
	}

	for i := 0; i < n; i++ {
		x := ints[i]
		ans := countLonelyUpTo[x]

		output.print(out, ans)
	}

	output.flush(out)
}

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

package main

import (
	"io"
	"io/ioutil"
	"os"
)

const _N int = 1e6 + 1

func processInput(in io.Reader) (int, []int) {
	buf, _ := ioutil.ReadAll(in)

	var i, l, n int
	l = len(buf)

	for ; buf[i] >= '0' && buf[i] <= '9'; i++ {
		n = (n * 10) + int(buf[i]&15)
	}

	ints := make([]int, n)
	for j := 0; j < n; j++ {
		for ; buf[i] < '0' || buf[i] > '9'; i++ {
		}

		for ; i < l && buf[i] >= '0' && buf[i] <= '9'; i++ {
			ints[j] = (ints[j] * 10) + int(buf[i]&15)
		}
	}

	return n, ints
}

const _B int = 2 * 1024 * 1024

type buffer struct {
	i    int
	size int
	arr  []byte
}

var output = &buffer{
	size: _B,
	arr:  make([]byte, _B),
}

func (o *buffer) print(out io.Writer, x int) {
	b := make([]byte, 8)
	i := 0

	for x > 0 {
		b[i] = byte(x%10) + '0'
		x /= 10
		i++
	}

	for j := i - 1; j >= 0; j-- {
		o.arr[o.i] = b[j]
		o.i++
	}

	o.arr[o.i] = '\n'
	o.i++

	if o.i >= (o.size/100)*95 {
		o.flush(out)
	}
}

func (o *buffer) flush(out io.Writer) {
	if o.i > 0 {
		out.Write(o.arr[:o.i])
		o.i = 0
	}
}

// Solution implements main logic to solve CF 1423 K
func Solution(in io.Reader, out io.Writer) {
	n, ints := processInput(in)

	primes := make([]bool, _N)
	for i := 1; i < _N; i++ {
		primes[i] = true
	}

	for p := 2; p*p < _N; p++ {
		if !primes[p] {
			continue
		}

		for i := p + p; i < _N; i += p {
			primes[i] = false
		}
	}

	countLonelyUpTo := make([]int, _N)
	p := 2
	counter := 0

	for i := 1; i < _N; i++ {
		if primes[i] {
			counter++
		}

		if p*p == i {
			counter--

			for p++; !primes[p]; p++ {
			}
		}

		countLonelyUpTo[i] = counter
	}

	for i := 0; i < n; i++ {
		x := ints[i]
		ans := countLonelyUpTo[x]

		output.print(out, ans)
	}

	output.flush(out)
}

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

package main

import (
	"io"
	"io/ioutil"
	"os"
)

const _N int = 1e6 + 1

func processInput(in io.Reader) (int, []int) {
	buf, _ := ioutil.ReadAll(in)

	var i, l, n int
	l = len(buf)

	for ; buf[i] >= '0' && buf[i] <= '9'; i++ {
		n = (n * 10) + int(buf[i]&15)
	}

	ints := make([]int, n)
	for j := 0; j < n; j++ {
		for ; buf[i] < '0' || buf[i] > '9'; i++ {
		}

		for ; i < l && buf[i] >= '0' && buf[i] <= '9'; i++ {
			ints[j] = (ints[j] * 10) + int(buf[i]&15)
		}
	}

	return n, ints
}

const _B int = 64 * 1024

type buffer struct {
	i    int
	size int
	arr  []byte
}

var output = &buffer{
	size: _B,
	arr:  make([]byte, _B),
}

func (o *buffer) print(out io.Writer, x int) {
	b := make([]byte, 8)
	i := 0

	for x > 0 {
		b[i] = byte(x%10) + '0'
		x /= 10
		i++
	}

	for j := i - 1; j >= 0; j-- {
		o.arr[o.i] = b[j]
		o.i++
	}

	o.arr[o.i] = '\n'
	o.i++

	if o.i >= (o.size/100)*95 {
		o.flush(out)
	}
}

func (o *buffer) flush(out io.Writer) {
	if o.i > 0 {
		out.Write(o.arr[:o.i])
		o.i = 0
	}
}

// Solution implements main logic to solve CF 1423 K
func Solution(in io.Reader, out io.Writer) {
	n, ints := processInput(in)

	primes := make([]bool, _N)
	for i := 1; i < _N; i++ {
		primes[i] = true
	}

	for p := 2; p*p < _N; p++ {
		if !primes[p] {
			continue
		}

		for i := p + p; i < _N; i += p {
			primes[i] = false
		}
	}

	countLonelyUpTo := make([]int, _N)
	p := 2
	counter := 0

	for i := 1; i < _N; i++ {
		if primes[i] {
			counter++
		}

		if p*p == i {
			counter--

			for p++; !primes[p]; p++ {
			}
		}

		countLonelyUpTo[i] = counter
	}

	for i := 0; i < n; i++ {
		x := ints[i]
		ans := countLonelyUpTo[x]

		output.print(out, ans)
	}

	output.flush(out)
}

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

package main

import (
	"io"
	"io/ioutil"
	"os"
)

const _N int = 1e6 + 1

func processInput(in io.Reader) (int, []int) {
	buf, _ := ioutil.ReadAll(in)

	var i, l, n int
	l = len(buf)

	for ; buf[i] >= '0' && buf[i] <= '9'; i++ {
		n = (n * 10) + int(buf[i]&15)
	}

	ints := make([]int, n)
	for j := 0; j < n; j++ {
		for ; buf[i] < '0' || buf[i] > '9'; i++ {
		}

		for ; i < l && buf[i] >= '0' && buf[i] <= '9'; i++ {
			ints[j] = (ints[j] * 10) + int(buf[i]&15)
		}
	}

	return n, ints
}

const _B int = 32 * 1024

type buffer struct {
	i    int
	size int
	arr  []byte
}

var output = &buffer{
	size: _B,
	arr:  make([]byte, _B),
}

func (o *buffer) print(out io.Writer, x int) {
	b := make([]byte, 8)
	i := 0

	for x > 0 {
		b[i] = byte(x%10) + '0'
		x /= 10
		i++
	}

	for j := i - 1; j >= 0; j-- {
		o.arr[o.i] = b[j]
		o.i++
	}

	o.arr[o.i] = '\n'
	o.i++

	if o.i >= (o.size/100)*95 {
		o.flush(out)
	}
}

func (o *buffer) flush(out io.Writer) {
	if o.i > 0 {
		out.Write(o.arr[:o.i])
		o.i = 0
	}
}

// Solution implements main logic to solve CF 1423 K
func Solution(in io.Reader, out io.Writer) {
	n, ints := processInput(in)

	primes := make([]bool, _N)
	for i := 1; i < _N; i++ {
		primes[i] = true
	}

	for p := 2; p*p < _N; p++ {
		if !primes[p] {
			continue
		}

		for i := p + p; i < _N; i += p {
			primes[i] = false
		}
	}

	countLonelyUpTo := make([]int, _N)
	p := 2
	counter := 0

	for i := 1; i < _N; i++ {
		if primes[i] {
			counter++
		}

		if p*p == i {
			counter--

			for p++; !primes[p]; p++ {
			}
		}

		countLonelyUpTo[i] = counter
	}

	for i := 0; i < n; i++ {
		x := ints[i]
		ans := countLonelyUpTo[x]

		output.print(out, ans)
	}

	output.flush(out)
}

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

package main

import (
	"fmt"
	"io/ioutil"
	"os"
)

const _N int = 1e6 + 1

func processInput() (int, []int) {
	buf, _ := ioutil.ReadAll(os.Stdin)

	var i, l, n int
	l = len(buf)

	for ; buf[i] >= '0' && buf[i] <= '9'; i++ {
		n = (n * 10) + int(buf[i]&15)
	}

	ints := make([]int, n)
	for j := 0; j < n; j++ {
		for ; buf[i] < '0' || buf[i] > '9'; i++ {
		}

		for ; i < l && buf[i] >= '0' && buf[i] <= '9'; i++ {
			ints[j] = (ints[j] * 10) + int(buf[i]&15)
		}
	}

	return n, ints
}

func main() {
	n, ints := processInput()

	// 1 lonely

	// 2 [4, 6, ..]
	// (2, 4) 2 1 2
	// (4, 6) 2 2 3
	// (6, 8) 2 3 4
	// (8, 10) 2, 4, 5
	// (10, 12) 2, 5, 6

	// 3 [6, 9, 12, ..]
	// (3, 6) 3, 1, 2 --WA
	// (6, 9) 3, 2, 3
	// (9, 12) 3, 3, 4
	// (12, 15) 3, 4, 5

	// 4 [8, 12, 16, ..]
	// (4, 8) 4, 1, 2 --WA
	// (8, 12) 4, 2, 3
	// ()

	primes := make([]bool, _N)
	friendly := make([]int, _N)

	// for each p prime number
	// start with x as ceil(half p) times p
	// and mark p as friendly from x->, and mark all x + (p * [1, 2, 3..]) as friendly from p->

	for i := 1; i < _N; i++ {
		primes[i] = true
	}
	for i := 2; i < _N; i++ {
		if !primes[i] {
			continue
		}
		for j := i + i; j < _N; j += i {
			primes[j] = false
		}

		if int64((i+1)/2)*int64(i) >= int64(_N) {
			continue
		}

		x := int((i+1)/2) * i
		friendly[i] = x

		for ; x < _N; x += i {
			friendly[x] = x
		}
	}

	// count friends/good up to every _N

	friends := make([]int, _N)
	for i := 1; i < _N; i++ {
		friends[friendly[i]]++
	}

	good := make([]int, _N)
	for i := 2; i < _N; i++ {
		good[i] = good[i-1] + friends[i]
	}

	// for each x from n inputs
	// print x - good[x]

	for i := 0; i < n; i++ {
		x := ints[i]
		fmt.Println(x - good[x])
	}
}

package main

import (
	"fmt"
	"io"
	"io/ioutil"
	"os"
)

const _N int = 1e6 + 1

func processInput(in io.Reader) (int, []int) {
	buf, _ := ioutil.ReadAll(in)

	var i, l, n int
	l = len(buf)

	for ; buf[i] >= '0' && buf[i] <= '9'; i++ {
		n = (n * 10) + int(buf[i]&15)
	}

	ints := make([]int, n)
	for j := 0; j < n; j++ {
		for ; buf[i] < '0' || buf[i] > '9'; i++ {
		}

		for ; i < l && buf[i] >= '0' && buf[i] <= '9'; i++ {
			ints[j] = (ints[j] * 10) + int(buf[i]&15)
		}
	}

	return n, ints
}

// Solution1 implements main logic to solve CF 1423 K
func Solution1(in io.Reader, out io.Writer) {
	n, ints := processInput(in)

	// 1 lonely

	// 2 [4, 6, ..]
	// (2, 4) 2 1 2
	// (4, 6) 2 2 3
	// (6, 8) 2 3 4
	// (8, 10) 2, 4, 5
	// (10, 12) 2, 5, 6

	// 3 [6, 9, 12, ..]
	// (3, 6) 3, 1, 2 --WA
	// (6, 9) 3, 2, 3
	// (9, 12) 3, 3, 4
	// (12, 15) 3, 4, 5

	// 4 [8, 12, 16, ..]
	// (4, 8) 4, 1, 2 --WA
	// (8, 12) 4, 2, 3
	// ()

	primes := make([]bool, _N)
	friendly := make([]int, _N)

	// for each p prime number
	// start with x as ceil(half p) times p
	// and mark p as friendly from x->, and mark all x + (p * [1, 2, 3..]) as friendly from p->

	for i := 1; i < _N; i++ {
		primes[i] = true
	}
	for i := 2; i < _N; i++ {
		if !primes[i] {
			continue
		}
		for j := i + i; j < _N; j += i {
			primes[j] = false
		}

		if int64((i+1)/2)*int64(i) >= int64(_N) {
			continue
		}

		x := int((i+1)/2) * i
		friendly[i] = x

		for ; x < _N; x += i {
			friendly[x] = x
		}
	}

	// count friends/good up to every _N

	friends := make([]int, _N)
	for i := 1; i < _N; i++ {
		friends[friendly[i]]++
	}

	good := make([]int, _N)
	for i := 2; i < _N; i++ {
		good[i] = good[i-1] + friends[i]
	}

	// for each x from n inputs
	// print x - good[x]

	for i := 0; i < n; i++ {
		x := ints[i]
		out.Write([]byte(fmt.Sprintln(x - good[x])))
	}
}

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

package main

import (
	"fmt"
	"io"
	"io/ioutil"
	"os"
	"syscall"
)

const _N int = 1e6 + 1

func processInput(in io.Reader) (int, []int) {
	buf, _ := ioutil.ReadAll(in)

	var i, l, n int
	l = len(buf)

	for ; buf[i] >= '0' && buf[i] <= '9'; i++ {
		n = (n * 10) + int(buf[i]&15)
	}

	ints := make([]int, n)
	for j := 0; j < n; j++ {
		for ; buf[i] < '0' || buf[i] > '9'; i++ {
		}

		for ; i < l && buf[i] >= '0' && buf[i] <= '9'; i++ {
			ints[j] = (ints[j] * 10) + int(buf[i]&15)
		}
	}

	return n, ints
}

// Solution1 implements main logic to solve CF 1423 K
func Solution1(in io.Reader, out io.Writer) {
	n, ints := processInput(in)

	primes := make([]bool, _N)
	for i := 1; i < _N; i++ {
		primes[i] = true
	}

	for p := 2; p*p < _N; p++ {
		if !primes[p] {
			continue
		}

		for i := p + p; i < _N; i += p {
			primes[i] = false
		}
	}

	countLonelyUpTo := make([]int, _N)
	p := 2
	counter := 0

	for i := 1; i < _N; i++ {
		if primes[i] {
			counter++
		}

		if p*p == i {
			counter--

			for p++; !primes[p]; p++ {
			}
		}

		countLonelyUpTo[i] = counter
	}

	for i := 0; i < n; i++ {
		x := ints[i]
		ans := countLonelyUpTo[x]

		if out == nil {
			syscall.Write(1, []byte(fmt.Sprintln(ans)))
		} else {
			out.Write([]byte(fmt.Sprintln(ans)))
		}
	}
}

func main() {
	Solution1(os.Stdin, nil)
}


We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings "ab" in the string and replace it with the string "bba". If we have no "ab" as a substring, our job is done. Print the minimum number of steps we should perform to make our job done modulo 109 + 7.The string "ab" appears as a substring if there is a letter 'b' right after the letter 'a' somewhere in the string.

The first line contains the initial string consisting of letters 'a' and 'b' only with length from 1 to 106.

Print the minimum number of steps modulo 109 + 7.

NoteThe first example: "ab"  →  "bba".The second example: "aab"  →  "abba"  →  "bbaba"  →  "bbbbaa".

package main

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

const mod = 1000000007

var in = bufio.NewScanner(os.Stdin)

func readString() string {
	if !in.Scan() {
		panic(in.Err())
	}
	return in.Text()
}

func main() {
	s, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}
	for {
		last := s[len(s)-1]
		if last == 'a' || last == 'b' {
			break
		}
		s = s[:len(s)-1]
	}

	res := int64(0)
	add := int64(0)
	for i := len(s) - 1; i >= 0; i-- {
		if s[i] == 'a' {
			res = (res + add) % mod
			add = 2 * add % mod
		} else {
			add = (add + 1) % mod
		}
	}
	fmt.Println(res)
}

package main

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

func main() {
	var s string
	buf := make([]byte, int(math.Pow(10, 7)))

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(buf, int(math.Pow(10, 7)))

	if !scanner.Scan() {
		panic(scanner.Err())
	}

	fmt.Sscanf(scanner.Text(), "%s", &s)

	var a, ret uint64
	a = 1
	m := uint64(math.Pow(10, 9)) + 7

	for _, v := range s {
		if v == 'a' {
			a = a << 1 % m
			continue
		}

		ret = (ret + a - 1) % m
	}

	fmt.Println(ret)
}

package main

import (
	"fmt"
	"io/ioutil"
	"math"
	"math/big"
	"os"
)

func main() {
	s, err := ioutil.ReadAll(os.Stdin)

	if err != nil {
		panic(err)
	}

	for {
		last := s[len(s)-1]
		if last == 'a' || last == 'b' {
			break
		}
		s = s[:len(s)-1]
	}

	a, res, aMod := &big.Int{}, &big.Int{}, &big.Int{}
	m := big.NewInt(int64(math.Pow(10, 9)) + 7)
	one, two := big.NewInt(1), big.NewInt(2)

	for _, v := range s {
		if v == 'a' {
			a.Add(a, one)
			continue
		}

		aMod.Exp(two, a, m)
		res.Add(res, aMod)
		res.Add(res, m)
		res.Sub(res, one)
		res.Mod(res, m)
	}

	fmt.Println(res.Uint64())
}

package main

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

func main() {
	var s string
	buf := make([]byte, int(math.Pow(10, 7)))

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(buf, int(math.Pow(10, 7)))

	if !scanner.Scan() {
		panic(scanner.Err())
	}

	fmt.Sscanf(scanner.Text(), "%s", &s)

	a, res, aMod := &big.Int{}, &big.Int{}, &big.Int{}
	m := big.NewInt(int64(math.Pow(10, 9)) + 7)
	one, two := big.NewInt(1), big.NewInt(2)

	for _, v := range s {
		if v == 'a' {
			a.Add(a, one)
			continue
		}

		aMod.Exp(two, a, m)
		res.Add(res, aMod)
		res.Add(res, m)
		res.Sub(res, one)
		res.Mod(res, m)
	}

	fmt.Println(res.Uint64())
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)

	var aCount, ret uint64

	for _, v := range s {
		if v == 'a' {
			aCount++
			continue
		}

		ret = (ret + (1<<aCount-1)%(uint64(math.Pow(10, 9))+7)) %
			(uint64(math.Pow(10, 9)) + 7)
	}

	fmt.Println(ret)
}

package main

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

func main() {
	var s string

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()

	fmt.Sscanf(scanner.Text(), "%s", &s)

	a, res, aMod := &big.Int{}, &big.Int{}, &big.Int{}
	m := big.NewInt(int64(math.Pow(10, 9)) + 7)
	one, two := big.NewInt(1), big.NewInt(2)

	for _, v := range s {
		if v == 'a' {
			a.Add(a, one)
			continue
		}

		aMod.Exp(two, a, m)
		res.Add(res, aMod)
		res.Add(res, m)
		res.Sub(res, one)
		res.Mod(res, m)
	}

	fmt.Println(res.Uint64())
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)

	ret := 0
	aCount := 0

	for _, v := range s {
		if v == 'a' {
			aCount++
			continue
		}

		if aCount == 0 {
			continue
		}

		ret = (ret + int(math.Pow(2, float64(aCount))) - 1) %
			(int(math.Pow(10, 9)) + 7)
	}

	fmt.Println(ret % (int(math.Pow(10, 9)) + 7))
}


Mocha is a young girl from high school. She has learned so much interesting knowledge from her teachers, especially her math teacher. Recently, Mocha is learning about binary system and very interested in bitwise operation.This day, Mocha got a sequence $$$a$$$ of length $$$n$$$. In each operation, she can select an arbitrary interval $$$[l, r]$$$ and for all values $$$i$$$ ($$$0\leq i \leq r-l$$$), replace $$$a_{l+i}$$$ with $$$a_{l+i} \,\&\, a_{r-i}$$$ at the same time, where $$$\&$$$ denotes the bitwise AND operation. This operation can be performed any number of times.For example, if $$$n=5$$$, the array is $$$[a_1,a_2,a_3,a_4,a_5]$$$, and Mocha selects the interval $$$[2,5]$$$, then the new array is $$$[a_1,a_2\,\&\, a_5, a_3\,\&\, a_4, a_4\,\&\, a_3, a_5\,\&\, a_2]$$$.Now Mocha wants to minimize the maximum value in the sequence. As her best friend, can you help her to get the answer?

Each test contains multiple test cases.  The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of two lines. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the length of the sequence. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).

For each test case, print one integer — the minimal value of the maximum value in the sequence.

NoteIn the first test case, Mocha can choose the interval $$$[1,2]$$$, then the sequence becomes $$$[ 0, 0]$$$, where the first element is $$$1\,\&\,2$$$, and the second element is $$$2\,\&\,1$$$.In the second test case, Mocha can choose the interval $$$[1,3]$$$, then the sequence becomes $$$[ 1,1,1]$$$, where the first element is $$$1\,\&\,3$$$, the second element is $$$1\,\&\,1$$$, and the third element is $$$3\,\&\,1$$$.

package main

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

var in = NewIn()
var out = NewOut()

func main() {
	defer out.flush()

	tests()
	// solve()
}

/* --- Solution A --- */
func solve() {
	n := in.nextInt()

	nums := make([]int, n)
	for i := 0; i < n; i++ {
		a := in.nextInt()
		nums[i] = a
	}

	answer := nums[0]
	for i := 1; i < n; i++ {
		answer = answer & nums[i]
	}

	out.println(answer)
}

func tests() {
	tt := in.nextInt()
	for ; tt > 0; tt-- {
		solve()
	}
}

/* --- I/O --- */
type In struct {
	scanner *bufio.Scanner
}

func NewIn() *In {
	in := In{bufio.NewScanner(os.Stdin)}
	in.scanner.Split(bufio.ScanWords)
	return &in
}

func (in *In) nextInt() int {
	in.scanner.Scan()
	i, _ := strconv.Atoi(in.scanner.Text())
	return i
}

func (in *In) nextLong() int64 {
	in.scanner.Scan()
	i, _ := strconv.ParseInt(in.scanner.Text(), 10, 64)
	return i
}

func (in *In) next() string {
	in.scanner.Scan()
	return in.scanner.Text()
}

type Out struct {
	writer *bufio.Writer
}

func NewOut() *Out {
	out := Out{bufio.NewWriter(os.Stdout)}
	return &out
}

func (out *Out) println(a ...interface{}) {
	fmt.Fprintln(out.writer, a...)
}

func (out *Out) printf(format string, a ...interface{}) {
	fmt.Fprintf(out.writer, format, a...)
}

func (out *Out) print(a ...interface{}) {
	fmt.Fprint(out.writer, a...)
}

func (out *Out) flush() {
	out.writer.Flush()
}

package main

import "fmt"

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

	for i := 0; i < nIt; i++ {
		var length int
		fmt.Scanf("%d\n", &length)

		var sequence []int
		for j := 0; j < length; j++ {
			var value int
			fmt.Scanf("%d", &value)
			sequence = append(sequence, value)
		}
		fmt.Scanf("\n")

		result := sequence[0]
		for j := 0; j < length; j++ {
			result &= sequence[j]
		}
		fmt.Println(result)
	}
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	t, n   int
)

func solve(n int, a []int) int {
	var r int
	for i := 0; i < 33; i++ {
		var b int
		for j := range a {
			b += (a[j] >> i) & 1
		}
		if b == n {
			b = 1
		} else {
			b = 0
		}
		r += b << i
	}
	return r
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		fmt.Println(solve(n, a))
	}
}

package main

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

func hand(err error){
	if err != nil {
		panic(err)
	}
}

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

	var (
		t,n int
		arr []int
	)

	_,err := fmt.Fscan(in,&t)

	hand(err)

	for i:=1;i<=t;i++ {
		arr = arr[:0:0]
		_,err = fmt.Fscan(in,&n)
		hand(err)

		for j:=1;j<=n;j++ {
			var x int
			_,err = fmt.Fscan(in,&x)
			hand(err)
			arr =append(arr,x)
		}
		for j:=1;j<n;j++ {
			arr[0]&=arr[j]
		}
		fmt.Fprintf(out,"%d\n",arr[0])

	}

}

package main

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

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

	tmpLine, _ := reader.ReadString('\n')
	testCount, _ := strconv.Atoi(strings.TrimSpace(tmpLine))

	for i := 0; i < testCount; i++ {
		reader.ReadString('\n')
		tmpLine, _ = reader.ReadString('\n')
		newArr := stringToInt(strings.Split(strings.TrimSpace(tmpLine), " "))
		init := newArr[0]
		for j := 0; j< len(newArr);j++{
			init = init&newArr[j]
		}
		fmt.Println(init)
	}
}

func stringToInt(ss []string) []int {
	res := make([]int, len(ss))
	for i := range ss {
		res[i], _ = strconv.Atoi(ss[i])
	}
	return res
}

func findMax(ii []int) int {
	max := math.MinInt32
	for i := range ii {
		if ii[i] > max {
			max = ii[i]
		}
	}
	return max
}

package main

import (
    "fmt"
)

func main() {
    var testCases int
    var length int
    fmt.Scan(&testCases)

    for i := 0; i < testCases; i++ {
        fmt.Scan(&length)
        result := 0
        var val int
        for j := 0; j < length; j++ {
            fmt.Scan(&val)
            if j == 0 {
                result = val
            } else {
                result &= val
            }
        }
        fmt.Println(result)
    }
}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MINN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func MAXX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

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

		ARR := make([]int64, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(input, &ARR[i])

		}

		Begin := ARR[0]
		for i := 1; i < n; i++ {
			Begin = BITAND(Begin, ARR[i])
		}
		fmt.Println(Begin)

	}

}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		var b int
		fmt.Scan(&b)
		for j := 1; j < a; j++ {
			var c int
			fmt.Scan(&c)
			b &= c
		}
		fmt.Println(b)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for c:=1;c<=t;c++{
		var n int
		fmt.Fscan(in,&n)
		var a [105]int
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		ans:=0
		for i:=1;i<=31;i++{
			flag := true
			for j:=1;j<=n;j++{
				if a[j]&(1<<(i-1)) == 0{
					flag = false
				}
			}
		//	fmt.Println(i,flag,1<<(i-1))
			if flag{
				ans+=1<<(i-1)
			}
		}
		fmt.Fprintln(out,ans)
	}
}

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 solve() {
	var n int
	scan(&n)
	a := make([]int, n)
	min := int(1e9)
	and := 0xffffffff
	for i := 0; i < n; i++ {
		scan(&a[i])
		and = and & a[i]
		if min > a[i] {
			min = a[i]
		}
	}
	if min > and {
		min = and
	}
	printf("%d\n", min)
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

// 00
package main

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

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		res := a[0]
		for i := 1; i < n; i++ {
			res &= a[i]
		}
		fmt.Println(res)
	}
}

package main

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

/*
3
1
1
2
21 0
2
2 1
---
1
0
0
======
*/

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

	bld := strings.Builder{}

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

	for ; t > 0; t-- {
		var n int
		scanf("%d\n", &n)

		acc := maxUint

		var a uint

		for i := 0; i < n; i++ {
			scanf("%d", &a)

			acc = acc & a
		}
		scanf("\n")

		fmt.Fprintln(&bld, acc)
	}

	printf("%s", bld.String())
}

const maxUint = ^uint(0)

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

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

//goland:noinspection GoUnusedType
type pair struct {
	x int64
	y int64
}

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

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

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

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

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

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

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

	for i := 5; i*i <= n; i += 6 {
		if n%i == 0 || n%(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 {
	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"
)

func main() {
	r := bufio.NewReaderSize(os.Stdin, 1024*1024)

	var T int

	fmt.Fscanf(r, "%d\n", &T)

	for t := 0; t < T; t++ {
		var n int
		fmt.Fscanf(r, "%d\n", &n)

		arr := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscanf(r, "%d", &arr[i])
		}
		fmt.Fscanf(r, "\n")

		found := true
		for found {
			max := 0
			for i := 0; i < n; i++ {
				if arr[i] > arr[max] {
					max = i
				}
			}

			b := 0
			for j := 0; j < n; j++ {
				if arr[max]&arr[j] < arr[max]&arr[b] {
					b = j
				}
			}
			v := arr[max]
			if b > max {
				max, b = b, max
			}
			for j := b; j <= max; j++ {
				arr[j] = arr[j] & arr[max-(j-b)]
			}
			found = arr[max] < v
		}
		max := 0
		for i := 0; i < n; i++ {
			if arr[i] > arr[max] {
				max = i
			}
		}
		fmt.Println(arr[max])
	}
}

package main

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

var _, _, _ = main, rw, do

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

func rw(r io.Reader, w io.Writer) {
	var t int
	var n int
	var a = make([]int, 105)
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		fmt.Fscan(r, &n)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &a[i])
		}
		w1 := do(n, a[:n])
		fmt.Fprint(w, w1)
		fmt.Fprintln(w)
	}
}

func do(n int, a []int) int {
	r := a[0]
	for i := 1; i < n; i++ {
		r &= a[i]
	}
	return r
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		t--
		var n int
		fmt.Scan(&n)
		ar := make([]int, n)
		for i := range ar {
			fmt.Scan(&ar[i])
		}
		ans := ar[0]
		for _, ele := range ar {
			ans = ans & ele
		}
		fmt.Println(ans)
	}
}

package main

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

func main() {
	in:=bufio.NewReader(os.Stdin)
	out:=os.Stdout
	var t int
	fmt.Fscan(in, &t)
	for i := 0;i<t;i++ {
		var temp []int
		var n int
		fmt.Fscan(in,&n)
		var sum int
		sum =0
		var a int
		for j := 0;j<n;j++ {
			fmt.Fscan(in,&a)
			temp=append(temp,a)
		}
		sum=temp[0]
		for j := 0;j<n;j++ {
			sum&=temp[j]
		}
		fmt.Fprintln(out, sum)
	}
}

// Go file
/***********************************************
# @Author: Charmber - charmber@qq.com
# @Create Time: 2021-08-15 16:42:11
# @Last Modified: 2021-08-15 16:42:11
***********************************************/

package main

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

var iost *Iost

type Iost struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}

func NewIost(fp io.Reader, wfp io.Writer) *Iost {
	const BufSize = 1000000
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	return &Iost{Scanner: scanner, Writer: bufio.NewWriter(wfp)}
}

func (i *Iost) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}

func (i *Iost) Atoi(s string) int                 { x, _ := strconv.Atoi(s); return x }
func (i *Iost) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *Iost) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *Iost) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *Iost) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *Iost) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *Iost) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *Iost) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *Iost) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }
func isLocal() bool                               { return os.Getenv("I") == "IronMan" }

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	if isLocal() {
		fp, _ = os.Open(os.Getenv("END_GAME"))
	}
	iost = NewIost(fp, wfp)
	defer func() {
		if isLocal() {
			iost.Println(recover())
		}
		iost.Writer.Flush()
	}()
	solve()
	for i := 0; isLocal() && i < 100; i++ {
		iost.Println("-----------------------------------")
		solve()
	}
}

func solve() {
	q := iost.GetNextInt()
	for q > 0 {
		q--
		func() {
			n := iost.GetNextInt()
			ret := 0
			for i := 0; i < n; i++ {
				v := iost.GetNextInt()
				if i == 0 {
					ret = v
				} else {
					ret &= v
				}
			}
			iost.Println(ret)
		}()
	}
}

package main

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

func main() {
	defer wr.Flush()
	t := scanInt()
	for i := 0; i < t; i++ {
		fmt.Fprintln(wr, solve())
	}
}

func solve() int {
	n := scanInt()
	x := scanInt()
	for i := 1; i < n; i++ {
		x &= scanInt()
	}
	return x
}

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()
	ret, _ := strconv.Atoi(sc.Text())
	return ret
}

package main

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

type Scanner struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) *Scanner {
	scanner := bufio.NewScanner(reader)
	scanner.Split(bufio.ScanWords)
	return &Scanner{scanner}
}

func (s *Scanner) Word() string {
	s.Scan()
	return s.Text()
}

func (s *Scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *Scanner) Int64() int64 {
	s.Scan()
	n, _ := strconv.ParseInt(s.Text(), 10, 64)
	return n
}

func (s *Scanner) Words(count int) []string {
	words := make([]string, count)
	for i := range words {
		words[i] = s.Word()
	}
	return words
}

func (s *Scanner) Ints(count int) []int {
	ints := make([]int, count)
	for i := range ints {
		ints[i] = s.Int()
	}
	return ints
}

func (s *Scanner) Int64s(count int) []int64 {
	int64s := make([]int64, count)
	for i := range int64s {
		int64s[i] = s.Int64()
	}
	return int64s
}

func solve(v []int) int {
	res := v[0]
	for _, x := range v {
		res &= x
	}
	return res
}

func main() {
	stdin := NewWordScanner(os.Stdin)
	tests := stdin.Int()

	for i := 0; i < tests; i += 1 {
		n := stdin.Int()
		v := stdin.Ints(n)
		fmt.Println(solve(v))
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"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)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		s := a[0]
		for _, v := range a {
			s&=v
		}
		Fprintln(out, s)
	}

	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"
	"strconv"
)

/* --- Solution C --- */
func solve(in *In, out *Out) {
	n := in.nextInt()

	a := make([]int, n)
	for i := 0; i < n; i++ {
		v := in.nextInt()
		a[i] = v
	}

	if a[n-1] == 0 {
		for i := 1; i <= n+1; i++ {
			out.printf("%d ", i)
		}
		out.print("\n")
		return
	}
	if a[0] == 1 {
		out.printf("%d ", n+1)
		for i := 1; i <= n; i++ {
			out.printf("%d ", i)
		}
		out.print("\n")
		return
	}
	for i := 0; i < n-1; i++ {
		if a[i] == 0 && a[i+1] == 1 {
			for j := 1; j <= i+1; j++ {
				out.printf("%d ", j)
			}
			out.print(n + 1)
			for j := i + 2; j <= n; j++ {
				out.printf("%d ", j)
			}
			out.print("\n")
			return
		}
	}
	out.println(-1)
}

func run(in *In, out *Out) {
	cases(in, out)
	// solve(in, out)
}

func main() {
	in := NewIn()
	out := NewOut()
	defer out.flush()

	run(in, out)
}

func cases(in *In, out *Out) {
	tt := in.nextInt()
	for ; tt > 0; tt-- {
		solve(in, out)
	}
}

/* --- I/O --- */
const BUF_MAX_CAP int = 1024

type In struct {
	scanner *bufio.Scanner
}

func NewIn() *In {
	scn := bufio.NewScanner(os.Stdin)

	buf := make([]byte, BUF_MAX_CAP)
	scn.Buffer(buf, BUF_MAX_CAP)
	scn.Split(bufio.ScanWords)

	return &In{scn}
}

func (in *In) nextInt() int {
	in.scanner.Scan()
	i, _ := strconv.Atoi(in.scanner.Text())
	return i
}

func (in *In) nextLong() int64 {
	in.scanner.Scan()
	i, _ := strconv.ParseInt(in.scanner.Text(), 10, 64)
	return i
}

func (in *In) next() string {
	in.scanner.Scan()
	return in.scanner.Text()
}

func (in *In) nextByte() byte {
	in.scanner.Scan()
	return in.scanner.Text()[0]
}

type Out struct {
	writer *bufio.Writer
}

func NewOut() *Out {
	out := Out{bufio.NewWriter(os.Stdout)}
	return &out
}

func (out *Out) println(a ...interface{}) {
	fmt.Fprintln(out.writer, a...)
}

func (out *Out) printf(format string, a ...interface{}) {
	fmt.Fprintf(out.writer, format, a...)
}

func (out *Out) print(a ...interface{}) {
	fmt.Fprint(out.writer, a...)
}

func (out *Out) flush() {
	out.writer.Flush()
}

package main

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

var in = NewIn()
var out = NewOut()

func main() {
	defer out.flush()

	tests()
	// solve()
}

/* --- Solution A --- */
func solve() {
	n := in.nextInt()

	var min uint32 = math.MaxUint32
	for i := 0; i < n; i++ {
		a := uint32(in.nextInt())
		if ^a&(a+1) < min {
			min = ^a & (a + 1)
		}
	}

	out.println(min - 1)
}

func tests() {
	tt := in.nextInt()
	for ; tt > 0; tt-- {
		solve()
	}
}

/* --- I/O --- */
type In struct {
	scanner *bufio.Scanner
}

func NewIn() *In {
	in := In{bufio.NewScanner(os.Stdin)}
	in.scanner.Split(bufio.ScanWords)
	return &in
}

func (in *In) nextInt() int {
	in.scanner.Scan()
	i, _ := strconv.Atoi(in.scanner.Text())
	return i
}

func (in *In) nextLong() int64 {
	in.scanner.Scan()
	i, _ := strconv.ParseInt(in.scanner.Text(), 10, 64)
	return i
}

func (in *In) next() string {
	in.scanner.Scan()
	return in.scanner.Text()
}

type Out struct {
	writer *bufio.Writer
}

func NewOut() *Out {
	out := Out{bufio.NewWriter(os.Stdout)}
	return &out
}

func (out *Out) println(a ...interface{}) {
	fmt.Fprintln(out.writer, a...)
}

func (out *Out) printf(format string, a ...interface{}) {
	fmt.Fprintf(out.writer, format, a...)
}

func (out *Out) print(a ...interface{}) {
	fmt.Fprint(out.writer, a...)
}

func (out *Out) flush() {
	out.writer.Flush()
}

package main

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

var in = NewIn()
var out = NewOut()

func main() {
	defer out.flush()

	tests()
	// solve()
}

/* --- Solution A --- */
func solve() {
	n := NewIn().nextInt()

	var min uint32 = math.MaxUint32
	for i := 0; i < n; i++ {
		a := uint32(in.nextInt())
		if ^a&(a+1) < min {
			min = ^a & (a + 1)
		}
	}

	out.println(min - 1)
}

func tests() {
	tt := in.nextInt()
	for ; tt > 0; tt-- {
		solve()
	}
}

/* --- I/O --- */
type In struct {
	scanner *bufio.Scanner
}

func NewIn() *In {
	in := In{bufio.NewScanner(os.Stdin)}
	in.scanner.Split(bufio.ScanWords)
	return &in
}

func (in *In) nextInt() int {
	in.scanner.Scan()
	i, _ := strconv.Atoi(in.scanner.Text())
	return i
}

func (in *In) nextLong() int64 {
	in.scanner.Scan()
	i, _ := strconv.ParseInt(in.scanner.Text(), 10, 64)
	return i
}

func (in *In) next() string {
	in.scanner.Scan()
	return in.scanner.Text()
}

type Out struct {
	writer *bufio.Writer
}

func NewOut() *Out {
	out := Out{bufio.NewWriter(os.Stdout)}
	return &out
}

func (out *Out) println(a ...interface{}) {
	fmt.Fprintln(out.writer, a...)
}

func (out *Out) printf(format string, a ...interface{}) {
	fmt.Fprintf(out.writer, format, a...)
}

func (out *Out) print(a ...interface{}) {
	fmt.Fprint(out.writer, a...)
}

func (out *Out) flush() {
	out.writer.Flush()
}

package main

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

var in = NewIn()
var out = NewOut()

func main() {
	defer out.flush()

	tests()
	// solve()
}

/* --- Solution A --- */
func solve() {
	n := NewIn().nextInt()

	min := math.MaxInt32
	for i := 0; i < n; i++ {
		a := in.nextInt()
		if ^a&(a+1) < min {
			min = ^a & (a + 1)
		}
	}

	out.println(min - 1)
}

func tests() {
	tt := in.nextInt()
	for ; tt > 0; tt-- {
		solve()
	}
}

/* --- I/O --- */
type In struct {
	scanner *bufio.Scanner
}

func NewIn() *In {
	in := In{bufio.NewScanner(os.Stdin)}
	in.scanner.Split(bufio.ScanWords)
	return &in
}

func (in *In) nextInt() int {
	in.scanner.Scan()
	i, _ := strconv.Atoi(in.scanner.Text())
	return i
}

func (in *In) nextLong() int64 {
	in.scanner.Scan()
	i, _ := strconv.ParseInt(in.scanner.Text(), 10, 64)
	return i
}

func (in *In) next() string {
	in.scanner.Scan()
	return in.scanner.Text()
}

type Out struct {
	writer *bufio.Writer
}

func NewOut() *Out {
	out := Out{bufio.NewWriter(os.Stdout)}
	return &out
}

func (out *Out) println(a ...interface{}) {
	fmt.Fprintln(out.writer, a...)
}

func (out *Out) printf(format string, a ...interface{}) {
	fmt.Fprintf(out.writer, format, a...)
}

func (out *Out) print(a ...interface{}) {
	fmt.Fprint(out.writer, a...)
}

func (out *Out) flush() {
	out.writer.Flush()
}

package main

import "fmt"

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

	for i := 0; i < nIt; i++ {
		var length int
		fmt.Scanf("%d\n", &length)

		var sequence []int
		for j := 0; j < length; j++ {
			var value int
			fmt.Scanf("%d", &value)
			sequence = append(sequence, value)
		}
		fmt.Scanf("\n")

		max := sequence[0]
		min := sequence[0]
		for j := 0; j < length; j++ {
			if sequence[j] > max {
				max = sequence[j]
			}
			if sequence[j] < min {
				min = sequence[j]
			}
		}

		result := int64(max) & int64(min)
		fmt.Println(result)
	}
}

package main

import "fmt"

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

	for i := 0; i < nIt; i++ {
		var length int
		fmt.Scanf("%d\n", &length)

		var sequence []int
		for j := 0; j < length; j++ {
			var value int
			fmt.Scanf("%d", &value)
			sequence = append(sequence, value)
		}
		fmt.Scanf("\n")

		max := sequence[0]
		min := sequence[0]
		for j := 0; j < length; j++ {
			if sequence[j] > max {
				max = sequence[j]
			}
			if sequence[j] < min {
				min = sequence[j]
			}
		}

		result := max & min
		fmt.Println(result)
	}
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	t, n   int
)

func solve(n int, a []int) int {
	m := 1000000000
	for _, x := range a {
		b := (x ^ (x + 1)) >> 1
		if m > b {
			m = b
		}
	}
	return m
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		fmt.Println(solve(n, a))
	}
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	t, n   int
)

func solve(n int, a []int) int {
	m := 999999999
	for _, x := range a {
		b := (x ^ (x + 1)) >> 1
		if m > b {
			m = b
		}
	}
	return m
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		fmt.Println(solve(n, a))
	}
}

package main

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

func hand(err error){
	if err != nil {
		panic(err)
	}
}

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

	var (
		t,n int
		arr []int
	)

	_,err := fmt.Fscan(in,&t)

	hand(err)

	for i:=1;i<=t;i++ {
		_,err = fmt.Fscan(in,&n)
		hand(err)

		arr = make([]int,n)

		for j:=1;j<=n;j++ {
			var x int
			_,err = fmt.Fscan(in,&x)
			hand(err)
			arr =append(arr,x)
		}
		for j:=1;j<n;j++ {
			arr[0]&=arr[i]
		}
		fmt.Fprintf(out,"%d\n",arr[0])

	}

}

package main

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

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

	tmpLine, _ := reader.ReadString('\n')
	testCount, _ := strconv.Atoi(strings.TrimSpace(tmpLine))

	outer:
	for i :=0;i<testCount; i ++ {
		reader.ReadString('\n')
		tmpLine, _ = reader.ReadString('\n')
		newArr := makeMultiple(stringToInt(strings.Split(strings.TrimSpace(tmpLine), " ")))
		max := findMax(newArr)
		for {
			newArr = makeMultiple(newArr)
			newMax := findMax(newArr)
			if newMax < max {
				max = newMax
			} else {
				here:
				newArr = makeMultipleTwo(newArr)
				newMax = findMax(newArr)
				if newMax < max {
					max = newMax
					goto here
				} else {
					fmt.Println(max)
					continue outer
				}
			}
		}
	}
}

func stringToInt(ss []string) []int {
	res := make([]int, len(ss))
	for i := range ss {
		res[i], _ = strconv.Atoi(ss[i])
	}
	return res
}

func findMax(ii []int) int {
	max := math.MinInt32
	for i := range ii {
		if ii[i] > max {
			max = ii[i]
		}
	}
	return max
}

func makeMultiple(arr []int) []int {
	newArr := make([]int, len(arr))
	for j, k := 0, len(arr)-1; j < len(arr);j,k = j+1, k-1{
		newArr[j]=arr[j]&arr[k]
	}
	return newArr
}

func makeMultipleTwo(arr []int) []int {
	newArr := make([]int, len(arr))
	for i := 0; i < len(arr)-1;i++{
		newArr[i]=arr[i]&arr[i+1]
	}
	return newArr
}

package main

import (
    "fmt"
    "math"
)

func main() {
    var testCases int
    var length int
    fmt.Scan(&testCases)

    for i := 0; i < testCases; i++ {
        fmt.Scan(&length)
        var arr []int
        var val int
        for j := 0; j < length; j++ {
            fmt.Scan(&val)
            arr = append(arr, val)
        }
        fmt.Println(mini(arr))
    }
}

func mini(arr []int) int {
    max, min := findMaxMin(arr)
    return max & min
}

func findMaxMin(arr []int) (int, int) {
    max := -1
    min := math.MaxInt8
    for _, v := range arr {
        if v > max {
            max = v
        }
        if v < min {
            min = v
        }
    }
    return max, min
}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MINN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func MAXX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int) int {
	var ans int
	begin := x
	sec := y
	count := 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int(begin / 2)
			sec = int(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int(begin / 2)
			sec = int(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

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

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

		}

		Begin := ARR[0]
		for i := 1; i < n; i++ {
			Begin = BITAND(Begin, ARR[i])
		}
		fmt.Println(Begin)

	}

}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		b := 1
		for j := 0; j < a; j++ {
			var c int
			fmt.Scan(&c)
			b &= c
		}
		fmt.Println(b)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for c:=1;c<=t;c++{
		var n int
		fmt.Fscan(in,&n)
		var a [105]int
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		mi:=math.MaxInt32
		for i:=1;i<=n;i++{
			for j:=1;j<=n;j++{
				if mi>(a[i]&a[j]){
					mi = a[i]&a[j]
				}
			}
		}
		fmt.Fprintln(out,mi)
	}
}


This problem differs from the previous one only in the absence of the constraint on the equal length of all numbers $$$a_1, a_2, \dots, a_n$$$.A team of SIS students is going to make a trip on a submarine. Their target is an ancient treasure in a sunken ship lying on the bottom of the Great Rybinsk sea. Unfortunately, the students don't know the coordinates of the ship, so they asked Meshanya (who is a hereditary mage) to help them. He agreed to help them, but only if they solve his problem.Let's denote a function that alternates digits of two numbers $$$f(a_1 a_2 \dots a_{p - 1} a_p, b_1 b_2 \dots b_{q - 1} b_q)$$$, where $$$a_1 \dots a_p$$$ and $$$b_1 \dots b_q$$$ are digits of two integers written in the decimal notation without leading zeros.In other words, the function $$$f(x, y)$$$ alternately shuffles the digits of the numbers $$$x$$$ and $$$y$$$ by writing them from the lowest digits to the older ones, starting with the number $$$y$$$. The result of the function is also built from right to left (that is, from the lower digits to the older ones). If the digits of one of the arguments have ended, then the remaining digits of the other argument are written out. Familiarize with examples and formal definitions of the function below.For example: $$$$$$f(1111, 2222) = 12121212$$$$$$ $$$$$$f(7777, 888) = 7787878$$$$$$ $$$$$$f(33, 44444) = 4443434$$$$$$ $$$$$$f(555, 6) = 5556$$$$$$ $$$$$$f(111, 2222) = 2121212$$$$$$Formally,  if $$$p \ge q$$$ then $$$f(a_1 \dots a_p, b_1 \dots b_q) = a_1 a_2 \dots a_{p - q + 1} b_1 a_{p - q + 2} b_2 \dots a_{p - 1} b_{q - 1} a_p b_q$$$;  if $$$p < q$$$ then $$$f(a_1 \dots a_p, b_1 \dots b_q) = b_1 b_2 \dots b_{q - p} a_1 b_{q - p + 1} a_2 \dots a_{p - 1} b_{q - 1} a_p b_q$$$. Mishanya gives you an array consisting of $$$n$$$ integers $$$a_i$$$, your task is to help students to calculate $$$\sum_{i = 1}^{n}\sum_{j = 1}^{n} f(a_i, a_j)$$$ modulo $$$998\,244\,353$$$.

The first line of the input contains a single integer $$$n$$$ ($$$1 \le n \le 100\,000$$$) — the number of elements in the array. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array.

Print the answer modulo $$$998\,244\,353$$$.

package main

import (
	"bufio"
	"os"
	"runtime"
	"strconv"
)

/* solution */

const mod = 998244353

func solve() {

	tens := make([]int64, 21)
	tens[1] = 1
	for i := 2; i <= 20; i++ {
		tens[i] = (10 * tens[i-1]) % mod
	}

	n := readInt()
	a := make([]int64, n)
	l := make([]int64, 11)

	for i := 0; i < n; i++ {
		v := readInt64()
		a[i] = v
		cnt := 0
		for ; v > 0; v /= 10 {
			cnt++
		}
		l[cnt]++
	}

	ans := int64(0)

	for i := 0; i < n; i++ {

		for v, idx := a[i], 1; v > 0; v, idx = v/10, idx+1 {

			digit := v % 10

			for k := 1; k <= 10; k++ {

				if k >= idx {
					ans = (ans + (digit*l[k]*tens[idx*2])%mod) % mod
				} else {
					ans = (ans + (digit*l[k]*tens[k+idx])%mod) % mod
				}

				if k >= idx-1 {
					ans = (ans + (digit*l[k]*tens[idx*2-1])%mod) % mod
				} else {
					ans = (ans + (digit*l[k]*tens[k+idx])%mod) % mod
				}

			}

		}

	}

	printInt64(ans)

}

/* stubs */

func main() {

	var f *os.File
	if runtime.GOROOT() == "C:\\Soft\\Go" {
		f, _ = os.Open("input.txt")
		defer f.Close()
	} else {
		f = os.Stdin
	}

	writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	reader = bufio.NewScanner(f)

	const maxCapacity = 1024 * 1024
	buf := make([]byte, maxCapacity)
	reader.Buffer(buf, maxCapacity)

	reader.Split(bufio.ScanWords)

	solve()

}

var reader *bufio.Scanner
var writer *bufio.Writer

func read() string {
	reader.Scan()
	return reader.Text()
}

func readInt() int {
	reader.Scan()
	ret, _ := strconv.Atoi(reader.Text())
	return ret
}

func print(s string) {
	writer.WriteString(s)
	writer.WriteString("\n")
}

func printInt(i int) {
	print(strconv.Itoa(i))
}

func printInt64(i int64) {
	print(strconv.FormatInt(i, 10))
}

func readInt64() int64 {
	reader.Scan()
	ret, _ := strconv.ParseInt(reader.Text(), 10, 64)
	return ret
}

package main

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

var (
	arr               [100005]int64
	digits            [100005]int64
	numbersWithDigits [15]int64
)

const (
	mod = 998244353
)

func modMultiply(a int64, b int64) int64 {
	return ((a % mod) * (b % mod)) % mod
}

func modAdd(a int64, b int64) int64 {
	return ((a % mod) + (b % mod)) % mod
}

func numberOfDigits(num int64) int64 {
	var d int64
	for d = 0; num > 0; num, d = num/10, d+1 {
	}
	return d
}

func contributionOfNumber(n int64, num int64) int64 {
	// fmt.Printf("number = %d\n", num)
	var i, d, p, sum int64
	sum = 0
	p = 1
	for i = 1; num > 0; i, num = i+1, num/10 {
		d = num % 10

		// fmt.Printf("\ti = %d, d = %d, p = %d\n", i, d, p)

		var q, k, j int64
		q = p
		k = 0

		for j = 1; j < i; j++ {
			q = q * 10

			// fmt.Printf("\t\tj = %d, q = %d\n", j, q)
			sum = modAdd(sum, modMultiply(modMultiply(modMultiply(d, q), numbersWithDigits[j]), 2))
			k = k + numbersWithDigits[j]
		}
		sum = modAdd(sum, modMultiply(modMultiply(d, q), n-k))
		sum = modAdd(sum, modMultiply(modMultiply(modMultiply(d, q), 10), n-k))
		p = p * 10
	}
	// fmt.Printf("sum = %d\n", sum)
	return sum
}

func main() {
	var n, i int64

	in := bufio.NewReader(os.Stdin)

	fmt.Fscan(in, &n)
	for i = 0; i < n; i++ {
		fmt.Fscan(in, &arr[i])
		digits[i] = numberOfDigits(arr[i])
		numbersWithDigits[digits[i]] += 1
	}

	var ans int64
	for i = 0; i < n; i++ {
		ans = modAdd(ans, contributionOfNumber(n, arr[i]))
	}

	fmt.Println(ans)
}

package main

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

const (
	mod = 998244353
)

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])
	}
	fmt.Fscanf(in, "\n")
	sort.Ints(a)
	sum := int64(0)
	for i := 0; i < 11; i++ {
		sumOfDigits := int64(0)
		for j := 0; j < n; j++ {
			sumOfDigits += int64(getDigit(a[j], i))
		}
		// AsFirst
		asFirst := int64(0)
		for j := 0; j < n; j++ {
			// x234 123 -> x would be 10^6 times
			// x234 1234 -> x would be 10^7 times
			asFirst += getMul(getLen(a[j], i+1) + i)
			asFirst %= mod
		}
		asSecond := int64(0)
		for j := 0; j < n; j++ {
			//  123 x234 -> x would be 10^6 times
			//  1234 x234 -> x would be 10^6 times
			asSecond += getMul(getLen(a[j], i) + i)
			asSecond %= mod
		}
		//fmt.Println(sumOfDigits, asFirst, asSecond)
		sum += sumOfDigits * (asFirst + asSecond)
		sum %= mod
	}
	fmt.Fprintf(out, "%d\n", sum)
}

// 10 ^ i
func getMul(i int) int64 {
	ans := int64(1)
	for j := 0; j < i; j++ {
		ans *= 10
		ans %= mod
	}
	return ans
}

func getLen(a int, pos int) int {
	ans := 0
	for i := 0; i < pos; i++ {
		a /= 10
		ans++
		if a == 0 {
			return ans
		}
	}
	return ans
}

func getDigit(a int, pos int) int {
	for i := 0; i < pos; i++ {
		a /= 10
	}
	return a % 10
}

func first(a int) int64 {
	ans := int64(0)
	base := int64(10)
	for a > 0 {
		tail := int64(a % 10)
		a /= 10
		ans += base * tail
		base *= 100
		ans %= mod
		base %= mod
	}
	return ans
}

func second(a int) int64 {
	ans := int64(0)
	base := int64(1)
	for a > 0 {
		tail := int64(a % 10)
		a /= 10
		ans += base * tail
		base *= 100
		ans %= mod
		base %= mod
	}
	return ans
}

package main

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

func getD(x, y int64) int64 {
	return ((x % (y * 10)) - x%y) / y
}
func getDigs(x int64) int64 {
	y := int64(10)
	for z := int64(1); z <= 10; z++ {
		if x/y == 0 {
			return z
		}
		y = y * 10
	}
	return int64(-1)
}
func tranR(p, mod int64) [11]int64 {
	y := int64(1)
	z := int64(1)
	res := int64(0)
	rez := [11]int64{}
	for ZZ := 0; ZZ <= 10; ZZ++ {
		res = int64(0)
		y = int64(1)
		z = int64(1)
		for x := 1; x <= 10; x++ {
			res = (res + getD(p, y)*z) % mod
			y = (y * 10)
			if x <= ZZ {
				z = (z * 100) % mod
			} else {
				z = (z * 10) % mod
			}
		}
		rez[ZZ] = res
	}
	return rez
}

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

	n := int64(0)
	mod := int64(998244353)
	fmt.Fscanf(input, "%d\n", &n)
	p := [11]int64{}
	ans := int64(0)
	h := [100100]int64{}
	for i := int64(0); i < n; i++ {
		fmt.Fscanf(input, "%d", &h[i])
		p[getDigs(h[i])]++
	}
	for i := int64(0); i < n; i++ {
		rezz := tranR(h[i], mod)
		for j := 1; j <= 10; j++ {
			ans = (ans + (rezz[j]+rezz[j-1]*10)%mod*p[j]) % mod
		}
	}
	fmt.Println(ans)
}


You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k \le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times:  if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;  if there is at least one letter 'b', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;  ...  remove the leftmost occurrence of the letter 'z' and stop the algorithm. This algorithm removes a single letter from the string. Polycarp performs this algorithm exactly $$$k$$$ times, thus removing exactly $$$k$$$ characters.Help Polycarp find the resulting string.

The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 4 \cdot 10^5$$$) — the length of the string and the number of letters Polycarp will remove. The second line contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.

Print the string that will be obtained from $$$s$$$ after Polycarp removes exactly $$$k$$$ letters using the above algorithm $$$k$$$ times. If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).

package main

import (
	"fmt"
)

var cnt, del [26]int
func main() {
	var k, n int
	var s string
	fmt.Scanf("%d %d\n%s", &n, &k, &s)

	res := make([]byte, 0, n - k)
	for i := 0;i < n;i ++ {
		cnt[int(s[i] - 'a')] ++
	}
	for i, sum := 0, 0;;i ++ {
		if sum + cnt[i] >= k {
			del[i] = k - sum
			break
		} else {
			del[i] = cnt[i]
			sum += cnt[i]
		}
	}
	for i := 0;i < n;i ++ {
		if del[int(s[i] - 'a')] == 0 {
			res = append(res, s[i])
		} else {
			del[int(s[i] - 'a')] --
		}
	}
	fmt.Printf("%s", string(res))
}

package main

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

const (
	DEAD = '#'
)

func Init() {
}

func Solve(io *FastIO) {
	io.NextInt()
	K := io.NextInt()
	S := []rune(io.NextLine())

	idxs := make([][]int, 256)
	for i, c := range S {
		idxs[c] = append(idxs[c], i)
	}
	pos := 'a'
	for i := 0; i < K; i++ {
		for len(idxs[pos]) == 0 {
			pos++
		}
		idx := idxs[pos][0]
		S[idx] = DEAD
		idxs[pos] = idxs[pos][1:]
	}

	var ans []rune
	for _, c := range S {
		if c != DEAD {
			ans = append(ans, c)
		}
	}
	io.Println(string(ans))
}

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

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

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

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

func main() {
	sc := NewScanner()
	N, K := sc.NextInt(), sc.NextInt()
	S := []byte(sc.NextLine())
	for i := byte('a'); i <= byte('z'); i++ {
		for j := 0; j < N; j++ {
			if S[j] == i {
				S[j] = '.'
				K--
				if K == 0 {
					goto end
				}
			}
		}
	}
end:
	fmt.Println(strings.Replace(string(S), ".", "", -1))
}

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) 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"
)

const (
	MaxN = 400005
)

var n, k int
var s string
var q [MaxN]int

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf,"%d %d\n", &n, &k)
	fmt.Fscanf(buf, "%s", &s)

	cnt := 1
	for i := 'a'; i <= 'z'; i++ {
		for j := 0; j < n; j++ {
			if s[j] == byte(i) {
				q[j] = cnt
				cnt++
			}
		}
	}

	out := bufio.NewWriter(os.Stdout)
	defer func() { out.Flush() } ()
	for i := 0; i < n; i++ {
		if q[i] > k {
			fmt.Printf("%c", s[i])
		}
	}
	fmt.Println()
}

package main

import (
	"fmt"
)

func main() {
	var l,m int
	var s string
	fmt.Scan(&l,&m,&s)

	n := make([]int,26)
	for _,x := range(s) {
		n[int(x-'a')]++
	}
	k:=0;
	p :=0;
	for i := 0;i<26; i++ {
		k = i
		if m>n[i] {
			m -= n[i]
		} else {
			p =  m
			break
		}
	}
	var a []rune
	for _,r := range(s){
			if int(r) > k + 'a' || (int(r) == k+'a' && p == 0){
				a = append(a,r)
			} else if  int(r) == k+'a' {
				p--
			}
	}

	fmt.Println(string(a))
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n, k int
	var s string

	fmt.Scanf("%d %d\n", &n, &k)
	fmt.Scanln(&s)

	for i := 97; i <= 122; i++ {
		char := string(rune(i))
		c := strings.Count(s, char)
		if c > 0 {
			if k < c {
				c = k
			}

			s = strings.Replace(s, char, "", c)
			k -= c

			if k <= 0 {
				break
			}
		}
	}

	fmt.Println(s)
}

package main

import (
	"os"
	"bufio"
	"strconv"
)
var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func ReadInt32() int {
	scanner.Scan()
	ans, _ := strconv.Atoi(scanner.Text())
	return ans
}
func ReadString() string {
	scanner.Scan()
	return scanner.Text()
}

func PrintInts(ints ...int) {
	for _, value := range ints {
		writer.WriteString(strconv.Itoa(value))
		writer.WriteByte(' ')
	}
}
func PrintStrings(strs ...string) {
	for _, value := range strs {
		writer.WriteString(value)
		writer.WriteByte(' ')
	}
}
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	_,m := ReadInt32(),ReadInt32()
	s := ReadString()

	var r []rune
	n := make([]int,26)
	for _,a := range(s) {
		n[int(a-'a')]++
		r = append(r,a)
	}
	k:=0;
	p :=0;
	for i := 0;i<26; i++ {
		k = i
		if m>n[i] {
			m -= n[i]
		} else {
			p =  m
			break
		}
	}
	var a []rune
	for i:=0;i<len(r);i++{

			if int(r[i]) > k + 'a' || (int(r[i]) == k+'a' && p == 0){
				a = append(a,r[i])
			}

			if  int(r[i]) == k+'a' && p > 0{
				p--
			}

	}

	PrintStrings(string(a),"\n")
}

package main

import (
	"os"
	"bufio"
	"strconv"
)
var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func ReadInt32() int {
	scanner.Scan()
	ans, _ := strconv.Atoi(scanner.Text())
	return ans
}
func ReadString() string {
	scanner.Scan()
	return scanner.Text()
}

func PrintInts(ints ...int) {
	for _, value := range ints {
		writer.WriteString(strconv.Itoa(value))
		writer.WriteByte(' ')
	}
}
func PrintStrings(strs ...string) {
	for _, value := range strs {
		writer.WriteString(value)
		writer.WriteByte(' ')
	}
}
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	_,m := ReadInt32(),ReadInt32()
	s := ReadString()

	var r []rune
	n := make([]int,26)
	for _,a := range(s) {
		n[int(a-'a')]++
		r = append(r,a)
	}
	k:=0;
	p :=0;
	for i := 0;i<25; i++ {
		k = i
		if m>n[i] {
			m -= n[i]
		} else {
			p =  m
			break
		}
	}
	for i:=0;i<len(r);i++{
			if int(r[i]) < k + 'a'{
				r = append(r[:i],r[i+1:]...)
				i--
			} else if int(r[i]) == k+'a' && p != 0 {
				r = append(r[:i],r[i+1:]...)
				p--
				i--
			}

		}
	/*for ru := 'a';m>0;ru++{
		for i:=0;i<len(r);i++{
			if r[i] == ru && m>0{
					r = append(r[:i],r[i+1:]...)
					m--
					i--

			}
		}
	}*/
	PrintStrings(string(r))
}

package main

import (
	"os"
	"bufio"
	"strconv"
)
var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func ReadInt32() int {
	scanner.Scan()
	ans, _ := strconv.Atoi(scanner.Text())
	return ans
}
func ReadString() string {
	scanner.Scan()
	return scanner.Text()
}

func PrintInts(ints ...int) {
	for _, value := range ints {
		writer.WriteString(strconv.Itoa(value))
		writer.WriteByte(' ')
	}
}
func PrintStrings(strs ...string) {
	for _, value := range strs {
		writer.WriteString(value)
		writer.WriteByte(' ')
	}
}
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	_,m := ReadInt32(),ReadInt32()
	s := ReadString()

	var r []rune
	n := make([]int,26)
	for _,a := range(s) {
		n[int(a-'a')]++
		r = append(r,a)
	}
	k:=0;
	p :=0;
	for i := 0;i<26; i++ {
		k = i
		if m>n[i] {
			m -= n[i]
		} else {
			p =  m
			break
		}
	}
	var a []rune
	for _,ru := range(r){
			if int(ru) > k + 'a' || (int(ru) == k+'a' && p == 0){
				a = append(a,ru)
			} else if  int(ru) == k+'a' {
				p--
			}
	}

	PrintStrings(string(a),"\n")
}

package main

import (
	"os"
	"bufio"
	"strconv"
)
var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func ReadInt32() int {
	scanner.Scan()
	ans, _ := strconv.Atoi(scanner.Text())
	return ans
}
func ReadString() string {
	scanner.Scan()
	return scanner.Text()
}

func PrintInts(ints ...int) {
	for _, value := range ints {
		writer.WriteString(strconv.Itoa(value))
		writer.WriteByte(' ')
	}
}
func PrintStrings(strs ...string) {
	for _, value := range strs {
		writer.WriteString(value)
		writer.WriteByte(' ')
	}
}
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	_,m := ReadInt32(),ReadInt32()
	s := ReadString()

	var r []rune
	n := make([]int,26)
	for _,a := range(s) {
		n[int(a-'a')]++
		r = append(r,a)
	}
	k:=0;
	p :=0;
	for i := 0;i<25; i++ {
		k = i
		if m>n[i] {
			m -= n[i]
		} else {
			p =  m
			break
		}
	}

	var a []rune
	for i:=0;i<len(r);i++{

			if int(r[i]) > k + 'a' || (int(r[i]) == k+'a' && p == 0){
				a = append(a,r[i])
			}

			if  int(r[i]) == k+'a' && p > 0{
				p--
			}

	}

	PrintStrings(string(a),"\n")
}

package main

import (
	"os"
	"bufio"
	"strconv"
)
var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func ReadInt32() int {
	scanner.Scan()
	ans, _ := strconv.Atoi(scanner.Text())
	return ans
}
func ReadString() string {
	scanner.Scan()
	return scanner.Text()
}

func PrintInts(ints ...int) {
	for _, value := range ints {
		writer.WriteString(strconv.Itoa(value))
		writer.WriteByte(' ')
	}
}
func PrintStrings(strs ...string) {
	for _, value := range strs {
		writer.WriteString(value)
		writer.WriteByte(' ')
	}
}
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	_,m := ReadInt32(),ReadInt32()
	s := ReadString()

	var r []rune
	n := make([]int,26)
	for _,a := range(s) {
		n[int(a-'a')]++
		r = append(r,a)
	}
	k:=0;
	p :=0;
	for i := 0;i<25; i++ {
		k = i
		if m>n[i] {
			m -= n[i]
		} else {
			p =  m
			break
		}
	}
	for i:=0;i<len(r);i++{
			if int(r[i]) < k + 'a'{
				r = append(r[:i],r[i+1:]...)
				i--
			} else if int(r[i]) == k+'a' && p > 0 {
				r = append(r[:i],r[i+1:]...)
				p--
				i--
			}

		}

	PrintStrings(string(r),"\n")
}


The subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.You are given an integer $$$n$$$. You have to find a sequence $$$s$$$ consisting of digits $$$\{1, 3, 7\}$$$ such that it has exactly $$$n$$$ subsequences equal to $$$1337$$$.For example, sequence $$$337133377$$$ has $$$6$$$ subsequences equal to $$$1337$$$:   $$$337\underline{1}3\underline{3}\underline{3}7\underline{7}$$$ (you can remove the second and fifth characters);  $$$337\underline{1}\underline{3}3\underline{3}7\underline{7}$$$ (you can remove the third and fifth characters);  $$$337\underline{1}\underline{3}\underline{3}37\underline{7}$$$ (you can remove the fourth and fifth characters);  $$$337\underline{1}3\underline{3}\underline{3}\underline{7}7$$$ (you can remove the second and sixth characters);  $$$337\underline{1}\underline{3}3\underline{3}\underline{7}7$$$ (you can remove the third and sixth characters);  $$$337\underline{1}\underline{3}\underline{3}3\underline{7}7$$$ (you can remove the fourth and sixth characters). Note that the length of the sequence $$$s$$$ must not exceed $$$10^5$$$.You have to answer $$$t$$$ independent queries.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10$$$) — the number of queries.  Next $$$t$$$ lines contains a description of queries: the $$$i$$$-th line contains one integer $$$n_i$$$ ($$$1 \le n_i \le 10^9$$$).

For the $$$i$$$-th query print one string $$$s_i$$$ ($$$1 \le |s_i| \le 10^5$$$) consisting of digits $$$\{1, 3, 7\}$$$. String $$$s_i$$$ must have exactly $$$n_i$$$ subsequences $$$1337$$$. If there are multiple such strings, print any of them.

package main

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

func Sol1202D(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var t, n, len3 int
	Fscan(in, &t)
	for ; t > 0; t-- {
		Fscan(in, &n)
		for len3 = 2; (len3+1)*len3 <= 2*n; len3++ {
		}
		n -= len3 * (len3 - 1) / 2
		Fprintln(out, "133"+strings.Repeat("7", n)+strings.Repeat("3", len3-2)+"7")
	}
}

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

package main

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

// ByAge implements sort.Interface for []Person based on
// the Age field.
type nodes []node

func (a nodes) Len() int           { return len(a) }
func (a nodes) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a nodes) Less(i, j int) bool { return a[i].val > a[j].val }

type node struct {
	val int64
	id  int
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; i < n; i++ {
		m := 0
		fmt.Fscanf(in, "%d\n", &m)
		a := []int{}
		//length := 0
		for m > 0 {
			tmp := find(m)
			a = append(a, tmp)
			m -= tmp * (tmp - 1) / 2
			//length += tmp
		}
		a = append(a, 0)
		for j := 0; j < len(a)-1; j++ {
			fmt.Fprintf(out, "1")
			for jj := 0; jj < a[j]-a[j+1]; jj++ {
				fmt.Fprintf(out, "3")
			}
		}
		fmt.Fprintf(out, "7\n")
	}
	return
}

func find(m int) int {
	m *= 2
	// a * (a - 1) <= m
	l := int64(0)
	r := int64(m)
	for l < r {
		mid := (l + r + 1) / 2
		if mid*(mid-1) > int64(m) {
			r = mid - 1
		} else {
			l = mid
		}
	}
	return int(l)
}

package main

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

// ByAge implements sort.Interface for []Person based on
// the Age field.
type nodes []node

func (a nodes) Len() int           { return len(a) }
func (a nodes) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a nodes) Less(i, j int) bool { return a[i].val > a[j].val }

type node struct {
	val int64
	id  int
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; i < n; i++ {
		m := 0
		fmt.Fscanf(in, "%d\n", &m)
		for j := 100000; j >= 1; j-- {
			if m%j == 0 {
				//fmt.Println(j)
				q := m / j
				if j+q+2 > 100000 {
					continue
				}
				for k := 0; k < j; k++ {
					fmt.Fprintf(out, "1")
				}
				fmt.Fprintf(out, "33")
				for k := 0; k < q; k++ {
					fmt.Fprintf(out, "7")
				}
				fmt.Fprintln(out)
				break
			}
		}
	}
	return
}


Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?The market analysts came up with a very smart plan: the name of the company should be identical to its reflection in a mirror! In other words, if we write out the name of the company on a piece of paper in a line (horizontally, from left to right) with large English letters, then put this piece of paper in front of the mirror, then the reflection of the name in the mirror should perfectly match the line written on the piece of paper.There are many suggestions for the company name, so coming up to the mirror with a piece of paper for each name wouldn't be sensible. The founders of the company decided to automatize this process. They asked you to write a program that can, given a word, determine whether the word is a 'mirror' word or not.

The first line contains a non-empty name that needs to be checked. The name contains at most 105 large English letters. The name will be written with the next sans serif font:

Print 'YES' (without the quotes), if the given name matches its mirror reflection. Otherwise, print 'NO' (without the quotes).

package main
import (
	"fmt"
	"bufio"
	"os"
)
func main() {
	//var cek string = "WTYUIOAHXVM"
	reader := bufio.NewReader(os.Stdin)
	var s string
	flag:=true
	fmt.Fscan(reader,&s)
	j:=len(s)-1
	for i:=0;i<=j;i++ {
		if((s[i]!=s[j])||(s[i]!='A'&&s[i]!='H'&&s[i]!='I'&&s[i]!='M'&&s[i]!='O'&&s[i]!='T'&&s[i]!='U'&&s[i]!='V'&&s[i]!='W'&&s[i]!='X'&&s[i]!='Y')){
			flag=false
			break
		}
		j--
	}
	if flag==true{
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}

package main

import (
    "fmt"
)

func main() {
    var s []byte
    fmt.Scanf("%s\n", &s)
    for i, l := 0, len(s)-1; i <= l; i, l = i+1, l-1 {
        switch {
        case s[i] == s[l]:
            if !inWhile(s[i]) {
                fmt.Println("NO")
                return
            }
        default:
            fmt.Println("NO")
            return
        }
    }
    fmt.Println("YES")
}

func inWhile(ch byte) bool {
    switch string(ch) {
    case "A", "H", "I", "M", "O", "T", "U", "V", "W", "X", "Y":
        return true
    default:
        return false
    }
}

package main

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

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

  symmetric := map[rune]bool{}
  for _, ch := range "AHIMOTUVWXY" {
    symmetric[ch] = true
  }
  line, _ := reader.ReadString('\n')
  s := strings.TrimSpace(line)
  n := len(s)
  for i := (n-1)/2; i >= 0; i-- {
    ch := s[i]
    if !symmetric[rune(ch)] || ch != s[n-1-i] {
      writer.WriteString("NO\n")
      return
    }
  }
  writer.WriteString("YES\n")
}

package main

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

func main() {
    reader := bufio.NewReader(os.Stdin)
    var s string
    fmt.Fscan(reader,&s)
    ans := "YES"
    for i := 0; i <= len(s)/2; i++ {
        if i == (len(s)-i-1) {
            if (s[i] != 'A') && (s[i] != 'H') && (s[i] != 'I') && (s[i] != 'M') && (s[i] != 'O') && (s[i] != 'T') && (s[i] != 'U') && (s[i] != 'V') && (s[i] != 'W') && (s[i] != 'X') && (s[i] != 'Y') {
                ans = "NO"
                break
            }
        } else if s[i] != s[len(s)-i-1] {
            ans = "NO"
            break
        }
    }
    fmt.Println(ans)
}