Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For each contest where this coder participated, he wrote out a single non-negative number — the number of points his favorite coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no two contests ran simultaneously).Vasya considers a coder's performance in a contest amazing in two situations: he can break either his best or his worst performance record. First, it is amazing if during the contest the coder earns strictly more points that he earned on each past contest. Second, it is amazing if during the contest the coder earns strictly less points that he earned on each past contest. A coder's first contest isn't considered amazing. Now he wants to count the number of amazing performances the coder had throughout his whole history of participating in contests. But the list of earned points turned out long and Vasya can't code... That's why he asks you to help him.

The first line contains the single integer n (1 ≤ n ≤ 1000) — the number of contests where the coder participated. The next line contains n space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed 10000.

NoteIn the first sample the performances number 2 and 3 are amazing.In the second sample the performances number 2, 4, 9 and 10 are amazing.

package main

import (
	"fmt"
)

func main() {
	var n, min, max, amazing int
	fmt.Scan(&n, &min)
	max = min
	for i := 1; i < n; i++ {
		var x int
		fmt.Scan(&x)
		if x < min {
			min = x
			amazing++
		} else if x > max {
			max = x
			amazing++
		}
	}
	fmt.Println(amazing)
}

package main

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

func main() {
	var n, s int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n)
	fmt.Fscan(in, &s)
	max, min := s, s
	count := 0
	for i := 1; i < n; i++ {
		fmt.Fscan(in, &s)
		if s < min {
			count++
			min = s
		}
		if s > max {
			count++
			max = s
		}
	}
	fmt.Println(count)
}

package main

import "fmt"

func main() {
	var n, bestScore int
	fmt.Scanf("%d\n", &n)
	fmt.Scanf("%d", &bestScore)
	worstScore := bestScore
	amazing := 0
	for i := 1; i < n; i++ {
		var nextScore int
		fmt.Scanf("%d", &nextScore)
		if nextScore > bestScore {
			amazing++
			bestScore = nextScore
		}
		if nextScore < worstScore {
			amazing++
			worstScore = nextScore
		}
	}
	fmt.Println(amazing)
}

package main

import(
    "fmt"
)

func main(){
    var(
        n,t1,t2,h,l int
    )
    fmt.Scan(&n)
    a:=make([]int,n)
    m:=make(map[int]int)
    for i:=0;i<n;i++{
        fmt.Scan(&a[i])
    }
    t1,t2,h,l=0,0,a[0],a[0]
    m[a[0]]=1
    if n>1{
        for i:=1;i<n;i++{
            _,ok:=m[a[i]]
            if a[i]>h && ok==false {
                h=a[i]
                t1++
                m[a[i]]=1
            }else{
                if l>a[i] && ok==false{
                    l=a[i]
                    m[a[i]]=1
                    t2++
                }
            }
        }
        if l!=a[0]{
            fmt.Println(t1+t2)
        }else{
            fmt.Println(t1)
        }
    }else{
        fmt.Println(t1)
    }
}

package main

import (
"fmt"
)

func main() {
	var n,x int64
	fmt.Scan(&n)
	var mini,maxi int64
	fmt.Scan(&mini)
	maxi = mini
	amaze := 0
	n--
	for ; n>0; n-- {
		fmt.Scan(&x)
		if x>maxi || x<mini {
			amaze++
		}
		if x > maxi {
			maxi = x
		}
		if x < mini {
			mini = x
		}
	}
	fmt.Printf("%d\n",amaze)
}

package main
import (
	"fmt"
)
func main() {
	var temp,n,max,min,counter int = 0,0,0,0,0
	fmt.Scan(&n)
	fmt.Scan(&temp)
	min,max= temp,temp
	for i:=1;i<n;i++ {
		fmt.Scan(&temp)
		if temp>max {
			max=temp
			counter++
		}
		if temp<min {
			min=temp
			counter++
		}
	}
	fmt.Println(counter)
}

package main

import ("fmt")

// func calculate(y,d int32){
// 	answer := y%d
// 	if answer==0{
// 		fmt.Println("YES")
// 	}else{
// 		fmt.Println("NO")
// 	}
// }

func main(){
	var t int
	fmt.Scanln(&t)
	var first int
	fmt.Scan(&first)
	var max int = first
	var min int = first
	count :=0
	for i:=1;i<t;i++{
		var next int
		fmt.Scan(&next)
		if next>max{
			count++
			max = next
		}
		if next<min{
			count++
			min = next
		}

	}
	fmt.Println(count)
}

package main
import "fmt"

func main()  {
	var input,high,low,n int
//	fmt.Println("Enter the number of values:")
	fmt.Scan(&n)
	var count int
	for i := 0; i < n; i++ {
		//fmt.Print("enter the value of input:")
		fmt.Scan(&input)
	   if i==0 {
		   high=input
		   low=input
		   continue
	   }
	   if input>high {
		   high=input
		   count++

	   }
	   if input<low {
		   low=input
		   count++
	   }
	}

	fmt.Println(count)
}

package main
import (
	"fmt"
)
func main() {
	var n int
	b:=0
	awe:=0
	fmt.Scan(&n)
	in:=make([]int,n)
	for i:=0;i<n;i++{
		fmt.Scan(&in[i])
		if i==0{b = in[i]}
		if in[i]>b{
			b = in[i]
			awe++
		}
		if b>in[i]{
			if in[0]>in[i]{
				in[0] = in[i]
				awe++
			}
		}
	}
	fmt.Println(awe)
}

package main

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

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

	reader := bufio.NewReader(os.Stdin)
	ss, _ := reader.ReadString('\n')
	list := strings.Split(strings.TrimRight(ss, "\r\n"), " ")

	max, _ := strconv.ParseUint(list[0], 10, 64)
	min, _ := strconv.ParseUint(list[0], 10, 64)
	count := 0
	for i := 1; i < n; i++ {
		t, _ := strconv.ParseUint(list[i], 10, 64)
		if t > max {
			max = t
			count++
		}
		if t < min {
			min = t
			count++
		}
	}
	fmt.Print(count)
}

package main

import "fmt"

func main() {
    var n,a int
    fmt.Scan(&n)
    fmt.Scan(&a)
    min, max, ans := a, a, 0
    for i := 1; i < n; i++ {
        fmt.Scan(&a)
        if (min > a) { min = a; ans++ }
        if (max < a) { max = a; ans++ }
    }
    fmt.Println(ans)
}

package main

import "fmt"

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

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

	minm := arr[0]
	maxm := arr[0]
	count := 0

	for i := 1; i < n; i++ {
		if arr[i] < minm {
			minm = arr[i]
			count++;
		}else if arr[i] > maxm {
			maxm = arr[i]
			count++;
		}
	}
	fmt.Println(count)
}

package main

import "bufio"
import "os"
import "fmt"

func Read(s *bufio.Reader) string {
    line, _ := s.ReadString('\n')
    return line
}

func Write(s *bufio.Writer, a ...interface{}) {
    fmt.Fprintln(s, a...)
    s.Flush()
}

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

    var n int
    fmt.Sscanln(Read(reader), &n)

    a := make([]int, n)

    for i := 0; i < n - 1; i++ {
        line, _ := reader.ReadString(' ')
        fmt.Sscanln(line, &a[i])
    }

    fmt.Sscanln(Read(reader), &a[n - 1])
    max, min := a[0], a[0]
    var counter int = 0

    for i := 1; i < n; i++ {
        if a[i] < min {
            min = a[i]
            counter++
        }

        if a[i] > max {
            max = a[i]
            counter++
        }
    }

    writer := bufio.NewWriter(os.Stdout)

    Write(writer, counter)
}

package main

import (
  "fmt"
)

func main() {
  var (
    n int
    max  = -1
    min = 1001
    current int
    answer = 0
  )
  fmt.Scanln(&n)
  fmt.Scan(&max)
  min = max
  for i:=1; i < n; i++ {
    fmt.Scan(&current)
    if current > max{
      answer++
      max = current
    } else {
      if current < min {
        answer++
        min = current
      }
    }
  }
  fmt.Println(answer)
}

package main

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

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

	scanner.Scan()
	_ = scanner.Text()

	scanner.Scan()
	scores := scanner.Text()

	var scoresList []int

	for _, scoreString := range strings.Split(scores, " ") {
		score, err := strconv.Atoi(scoreString)
		if err != nil {
			log.Fatal(err)
		}
		scoresList = append(scoresList, score)
	}

	var (
		counter int
		min     int
		max     int
	)

	min, max = scoresList[0], scoresList[0]

	for i := 1; i < len(scoresList); i++ {
		if scoresList[i] > max {
			counter++
			max = scoresList[i]
		} else if scoresList[i] < min {
			counter++
			min = scoresList[i]
		}
	}

	fmt.Println(counter)
}

package main

import "fmt"

func main() {
	var n, v, min, max int
	fmt.Scan(&n)

	amazing := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&v)
		if i == 0 {
			min, max = v, v
		} else {
			if v > max {
				amazing += 1
				max = v
			}
			if v < min {
				amazing += 1
				min = v
			}
		}
	}

	fmt.Print(amazing)
}

package main

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

var reader *bufio.Reader

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

var n int

func main() {
	fmt.Fscan(reader, &n)
	var ans, min, max int
	for i := 0; i < n; i++ {
		var a int
		fmt.Fscan(reader, &a)
		if i == 0 {
			min, max = a, a
		}
		if a < min {
			min = a
			ans++
		}
		if a > max {
			max = a
			ans++
		}
	}
	fmt.Println(ans)
}

package main

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

func main() {
	var n, m, l, c, t uint16
	in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d\n", &n)
	for i:=uint16(0); i < n - 1; i++{
		fmt.Fscanf(in, "%d ", &t)
		if i == 0{
			m = t
			l = t
		}
		if i > 0{
			if t > m{
				m = t
				c++
			}else if t < l{
				l = t
				c++
			}
		}

	}
	fmt.Fscanf(in, "%d\n", &t)
	if t > m{
		m = t
		c++
	}else if t < l{
		l = t
		c++
	}
	if n < 2{
		fmt.Println(0)
	}else{
		fmt.Println(c)
	}
}

package main

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

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

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

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

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return 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...)
}

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

// 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 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 abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int64) int64 {
	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)
}

func main() {
	defer Flush()

	n := readi()
	a := make([]int, n)
	for i := range a {
		a[i] = readi()
	}
	var ans int
	maxv := a[0]
	minv := a[0]
	for i := range a {
		if maxv < a[i] {
			ans++
			maxv = a[i]
		}
		if a[i] < minv {
			ans++
			minv = a[i]
		}
	}
	println(ans)
}

// 155A-arnold
package main

import (
	"fmt"
)

func main() {
	var n, poin int
	fmt.Scan(&n)
	fmt.Scan(&poin)
	a := 0
	min := poin
	max := poin
	for x := n; x >= 0; x-- {
		fmt.Scan(&poin)
		if poin < min {
			min = poin
			a++
		}
		if poin > max {
			max = poin
			a++
		}
	}
	fmt.Print(a)
}

package main

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

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

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

    bs.Scan()
    num, _ := strconv.Atoi(bs.Text())

    min := num
    max := num
    result := 0
    for i := 1; i < n; i++ {
        bs.Scan()
        num, _ = strconv.Atoi(bs.Text())
        if min > num {
            min = num
            result++
        }
        if max < num {
            max = num
            result++
        }
    }

    fmt.Println(result)
}

package main
import (
    "fmt"
)

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

    //setup
    var first int
    fmt.Scan(&first)
    max := first
    min := first
    counter := 0

    for i := 1; i < num; i++ {
        var temp int
        fmt.Scan(&temp)
        if temp > max {
            max = temp
            counter++
        }
        if temp < min {
            min = temp
            counter ++
        }
    }

    fmt.Println(counter)
}

// 155A-Mic
package main

import (
    "fmt"
)

func main() {
    var max, min, input, n, cou int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        fmt.Scan(&input)
        if i == 0 {
            min = input
            max = input
        }
        if input < min {
            cou++
            min = input
        }
        if input > max {
            cou++
            max = input
        }
    }
    fmt.Println(cou)
}

package main
import "fmt"

func main(){
	var n int
	fmt.Scanf("%d\n", &n)
	var a [1005]int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}
	min, max := a[0], a[0]
	r := 0
	for i := 1; i < n; i++ {
		if a[i] < min {
			r = r + 1
			min = a[i]
		}
		if a[i] > max {
			r = r + 1
			max = a[i]
		}
	}
	fmt.Println(r)
}

package main

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

// https://codeforces.com/problemset/problem/155/A
// A. I_love_%username%
// time limit per test
// 2 seconds
// memory limit per test
// 256 megabytes
// input
// standard input
// output
// standard output

// Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.

// One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For each contest where this coder participated, he wrote out a single non-negative number — the number of points his favorite coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no two contests ran simultaneously).

// Vasya considers a coder's performance in a contest amazing in two situations: he can break either his best or his worst performance record. First, it is amazing if during the contest the coder earns strictly more points that he earned on each past contest. Second, it is amazing if during the contest the coder earns strictly less points that he earned on each past contest. A coder's first contest isn't considered amazing. Now he wants to count the number of amazing performances the coder had throughout his whole history of participating in contests. But the list of earned points turned out long and Vasya can't code... That's why he asks you to help him.
// Input

// The first line contains the single integer n (1 ≤ n ≤ 1000) — the number of contests where the coder participated.

// The next line contains n space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed 10000.
// Output

// Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests.

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

	var n int
	_, _ = fmt.Fscan(bufStdin, &n)

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

	bestScore := scores[0]
	worstScore := scores[0]
	var nAmazingPerformances int
	for i := 1; i < n; i++ {
		v := scores[i]
		if v > bestScore {
			bestScore = v
			nAmazingPerformances++
		} else if v < worstScore {
			worstScore = v
			nAmazingPerformances++
		}
	}

	fmt.Print(nAmazingPerformances)
}

package main

import "fmt"

// https://codeforces.com/problemset/problem/155/A
// комментарии к решению
// Т.к. чисел не много и ограничение сверху целых 2 сек, то используем fmt.Scan
func taskSolution(a []int) (ans int) {
	min := a[0]
	max := a[0]
	for i := 1; i < len(a); i += 1 {
		if min > a[i] {
			min, ans = a[i], ans+1
		} else if max < a[i] {
			max, ans = a[i], ans+1
		}
	}
	return ans
}

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

	a := []int{}
	for i := 0; i < n; i += 1 {
		var ai int
		if _, err := fmt.Scan(&ai); err != nil {
			panic(err)
		}
		a = append(a, ai)
	}

	fmt.Println(taskSolution(a))
}

package main

import(
    "fmt"
)

func main(){
    var(
        n,temp int
    )
    fmt.Scan(&n)
    arr:=make([]int,n)
    for i:=0;i<n;i++{
        fmt.Scan(&arr[i])
    }
    temp=0
    for i:=1;i<n;i++{
        if arr[i]>arr[i-1]{
            temp++
        }
    }
    fmt.Println(temp)
}

package main

import(
    "fmt"
)

func main(){
    var(
        n,t1,h,l int
    )
    fmt.Scan(&n)
    a:=make([]int,n)
    m:=make(map[int]int)
    for i:=0;i<n;i++{
        fmt.Scan(&a[i])
    }
    t1,h,l=0,a[0],a[0]
    m[a[0]]=1
    if n>1{
        for i:=1;i<n;i++{
            if a[i]>h{
                h=a[i]
                t1++
            }else{
                if l>a[i]{
                    l=a[i]
                }
            }
        }
        if l!=a[0]{
            fmt.Println(t1+1)
        }else{
            fmt.Println(t1)
        }
    }else{
        fmt.Println(t1)
    }
}

package main
import (
	"fmt"
)
func main() {
	var n int
	b:=0
	awe:=0
	fmt.Scan(&n)
	in:=make([]int,n)
	for i:=0;i<n;i++{
		fmt.Scan(&in[i])
		if in[i]>b{
			b = in[i]
			awe+=1
		}
		if b>in[i]{
			if in[0]>in[i]{
				in[0] = in[i]
				awe+=1
			}
		}
	}
	fmt.Println(awe-1)
}

package main
import (
	"fmt"
)
func main() {
	var n int
	b:=0
	awe:=0
	fmt.Scan(&n)
	in:=make([]int,n)
	for i:=0;i<n;i++{
		fmt.Scan(&in[i])
		if in[i]>b{
			b = in[i]
			awe+=1

		}else{
			if b>in[i]{
				if in[0]>in[i]{
					in[0] = in[i]
					awe+=1
				}
			}
		}
	}
	fmt.Println(awe-1)
}

package main

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

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

	scanner.Scan()
	_ = scanner.Text()

	scanner.Scan()
	scores := scanner.Text()

	var scoresList []int

	for _, scoreString := range strings.Split(scores, " ") {
		score, err := strconv.Atoi(scoreString)
		if err != nil {
			log.Fatal(err)
		}
		scoresList = append(scoresList, score)
	}

	var (
		counter int
		min     int
		max     int
	)

	min, max = scoresList[0], scoresList[0]

	for i := 1; i < len(scoresList); i++ {
		if scoresList[i] > max {
			counter++
			max = scoresList[i]
		} else if scoresList[i] < min {
			counter++
			min = scoresList[i]
		}
	}

	print(counter)
}

package main

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

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

	scanner.Scan()
	_ = scanner.Text()

	scanner.Scan()
	scores := scanner.Text()

	var scoresList []int

	for _, scoreString := range strings.Split(scores, " ") {
		score, err := strconv.Atoi(scoreString)
		if err != nil {
			log.Fatal(err)
		}
		scoresList = append(scoresList, score)
	}

	var (
		counter int
		min     int
		max     int
	)

	min, max = scoresList[0], scoresList[0]

	for i := 1; i < len(scoresList); i++ {
		if scoresList[i] > max {
			counter++
			max = scoresList[i]
		} else if scoresList[i] < min {
			counter++
			min = scoresList[i]
		}
	}

	log.Println(counter)
}

package main

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

func main() {
	var n, m, l, c, t uint16
	in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d\n", &n)
	for i:=uint16(0); i < n - 1; i++{
		fmt.Fscanf(in, "%d ", &t)
		if i == 0{
			m = t
			l = t
		}
		if i > 0{
			if t > m{
				m = t
				c++
			}else if t < l{
				l = t
				c++
			}
		}

	}
	fmt.Fscanf(in, "%d\n", &t)
	if t > m{
		m = t
		c++
	}else if t < l{
		l = t
		c++
	}
	fmt.Println(c)
}

package main

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

func main() {
	var n, m, l, c, t uint16
	in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d\n", &n)
	for i:=uint16(0); i < n - 1; i++{
		fmt.Fscanf(in, "%d ", &t)
		if i == 0{
			m = t
			l = t
		}
		if i > 0{
			if t > m{
				m = t
				c++
			}else if t < l{
				l = t
				c++
			}
		}

	}
	fmt.Fscanf(in, "%d\n", &t)
	if t > m{
		m = t
		c++
	}else if t < l{
		l = t
		c++
	}
	if n < 3{
		fmt.Println(0)
	}else{
		fmt.Println(c)
	}
}

// 155A-arnold
package main

import (
    "fmt"
)

func main() {
    var n, poin int
    fmt.Scan(n)
    fmt.Scan(poin)
    a := 0
    min := poin
    max := poin
    for x := n; x > 0; x-- {
        fmt.Scan(poin)
        if poin < min {
            min = poin
            a++
        }
        if poin > max {
            max = poin
            a++
        }
    }
    fmt.Print(a)
}

// 155A-arnold
package main

import (
    "fmt"
)

func main() {
    var n, poin int
    fmt.Scan(n)
    fmt.Scan(poin)
    a := 0
    min := poin
    max := poin
    for a = n; a > 0; a-- {
        fmt.Scan(poin)
        if poin < min {
            min = poin
            a++
        }
        if poin > max {
            max = poin
            a++
        }
    }
    fmt.Print(a)
}

// 155A-arnold
package main

import (
	"fmt"
)

func main() {
	var n, poin int
	fmt.Scan(&n)
	fmt.Scan(&poin)
	a := 0
	var min, max int
	for x := n; x >= 0; x-- {
		fmt.Scan(poin)
		if poin < min {
			min = poin
			a++
		}
		if poin > max {
			max = poin
			a++
		}
	}
	fmt.Print(a)
}

// 155A-arnold
package main

import (
	"fmt"
)

func main() {
	var n, poin int
	fmt.Scan(n)
	fmt.Scan(poin)
	a := 0
	var min, max int
	for x := n; x > 0; x-- {
		fmt.Scan(poin)
		if poin < min {
			min = poin
			a++
		}
		if poin > max {
			max = poin
			a++
		}
	}
	fmt.Print(a)
}

// 155A-arnold
package main

import (
    "fmt"
)

func main() {
    var n, poin int
    fmt.Scanln(n)
    fmt.Scanln(poin)
    a := 0
    min := poin
    max := poin
    for x := n; x > 0; x-- {
        fmt.Scan(poin)
        if poin < min {
            min = poin
            a++
        }
        if poin > max {
            max = poin
            a++
        }
    }
    fmt.Print(a)
}

// 155A-arnold
package main

import (
	"fmt"
)

func main() {
	var n, poin int
	fmt.Scan(&n)
	fmt.Scan(&poin)
	a := 0
	min := poin
	max := poin
	for x := n; x >= 0; x-- {
		fmt.Scan(poin)
		if poin < min {
			min = poin
			a++
		}
		if poin > max {
			max = poin
			a++
		}
	}
	fmt.Print(a)
}

package main
import (
    "fmt"
)

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

    max := 0
    min := 10000
    counter := 0

    for i := 0; i < num; i++ {
        var temp int
        fmt.Scan(&temp)
        if temp > max {
            max = temp
            counter++
        }
        if temp < min {
            min = temp
            counter ++
        }
    }

    fmt.Println(counter-2)
}

// 155A-Mic
package main

import (
    "fmt"
)

func main() {
    var max, min, input, n, cou int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        fmt.Scan(&input)
        if i == 0 {
            min = input
            max = input
        }
        if input < min {
            cou++
            min = input
        }
        if input > max {
            cou++
            max = input
        }

    }
}

package main
import "fmt"

func main(){
	var n int
	fmt.Scanf("%d", &n)
	var x int
	fmt.Scanf("%d", &x)
	min, max := x, x
	r := 0
	for i := 1; i < n; i++ {
		fmt.Scanf("%d", &x)
		if x < min {
			r = r + 1
			min = x
		}
		if x > max {
			r = r + 1
			max = x
		}
	}
	fmt.Println(r)
}

package main
import "fmt"

func main(){
	var n int
	fmt.Scanf("%d", &n)
	var a [1005]int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}
	min, max := a[0], a[0]
	r := 0
	for i := 1; i < n; i++ {
                if n == 10 {
                        fmt.Println(a[i])
                }
		if a[i] < min {
			r = r + 1
			min = a[i]
		}
		if a[i] > max {
			r = r + 1
			max = a[i]
		}
	}
	fmt.Println(r)
}

package main
import "fmt"

func main(){
	var n int
	fmt.Scanf("%d", &n)
	var a [1005]int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}
	min, max := a[0], a[0]
	r := 0
	for i := 1; i < n; i++ {
                if n == 10 {
                        fmt.Println(n)
                }
		if a[i] < min {
			r = r + 1
			min = a[i]
		}
		if a[i] > max {
			r = r + 1
			max = a[i]
		}
	}
	fmt.Println(r)
}

package main
import "fmt"

func main(){
	var n int
	fmt.Scanf("%d\n", &n)
	var a [1005]int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}
	min, max := a[0], a[0]
	if n == 10 {
		fmt.Println(a[0])
	}
	r := 0
	for i := 1; i < n; i++ {
                if n == 10 {
                        fmt.Println(a[i])
                }
		if a[i] < min {
			r = r + 1
			min = a[i]
		}
		if a[i] > max {
			r = r + 1
			max = a[i]
		}
	}
	fmt.Println(r)
}

package main
import "fmt"

func main(){
	var n int
	fmt.Scanf("%d", &n)
	var a [1005]int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}
	min, max := a[0], a[0]
	if n == 10 {
		fmt.Println(a[0])
	}
	r := 0
	for i := 1; i < n; i++ {
                if n == 10 {
                        fmt.Println(a[i])
                }
		if a[i] < min {
			r = r + 1
			min = a[i]
		}
		if a[i] > max {
			r = r + 1
			max = a[i]
		}
	}
	fmt.Println(r)
}

package main
import "fmt"

func main(){
	var n int
	fmt.Scanf("%d", &n)
	var a [1005]int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}
	min, max := a[0], a[0]
	r := 0
	for i := 1; i < n; i++ {
		if a[i] < min {
			r = r + 1
			min = a[i]
		}
		if a[i] > max {
			r = r + 1
			max = a[i]
		}
	}
	fmt.Println(r)
}

package main
import "fmt"

func main(){
	var n int
	fmt.Scanf("%d\n", &n)
	var a [1005]int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}
	min, max := a[0], a[0]
	fmt.Println(a[0])
	r := 0
	for i := 1; i < n; i++ {
                if n == 10 {
                        fmt.Println(a[i])
                }
		if a[i] < min {
			r = r + 1
			min = a[i]
		}
		if a[i] > max {
			r = r + 1
			max = a[i]
		}
	}
	fmt.Println(r)
}


Now you can take online courses in the Berland State University! Polycarp needs to pass k main online courses of his specialty to get a diploma. In total n courses are availiable for the passage.The situation is complicated by the dependence of online courses, for each course there is a list of those that must be passed before starting this online course (the list can be empty, it means that there is no limitation).Help Polycarp to pass the least number of courses in total to get the specialty (it means to pass all main and necessary courses). Write a program which prints the order of courses. Polycarp passes courses consistently, he starts the next course when he finishes the previous one. Each course can't be passed more than once.

The first line contains n and k (1 ≤ k ≤ n ≤ 105) — the number of online-courses and the number of main courses of Polycarp's specialty.  The second line contains k distinct integers from 1 to n — numbers of main online-courses of Polycarp's specialty.  Then n lines follow, each of them describes the next course: the i-th of them corresponds to the course i. Each line starts from the integer ti (0 ≤ ti ≤ n - 1) — the number of courses on which the i-th depends. Then there follows the sequence of ti distinct integers from 1 to n — numbers of courses in random order, on which the i-th depends. It is guaranteed that no course can depend on itself.  It is guaranteed that the sum of all values ti doesn't exceed 105.

Print -1, if there is no the way to get a specialty.  Otherwise, in the first line print the integer m — the minimum number of online-courses which it is necessary to pass to get a specialty. In the second line print m distinct integers — numbers of courses which it is necessary to pass in the chronological order of their passage. If there are several answers it is allowed to print any of them.

NoteIn the first test firstly you can take courses number 1 and 2, after that you can take the course number 4, then you can take the course number 5, which is the main. After that you have to take only the course number 3, which is the last not passed main course.

//https://codeforces.com/problemset/problem/770/C
package main

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

var isCyclic bool

func dfs(graph [][]int, cur int, res *[]int, visited []byte) {
	//'v' == visited
	//'t' == visiting
	visited[cur] = 't'

	for i := range graph[cur] {
		if visited[graph[cur][i]] == 't' {
			isCyclic = true
			return
		}
		if visited[graph[cur][i]] != 'v' {
			dfs(graph, graph[cur][i], res, visited)
			visited[graph[cur][i]] = 'v'
		}
	}

	(*res) = append((*res), cur)
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, k, m, c int
	fmt.Fscanf(r, "%d %d\n", &n, &k)
	mainCourses := make([]int, k)
	for i := range mainCourses {
		fmt.Fscanf(r, "%d", &mainCourses[i])
	}
	fmt.Fscanln(r)

	graph := make([][]int, n+1)
	for i := 1; i <= n; i++ {
		fmt.Fscanf(r, "%d", &m)
		for j := 0; j < m; j++ {
			fmt.Fscanf(r, "%d", &c)
			graph[i] = append(graph[i], c)
		}
		fmt.Fscanln(r)
	}

	res := []int{}
	visited := make([]byte, n+1)
	for i := range mainCourses {
		if visited[mainCourses[i]] != 'v' {
			dfs(graph, mainCourses[i], &res, visited)
			visited[mainCourses[i]] = 'v'
			if isCyclic {
				break
			}
		}
	}

	if isCyclic {
		fmt.Fprintf(os.Stdout, "%d\n", -1)
	} else {
		fmt.Fprintf(os.Stdout, "%d\n", len(res))
		for i := range res {
			fmt.Fprintf(os.Stdout, "%d ", res[i])
		}
		fmt.Fprintln(os.Stdout)
	}
}


Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down.There is a cursor pointing at some symbol of the string. Suppose that cursor is at position i (1 ≤ i ≤ n, the string uses 1-based indexing) now. Left and right arrow keys are used to move cursor around the string. The string is cyclic, that means that when Nam presses left arrow key, the cursor will move to position i - 1 if i > 1 or to the end of the string (i. e. position n) otherwise. The same holds when he presses the right arrow key (if i = n, the cursor appears at the beginning of the string).When Nam presses up arrow key, the letter which the text cursor is pointing to will change to the next letter in English alphabet (assuming that alphabet is also cyclic, i. e. after 'z' follows 'a'). The same holds when he presses the down arrow key.Initially, the text cursor is at position p. Because Nam has a lot homework to do, he wants to complete this as fast as possible. Can you help him by calculating the minimum number of arrow keys presses to make the string to be a palindrome?

The first line contains two space-separated integers n (1 ≤ n ≤ 105) and p (1 ≤ p ≤ n), the length of Nam's string and the initial position of the text cursor. The next line contains n lowercase characters of Nam's string.

Print the minimum number of presses needed to change string into a palindrome.

NoteA string is a palindrome if it reads the same forward or reversed.In the sample test, initial Nam's string is:  (cursor position is shown bold).In optimal solution, Nam may do 6 following steps:The result, , is now a palindrome.

package main

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

var (
	in  = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	n   int
	p   int
	st  string
	pos []byte
)

func main() {

	defer out.Flush()
	in.Split(bufio.ScanWords)

	fmt.Scanf("%d %d", &n, &p)
	//readInt(&n, &p)
	p--

	//readString(&st)
	fmt.Scan(&st)

	pos = []byte(st)
	a := make([]int, n)
	b := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = get(i, n-i-1)
	}

	if p >= n/2 {
		p -= (n + 1) / 2
		st = st[(n+1)/2:]
		b = a[(n+1)/2:]
	} else {
		st = st[:n/2]
		b = a[:n/2]
	}

	/*	for _, value := range b {
			write(value)
		}
		out.WriteString("\n")
	*/
	ans := 0
	ln := len(b)

	left := 0
	right := ln - 1

	for (left < ln) && (b[left] == 0) {
		left++
	}
	for (right >= 0) && (b[right] == 0) {
		right--
	}
	//write(p, left, right)
	//out.WriteString("\n")

	if right < left {
		ans = 0
	} else if (left > p) || (right < p) {
		ans = min(abs(left-p), abs(p-right)) + (right - left)
	} else if abs(left-p) < abs(right-p) {
		ans = (right - left) + (p - left)
	} else {
		ans = (right - left) + (right - p)
	}

	sum := 0
	for _, value := range b {
		sum += value
	}

	write(sum + ans)

	//out.WriteString(st + "\n")
}

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

func min(x int, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

func get(x int, y int) int {
	if pos[x] > pos[y] {
		return min(int(pos[x]-pos[y]), int(pos[y]-pos[x]+26))
	} else {
		return min(int(pos[y]-pos[x]), int(pos[x]-pos[y]+26))
	}
}

func write(num ...int) {
	for _, value := range num {
		str := strconv.Itoa(value)
		out.WriteString(str + " ")
	}
	//out.WriteString("\n")
}
func readInt(num ...*int) {

	for _, value := range num {
		in.Scan()
		*value, _ = strconv.Atoi(in.Text())
	}
}

func readString(st *string) {
	in.Scan()
	*st = in.Text()
}

package main

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

var testCases = []struct {
	s           string
	p           int
	expectedRet int
}{
	{"aaaabbbb", 3, 8},
	{"aabbbbaaaaccccaa", 4, 8},
	{"aabbbbaaaaccccaa", 1, 9},
	{"a", 1, 0},
	{"ab", 1, 1},
	{"abc", 2, 3},
	{"aeabcaez", 3, 6},
	{"abcdefdcba", 6, 1},
}

func min(x int, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

func solve(s string, p int) int {
	p-- // To zero index base

	// Transform p to be in the first half if it's not, this does not change
	// the problem.
	if p >= len(s)/2 {
		p = len(s) - 1 - p
	}

	a := 0
	b := (len(s) - 1) / 2
	for ; b >= 0 && s[b] == s[len(s)-1-b]; b-- {
	}
	if b < 0 {
		// Already a palindrome
		return 0
	}
	for ; a < b && s[a] == s[len(s)-1-a]; a++ {
	}

	ret := 0
	// Calculate number of moves needed to change the letters.  Has to be
	// made no matter what.
	for i := a; i <= b; i++ {
		c1 := s[i]
		c2 := s[len(s)-1-i]
		ret += min((26+int(c1)-int(c2))%26, (26+int(c2)-int(c1))%26)
	}

	if p < a {
		ret += a - p
		p = a
	}
	if p > b {
		ret += p - b
		p = b
	}

	ret += b - a + min(b-p, p-a)
	return ret
}

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

	for _, t := range testCases {
		var ret = solve(t.s, t.p)
	  if ret != t.expectedRet {
			log.Fatalf("Wrong ret for (%v, %v): expected %v, got %v", t.s, t.p, t.expectedRet, ret)
	  }
	}

	var n, p int
	var s string
	fmt.Fscanf(o, "%d %d %s ", &n, &p, &s)
	if len(s) != n {
		log.Fatalf("%d != %d", len(s), n)
	}

	fmt.Printf("%d\n", solve(s, p))
}

package main

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

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

	var n, p int
	var s string
	Fscan(in, &n, &p, &s)
	n2 := n / 2
	p--
	if p >= n2 {
		p = n - 1 - p
	}

	pos := []int{}
	ans := 0
	for i := 0; i < n2; i++ {
		if s[i] != s[n-1-i] {
			pos = append(pos, i)
			d := (s[i] - s[n-1-i] + 26) % 26
			if d > 13 {
				d = 26 - d
			}
			ans += int(d)
		}
	}
	if ans == 0 {
		Fprint(out, 0)
		return
	}
	dl, dr := p-pos[0], pos[len(pos)-1]-p
	if dl <= 0 {
		ans += dr
	} else if dr <= 0 {
		ans += dl
	} else {
		if dl <= dr {
			ans += 2*dl + dr
		} else {
			ans += 2*dr + dl
		}
	}
	Fprintln(out, ans)
}

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

package main

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

var (
	in  = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	n   int
	p   int
	st  string
	pos []byte
)

func main() {

	defer out.Flush()
	in.Split(bufio.ScanWords)

	readInt(&n, &p)
	p--

	readString(&st)

	pos = []byte(st)
	a := make([]int, n)
	b := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = get(i, n-i-1)
	}
	/*
		for _, value := range a {
			write(value)
		}
		out.WriteString("\n")

	*/
	if p > (n / 2) {
		p -= (n + 1) / 2
		st = st[(n+1)/2:]
		b = a[(n+1)/2:]
	} else {
		st = st[:n/2]
		b = a[:n/2]
	}

	ans := 0
	ln := len(b)

	if (ln-1)+(ln-p-1) > ln+p-1 {
		ans = ln + p - 1
	} else {
		ans = (ln - 1) + (ln - p - 1)
	}

	sum := 0
	for _, value := range b {
		sum += value
	}

	write(sum + ans)

	//out.WriteString(st + "\n")
}

func min(x int, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

func get(x int, y int) int {
	if pos[x] > pos[y] {
		return min(int(pos[x]-pos[y]), int(pos[y]-pos[x]+26))
	} else {
		return min(int(pos[y]-pos[x]), int(pos[x]-pos[y]+26))
	}
}

func write(num ...int) {
	for _, value := range num {
		str := strconv.Itoa(value)
		out.WriteString(str + " ")
	}
	//out.WriteString("\n")
}
func readInt(num ...*int) {

	for _, value := range num {
		in.Scan()
		*value, _ = strconv.Atoi(in.Text())
	}
}

func readString(st *string) {
	in.Scan()
	*st = in.Text()
}

package main

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

var (
	in  = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	n   int
	p   int
	st  string
	pos []byte
)

func main() {

	defer out.Flush()
	in.Split(bufio.ScanWords)

	fmt.Scanf("%d %d", &n, &p)
	//readInt(&n, &p)
	p--

	//readString(&st)
	fmt.Scan(&st)

	pos = []byte(st)
	a := make([]int, n)
	b := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = get(i, n-i-1)
	}

	if p > (n / 2) {
		p -= (n + 1) / 2
		st = st[(n+1)/2:]
		b = a[(n+1)/2:]
	} else {
		st = st[:n/2]
		b = a[:n/2]
	}

	/*
		for _, value := range b {
			write(value)
		}
		out.WriteString("\n")
	*/
	ans := 0
	ln := len(b)

	left := 0
	right := ln - 1

	for (left < ln) && (b[left] == 0) {
		left++
	}
	for (right >= 0) && (b[right] == 0) {
		right--
	}
	//write(p, left, right)
	//out.WriteString("\n")

	if right < left {
		ans = 0
	} else if (left > p) || (right < p) {
		ans = min(abs(left-p), abs(p-right)) + (right - left)
	} else if abs(left-p) < abs(right-p) {
		ans = (right - left) + (p - left)
	} else {
		ans = (right - left) + (right - p)
	}

	sum := 0
	for _, value := range b {
		sum += value
	}

	write(sum + ans)

	//out.WriteString(st + "\n")
}

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

func min(x int, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

func get(x int, y int) int {
	if pos[x] > pos[y] {
		return min(int(pos[x]-pos[y]), int(pos[y]-pos[x]+26))
	} else {
		return min(int(pos[y]-pos[x]), int(pos[x]-pos[y]+26))
	}
}

func write(num ...int) {
	for _, value := range num {
		str := strconv.Itoa(value)
		out.WriteString(str + " ")
	}
	//out.WriteString("\n")
}
func readInt(num ...*int) {

	for _, value := range num {
		in.Scan()
		*value, _ = strconv.Atoi(in.Text())
	}
}

func readString(st *string) {
	in.Scan()
	*st = in.Text()
}

package main

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

var (
	in  = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	n   int
	p   int
	st  string
	pos []byte
)

func main() {

	defer out.Flush()
	in.Split(bufio.ScanWords)

	fmt.Scanf("%d %d", &n, &p)
	//readInt(&n, &p)
	p--

	//readString(&st)
	fmt.Scan(&st)

	pos = []byte(st)
	a := make([]int, n)
	b := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = get(i, n-i-1)
	}

	if p > (n / 2) {
		p -= (n + 1) / 2
		st = st[(n+1)/2:]
		b = a[(n+1)/2:]
	} else {
		st = st[:n/2]
		b = a[:n/2]
	}

	/*
		for _, value := range b {
			write(value)
		}
		out.WriteString("\n")
	*/
	ans := 0
	ln := len(b)

	left := 0
	right := ln - 1

	for (left < ln) && (b[left] == 0) {
		left++
	}
	for (right >= 0) && (b[right] == 0) {
		right--
	}

	//write(p, left, right)
	//out.WriteString("\n")

	if (left > p) || (right < p) {
		ans = min(abs(left-p), abs(p-right)) + (right - left)
	} else if abs(left-p) < abs(right-p) {
		ans = (right - left) + (p - left)
	} else {
		ans = (right - left) + (right - p)
	}

	sum := 0
	for _, value := range b {
		sum += value
	}

	write(sum + ans)

	//out.WriteString(st + "\n")
}

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

func min(x int, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

func get(x int, y int) int {
	if pos[x] > pos[y] {
		return min(int(pos[x]-pos[y]), int(pos[y]-pos[x]+26))
	} else {
		return min(int(pos[y]-pos[x]), int(pos[x]-pos[y]+26))
	}
}

func write(num ...int) {
	for _, value := range num {
		str := strconv.Itoa(value)
		out.WriteString(str + " ")
	}
	//out.WriteString("\n")
}
func readInt(num ...*int) {

	for _, value := range num {
		in.Scan()
		*value, _ = strconv.Atoi(in.Text())
	}
}

func readString(st *string) {
	in.Scan()
	*st = in.Text()
}

package main

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

var testCases = []struct {
	s           string
	p           int
	expectedRet int
}{
	//{"aaaabbbb", 3, 8},
	// {"aabbbbaaaaccccaa", 4, 8},
	// {"aabbbbaaaaccccaa", 1, 9},
	// {"a", 1, 0},
	// {"ab", 1, 1},
	// {"abc", 2, 3},
	{"aeabcaez", 3, 6},
}

func min(x int, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

func solve(s string, p int) int {
	p-- // To zero index base

	// Transform p to be in the first half if it's not, this does not change
	// the problem.
	if p > len(s)/2 {
		p = len(s) - 1 - p
	}

	a := 0
	b := (len(s) - 1) / 2
	for ; b >= 0 && s[b] == s[len(s)-1-b]; b-- {
	}
	if b < 0 {
		// Already a palindrome
		return 0
	}
	for ; a < b && s[a] == s[len(s)-1-a]; a++ {
	}

	ret := 0
	// Calculate number of moves needed to change the letters.  Has to be
	// made no matter what.
	for i := a; i <= b; i++ {
		c1 := s[i]
		c2 := s[len(s)-1-i]
		ret += min((26+int(c1)-int(c2))%26, (26+int(c2)-int(c1))%26)
	}

	if p < a {
		ret += a - p
		p = a
	}
	if p > b {
		ret += p - b
		p = b
	}

	ret += b - a + min(b-p, p-a)
	return ret
}

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

	for _, t := range testCases {
		var ret = solve(t.s, t.p)
	  if ret != t.expectedRet {
			log.Fatalf("Wrong ret for (%v, %v): expected %v, got %v", t.s, t.p, t.expectedRet, ret)
	  }
	}

	var n, p int
	var s string
	fmt.Fscanf(o, "%d %d %s ", &n, &p, &s)
	if len(s) != n {
		log.Fatalf("%d != %d", len(s), n)
	}

	fmt.Printf("%d\n", solve(s, p))
}

package main

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

var testCases = []struct {
	s           string
	p           int
	expectedRet int
}{
	{"aaaabbbb", 3, 8},
	{"aabbbbaaaaccccaa", 4, 8},
	{"aabbbbaaaaccccaa", 1, 9},
	{"a", 1, 0},
	{"ab", 1, 1},
	{"abc", 2, 3},
}

func min(x int, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

func solve(s string, p int) int {
	p-- // To zero index base

	// Transform p to be in the first half if it's not, this does not change
	// the problem.
	if p > len(s)/2 {
		p = len(s) - 1 - p
	}

	a := 0
	b := (len(s) - 1) / 2
	for ; b >= 0 && s[b] == s[len(s)-1-b]; b-- {
	}
	if b < 0 {
		// Already a palindrome
		return 0
	}
	for ; a < b && s[a] == s[len(s)-1-a]; a++ {
	}

	ret := 0
	// Calculate number of moves needed to change the letters.  Has to be
	// made no matter what.
	for i := a; i <= b; i++ {
		c1 := s[i]
		c2 := s[len(s)-1-i]
		ret += min((26+int(c1-c2))%26, (26+int(c2-c1))%26)
	}

	if p < a {
		ret += a - p
		p = a
	}
	if p > b {
		ret += p - b
		p = b
	}

	ret += b - a + min(b-p, p-a)
	return ret
}

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

	for _, t := range testCases {
		var ret = solve(t.s, t.p)
	  if ret != t.expectedRet {
			log.Fatalf("Wrong ret for (%v, %v): expected %v, got %v", t.s, t.p, t.expectedRet, ret)
	  }
	}

	var n, p int
	var s string
	fmt.Fscanf(o, "%d %d %s ", &n, &p, &s)
	if len(s) != n {
		log.Fatalf("%d != %d", len(s), n)
	}

	fmt.Printf("%d\n", solve(s, p))
}


It is a holiday season, and Koala is decorating his house with cool lights! He owns $$$n$$$ lights, all of which flash periodically.After taking a quick glance at them, Koala realizes that each of his lights can be described with two parameters $$$a_i$$$ and $$$b_i$$$. Light with parameters $$$a_i$$$ and $$$b_i$$$ will toggle (on to off, or off to on) every $$$a_i$$$ seconds starting from the $$$b_i$$$-th second. In other words, it will toggle at the moments $$$b_i$$$, $$$b_i + a_i$$$, $$$b_i + 2 \cdot a_i$$$ and so on.You know for each light whether it's initially on or off and its corresponding parameters $$$a_i$$$ and $$$b_i$$$. Koala is wondering what is the maximum number of lights that will ever be on at the same time. So you need to find that out.    Here is a graphic for the first example.

The first line contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$), the number of lights. The next line contains a string $$$s$$$ of $$$n$$$ characters. The $$$i$$$-th character is "1", if the $$$i$$$-th lamp is initially on. Otherwise, $$$i$$$-th character is "0". The $$$i$$$-th of the following $$$n$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le a_i, b_i \le 5$$$)  — the parameters of the $$$i$$$-th light.

Print a single integer — the maximum number of lights that will ever be on at the same time.

NoteFor first example, the lamps' states are shown in the picture above. The largest number of simultaneously on lamps is $$$2$$$ (e.g. at the moment $$$2$$$).In the second example, all lights are initially on. So the answer is $$$4$$$.

/*
URL:
https://codeforces.com/problemset/problem/1209/B
*/

package main

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

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

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

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

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

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

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

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

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

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

var (
	n    int
	S    []rune
	A, B []int

	L [10000 + 50]int
)

func main() {
	n = ReadInt()
	S = ReadRuneSlice()
	for i := 0; i < n; i++ {
		a, b := ReadInt2()
		A = append(A, a)
		B = append(B, b)
	}

	for i := 0; i < n; i++ {
		a, b := A[i], B[i]

		cur := 1
		if S[i] == '1' {
			cur = -1
			L[0]++
		}

		for j := b + 1; j <= 10000; j += a {
			L[j] += cur
			if cur == 1 {
				cur = -1
			} else {
				cur = 1
			}
		}
	}

	for i := 1; i <= 10000; i++ {
		L[i] += L[i-1]
	}

	ans := 0
	for i := 0; i <= 10000; i++ {
		ChMax(&ans, L[i])
	}
	fmt.Println(ans)
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

package main

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

func main() {
	defer Flush()

	n := readi()
	s := readb()
	a := make([]int, n)
	b := make([]int, n)
	for i := range a {
		a[i] = readi()
		b[i] = readi()
	}

	m := make(map[int]bool)
	for i, c := range s {
		if c == '1' {
			m[i] = true
		}
	}

	ans := len(m)
	for t := 1; t <= 2*3*4*5+100; t++ {
		for i := range a {
			if t < b[i] {
				continue
			}
			if (t-b[i])%a[i] == 0 {
				if m[i] {
					delete(m, i)
				} else {
					m[i] = true
				}
			}
		}
		ans = max(ans, len(m))
	}
	println(ans)

}

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

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

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

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

// reverse slice in place
func reverse(a []int) {
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
}

// areverse: allocating reverse
func areverse(a []int) []int {
	b := make([]int, len(a))
	for i := range a {
		b[i] = a[len(a)-i-1]
	}
	return b
}

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

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


This is an interactive problem. In the output section below you will see the information about flushing the output.Bear Limak thinks of some hidden number — an integer from interval [2, 100]. Your task is to say if the hidden number is prime or composite.Integer x > 1 is called prime if it has exactly two distinct divisors, 1 and x. If integer x > 1 is not prime, it's called composite.You can ask up to 20 queries about divisors of the hidden number. In each query you should print an integer from interval [2, 100]. The system will answer "yes" if your integer is a divisor of the hidden number. Otherwise, the answer will be "no".For example, if the hidden number is 14 then the system will answer "yes" only if you print 2, 7 or 14.When you are done asking queries, print "prime" or "composite" and terminate your program.You will get the Wrong Answer verdict if you ask more than 20 queries, or if you print an integer not from the range [2, 100]. Also, you will get the Wrong Answer verdict if the printed answer isn't correct.You will get the Idleness Limit Exceeded verdict if you don't print anything (but you should) or if you forget about flushing the output (more info below).

After each query you should read one string from the input. It will be "yes" if the printed integer is a divisor of the hidden number, and "no" otherwise.

Up to 20 times you can ask a query — print an integer from interval [2, 100] in one line. You have to both print the end-of-line character and flush the output. After flushing you should read a response from the input. In any moment you can print the answer "prime" or "composite" (without the quotes). After that, flush the output and terminate your program. To flush you can use (just after printing an integer and end-of-line):    fflush(stdout) in C++;  System.out.flush() in Java;  stdout.flush() in Python;  flush(output) in Pascal;  See the documentation for other languages.  Hacking. To hack someone, as the input you should print the hidden number — one integer from the interval [2, 100]. Of course, his/her solution won't be able to read the hidden number from the input.

NoteThe hidden number in the first query is 30. In a table below you can see a better form of the provided example of the communication process.The hidden number is divisible by both 2 and 5. Thus, it must be composite. Note that it isn't necessary to know the exact value of the hidden number. In this test, the hidden number is 30.59 is a divisor of the hidden number. In the interval [2, 100] there is only one number with this divisor. The hidden number must be 59, which is prime. Note that the answer is known even after the second query and you could print it then and terminate. Though, it isn't forbidden to ask unnecessary queries (unless you exceed the limit of 20 queries).

package main

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

const maxCapacity = 1024

var scanner *bufio.Scanner
var writer *bufio.Writer

func ioPrepare() {
	scanner = bufio.NewScanner(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)

	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)
}

func solve() {
	primes := []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47}
	count := 0
	prime := 0
	for _, i := range primes {
		fmt.Println(i)
		scanner.Scan()
		result := scanner.Text()
		if result == "yes" {
			prime = i
			count++
		}
	}
	if count == 0 {
		fmt.Println("prime")
	} else if count >= 2 {
		fmt.Println("composite")
	} else {
		num := prime * prime
		if num > 100 {
			fmt.Println("prime")
		} else {
			fmt.Println(num)
			scanner.Scan()
			result := scanner.Text()
			if result == "yes" {
				fmt.Println("composite")
			} else {
				fmt.Println("prime")
			}
		}
	}
}

func main() {
	ioPrepare()
	solve()
}

package main

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

const maxCapacity = 1024 * 1024 * 10

var scanner *bufio.Scanner
var writer *bufio.Writer

func ioPrepare() {
	scanner = bufio.NewScanner(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)

	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)
}

func solve() {
	primes := []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47}
	count := 0
	prime := 0
	for _, i := range primes {
		fmt.Println(i)
		scanner.Scan()
		result := scanner.Text()
		if result == "yes" {
			prime = i
			count++
		}
	}
	if count == 0 {
		fmt.Println("prime")
	} else if count >= 2 {
		fmt.Println("composite")
	} else {
		num := prime * prime
		if num > 100 {
			fmt.Println("prime")
		} else {
			fmt.Println(num)
			scanner.Scan()
			result := scanner.Text()
			if result == "yes" {
				fmt.Println("composite")
			} else {
				fmt.Println("prime")
			}
		}
	}
}

func main() {
	ioPrepare()
	solve()
}

package main

import "fmt"

func main() {
	is_prime := make([]bool, 101, 101)
	for i := 1; i <= 100; i++ {
		is_prime[i] = true
	}

	for i := 2; i <= 10; i++ {
		if !is_prime[i] {
			continue
		}
		for j := i + i; j <= 100; j += i {
			is_prime[j] = false
		}
	}

	var judge string
	cnt := 0
	for i := 2; i <= 50; i++ {
		if is_prime[i] {
			fmt.Println(i)
			fmt.Scan(&judge)
			if judge == "yes" {
				cnt++
			}

			if i*i <= 100 {
				fmt.Println(i * i)
				fmt.Scan(&judge)
				if judge == "yes" {
					cnt++
				}
			}

			if cnt >= 2 {
				break
			}
		}
	}

	if cnt >= 2 {
		fmt.Println("composite")
	} else {
		fmt.Println("prime")
	}
}

package main

import "fmt"
import "os"

func main() {
    var p = []int{4, 9, 25, 49, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47}
    var i int = 0
    var count int = 0
    for i < 19 {
        fmt.Printf("%d\n", p[i])
        os.Stdout.Sync()
        var line string
        fmt.Scanln(&line)
        if line == "yes" {
            count++
            if (count > 1 || i < 4) {
                fmt.Printf("composite")
                os.Stdout.Sync()
                os.Exit(0)
            }
        }
        i++
    }
    fmt.Printf("prime")
    os.Stdout.Sync()
}

package main

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

func main() {
	primes := []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47}
	cum := 1
	divisors := 0
	bufin, bufout := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	for _, p := range primes {
		if p*cum > 100 {
			break
		}
		_, err := fmt.Fprintln(bufout, p)
		if err != nil {
			panic(err)
		}
		err = bufout.Flush()
		if err != nil {
			panic(err)
		}
		var s string
		_, err = fmt.Fscanln(bufin, &s)
		if err != nil {
			panic(err)
		}
		if s == "yes" {
			divisors++
			cum *= p
			if divisors < 2 && p*p <= 100 {
				_, err := fmt.Fprintln(bufout, p*p)
				if err != nil {
					panic(err)
				}
				err = bufout.Flush()
				if err != nil {
					panic(err)
				}
				var s string
				_, err = fmt.Fscanln(bufin, &s)
				if err != nil {
					panic(err)
				}
				if s == "yes" {
					divisors++
					cum *= p
				}
			}
		}
		if divisors >= 2 {
			break
		}
	}
	isprime := divisors < 2
	results := map[bool]string{
		false: "composite",
		true:  "prime",
	}
	_, err := fmt.Fprintln(bufout, results[isprime])
	if err != nil {
		panic(err)
	}
	err = bufout.Flush()
	if err != nil {
		panic(err)
	}
}

package main

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

const maxCapacity = 1024 * 1024 * 10

var scanner *bufio.Scanner
var writer *bufio.Writer

func ioPrepare() {
	scanner = bufio.NewScanner(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)

	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)
}

func solve() {
	primes := []int{2, 3, 5, 7}
	count := 0
	prime := 0
	for _, i := range primes {
		fmt.Println(i)
		scanner.Scan()
		result := scanner.Text()
		if result == "yes" {
			prime = i
			count++
		}
	}
	if count == 0 {
		fmt.Println("prime")
	} else if count >= 2 {
		fmt.Println("composite")
	} else {
		num := prime * prime
		fmt.Println(num)
		scanner.Scan()
		result := scanner.Text()
		if result == "yes" {
			fmt.Println("composite")
		} else {
			fmt.Println("prime")
		}
	}
}

func main() {
	ioPrepare()
	solve()
}

package main

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

const maxCapacity = 1024 * 1024 * 10

var scanner *bufio.Scanner
var writer *bufio.Writer

func ioPrepare() {
	scanner = bufio.NewScanner(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)

	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)
}

func solve() {
	primes := []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47}
	count := 0
	prime := 0
	for _, i := range primes {
		fmt.Println(i)
		scanner.Scan()
		result := scanner.Text()
		if result == "yes" {
			prime = i
			count++
		}
	}
	if count == 0 {
		fmt.Println("prime")
	} else if count >= 2 {
		fmt.Println("composite")
	} else {
		num := prime * prime
		fmt.Println(num)
		scanner.Scan()
		result := scanner.Text()
		if result == "yes" {
			fmt.Println("composite")
		} else {
			fmt.Println("prime")
		}
	}
}

func main() {
	ioPrepare()
	solve()
}

package main

import "fmt"

func main() {
	is_prime := make([]bool, 101, 101)
	for i := 1; i <= 100; i++ {
		is_prime[i] = true
	}

	for i := 2; i <= 10; i++ {
		if !is_prime[i] {
			continue
		}
		for j := i + i; j <= 10; j += i {
			is_prime[j] = false
		}
	}

	var judge string
	cnt := 0
	for i := 2; i <= 100; i++ {
		if is_prime[i] {
			fmt.Println(i)
			fmt.Scan(&judge)
			if judge == "yes" {
				cnt++
			}

			if i*i <= 100 {
				fmt.Println(i * i)
				fmt.Scan(&judge)
				if judge == "yes" {
					cnt++
				}
			}

			if cnt >= 2 {
				break
			}
		}
	}

	if cnt >= 2 {
		fmt.Println("composite")
	} else {
		fmt.Println("prime")
	}
}

package main

import "fmt"

func main() {
	is_prime := make([]bool, 101, 101)
	for i := 1; i <= 100; i++ {
		is_prime[i] = true
	}

	for i := 2; i <= 10; i++ {
		if !is_prime[i] {
			continue
		}
		for j := i + i; j <= 10; j += i {
			is_prime[j] = false
		}
	}

	var judge string
	cnt := 0
	for i := 2; i <= 50; i++ {
		if is_prime[i] {
			fmt.Println(i)
			fmt.Scan(&judge)
			if judge == "yes" {
				cnt++
			}

			if i*i <= 100 {
				fmt.Println(i * i)
				fmt.Scan(&judge)
				if judge == "yes" {
					cnt++
				}
			}

			if cnt >= 2 {
				break
			}
		}
	}

	if cnt >= 2 {
		fmt.Println("composite")
	} else {
		fmt.Println("prime")
	}
}

package main

import "fmt"
import "os"

func main() {
    var p = []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71}
    var i int = 0
    var count int = 0
    for i < 20 {
        fmt.Printf("%d\n", p[i])
        os.Stdout.Sync()
        var line string
        fmt.Scanln(&line)
        if line == "yes" {
            count++
        }
        i++
        if (count > 1) {
            fmt.Printf("composite")
            os.Stdout.Sync()
            os.Exit(0)
        }
    }
    fmt.Printf("prime")
    os.Stdout.Sync()
}


Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the board are adjacent if they share a side.

The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.

Print "YES" or "NO" (without the quotes) depending on the answer to the problem.

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.txt"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n int
	for I(&n, "\n") == nil {
		solve(n)
	}
}

func solve(n int) {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		I(&a[i], "\n")
	}
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			t := 0
			if j+1 < n && a[i][j+1] == 'o' {
				t++
			}
			if j-1 >= 0 && a[i][j-1] == 'o' {
				t++
			}
			if i+1 < n && a[i+1][j] == 'o' {
				t++
			}
			if i-1 >= 0 && a[i-1][j] == 'o' {
				t++
			}
			if t%2 != 0 {
				O("NO", "\n")
				return
			}
		}
	}
	O("YES", "\n")
}

package main

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

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

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	a := make([]string ,n)
	count := 0

	for i := 0; i < n; i++ {
		a[i] = next()
	}

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

			if j > 0 && a[i][j - 1] == 'o' {
				count++
			}

			if j < n - 1 && a[i][j + 1] == 'o' {
				count++
			}

			if i > 0 && a[i - 1][j] == 'o' {
				count++
			}

			if i < n - 1 && a[i + 1][j] == 'o' {
				count++
			}

			if count % 2 != 0 {
				println("NO")
				return
			}
		}
	}

	println("YES")
}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

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

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

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

package main

//14:17

import (
    "fmt"
)

func main() {
    var n int
    fmt.Scanf("%d ", &n)
    array := make([][]int8, n)
    for i:=0;i<n;i++{
        array[i] = make([]int8,n)
    }
    for i:=0;i<n;i++ {
        for j:=0;j<n;j++{
            fmt.Scanf("%c", &array[i][j])
        }
        fmt.Scanf(" ")
    }
    for i:=0;i<n;i++ {
        for j:=0;j<n;j++{
            var o int
            if i>0 && array[i-1][j]== 'o'{
                o += 1
            }
            if i<n-1 && array[i+1][j] =='o'{
                o += 1
            }
            if j>0 && array[i][j-1]== 'o'{
                o += 1
            }
            if j<n-1 && array[i][j+1] =='o'{
                o += 1
            }
            if o%2 !=0 {
                fmt.Printf("NO")
                return
            }
        }
    }
    fmt.Printf("YES")
}

package main

import (
	"fmt"
)

func main() {
	var n int
	var board [100][100]rune
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		rs := []rune(s)
		for j, r := range rs {
			board[i][j] = r
		}
	}
	check := func() string {
		xs := [4]int{1, 0, -1, 0}
		ys := [4]int{0, 1, 0, -1}
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				z := 0
				for k := 0; k < 4; k++ {
					dx := xs[k]
					dy := ys[k]
					x := i + dx
					y := j + dy
					if x < 0 || n <= x || y < 0 || n <= y {
						continue
					}
					if board[x][y] == 'o' {
						z++
					}
				}
				if (z & 1) > 0 {
					return "NO"
				}
			}
		}
		return "YES"
	}
	fmt.Println(check())
}

package main

import (
    "fmt"
    )

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

    lines := make([]string, n, n)
    for i := 0; i < n; i++ {
        fmt.Scan(&lines[i])
    }

    moves := [...][2]int {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}

    ans := true
    for i := 0; i < n; i++ {
        for j := 0; j < n; j++ {
            count := 0
            for k := 0; k < 4; k++ {
                x, y := i + moves[k][0], j + moves[k][1]
                if x >= 0 && x < n && y >= 0 && y < n {
                    if lines[x][y] == 'o' {
                        count++
                    }
                }
            }

            if count % 2 != 0 {
                ans = false
                break
            }
        }

        if ans == false {
            break
        }
    }

    if ans == true {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}

package main

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

func main() {

	dx := []int {0, 0, -1, 1}
	dy := []int {-1, 1, 0, 0}

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

	line, _ := reader.ReadString('\n')

	n,_ = strconv.Atoi(strings.TrimSpace(line))

	lines := []string{}

	for i:=0; i<n; i++ {
		line, _ := reader.ReadString('\n')
		lines = append(lines, line)
	}
	for i:=0; i<n; i++ {
		for j:=0; j<n; j++{
			num := 0
			for dir:=0; dir<4; dir ++ {
				cx := i + dx[dir]
				cy := j + dy[dir]
				if cx>=0 && cx < n && cy >= 0 && cy < n && lines[cx][cy] == 'o' {
					num ++
				}
			}
			if ((num&1)==1) {
				goto exit
			}
		}
	}

    fmt.Println("YES")
    return
    exit:
    fmt.Println("NO")
    return
}

package main

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

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

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	a := make([]string ,n)
	count := 0

	for i := 0; i < n; i++ {
		a[i] = next()
	}

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

			if a[i][j] == 'x' {
				if j > 0 && a[i][j - 1] == 'o' {
					count++
				}

				if j < n - 1 && a[i][j + 1] == 'o' {
					count++
				}

				if i > 0 && a[i - 1][j] == 'o' {
					count++
				}

				if i < n - 1 && a[i + 1][j] == 'o' {
					count++
				}

				if count % 2 != 0 {
					println("NO")
					return
				}
			}
		}
	}

	println("YES")
}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

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

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

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

package main

import (
	"fmt"
)

func main() {
	var n int
	var board [100][100]rune
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		rs := []rune(s)
		for j, r := range rs {
			board[i][j] = r
		}
	}
	check := func() string {
		xs := [4]int{1, 0, -1, 0}
		ys := [4]int{0, 1, 0, -1}
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				z := 0
				for k := 0; k < 4; k++ {
					dx := xs[k]
					dy := ys[k]
					x := i + dx
					y := k + dy
					if x < 0 || n <= x || y < 0 || n <= y {
						continue
					}
					if board[x][y] == 'o' {
						z++
					}
				}
				if (z & 1) > 0 {
					return "NO"
				}
			}
		}
		return "YES"
	}
	fmt.Println(check())
}

package main

import (
	"fmt"
)

func main() {
	var n int
	var board [100][100]rune
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		rs := []rune(s)
		for j, r := range rs {
			board[i][j] = r
		}
	}
	check := func() string {
		xs := [4]int{1, 0, -1, 0}
		ys := [4]int{0, 1, 0, -1}
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				z := 0
				for k := 0; k < 4; k++ {
					dx := xs[k]
					dy := ys[k]
					x := i + dx
					y := k + dy
					if x < 0 || n <= x || y < 0 || n <= y {
						continue
					}
					if board[x][y] == 'o' {
						z++
					}
				}
				if (z & 1) > 0 {
					return "No"
				}
			}
		}
		return "Yes"
	}
	fmt.Println(check())
}