package main

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

const N = 1000000

func sieveOfAtkins() []int {
	var x, y, n int
	nSqrt := math.Sqrt(N)

	isPrime := [N]bool{}

	for x = 1; float64(x) <= nSqrt; x++ {
		for y = 1; float64(y) <= nSqrt; y++ {
			n = 4*(x*x) + y*y
			if n <= N && (n%12 == 1 || n%12 == 5) {
				isPrime[n] = !isPrime[n]
			}
			n = 3*(x*x) + y*y
			if n <= N && n%12 == 7 {
				isPrime[n] = !isPrime[n]
			}
			n = 3*(x*x) - y*y
			if x > y && n <= N && n%12 == 11 {
				isPrime[n] = !isPrime[n]
			}
		}
	}

	for n = 5; float64(n) <= nSqrt; n++ {
		if isPrime[n] {
			for y = n*n; y < N; y += n*n {
				isPrime[y] = false
			}
		}
	}

	isPrime[2] = true
	isPrime[3] = true

	primes := make([]int, 0, 1270606)
	for x = 0; x < len(isPrime)-1; x++ {
		if isPrime[x] {
			primes = append(primes, x)
		}
	}
	return primes
}

func main() {
	primes := sieveOfAtkins()
	var n int
	r := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscanf(r, "%d\n", &n)
	arr := make([]float64, n, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(r, "%f", &arr[i])
	}
	for _, element := range arr {
		var elementSqrt int
		elementSqrt1 := math.Sqrt(element)
		if elementSqrt1 != float64(int64(elementSqrt1)) {
			fmt.Println("NO")
			continue
		} else {
			elementSqrt = int(elementSqrt1)
		}
		left := -1
		right := len(primes)
		for right > left + 1 {
			middle := (left + right) / 2
			if primes[middle] > elementSqrt {
				right = middle
			} else {
				left = middle
			}
		}
		if left >= 0 && primes[left] == elementSqrt {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

/*
go run a.go
*/
/*
i solved this problem with c++ but couldnt get to make it work in golang just cause the console input outut doiesnt work...anyway i learned a lot about golang from this
*/
package main

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

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

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

const mx = 1001000

var status [(mx / 32) + 2]int //wow mx ke constant hote hobe..go wont take any chances
var n int

var x int64
var num []int64

func on(n int, pos uint) int {
	n = (n | (1 << pos)) //u cannot do return n=soemthing
	return n
}
func check(n int, pos uint) int {
	var res int
	res = (n & (1 << pos)) //wow pos has to be unsigned...go wont take any chances
	return res
}
func sieve() {
	var i, j, sqrtN int
	sqrtN = int(math.Sqrt(float64(mx)))
	status[0] = on(status[0], 1)
	for i = 3; i <= sqrtN; i += 2 { //wow u cant even do for()
		if check(status[i>>5], uint(i&31)) == 0 { //i & 31 => i%32
			for j = i * i; j <= mx; j += (i << 1) { //i << 1 => j += 2*i
				//         //status[j >> 5] is equivalent to status[j/32] but faster
				status[j>>5] = on(status[j>>5], uint(j&31))
			}
		}
	}
}

func numbers(s string) {
	for _, f := range strings.Fields(s) {
		//jodi int32 hoy tobe strconv.ParseInt(f, 10, 64) er bodole strconv.Atoi(f) use koro just
		i, err := strconv.ParseInt(f, 10, 64)
		if err == nil {
			num = append(num, i)
		} else {
			fmt.Println("SHIT ", err)
		}
	}
}
func main() {
	defer writer.Flush()

	sieve()
	in := bufio.NewReader(os.Stdin)
	a, _ := in.ReadString('\n')
	a = a[0 : len(a)-2]
	n, err := strconv.Atoi(a)
	if err != nil {
		fmt.Println(err)
		fmt.Println(n)
	}
	//for i := 1; i <= n; i++ {
	a, _ = in.ReadString('\n')
	a = a[0 : len(a)-2]
	//num[i], err = strconv.ParseInt(a, 10, 64)
	//	if err != nil {
	//		fmt.Println("FUCK AGAIN ", err)
	//	}
	//}

	numbers(a)

	for i := 0; i < len(num); i++ {
		x = int64(math.Sqrt(float64(num[i])))

		if num[i] == 4 {
			printf("YES\n")
		} else if (num[i]%2 != 0) && x*x == num[i] && check(status[x>>5], uint(x&31)) == 0 {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
	}

}

package main

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

var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

// Sieve 埃氏筛法
func Sieve(n int) (prime []int, isPrime []bool) {
	isPrime = make([]bool, n+1)
	for i := 2; i <= n; i++ {
		isPrime[i] = true
	}
	for i := 2; i <= n; i++ {
		if isPrime[i] {
			prime = append(prime, i)
			for j := i * 2; j <= n; j += i {
				isPrime[j] = false
			}
		}
	}
	return
}

var n int

func main() {
	fmt.Fscan(reader, &n)
	_, isPrime := Sieve(1e6)

	for ; n != 0; n-- {
		var a int64
		fmt.Fscan(reader, &a)
		b := int64(math.Sqrt(float64(a)))
		if b*b == a && isPrime[int(b)] {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    writer := bufio.NewWriter(os.Stdout)
    prime := make([]bool,1000001)
    Tprime := make(map[int64]bool)
    for i := 2; i <= 1000000; i++ {
        if !prime[i] {
            a := int64(i)*int64(i)
            Tprime[a] = true
            for a <= 1000000 {
                prime[a] = true
                a += int64(i)
            }
        }
    }
    var n int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        for scanner.Scan() {
            if scanner.Text() != "" { break }
        }
        x, _ := strconv.ParseInt(scanner.Text(),10,64)
        if Tprime[x] == true {
            writer.WriteString("YES\n")
        } else {
            writer.WriteString("NO\n")
        }
    }
    writer.Flush()
}

package main

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

var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

// Sieve Sieve
func Sieve(n int) (prime []int) {
	isPrime := make([]bool, n+1)
	for i := 0; i <= n; i++ {
		isPrime[i] = true
	}
	isPrime[0], isPrime[1] = false, false
	for i := 2; i <= n; i++ {
		if isPrime[i] {
			prime = append(prime, i)
			for j := i * 2; j <= n; j += i {
				isPrime[j] = false
			}
		}
	}
	return
}

var n int

func main() {
	fmt.Fscan(reader, &n)
	m := make(map[int]bool)
	prime := Sieve(1e6)
	for i := 0; i < len(prime); i++ {
		m[prime[i]] = true
	}

	for ; n != 0; n-- {
		var a int64
		fmt.Fscan(reader, &a)
		b := int64(math.Sqrt(float64(a)))
		if b*b == a && m[int(b)] {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

type s struct{}

var exists s = s{}

const max = uint64(1000000000000)

func isPrime(primes []uint64, num uint64) bool {
	for i := 0; i < len(primes) && primes[i]*primes[i] <= num; i += 1 {
		if num%primes[i] == 0 {
			return false
		}
	}
	return true
}

func generatePrimes(m uint64) []uint64 {
	ans := []uint64{2}
	for i := uint64(3); i*i <= m; i += uint64(2) {
		if isPrime(ans, i) {
			ans = append(ans, i)
		}
	}
	return ans
}

func generateTPrimes(m uint64) map[uint64]s {
	ans := map[uint64]s{}
	primes := generatePrimes(m)
	for _, p := range primes {
		ans[p*p] = exists
	}
	return ans
}

// parse uint64 from byte slice
func parseUInt64(a []byte, start int) (ans uint64) {
	for i := start; i < len(a) && a[i] >= '0' && a[i] <= '9'; i += 1 {
		// skip overflow check
		ans = 10*ans + uint64(a[i]-'0')
	}
	return ans
}

// https://codeforces.com/problemset/problem/230/B
// комментарии к решению
// Задача сводиться к проверке является ли число квадратом простого числа или нет
// Сначала необходимо сгенерировать все простые числа до нужного порога,
// потом сгенерировать из них Т-простые числа,
// после чего можно итерироваться по входному потоку.
// Для хранения Т-простых хорошо подходит set (тип map[int]struct{} в golang)
// Плюсом реализуем свою parseInt, т.к. fmt.Scan не справляется с такими входными данными
func taskSolution(a []byte, n int) string {
	// 4 == "YES\n"
	ans := make([]byte, 0, 4*n)
	tPrimes := generateTPrimes(max)

	intStart := 0
	// check first and iterate from second to prevent trimming end space
	cur := parseUInt64(a, intStart)
	if _, ok := tPrimes[cur]; ok {
		ans = append(ans, []byte("YES")...)
	} else {
		ans = append(ans, []byte("NO")...)
	}
	for intStart < len(a) {
		// find next
		for intStart < len(a) && a[intStart] >= '0' && a[intStart] <= '9' {
			intStart += 1
		}
		for intStart < len(a) && !(a[intStart] >= '0' && a[intStart] <= '9') {
			intStart += 1
		}
		if intStart >= len(a) {
			break
		}
		// found
		cur = parseUInt64(a, intStart)
		if _, ok := tPrimes[cur]; ok {
			ans = append(ans, []byte("\nYES")...)
		} else {
			ans = append(ans, []byte("\nNO")...)
		}
	}
	return string(ans)
}

func main() {
	var n int
	if _, err := fmt.Scan(&n); err != nil {
		panic(err)
	}

	inRaw, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}

	fmt.Println(taskSolution(bytes.TrimSpace(inRaw), n))
}

package main

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

type s struct{}

var exists s = s{}

const max = uint64(1000000000000)

func isPrime(primes []uint64, num uint64) bool {
	for i := 0; i < len(primes) && primes[i]*primes[i] <= num; i += 1 {
		if num%primes[i] == 0 {
			return false
		}
	}
	return true
}

func generatePrimes(m uint64) []uint64 {
	ans := []uint64{2}
	for i := uint64(3); i*i <= m; i += uint64(2) {
		if isPrime(ans, i) {
			ans = append(ans, i)
		}
	}
	return ans
}

func generateTPrimes(m uint64) map[uint64]s {
	ans := map[uint64]s{}
	primes := generatePrimes(m)
	for _, p := range primes {
		ans[p*p] = exists
	}
	return ans
}

// parse uint64 from byte slice
func parseUInt64(a []byte, start int) (ans uint64) {
	for i := start; i < len(a) && a[i] >= '0' && a[i] <= '9'; i += 1 {
		// skip overflow check
		ans = 10*ans + uint64(a[i]-'0')
	}
	return ans
}

// https://codeforces.com/problemset/problem/230/B
// комментарии к решению
// Задача сводиться к проверке является ли число квадратом простого числа или нет
// Сначала необходимо сгенерировать все простые числа до нужного порога,
// потом сгенерировать из них Т-простые числа,
// после чего можно итерироваться по входному потоку.
// Для хранения Т-простых хорошо подходит set (тип map[int]struct{} в golang)
// Плюсом реализуем свою parseInt, т.к. fmt.Scan не справляется с такими входными данными
func taskSolution(a []byte) string {
	ans := []byte{}
	tPrimes := generateTPrimes(max)

	intStart := 0
	// check first and iterate from second to prevent trimming end space
	cur := parseUInt64(a, intStart)
	if _, ok := tPrimes[cur]; ok {
		ans = append(ans, []byte("YES")...)
	} else {
		ans = append(ans, []byte("NO")...)
	}
	for intStart < len(a) {
		// find next
		for intStart < len(a) && a[intStart] >= '0' && a[intStart] <= '9' {
			intStart += 1
		}
		for intStart < len(a) && !(a[intStart] >= '0' && a[intStart] <= '9') {
			intStart += 1
		}
		if intStart >= len(a) {
			break
		}
		// found
		cur = parseUInt64(a, intStart)
		if _, ok := tPrimes[cur]; ok {
			ans = append(ans, []byte("\nYES")...)
		} else {
			ans = append(ans, []byte("\nNO")...)
		}
	}
	return string(ans)
}

func main() {
	var n int
	if _, err := fmt.Scan(&n); err != nil {
		panic(err)
	}

	inRaw, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}

	fmt.Println(taskSolution(bytes.TrimSpace(inRaw)))
}

package main

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

var DEBUG = true

func main() {
	defer Flush()
	n := readi()
	x := make([]int64, n)
	for i := range x {
		x[i] = readll()
	}

	ps := NewPrimes(1001001)

	for _, v := range x {
		r := int64(math.Sqrt(float64(v)))
		if r*r == v && ps.IsPrime(int(r)) {
			println("YES")
		} else {
			println("NO")
		}
	}

}

type Primes struct {
	p []bool
	d []int
}

func NewPrimes(n int) Primes {
	m := n + 1
	p := Primes{
		p: make([]bool, m),
		d: make([]int, m),
	}
	p.d[1] = 1
	for i := 3; i < m; i += 2 {
		p.p[i] = true
		p.d[i-1] = 2
	}
	if n%2 == 0 {
		p.d[n] = 2
	}
	p.p[2] = true
	i := 3
	for ; i*i < m; i += 2 {
		if !p.p[i] {
			continue
		}
		p.d[i] = i
		for j := i * i; j < m; j += i {
			p.p[j] = false
			if p.d[j] == 0 {
				p.d[j] = i
			}
		}
	}

	for i = i - 2; i < m; i += 2 {
		if p.d[i] == 0 {
			p.d[i] = i
		}
	}

	return p
}

func (ps Primes) IsPrime(x int) bool {
	return ps.p[x]
}

func (ps Primes) Divisor(x int) int {
	return ps.d[x]
}

func (ps Primes) Factorize(x int) [][2]int {
	res := make([][2]int, 0)
	if x == 1 {
		res = append(res, [2]int{1, 1})
		return res
	}
	v := x
	for v != 1 {
		d := ps.d[v]
		if d == x {
			break
		}
		if 0 < len(res) && res[len(res)-1][0] == d {
			res[len(res)-1][1]++
		} else {
			res = append(res, [2]int{d, 1})
		}
		v /= d
	}
	return res
}

func (ps Primes) FactorizeMap(x int) map[int]int {
	m := make(map[int]int)
	for _, f := range ps.Factorize(x) {
		m[f[0]] = f[1]
	}
	return m
}

// newFactorial(n, p int) returns 2 functions.
// 1. factorial(x int) int: returns factorial x modulo p (0 <= x <= n)
// 2. combination(x, r int int: returns xCr modulo p (1 <= r <= x <= n)
func newFactorial(n, p int) (factorial func(int) int, combination func(int, int) int) {
	if n < 1 {
		panic("newFactorial: n must be more than 0")
	}

	fact := make([]int, n+1)
	fact[1] = 1
	for i := 2; i <= n; i++ {
		fact[i] = mul(fact[i-1], i, p)
	}

	ifact := make([]int, n+1)
	ifact[n] = inv(fact[n], p)
	for i := n - 1; 0 <= i; i-- {
		ifact[i] = mul(ifact[i+1], i+1, p)
	}

	factorial = func(i int) int {
		return fact[i]
	}
	combination = func(n, r int) int {
		if r == 0 {
			return 1
		}
		return mul3(fact[n], ifact[n-r], ifact[r], p)
	}
	return
}

func mul(a, b, p int) int {
	return int(int64(a) * int64(b) % int64(p))
}

func mul3(a, b, c, p int) int {
	return int(int64(a) * int64(b) % int64(p) * int64(c) % int64(p))
}

func mulm(a, b int, rest ...int) int {
	n := len(rest) - 1
	p := int64(rest[n])
	rest = rest[:n]
	res := int64(a) * int64(b) % p
	for _, v := range rest {
		res = res * int64(v) % p
	}

	return int(res)
}

func div(n, d, p int) int {
	return mul(n, inv(d, p), p)
}

func inv(a, p int) int {
	return exp(a, p-2, p)
}

func exp(n, e, p int) int {
	if e == 0 {
		return 1
	}
	if e&1 == 1 {
		return mul(n, exp(n, e-1, p), p)
	} else {
		return square(exp(n, e/2, p), p)
	}
}

func square(a, p int) int {
	return mul(a, a, p)
}

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

// 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"
    "bufio"
    "os"
    "strconv"
    "math"
    )

const c_max = 1000000

func check(x int64, is_prime []bool) string {
    if x < 4 {
        return "NO"
    }

    var sqrt int64
    sqrt = int64(math.Sqrt(float64(x)))
    if sqrt * sqrt != x {
        return "NO"
    }

    if is_prime[sqrt] {
        return "YES"
    }

    return "NO"
}

func init_prime(is_prime []bool) {
    for i := 0; i <= c_max; i++ {
        is_prime[i] = true
    }

    sq := int(math.Sqrt(float64(c_max))) + 1
    for i := 2; i <= sq; i++ {
        if is_prime[i] {
            for j := 2; j <= c_max/i; j++ {
                is_prime[i*j] = false
            }
        }
    }
}

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

    is_prime := make([]bool, c_max+1, c_max+1)
    init_prime(is_prime)

    bs := bufio.NewScanner(os.Stdin)
    bs.Split(bufio.ScanWords)
    for i := 0; i < n; i++ {
        bs.Scan()
        x, _ := strconv.ParseInt(bs.Text(), 10, 64)
        fmt.Println(check(x, is_prime))
    }
}

package main

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

const MAXN int = 1000005

func main() {

	var n int
	fmt.Scan(&n)

	arr := make([]bool, MAXN)
	for i:=2;i*i<MAXN;i++ {
		for j:=i*i;j<MAXN;j+=i {
			arr[j] = true
		}
	}
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	for i:=0;i<n;i++ {
		var x = readInt64(scanner)
		if x == 1 {
			writer.WriteString("NO\n")
			continue
		}
		sqrt := int64(math.Sqrt(float64(x)))
		if !arr[sqrt] && sqrt*sqrt == x{
			writer.WriteString("YES\n")
		} else {
			writer.WriteString("NO\n")
		}
	}
	writer.Flush()

}
func readInt64(scanner *bufio.Scanner) int64 {
	scanner.Scan()
	value, _ := strconv.ParseInt(scanner.Text(),10,64)
	return value
}

package main

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

func main() {

	//sieve of Atkin
	const N = 1000002
	var x, y, n int
	nsqrt := math.Sqrt(float64(N))

	isPrime := [N]bool{}

	for x = 1; float64(x) <= nsqrt; x++ {
		for y = 1; float64(y) <= nsqrt; y++ {
			n = 4*(x*x) + y*y
			if n <= N && (n%12 == 1 || n%12 == 5) {
				isPrime[n] = !isPrime[n]
			}
			n = 3*(x*x) + y*y
			if n <= N && n%12 == 7 {
				isPrime[n] = !isPrime[n]
			}
			n = 3*(x*x) - y*y
			if x > y && n <= N && n%12 == 11 {
				isPrime[n] = !isPrime[n]
			}
		}
	}

	for n = 5; float64(n) <= nsqrt; n++ {
		if isPrime[n] {
			for y = n * n; y < N; y += n * n {
				isPrime[y] = false
			}
		}
	}

	isPrime[2] = true
	isPrime[3] = true

	// primes is now a slice that contains all primes numbers up to N
	var nn int

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

	fmt.Scan(&nn)
	for i := 0; i < nn; i++ {
		for scanner.Scan() {
			if scanner.Text() != "" {
				break
			}
		}
		vl, _ := strconv.ParseInt(scanner.Text(), 10, 64)

		sqt := int64(math.Sqrt(float64(vl)))

		if sqt*sqt == vl {

			if isPrime[sqt] {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		} else {
			fmt.Println("NO")
		}
	}
}

package main

//import "fmt"
import "math"
import "os"
import "bufio"
import "strconv"

var Sieve []bool

func tPrime(a int64) bool {
	if a == 1 {
		return false
	}
	r := int64(math.Sqrt(float64(a)))
	return r * r == a && Sieve[int(r)]
}

func sieve(n int) []bool {
	sieve := make([]bool, n)
	sieve[2] = true
	for i := 3; i < n; i += 2 {
		sieve[i] = true
	}
	for i := 2; i * i <= n; i++ {
		if sieve[i] {
			for j := i * i; j < n; j += i {
				sieve[j] = false
			}
		}
	}
	return sieve
}

func main() {
	fastio := NewFastIO()
	Sieve = sieve(1e6 + 1)
	n := fastio.NextInt()
	for i := 0; i < n; i++ {
		a := fastio.NextInt64()
		if tPrime(a) {
			fastio.WriteString("YES\n")
		} else {
			fastio.WriteString("NO\n")
		}
	}
	fastio.Flush()
}

//=========================
// FastIO
//=========================
type FastIO struct {
	*bufio.Writer
	scanner *bufio.Scanner
}

func NewFastIO() *FastIO {
	ret := new(FastIO)
	ret.scanner = bufio.NewScanner(os.Stdin)
	ret.scanner.Split(bufio.ScanWords)
	ret.Writer = bufio.NewWriter(os.Stdout)
	return ret
}

func (p *FastIO) NextInt() int {
	p.scanner.Scan()
	a, _ := strconv.ParseInt(p.scanner.Text(),10,64)
	return int(a)
}

func (p *FastIO) NextInt64() int64 {
	p.scanner.Scan()
	a, _ := strconv.ParseInt(p.scanner.Text(),10,64)
	return a
}

package main

import "fmt"
import "math"
import "os"
import "bufio"
import "strconv"

var sieve = make([]bool, 1e6 + 1)

func isPrime(a int32) bool {
	return !sieve[a]
}

func tPrime(a int64) bool {
	if a == 1 {
		return false
	}
	r := int64(math.Sqrt(float64(a)))
	return r * r == a && isPrime(int32(r))
}

func calc_sieve() {
	n := len(sieve)
	sieve[0] = true
	sieve[1] = true
	for i := 2; i * i <= n; i++ {
		if !sieve[i] {
			for j := i * i; j < n; j += i {
				sieve[j] = true
			}
		}
	}
}

func main() {
	calc_sieve()
	var n int
	fmt.Scan(&n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	for i := 0; i < n; i++ {
		for scanner.Scan() {
		    if scanner.Text() != "" { break }
		}
		a, _ := strconv.ParseInt(scanner.Text(),10,64)
		if tPrime(a) {
			writer.WriteString("YES\n")
		} else {
			writer.WriteString("NO\n")
		}
	}
	writer.Flush()
}

package main

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

func toInt(buf []byte) (n int64) {
	for _, v := range buf {
		n = n*10 + int64(v-'0')
	}
	return
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	d := bufio.NewWriter(os.Stdout)
	defer d.Flush()
	scanner.Scan()
	n := int(toInt(scanner.Bytes()))
	numbers := make([]int64, n)
	var max int64
	for i := 0; i < n; i++ {
		scanner.Scan()
		temp := toInt(scanner.Bytes())
		if temp > max {
			max = temp
		}
		numbers[i] = temp
	}
	primes := make([]bool, int(math.Sqrt(float64(max))) + 1)
	primes[0], primes[1] = true, true
	length := len(primes)
	for i := 2; i * i < length; i++ {
		if !primes[i] {
			for j := i; j * i < length; j++ {
				primes[j * i] = true
			}
		}
	}
	for _, number := range numbers {
		r := int64(math.Sqrt(float64(number)))
		if number != 1 &&  r * r == number && !primes[r] {
			d.WriteString("YES\n")
		}else {
			d.WriteString("NO\n")
		}
	}
}

package main

//import "fmt"
import "math"
import "os"
import "bufio"
import "strconv"

var Sieve []bool

func tPrime(a int64) bool {
	if a == 1 {
		return false
	}
	r := int64(math.Sqrt(float64(a)))
	return r * r == a && Sieve[int(r)]
}

func sieve(n int) []bool {
	sieve := make([]bool, n)
	sieve[2] = true
	for i := 3; i < n; i += 2 {
		sieve[i] = true
	}
	for i := 2; i * i <= n; i++ {
		if sieve[i] {
			for j := i * i; j < n; j += i {
				sieve[j] = false
			}
		}
	}
	return sieve
}

func main() {
	fastio := NewFastIO()
	Sieve = sieve(1e6 + 1)
	n := fastio.NextInt()
	for i := 0; i < n; i++ {
		a := fastio.NextInt64()
		if tPrime(a) {
			fastio.WriteString("YES\n")
		} else {
			fastio.WriteString("NO\n")
		}
	}
	fastio.Flush()
}

type FastIO struct {
	*bufio.Writer
	scanner *bufio.Scanner
}

func NewFastIO() *FastIO {
	ret := new(FastIO)
	ret.scanner = bufio.NewScanner(os.Stdin)
	ret.scanner.Split(bufio.ScanWords)
	ret.Writer = bufio.NewWriter(os.Stdout)
	return ret
}

func (p *FastIO) NextInt() int {
	p.scanner.Scan()
	a, _ := strconv.ParseInt(p.scanner.Text(),10,64)
	return int(a)
}

func (p *FastIO) NextInt64() int64 {
	p.scanner.Scan()
	a, _ := strconv.ParseInt(p.scanner.Text(),10,64)
	return a
}

// https://codeforces.com/contest/230/problem/B

package main

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

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

func main() {
	defer writer.Flush()

	var prime [1000005]bool
	for i := range prime {
		if (i!=1) {
			prime[i] = true
		}
	}

	for i:=2;i*i<=1000000;i++ {
		if (prime[i]) {
			for j:=i*i;j<=1000000;j+=i {
				prime[j] = false;
			}
		}
	}

	var n int
	scanf("%d\n", &n)
	for i:=0;i<n;i++ {
		var temp int64
		scanf("%d ", &temp)
		var sTemp int64 = int64(math.Sqrt(float64(temp)))
		if (sTemp * sTemp == temp) && prime[sTemp] {
			printf("%s\n", "YES")
		} else {
			printf("%s\n", "NO")
		}
	}
}

package main

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

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

func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)
	prime := make([]bool, 1000001)
	Tprime := make(map[int64]bool)
	for i := 2; i <= 1000000; i++ {
		if !prime[i] {
			a := int64(i) * int64(i)
			Tprime[a] = true
			for a <= 1000000 {
				prime[a] = true
				a += int64(i)
			}
		}
	}
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		for scanner.Scan() {
			if scanner.Text() != "" {
				break
			}
		}
		x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
		if Tprime[x] == true {
			writer.WriteString("YES\n")
		} else {
			writer.WriteString("NO\n")
		}
	}

}

package main

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

// Square root of maximum number we can encounter
const LIMIT_ROOT = 1000000

var is_prime []bool

func sieve() {
	// Initialize all numbers upto 10**6 to true, i.e. prime
	is_prime = make([]bool, LIMIT_ROOT+1)
	// for i := 0; i <= LIMIT_ROOT; i++ {
	//	is_prime[i] = true
	// }

	p_square := 4
	for p := 2; p_square <= LIMIT_ROOT; p++ {
		if !is_prime[p] {
			for mul := p * p; mul <= LIMIT_ROOT; mul += p {
				is_prime[mul] = true
			}
		}
		p_square += 2*p + 1
	}
}

func main() {
	sieve()
	reader := bufio.NewReaderSize(os.Stdin, 1024*1024)
	var tc int
	var n int64
	fmt.Fscanf(reader, "%d\n", &tc)

	for i := 0; i < tc; i++ {
		fmt.Fscanf(reader, "%d", &n)
		if n <= 3 {
			fmt.Println("NO")
			continue
		}
		root := int64(math.Sqrt(float64(n)))
		if root*root != n || is_prime[root] {
			fmt.Println("NO")
			continue
		}
		fmt.Println("YES")
	}
}

package main

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

const INF  = 1000000001

type Pair struct {
	first, second int
}

func sort(arr []Pair) []Pair {
	if len(arr) < 2 {
		return arr
	}
	left := 0
	right := len(arr) - 1
	pivot := rand.Int() % len(arr)

	arr[pivot], arr[right] = arr[right], arr[pivot]

	for i := 0; i < len(arr); i++ {
		if arr[i].first > arr[right].first {
			arr[i], arr[left] = arr[left], arr[i]
			left++
		}
	}

	arr[left], arr[right] = arr[right], arr[left]

	sort(arr[:left])
	sort(arr[left+1:])
	return arr
}

func sort2(arr []int) []int {
	if len(arr) < 2 {
		return arr
	}
	left := 0
	right := len(arr) - 1
	pivot := rand.Int() % len(arr)

	arr[pivot], arr[right] = arr[right], arr[pivot]

	for i := 0; i < len(arr); i++ {
		if arr[i] < arr[right] {
			arr[i], arr[left] = arr[left], arr[i]
			left++
		}
	}

	arr[left], arr[right] = arr[right], arr[left]

	sort2(arr[:left])
	sort2(arr[left+1:])
	return arr
}

func gcd (a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd (b, a % b);
}

func solution(reader io.Reader, writer io.Writer) {
	p := make([]bool, 1000001)
	p[0] = true
	p[1] = true
	for i := int64(2); i < 1000001; i++ {
		if !p[i] {
			for j := i * i; j < 1000001; j+=i {
				p[j] = true
			}
		}
	}
	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	for i := 0; i < n; i++ {
		var a int64
		fmt.Fscanf(reader, "%d", &a)
		m := int64(math.Sqrt(float64(a)))
		if m * m == a && !p[m] {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func main() {

	//stdin, err := os.Open("file.in")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("file.out")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)
	defer writer.Flush()

	solution(reader, writer)
}

package main

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

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

const MAX = 1000000

func main() {
	var n int;
	var a int64;

	nonPrime := make([]bool, MAX+1)
	tprime := make(map[int64]bool)

	nonPrime[0], nonPrime[1] = true, true
	for i := 2; i*i <= MAX; i++ {
		if !nonPrime[i] {
			for j := i*i; j <= MAX; j+=i {
				nonPrime[j] = true
			}
		}
	}

	for i := 2; i < MAX; i++ {
		if !nonPrime[i] {
			tprime[int64(i)*int64(i)] = true
		}
	}

	scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		scanf("%d", &a)
		if tprime[a] {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"math"
)

const MAXN int = 1000005

func main() {

	var n int
	fmt.Scan(&n)
	arr := make([]bool, MAXN)
	for i:=2;i*i<MAXN;i++ {
		for j:=i*i;j<MAXN;j+=i {
			arr[j] = true
		}
	}
	for i:=0;i<n;i++ {
		var x int64
		fmt.Scan(&x)
		sqrt := int64(math.Sqrt(float64(x)))
		if !arr[sqrt] && sqrt*sqrt == x{
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

package main

import (
	"fmt"
)

func main() {

	var n int
	fmt.Scan(&n)
	for i:=0; i<n;i++ {
		var number int
		fmt.Scan(&number)
		if checkTPrime(number) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func checkTPrime(number int) bool {
	var i int = 2
	for ;i*i<number;i++ {
		if number % i == 0 {
			return false
		}
	}
	if i*i == number {
		return true
	}
	return false
}

package main

import "fmt"
import "math"

func tPrime(a int64) bool {
	if a == 1 {
		return false
	}
	r := int64(math.Sqrt(float64(a)))
	return r * r == a
}

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a int64
		fmt.Scan(&a)
		if tPrime(a) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func toInt(buf []byte) (n int64) {
	for _, v := range buf {
		n = n*10 + int64(v-'0')
	}
	return
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	d := bufio.NewWriter(os.Stdout)
	defer d.Flush()
	scanner.Scan()
firstLoop:	for scanner.Scan() {
		num := toInt(scanner.Bytes())
		if num == 1 {
			d.WriteString("NO\n")
			continue
		}
		i := math.Sqrt(float64(num))
		if i == math.Floor(i) {
			for j := 2; j < int(i); j++ {
				if num % int64(j) == 0 {
					d.WriteString("No\n")
					continue firstLoop
				}
			}
			d.WriteString("YES\n")
		}else {
			d.WriteString("NO\n")
		}
	}
}

package main

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

func toInt(buf []byte) (n int64) {
	for _, v := range buf {
		n = n*10 + int64(v-'0')
	}
	return
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	d := bufio.NewWriter(os.Stdout)
	defer d.Flush()
	scanner.Scan()
firstLoop:	for scanner.Scan() {
		num := toInt(scanner.Bytes())
		i := math.Sqrt(float64(num))
		if i == math.Floor(i) {
			for j := 2; j < int(i); j++ {
				if num % int64(j) == 0 {
					d.WriteString("No\n")
					continue firstLoop
				}
			}
			d.WriteString("YES\n")
		}else {
			d.WriteString("NO\n")
		}
	}
}

package main

import (
	"fmt"
	"math"
)

const (
	MAX = 1e6 + 1
)

func main() {
	sieve := make([]bool, 1e6+1)
	sieve[0] = false
	sieve[1] = false
	sieve [2] = true
	for i := 3; i < MAX; i += 2 {
		sieve[i] = true
	}
	for i := 2; i * i <= MAX; i++ {
		if sieve[i] {
			for j := i * i; j < MAX; j += i {
				sieve[j] = false
			}
		}
	}

	var n int64
	fmt.Scanf("%d", &n)
	var j int64
	for j=0;j< n;j++{
		var number int64
		fmt.Scanf("%d", &number)
		if number == 1 {
			fmt.Println("NO")
		}
		r := int64(math.Sqrt(float64(number)))
		if r*r == number && sieve[r]{
			fmt.Println("YES")
		}else {
			fmt.Println("NO")
		}
	}

}

package main

import (
	"fmt"
)

func main() {
	var n int64
	fmt.Scanf("%d", &n)
	scanNumber := make([]int64, 100000)
	var k int64
	for k =0;k<n;k++{
		fmt.Scanf("%d", &scanNumber[k])
	}
	numbers := make([]int64, 100000)
	var max int64
	for k=0;k<n;k++{
		if scanNumber[k] > max{
			max = scanNumber[k]
		}
	}
	var i int64
	numbers[0] = 0
	numbers[1] = 0
	numbers [2] = 1
	for i = 2;i<max;i++{
		numbers[i] = 1
	}
	for i = 2;i< max;i++{
		mul := i*2
		if mul <= max {
			numbers[mul]+=2
		}
	}
	var j int64
	for j=0;j<n;j++ {
		if numbers[scanNumber[j]] == 3{
			fmt.Println("YES")
		}else {
			fmt.Println("NO")
		}
	}
}

package main

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

const N = 1000000

func sieveOfAtkins() []int {
	var x, y, n int
	nSqrt := math.Sqrt(N)

	isPrime := [N]bool{}

	for x = 1; float64(x) <= nSqrt; x++ {
		for y = 1; float64(y) <= nSqrt; y++ {
			n = 4*(x*x) + y*y
			if n <= N && (n%12 == 1 || n%12 == 5) {
				isPrime[n] = !isPrime[n]
			}
			n = 3*(x*x) + y*y
			if n <= N && n%12 == 7 {
				isPrime[n] = !isPrime[n]
			}
			n = 3*(x*x) - y*y
			if x > y && n <= N && n%12 == 11 {
				isPrime[n] = !isPrime[n]
			}
		}
	}

	for n = 5; float64(n) <= nSqrt; n++ {
		if isPrime[n] {
			for y = n*n; y < N; y += n*n {
				isPrime[y] = false
			}
		}
	}

	isPrime[2] = true
	isPrime[3] = true

	primes := make([]int, 0, 1270606)
	for x = 0; x < len(isPrime)-1; x++ {
		if isPrime[x] {
			primes = append(primes, x)
		}
	}
	return primes
}

func main() {
	primes := sieveOfAtkins()
	var n int
	r := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscanf(r, "%d\n", &n)
	arr := make([]float64, n, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(r, "%f", &arr[i])
	}
	for _, element := range arr {
		elementSqrt := math.Sqrt(element)
		left := -1
		right := n
		for right > left + 1 {
			middle := (left + right) / 2
			if float64(primes[middle]) > elementSqrt {
				right = middle
			} else {
				left = middle
			}
		}
		if left >= 0 && float64(primes[left]) == elementSqrt {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    writer := bufio.NewWriter(os.Stdout)
    prime := make([]bool,1000001)
    Tprime := make(map[int64]bool)
    for i := 2; i <= 1000000; i++ {
        if !prime[i] {
            a := int64(i)*int64(i)
            Tprime[a] = true
            for a <= 1000000 {
                prime[a] = true
                a += int64(i)
            }
        }
    }
    var n int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        for scanner.Scan() {
            if scanner.Text() != "" { break }
        }
        tx, _ := strconv.Atoi(scanner.Text())
        x := int64(tx)
        if Tprime[x] == true {
            writer.WriteString("YES\n")
        } else {
            writer.WriteString("NO\n")
        }
    }
    writer.Flush()
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    writer := bufio.NewWriter(os.Stdout)
    prime := make([]bool,1000001)
    Tprime := make(map[int64]bool)
    for i := 2; i <= 1000000; i++ {
        if !prime[i] {
            a := int64(i)*int64(i)
            Tprime[a] = true
            for a <= 1000000 {
                prime[a] = true
                a += int64(i)
            }
        }
    }
    var n int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        scanner.Scan()
        tx, _ := strconv.Atoi(scanner.Text())
        x := int64(tx)
        if Tprime[x] == true {
            writer.WriteString("YES\n")
        } else {
            writer.WriteString("NO\n")
        }
    }
    writer.Flush()
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    writer := bufio.NewWriter(os.Stdout)
    prime := make([]bool,1000001)
    Tprime := make(map[int64]bool)
    for i := 2; i <= 1000000; i++ {
        if !prime[i] {
            a := int64(i)*int64(i)
            Tprime[a] = true
            for a <= 1000000 {
                prime[a] = true
                a += int64(i)
            }
        }
    }
    var n int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        scanner.Scan()
        tx, _ := strconv.Atoi(scanner.Text())
        x := int64(tx)
        fmt.Println(x)
        if Tprime[x] == true {
            writer.WriteString("YES\n")
        } else {
            writer.WriteString("NO\n")
        }
    }
    writer.Flush()
}

package main

import (
	"fmt"
	"math"
)

// Square root of maximum number we can encounter
const LIMIT_ROOT = 1000000
const YES = "YES"
const NO = "NO"

var is_prime []bool

func sieve() {
	// Initialize all numbers upto 10**6 to true, i.e. prime
	is_prime = make([]bool, LIMIT_ROOT+1)
	for i := 0; i <= LIMIT_ROOT; i++ {
		is_prime[i] = true
	}

	p_square := 4
	for p := 2; p_square <= LIMIT_ROOT; p++ {
		for mul := p * 2; mul <= LIMIT_ROOT; mul += p {
			is_prime[mul] = false
		}
		p_square += 2*p + 1
	}
}

func is_t_prime(n int) string {
	if is_prime[n] {
		return NO
	}
	if root := int(math.Sqrt(float64(n))); root*root != n || !is_prime[root] {
		return NO
	}
	return YES
}

func main() {
	sieve()
	var tc, n int
	fmt.Scanln(&tc)
	results := make([]string, tc)
	for i := 0; i < tc; i++ {
		fmt.Scanf("%d", &n)
		results[i] = is_t_prime(n)
	}
	for _, answer := range results {
		fmt.Println(answer)
	}
}

package main

import (
	"fmt"
	"math"
)

// Square root of maximum number we can encounter
const LIMIT_ROOT = 1000000
const YES = "YES"
const NO = "NO"

var is_prime []bool

func sieve() {
	// Initialize all numbers upto 10**6 to true, i.e. prime
	is_prime = make([]bool, LIMIT_ROOT+1)
	for i := 0; i <= LIMIT_ROOT; i++ {
		is_prime[i] = true
	}

	p_square := 4
	for p := 2; p_square <= LIMIT_ROOT; p++ {
		for mul := p * 2; mul <= LIMIT_ROOT; mul += p {
			is_prime[mul] = false
		}
		p_square += 2*p + 1
	}
}

func is_t_prime(n int) string {
	if root := int(math.Sqrt(float64(n))); root*root != n || !is_prime[root] {
		return NO
	}
	return YES
}

func main() {
	sieve()
	var tc, n int
	fmt.Scanln(&tc)
	results := make([]string, tc)
	for i := 0; i < tc; i++ {
		fmt.Scanf("%d", &n)
		results[i] = is_t_prime(n)
	}
	for _, answer := range results {
		fmt.Println(answer)
	}
}

package main

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

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

const MAX = 1000000

func main() {
	var n int;
	var a int64;

	nonPrime := make([]bool, MAX+1)
	tprime := make(map[int64]bool)

	nonPrime[0], nonPrime[1] = true, true
	for i := 2; i*i <= MAX; i++ {
		if !nonPrime[i] {
			for j := i*i; j <= MAX; j+=i {
				nonPrime[j] = true
			}
		}
	}
	for i := 2; i < MAX; i++ {
		if !nonPrime[i] {
			tprime[int64(i*i)] = true
		}
	}

	scanf("%d\n", &n)
	for i:=0; i<n;i++{
		scanf("%d", &a)
		if tprime[a] {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

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

func isprime(n int64) bool{
	for i:= int64(2); i*i < n; i++ {
		if n % i == 0 {
			return false
		}
	}
	return true
}

func sqrt(n int64) int64 {

	if n == int64(1) || n == int64(0){
		return n
	}

	l, r := int64(1), n
	var res int64

	for l <= r {
		res = (l+r)/2

		switch {
		case res*res == n:
			return res
		case res*res < n:
			l = res + 1
		default:
			r = res - 1
		}
	}

	return res
}

func count ( n int64 ) {
	sq := sqrt(n)
	if sq*sq != n {
		fmt.Println("NO")
		return
	}

	if isprime(sq){
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

func main() {
	var n int;
	var a int64;
	scanf("%d\n", &n)
	for i:=0; i<n;i++{
		scanf("%d", &a)
		count(a)
	}
}

package main

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

var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

var n int

// IsPrime 素性测试
func IsPrime(n int64) bool {
	for i := int64(2); i*i < n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return n != 1
}

func main() {
	fmt.Fscan(reader, &n)
	m := make(map[int64]bool)
	for i := int64(2); i <= 1e5; i++ {
		if IsPrime(i) {
			m[i] = true
		}
	}

	for ; n != 0; n-- {
		var a int64
		fmt.Fscan(reader, &a)
		b := int64(math.Sqrt(float64(a)))
		if b*b == a && m[b] {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

var n int

// IsPrime 素性测试
func IsPrime(n int64) bool {
	for i := int64(2); i*i < n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return n != 1
}

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

	for ; n != 0; n-- {
		var a int64
		fmt.Fscan(reader, &a)
		b := int64(math.Sqrt(float64(a)))
		if b*b == a && IsPrime(b) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func check(x int64) string {
    if x < 4 {
        return "NO"
    }

    var i, sqrt, y int64
    sqrt = int64(math.Sqrt(float64(x)))
    if sqrt * sqrt != x {
        return "NO"
    }

    y = int64(math.Sqrt(float64(sqrt)))
    for i = 2; i < y; i++ {
        if y % i == 0 {
            return "NO"
        }
    }
    return "YES"
}

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

    bs := bufio.NewScanner(os.Stdin)
    bs.Split(bufio.ScanWords)
    for i := 0; i < n; i++ {
        bs.Scan()
        x, _ := strconv.ParseInt(bs.Text(), 10, 64)
        fmt.Println(check(x))
    }
}

package main

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

func check(x int64) string {
    if x < 4 {
        return "NO"
    }

    var i, sqrt, y int64
    sqrt = int64(math.Sqrt(float64(x)))
    if sqrt * sqrt != x {
        return "NO"
    }

    y = int64(math.Sqrt(float64(sqrt)))
    for i = 2; i <= y; i++ {
        if y % i == 0 {
            return "NO"
        }
    }
    return "YES"
}

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

    bs := bufio.NewScanner(os.Stdin)
    bs.Split(bufio.ScanWords)
    for i := 0; i < n; i++ {
        bs.Scan()
        x, _ := strconv.ParseInt(bs.Text(), 10, 64)
        fmt.Println(check(x))
    }
}

package main

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

func check(x int64, is_prime []bool) string {
    if x < 4 {
        return "NO"
    }

    var sqrt int64
    sqrt = int64(math.Sqrt(float64(x)))
    if sqrt * sqrt != x {
        return "NO"
    }

    if is_prime[sqrt] {
        return "YES"
    }

    return "NO"
}

func init_prime(is_prime []bool) {
    for i := 0; i < 1000001; i++ {
        is_prime[i] = true
    }
    for i := 2; i < 1001; i++ {
        if is_prime[i] {
            for j := 2; j < 1000001/i; j++ {
                is_prime[i*j] = false
            }
        }
    }
}

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

    is_prime := make([]bool, 1000001, 1000001)
    init_prime(is_prime)

    bs := bufio.NewScanner(os.Stdin)
    bs.Split(bufio.ScanWords)
    for i := 0; i < n; i++ {
        bs.Scan()
        x, _ := strconv.ParseInt(bs.Text(), 10, 64)
        fmt.Println(check(x, is_prime))
    }
}

package main

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

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

	scanner.Scan()
	_ = scanner.Text()
	scanner.Scan()
	ab := scanner.Text()
	var chList []int
	for _, ch := range strings.Split(ab, " ") {
		ch, err := strconv.Atoi(ch)
		if err != nil {
			log.Fatal(err)
		}
		chList = append(chList, ch)
	}
	var del int
	var c int
	for _, ch := range chList {
		chastnoe := 0
		del = ch
		last := 0
		for i := 1; chastnoe != ch; i++ {
			if ch%i != 0 {
				continue
			}
			del = ch / i
			chastnoe = ch / del
			c += 2
			if chastnoe == last || chastnoe == del {
				c = c - 1
				break
			}
			last = del
			if c > 3 {
				break
			}
		}
		if c == 3 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

	}
}

/*
given 3 integer x,y,z
u need to find min p so
that (x + p)/z + (y - p)/z maximizes
where the divisions are ineteger division

solution: the maximum value of (x + p)/z + (y - p)/z  is (x+y)/z

go run a.go
582426543750017 789023129080207 4395672028302
312 2197836014149
*/
package main

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

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

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

const mx = 1001000

var status [(mx / 32) + 2]int //wow mx ke constant hote hobe..go wont take any chances
var n int

var x int64

func on(n int, pos uint) int {
	n = (n | (1 << pos)) //u cannot do return n=soemthing
	return n
}
func check(n int, pos uint) int {
	var res int
	res = (n & (1 << pos)) //wow pos has to be unsigned...go wont take any chances
	return res
}
func sieve() {
	var i, j, sqrtN int
	sqrtN = int(math.Sqrt(float64(mx)))
	status[0] = on(status[0], 1)
	for i = 3; i <= sqrtN; i += 2 { //wow u cant even do for()
		if check(status[i>>5], uint(i&31)) == 0 { //i & 31 => i%32
			for j = i * i; j <= mx; j += (i << 1) { //i << 1 => j += 2*i
				//         //status[j >> 5] is equivalent to status[j/32] but faster
				status[j>>5] = on(status[j>>5], uint(j&31))
			}
		}
	}
}
func numbers(s string) []int64 {
	var n []int64
	for _, f := range strings.Fields(s) {
		i, err := strconv.ParseInt(f, 10, 64)
		if err == nil {
			n = append(n, i)
		}
	}
	return n
}
func main() {
	defer writer.Flush()
	var num []int64
	sieve()
	scanf("%d", &n)
	writer.Flush()
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	writer.Flush()
	num = numbers(scanner.Text())
	// for i := 1; i <= n; i++ { //wow u cant static declare variable in for loop but can dynamic declare
	// 	scanf("%d", &num[i])
	// }

	// for i := 0; i < len(num); i++ {
	// 	printf("%d\n", num[i])
	// }
	if len(num) == 0 {
		printf("SUCKER\n")
	}
	for i := 0; i < len(num); i++ {
		x = int64(math.Sqrt(float64(num[i])))

		if num[i] == 4 {
			printf("YES\n")
		} else if (num[i]%2 != 0) && x*x == num[i] && check(status[x>>5], uint(x&31)) == 0 {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
	}

}

/*
given 3 integer x,y,z
u need to find min p so
that (x + p)/z + (y - p)/z maximizes
where the divisions are ineteger division

solution: the maximum value of (x + p)/z + (y - p)/z  is (x+y)/z

go run a.go
582426543750017 789023129080207 4395672028302
312 2197836014149

10
10
9
8
7
6
5
4
3
2
1
*/
package main

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

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

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

const mx = 1001000

var status [(mx / 32) + 2]int //wow mx ke constant hote hobe..go wont take any chances
var n int

var x int64

func on(n int, pos uint) int {
	n = (n | (1 << pos)) //u cannot do return n=soemthing
	return n
}
func check(n int, pos uint) int {
	var res int
	res = (n & (1 << pos)) //wow pos has to be unsigned...go wont take any chances
	return res
}
func sieve() {
	var i, j, sqrtN int
	sqrtN = int(math.Sqrt(float64(mx)))
	status[0] = on(status[0], 1)
	for i = 3; i <= sqrtN; i += 2 { //wow u cant even do for()
		if check(status[i>>5], uint(i&31)) == 0 { //i & 31 => i%32
			for j = i * i; j <= mx; j += (i << 1) { //i << 1 => j += 2*i
				//         //status[j >> 5] is equivalent to status[j/32] but faster
				status[j>>5] = on(status[j>>5], uint(j&31))
			}
		}
	}
}
func numbers(s string) []int64 {
	var n []int64
	for _, f := range strings.Fields(s) {
		i, err := strconv.ParseInt(f, 10, 64)
		if err == nil {
			n = append(n, i)
		}
	}
	return n
}
func ehhe(s string) []int64 {
	var n []int64
	for _, f := range strings.Fields(s) {
		i, err := strconv.ParseInt(f, 10, 64)
		if err == nil {
			n = append(n, i)
		}
	}
	return n
}

func main() {
	defer writer.Flush()
	var num [mx]int64
	sieve()
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	n, err := strconv.Atoi(scanner.Text())
	if err != nil {

	}
	for i := 0; i < n; i++ {
		scanner.Scan()
		w, err := strconv.ParseInt(scanner.Text(), 10, 64)
		num[i] = w
		if err != nil {

		}
	}

	// for i := 0; i < len(num); i++ {
	// 	printf("%d\n", num[i])
	// }

	// reader := bufio.NewReader(os.Stdin)
	// text, _ := reader.ReadString('\n')
	// num = numbers(text)

	if len(num) == 0 {
		printf("SUCKER\n")
	}
	for i := 0; i < n; i++ {
		x = int64(math.Sqrt(float64(num[i])))

		if num[i] == 4 {
			printf("YES\n")
		} else if (num[i]%2 != 0) && x*x == num[i] && check(status[x>>5], uint(x&31)) == 0 {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
	}

}

/*
given 3 integer x,y,z
u need to find min p so
that (x + p)/z + (y - p)/z maximizes
where the divisions are ineteger division

solution: the maximum value of (x + p)/z + (y - p)/z  is (x+y)/z

go run a.go
582426543750017 789023129080207 4395672028302
312 2197836014149
*/
package main

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

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

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

const mx = 1001000

var status [(mx / 32) + 2]int //wow mx ke constant hote hobe..go wont take any chances
var n int

var x int64

func on(n int, pos uint) int {
	n = (n | (1 << pos)) //u cannot do return n=soemthing
	return n
}
func check(n int, pos uint) int {
	var res int
	res = (n & (1 << pos)) //wow pos has to be unsigned...go wont take any chances
	return res
}
func sieve() {
	var i, j, sqrtN int
	sqrtN = int(math.Sqrt(float64(mx)))
	status[0] = on(status[0], 1)
	for i = 3; i <= sqrtN; i += 2 { //wow u cant even do for()
		if check(status[i>>5], uint(i&31)) == 0 { //i & 31 => i%32
			for j = i * i; j <= mx; j += (i << 1) { //i << 1 => j += 2*i
				//         //status[j >> 5] is equivalent to status[j/32] but faster
				status[j>>5] = on(status[j>>5], uint(j&31))
			}
		}
	}
}
func numbers(s string) []int64 {
	var n []int64
	for _, f := range strings.Fields(s) {
		i, err := strconv.ParseInt(f, 10, 64)
		if err == nil {
			n = append(n, i)
		}
	}
	return n
}
func main() {
	defer writer.Flush()
	var num []int64
	sieve()
	scanf("%d", &n)
	writer.Flush()
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	writer.Flush()
	num = numbers(scanner.Text())
	// for i := 1; i <= n; i++ { //wow u cant static declare variable in for loop but can dynamic declare
	// 	scanf("%d", &num[i])
	// }

	// for i := 0; i < len(num); i++ {
	// 	printf("%d\n", num[i])
	// }

	for i := 0; i < len(num); i++ {
		x = int64(math.Sqrt(float64(num[i])))

		if num[i] == 4 {
			printf("YES\n")
		} else if (num[i]%2 != 0) && x*x == num[i] && check(status[x>>5], uint(x&31)) == 0 {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
	}

}

/*
given 3 integer x,y,z
u need to find min p so
that (x + p)/z + (y - p)/z maximizes
where the divisions are ineteger division

solution: the maximum value of (x + p)/z + (y - p)/z  is (x+y)/z

go run a.go
582426543750017 789023129080207 4395672028302
312 2197836014149
*/
package main

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

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

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

const mx = 1001000

var status [(mx / 32) + 2]int //wow mx ke constant hote hobe..go wont take any chances
var n int

var x int64

func on(n int, pos uint) int {
	n = (n | (1 << pos)) //u cannot do return n=soemthing
	return n
}
func check(n int, pos uint) int {
	var res int
	res = (n & (1 << pos)) //wow pos has to be unsigned...go wont take any chances
	return res
}
func sieve() {
	var i, j, sqrtN int
	sqrtN = int(math.Sqrt(float64(mx)))
	status[0] = on(status[0], 1)
	for i = 3; i <= sqrtN; i += 2 { //wow u cant even do for()
		if check(status[i>>5], uint(i&31)) == 0 { //i & 31 => i%32
			for j = i * i; j <= mx; j += (i << 1) { //i << 1 => j += 2*i
				//         //status[j >> 5] is equivalent to status[j/32] but faster
				status[j>>5] = on(status[j>>5], uint(j&31))
			}
		}
	}
}
func numbers(s string) []int64 {
	var n []int64
	for _, f := range strings.Fields(s) {
		i, err := strconv.ParseInt(f, 10, 64)
		if err == nil {
			n = append(n, i)
		}
	}
	return n
}
func main() {
	defer writer.Flush()
	var num []int64
	sieve()
	scanf("%d", &n)
	//writer.Flush()
	//scanner := bufio.NewScanner(os.Stdin)
	//scanner.Scan()
	//writer.Flush()
	//num = numbers(scanner.Text())
	// for i := 1; i <= n; i++ { //wow u cant static declare variable in for loop but can dynamic declare
	// 	scanf("%d", &num[i])
	// }

	// for i := 0; i < len(num); i++ {
	// 	printf("%d\n", num[i])
	// }

	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	num = numbers(text)

	if len(num) == 0 {
		printf("SUCKER\n")
	}
	for i := 0; i < len(num); i++ {
		x = int64(math.Sqrt(float64(num[i])))

		if num[i] == 4 {
			printf("YES\n")
		} else if (num[i]%2 != 0) && x*x == num[i] && check(status[x>>5], uint(x&31)) == 0 {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
	}

}

/*
given 3 integer x,y,z
u need to find min p so
that (x + p)/z + (y - p)/z maximizes
where the divisions are ineteger division

solution: the maximum value of (x + p)/z + (y - p)/z  is (x+y)/z

go run a.go
582426543750017 789023129080207 4395672028302
312 2197836014149
*/
package main

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

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

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

const mx = 1001000

var status [(mx / 32) + 2]int //wow mx ke constant hote hobe..go wont take any chances
var n int

var x int64

func on(n int, pos uint) int {
	n = (n | (1 << pos)) //u cannot do return n=soemthing
	return n
}
func check(n int, pos uint) int {
	var res int
	res = (n & (1 << pos)) //wow pos has to be unsigned...go wont take any chances
	return res
}
func sieve() {
	var i, j, sqrtN int
	sqrtN = int(math.Sqrt(float64(mx)))
	status[0] = on(status[0], 1)
	for i = 3; i <= sqrtN; i += 2 { //wow u cant even do for()
		if check(status[i>>5], uint(i&31)) == 0 { //i & 31 => i%32
			for j = i * i; j <= mx; j += (i << 1) { //i << 1 => j += 2*i
				//         //status[j >> 5] is equivalent to status[j/32] but faster
				status[j>>5] = on(status[j>>5], uint(j&31))
			}
		}
	}
}
func numbers(s string) []int64 {
	var n []int64
	for _, f := range strings.Fields(s) {
		i, err := strconv.ParseInt(f, 10, 64)
		if err == nil {
			n = append(n, i)
		}
	}
	return n
}
func main() {
	defer writer.Flush()
	var num []int64
	sieve()
	scanf("%d", &n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	num = numbers(scanner.Text())
	// for i := 1; i <= n; i++ { //wow u cant static declare variable in for loop but can dynamic declare
	// 	scanf("%d", &num[i])
	// }

	// for i := 0; i < len(num); i++ {
	// 	printf("%d\n", num[i])
	// }

	for i := 0; i < len(num); i++ {
		x = int64(math.Sqrt(float64(num[i])))

		if num[i] == 4 {
			printf("YES\n")
		} else if (num[i]%2 != 0) && x*x == num[i] && check(status[x>>5], uint(x&31)) == 0 {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
	}

}

package main

import (
	"fmt"
	"math"
)

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

	for i := 0; i < n; i++ {
		fmt.Scan(&a)

		val := int(math.Sqrt(float64(a)))
		if math.Pow(float64(val), 2) == float64(a) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

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

	for i := 0; i < n; i++ {
		fmt.Scan(&a)

		val := int(math.Sqrt(float64(a)))
		val1 := big.NewInt(int64(val))
		if a != 1 && math.Pow(float64(val), 2) == float64(a) && val1.ProbablyPrime(5) == true {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"math"
)

func main() {

	//sieve of Atkin
	const N = 1000000
	var x, y, n int
	nsqrt := math.Sqrt(float64(N))

	is_prime := [N + 1]bool{}

	for x = 1; float64(x) <= nsqrt; x++ {
		for y = 1; float64(y) <= nsqrt; y++ {
			n = 4*(x*x) + y*y
			if n <= N && (n%12 == 1 || n%12 == 5) {
				is_prime[n] = !is_prime[n]
			}
			n = 3*(x*x) + y*y
			if n <= N && n%12 == 7 {
				is_prime[n] = !is_prime[n]
			}
			n = 3*(x*x) - y*y
			if x > y && n <= N && n%12 == 11 {
				is_prime[n] = !is_prime[n]
			}
		}
	}

	for n = 5; float64(n) <= nsqrt; n++ {
		if is_prime[n] {
			for y = n * n; y < N; y += n * n {
				is_prime[y] = false
			}
		}
	}

	is_prime[2] = true
	is_prime[3] = true

	// primes is now a slice that contains all primes numbers up to N
	var nn int
	var vl int64

	fmt.Scan(&nn)
	for i := 0; i < nn; i++ {
		fmt.Scan(&vl)

		arr := int(math.Sqrt(float64(vl)))

		if int64(arr*arr) == vl {

			if is_prime[arr] {
				fmt.Println("YES")
			} else {
				fmt.Println("NO1")
			}
		} else {
			fmt.Println("NO2")
		}
	}
}

package main

import (
	"fmt"
	"math"
)

func main() {

	//sieve of Atkin
	const N = 1002001
	var x, y, n int
	nsqrt := math.Sqrt(float64(N))

	is_prime := [N + 1]bool{}

	for x = 1; float64(x) <= nsqrt; x++ {
		for y = 1; float64(y) <= nsqrt; y++ {
			n = 4*(x*x) + y*y
			if n <= N && (n%12 == 1 || n%12 == 5) {
				is_prime[n] = !is_prime[n]
			}
			n = 3*(x*x) + y*y
			if n <= N && n%12 == 7 {
				is_prime[n] = !is_prime[n]
			}
			n = 3*(x*x) - y*y
			if x > y && n <= N && n%12 == 11 {
				is_prime[n] = !is_prime[n]
			}
		}
	}

	for n = 5; float64(n) <= nsqrt; n++ {
		if is_prime[n] {
			for y = n * n; y < N; y += n * n {
				is_prime[y] = false
			}
		}
	}

	is_prime[2] = true
	is_prime[3] = true

	// primes is now a slice that contains all primes numbers up to N
	var nn int
	var vl int64

	fmt.Scan(&nn)
	for i := 0; i < nn; i++ {
		fmt.Scan(&vl)

		arr := int(math.Sqrt(float64(vl)))

		if int64(arr*arr) == vl {

			if is_prime[arr] {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"math"
)

func main() {

	//sieve of Atkin
	const N = 1000000
	var x, y, n int
	nsqrt := math.Sqrt(float64(N))

	is_prime := [N + 1]bool{}

	for x = 1; float64(x) <= nsqrt; x++ {
		for y = 1; float64(y) <= nsqrt; y++ {
			n = 4*(x*x) + y*y
			if n <= N && (n%12 == 1 || n%12 == 5) {
				is_prime[n] = !is_prime[n]
			}
			n = 3*(x*x) + y*y
			if n <= N && n%12 == 7 {
				is_prime[n] = !is_prime[n]
			}
			n = 3*(x*x) - y*y
			if x > y && n <= N && n%12 == 11 {
				is_prime[n] = !is_prime[n]
			}
		}
	}

	for n = 5; float64(n) <= nsqrt; n++ {
		if is_prime[n] {
			for y = n * n; y < N; y += n * n {
				is_prime[y] = false
			}
		}
	}

	is_prime[2] = true
	is_prime[3] = true

	// primes is now a slice that contains all primes numbers up to N
	var nn int
	var vl int64

	fmt.Scan(&nn)
	for i := 0; i < nn; i++ {
		fmt.Scan(&vl)

		arr := int(math.Sqrt(float64(vl)))

		if int64(arr*arr) == vl {

			if is_prime[arr] {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {

	//sieve of Atkin
	const N = 1000000
	var x, y, n int
	nsqrt := math.Sqrt(float64(N))

	isPrime := [N]bool{}

	for x = 1; float64(x) <= nsqrt; x++ {
		for y = 1; float64(y) <= nsqrt; y++ {
			n = 4*(x*x) + y*y
			if n <= N && (n%12 == 1 || n%12 == 5) {
				isPrime[n] = !isPrime[n]
			}
			n = 3*(x*x) + y*y
			if n <= N && n%12 == 7 {
				isPrime[n] = !isPrime[n]
			}
			n = 3*(x*x) - y*y
			if x > y && n <= N && n%12 == 11 {
				isPrime[n] = !isPrime[n]
			}
		}
	}

	for n = 5; float64(n) <= nsqrt; n++ {
		if isPrime[n] {
			for y = n * n; y < N; y += n * n {
				isPrime[y] = false
			}
		}
	}

	isPrime[2] = true
	isPrime[3] = true

	primes := make([]int, 0, 1270606)
	for x = 0; x < len(isPrime)-1; x++ {
		if isPrime[x] {
			primes = append(primes, x)
		}
	}

	// primes is now a slice that contains all primes numbers up to N
	var nn int
	var vl int64

	fmt.Scan(&nn)
	for i := 0; i < nn; i++ {
		fmt.Scan(&vl)

		arr := int(math.Sqrt(float64(vl)))

		if int64(arr*arr) == vl {
			ii := sort.Search(len(primes), func(ii int) bool { return primes[ii] >= arr })

			if ii < len(primes) && primes[ii] == arr {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"math"
)

func isPrime(value int) bool {
	if value > 2 && value%2 == 0 {
		return false
	}

	for i := 3; i <= int(math.Floor(math.Sqrt(float64(value)))); i += 2 {
		if value%i == 0 {
			return false
		}
	}
	return value > 1
}

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

	for i := 0; i < n; i++ {
		fmt.Scan(&a)

		val := int(math.Sqrt(float64(a)))
		if math.Pow(float64(val), 2) == float64(a) && isPrime(val) == true {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"math"
)

func main() {

	//sieve of Atkin
	const N = 1000001
	var x, y, n int
	nsqrt := math.Sqrt(float64(N))

	is_prime := [N + 1]bool{}

	for x = 1; float64(x) <= nsqrt; x++ {
		for y = 1; float64(y) <= nsqrt; y++ {
			n = 4*(x*x) + y*y
			if n <= N && (n%12 == 1 || n%12 == 5) {
				is_prime[n] = !is_prime[n]
			}
			n = 3*(x*x) + y*y
			if n <= N && n%12 == 7 {
				is_prime[n] = !is_prime[n]
			}
			n = 3*(x*x) - y*y
			if x > y && n <= N && n%12 == 11 {
				is_prime[n] = !is_prime[n]
			}
		}
	}

	for n = 5; float64(n) <= nsqrt; n++ {
		if is_prime[n] {
			for y = n * n; y < N; y += n * n {
				is_prime[y] = false
			}
		}
	}

	is_prime[2] = true
	is_prime[3] = true

	// primes is now a slice that contains all primes numbers up to N
	var nn int
	var vl int64

	fmt.Scan(&nn)
	for i := 0; i < nn; i++ {
		fmt.Scan(&vl)

		arr := int(math.Sqrt(float64(vl)))

		if int64(arr*arr) == vl {

			if is_prime[arr] {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

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

	for i := 0; i < n; i++ {
		fmt.Scan(&a)

		val := int(math.Sqrt(float64(a)))
		val1 := big.NewInt(int64(val))
		if a != 1 && math.Pow(float64(val), 2) == float64(a) && val1.ProbablyPrime(1) == true {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"math"
)

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

	for i := 0; i < n; i++ {
		fmt.Scan(&a)

		val := int(math.Sqrt(float64(a)))
		if a != 1 && math.Pow(float64(val), 2) == float64(a) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1379C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ a, b int }

	var t, N, m int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &N, &m)
		f := make([]pair, m)
		a := make([]int, m)
		for i := range f {
			Fscan(in, &f[i].a, &f[i].b)
			a[i] = f[i].a
		}
		sort.Slice(f, func(i, j int) bool { a, b := f[i], f[j]; return a.b > b.b || a.b == b.b && a.a > b.a })
		sort.Ints(a)
		ans := int64(0)
		i, sa := m-1, int64(0)
		for _, p := range f {
			for ; N > 0 && i >= 0 && a[i] >= p.b; i-- {
				sa += int64(a[i])
				N--
			}
			n, s := N, sa
			if n > 0 {
				if p.a < p.b {
					s += int64(p.a)
					n--
				}
				s += int64(n) * int64(p.b)
			}
			if s > ans {
				ans = s
			}
		}
		Fprintln(out, ans)
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1379C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ a, b int }

	var t, N, m int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &N, &m)
		f := make([]pair, m)
		for i := range f {
			Fscan(in, &f[i].a, &f[i].b)
		}
		sort.Slice(f, func(i, j int) bool { a, b := f[i], f[j]; return a.b > b.b || a.b == b.b && a.a > b.a })
		f2 := make([]pair, m)
		copy(f2, f)
		sort.Slice(f2, func(i, j int) bool { return f2[i].a > f2[j].a })
		ans := int64(0)
		i, sa := 0, int64(0)
		for _, p := range f {
			for ; N > 0 && i < m && f2[i].a >= p.b; i++ {
				sa += int64(f2[i].a)
				N--
			}
			n, s := N, sa
			if n > 0 {
				if p.a < p.b {
					s += int64(p.a)
					n--
				}
				s += int64(n) * int64(p.b)
			}
			if s > ans {
				ans = s
			}
		}
		Fprintln(out, ans)
	}
}

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

package main

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

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 main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)
	var buf bytes.Buffer
	for tc > 0 {
		tc--
		m, n := readTwoNums(reader)
		F := make([][]int, n)
		for i := 0; i < n; i++ {
			F[i] = readNNums(reader, 2)
		}
		buf.WriteString(fmt.Sprintf("%d\n", solve(m, n, F)))
		if tc > 0 {
			reader.ReadBytes('\n')
		}
	}
	fmt.Print(buf.String())
}

func solve(m, n int, F [][]int) int64 {
	//let iterate i from 0 ~ n, make sure it (only) has more than 1 flowers
	ps := make([]Pair, n)
	for i := 0; i < n; i++ {
		ps[i] = Pair{F[i][0], i}
	}

	sort.Sort(Pairs(ps))

	X := make([]int64, n+1)
	for i := 0; i < n; i++ {
		X[i+1] = X[i] + int64(ps[i].first)
	}
	var ans int64

	if m <= n {
		ans = X[m]
	}

	for i := 0; i < n; i++ {
		cur := F[ps[i].second][1]

		j := sort.Search(n, func(j int) bool {
			return ps[j].first <= cur
		})
		var left = m - j
		if left > 0 {
			tmp := X[j]
			if j <= i {
				tmp += int64(F[ps[i].second][0]) + int64(left-1)*int64(F[ps[i].second][1])
			} else {
				tmp += int64(left) * int64(F[ps[i].second][1])
			}
			if tmp > ans {
				ans = tmp
			}
		}
	}

	return ans
}

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

type Pair struct {
	first, second int
}

type Pairs []Pair

func (ps Pairs) Len() int {
	return len(ps)
}

func (ps Pairs) Less(i, j int) bool {
	return ps[i].first > ps[j].first || ps[i].first == ps[j].first && ps[i].second < ps[j].second
}

func (ps Pairs) Swap(i, j int) {
	ps[i], ps[j] = ps[j], ps[i]
}

package main

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

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 main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)
	var buf bytes.Buffer
	for tc > 0 {
		tc--
		m, n := readTwoNums(reader)
		F := make([][]int, n)
		for i := 0; i < n; i++ {
			F[i] = readNNums(reader, 2)
		}
		buf.WriteString(fmt.Sprintf("%d\n", solve(m, n, F)))
		if tc > 0 {
			reader.ReadBytes('\n')
		}
	}
	fmt.Print(buf.String())
}

func solve(m, n int, F [][]int) int64 {
	//let iterate i from 0 ~ n, make sure it (only) has more than 1 flowers
	ps := make([]Pair, n)
	for i := 0; i < n; i++ {
		ps[i] = Pair{F[i][0], i}
	}

	sort.Sort(Pairs(ps))

	X := make([]int64, n+1)
	for i := 0; i < n; i++ {
		X[i+1] = X[i] + int64(ps[i].first)
	}
	var cur = -1
	var ans int64
	for i := 0; i < n; i++ {
		if i+1 <= m && ans < X[i+1] {
			ans = X[i+1]
		}

		if cur < 0 || F[ps[cur].second][1] < F[ps[i].second][1] {
			cur = i
		}

		j := sort.Search(i+1, func(j int) bool {
			return ps[j].first <= F[ps[cur].second][1]
		})
		var left = m - j
		if left > 0 {
			tmp := X[j]
			if j <= cur {
				tmp += int64(F[cur][0]) + int64(left-1)*int64(F[cur][1])
			} else {
				tmp += int64(left) * int64(F[cur][1])
			}
			if tmp > ans {
				ans = tmp
			}
		}
	}

	return ans
}

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

type Pair struct {
	first, second int
}

type Pairs []Pair

func (ps Pairs) Len() int {
	return len(ps)
}

func (ps Pairs) Less(i, j int) bool {
	return ps[i].first > ps[j].first || ps[i].first == ps[j].first && ps[i].second < ps[j].second
}

func (ps Pairs) Swap(i, j int) {
	ps[i], ps[j] = ps[j], ps[i]
}

package main

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

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 main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)
	var buf bytes.Buffer
	for tc > 0 {
		tc--
		m, n := readTwoNums(reader)
		F := make([][]int, n)
		for i := 0; i < n; i++ {
			F[i] = readNNums(reader, 2)
		}
		buf.WriteString(fmt.Sprintf("%d\n", solve(m, n, F)))
		if tc > 0 {
			reader.ReadBytes('\n')
		}
	}
	fmt.Print(buf.String())
}

func solve(m, n int, F [][]int) int64 {
	//let iterate i from 0 ~ n, make sure it (only) has more than 1 flowers
	ps := make([]Pair, n)
	for i := 0; i < n; i++ {
		ps[i] = Pair{F[i][0], i}
	}

	sort.Sort(Pairs(ps))

	X := make([]int64, n+1)
	for i := 0; i < n; i++ {
		X[i+1] = X[i] + int64(ps[i].first)
	}
	var cur = -1
	var ans int64
	for i := 0; i < n; i++ {
		if i+1 <= m && ans < X[i+1] {
			ans = X[i+1]
		}

		if cur < 0 || F[ps[cur].second][1] < F[ps[i].second][1] {
			cur = i
		}

		j := sort.Search(i+1, func(j int) bool {
			return ps[j].first <= F[ps[cur].second][1]
		})
		var left = m - j
		if left > 0 {
			tmp := X[j]
			if j <= cur {
				tmp += int64(F[ps[cur].second][0]) + int64(left-1)*int64(F[ps[cur].second][1])
			} else {
				tmp += int64(left) * int64(F[cur][1])
			}
			if tmp > ans {
				ans = tmp
			}
		}
	}

	return ans
}

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

type Pair struct {
	first, second int
}

type Pairs []Pair

func (ps Pairs) Len() int {
	return len(ps)
}

func (ps Pairs) Less(i, j int) bool {
	return ps[i].first > ps[j].first || ps[i].first == ps[j].first && ps[i].second < ps[j].second
}

func (ps Pairs) Swap(i, j int) {
	ps[i], ps[j] = ps[j], ps[i]
}