Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the opposite poles will attract each other.Mike starts by laying one magnet horizontally on the table. During each following step Mike adds one more magnet horizontally to the right end of the row. Depending on how Mike puts the magnet on the table, it is either attracted to the previous one (forming a group of multiple magnets linked together) or repelled by it (then Mike lays this magnet at some distance to the right from the previous one). We assume that a sole magnet not linked to others forms a group of its own.  Mike arranged multiple magnets in a row. Determine the number of groups that the magnets formed.

NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.

package main

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

func main(){
	var (
		tmp,sum,x,n int
	)
	tmp = 0
	sum = 0
	x = 0
	in := bufio.NewReader(os.Stdin)
	fmt.Scan(&n)
	for i:=0;i<n;i++{
		fmt.Fscan(in, &x)
		if x!=tmp{
			sum++
			tmp = x
		}
	}
	fmt.Println(sum)
}

package main

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

func main() {
	var n int
	var m1, m2 string
	var ost int
	fmt.Scanln(&n)
	fmt.Scanln(&m1)
	ost = 1
	reader := bufio.NewReader(os.Stdin)
	for i := 1; i < n; i++ {
		m2, _ = reader.ReadString('\n')
		//fmt.Print(m2)
		m2 = strings.TrimSpace(m2)
		if m1 != m2 {
			ost++
		}
		m1 = m2
	}
	fmt.Println(ost)
}

package main

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

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

	gr := 0
	lst := ""
	for scanner.Scan() {
		cur := scanner.Text()
		if cur != lst {
			lst = cur
			gr++
		}
	}

	fmt.Println(gr)
}

package main

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

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	var groups, prevX, x int
	scanner := bufio.NewScanner(os.Stdin)

	for i := 0; i < n; i++ {
		// fmt.Scan(&x)
		scanner.Scan()
		x = toInt(scanner.Bytes())
		if x != prevX {
			groups++
		}
		prevX = x
	}
	fmt.Println(groups)
}
func toInt(buf []byte) (n int) {
	for _, v := range buf {
		n = n*10 + int(v-'0')
	}
	return
}

package main

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

func main() {
	var n, m, c int

	scr := bufio.NewReader(os.Stdin)
	ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &n)
	fmt.Fscanln(scr, &m)

	cnt := 1

	for i := 0; i < n-1; i++ {
		fmt.Fscanln(scr, &c)
		if c != m {
			cnt++
			m = c
		}
	}
	fmt.Fprintln(ocr, cnt)
	ocr.Flush()

}

package main

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

var n int
var a []string

func main() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader := bufio.NewReaderSize(stdin, 1<<20)
	fmt.Fscanf(reader, "%d\n", &n)

	a = make([]string, n)
	ans := 1
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%s\n", &a[i])

		if i != 0 {
			if a[i][0] == a[i-1][1] {
				ans++
			}
		}
	}

	fmt.Println(ans)
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n,a,p,c uint32
	fmt.Fscanf(in, "%d\n", &n)
	for i:=0; uint32(i) < n; i++{
		fmt.Fscanf(in, "%d\n", &a)

		if p != 0 && p != a{
			c++
		}
		p = a
	}
	fmt.Println(c+1)
}

package main

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

func main() {
	var n int
	fmt.Scan(&n)
	var cnt int
	r := bufio.NewScanner(os.Stdin)
	var prev string
	for r.Scan() {
		t := r.Text()
		if t != prev {
			prev = t
			cnt++
		}
	}
	fmt.Print(cnt)
}

package main

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

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

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

func main() {
	defer writer.Flush()

	var (
		n       int
		groups  int
		current int
		old     int
	)

	scanf("%d\n", &n)

	for i := 0; i < n; i++ {
		scanf("%d\n", &current)
		if current != old {
			groups++
		}
		old = current
	}

	printf("%d\n", groups)
}

package main

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

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

    magnets := make([]string, n, n)
    /*bs := bufio.NewScanner(os.Stdin)
    for i := 0; i < n; i++ {
        bs.Scan()
        magnets[i] = bs.Text()
    }*/

    reader := bufio.NewReader(os.Stdin)
    for i := 0; i < n; i++ {
        bytes, _, _ := reader.ReadLine()
        magnets[i] = string(bytes)
    }

    group := 1
    pre := magnets[0]
    for i := 1; i < n; i++ {
        if pre != magnets[i] {
            pre = magnets[i]
            group += 1
        }
    }

    fmt.Println(group)
}

package main

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

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

    magnets := make([]string, n, n)
    bs := bufio.NewScanner(os.Stdin)
    for i := 0; i < n; i++ {
        bs.Scan()
        magnets[i] = bs.Text()
    }

    /*reader := bufio.NewReader(os.Stdin)
    for i := 0; i < n; i++ {
        bytes, _, _ := reader.ReadLine()
        magnets[i] = string(bytes)
    }*/

    group := 1
    pre := magnets[0]
    for i := 1; i < n; i++ {
        if pre != magnets[i] {
            pre = magnets[i]
            group += 1
        }
    }

    fmt.Println(group)
}

//  URL: http://codeforces.com/problemset/problem/344/A
//  ~ Basic Implementation Problem

package main

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

func solve(magnets []string, prevMagnet string, groups int) int {
	if len(magnets) == 0 {
		return groups
	}
	if magnets[0] != prevMagnet {
		return solve(magnets[1:], magnets[0], groups + 1)
	} else {
		return solve(magnets[1:], prevMagnet, groups)
	}
}

func main() {
	reader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	magnets := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%s\n", &magnets[i])
	}
	fmt.Fprintf(writer, "%d\n", solve(magnets, "", 0))
}

package main

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

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

	var current, prev string
	scanner.Scan()

	island := 1
	scanner.Scan()
	current = scanner.Text()
	prev = current
	for scanner.Scan() {
		current = scanner.Text()
		if (current != prev) {
			island++;
		}
		prev = current
	}

	fmt.Println(island)
}

package main

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

var scanner *bufio.Scanner
func read() string {
    if !scanner.Scan() {
		panic("Scan returned false")
	}
	return scanner.Text()
}
func readInt() int {
	num, _ := strconv.Atoi(read())
	return num
}

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

    grp := 0
    prev := -1
    for i := 0; i < n; i++ {
        curr := readInt()
        if curr != prev {
            grp++
            prev = curr
        }
    }

    fmt.Println(grp)
}

package main

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

func main() {
	var numberOfMagnets int
	fmt.Scan(&numberOfMagnets)
	var numberOfGroups int
	r := bufio.NewScanner(os.Stdin)
	var previousMagnet string

	for r.Scan() {
		currentMagnet := r.Text()
		if currentMagnet != previousMagnet {
			previousMagnet = currentMagnet
			numberOfGroups++
		}
	}
	fmt.Print(numberOfGroups)
}

package main

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

func main() {
	var line string
	var flag bool
	var n, summ int
	reader := bufio.NewReader(os.Stdin)
	fmt.Scanf("%d\n", &n)
	line, _ = reader.ReadString('\n')
	line = strings.TrimSpace(line)
	if line == "10" {
		flag = true
	}
	for i := 1; i < n; i++ {
		line, _ = reader.ReadString('\n')
		line = strings.TrimSpace(line)
		if line == "10" {
			if !flag {
				summ++
			}
			flag = true
		} else {
			if flag {
				summ++
			}
			flag = false
		}
	}
	fmt.Println(summ + 1)
}

package main

import "fmt"

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

package main

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

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func main(){

	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)

	n, _ := strconv.Atoi(readString())
	list := make([]string, n)
	for i := 0; i < n; i++ {
		list[i] = readString()
	}
	res := 1

	for i := 1; i < n; i++ {
		if list[i - 1][1] == list[i][0] {
			res ++
		}
	}
	fmt.Println(res)
}

package main

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

func ReadInts() (r []int) {
    var buf []byte
    buf, _ = ioutil.ReadAll(os.Stdin)
    num := 0
    found := false
    for _, v := range buf {
        if v >= '0' && v <= '9' {
            num = 10*num + int(v-'0')
            found = true
        } else if found {
            r = append(r,num)
            found, num = false, 0
        }
    }
    if found {
        r = append(r,num)
        found, num = false, 0
    }
    return
}

func main() {
    var n int
    fmt.Scan(&n)
    ans := 1
    a := ReadInts()
    for i := 1; i < n; i++ {
        if (a[i]/10) == (a[i-1]%10) { ans++ }
    }
    fmt.Println(ans)
}

package main

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

// https://codeforces.com/problemset/problem/344/A
// A. Magnets
// time limit per test
// 1 second
// memory limit per test
// 256 megabytes
// input
// standard input
// output
// standard output

// Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the opposite poles will attract each other.

// Mike starts by laying one magnet horizontally on the table. During each following step Mike adds one more magnet horizontally to the right end of the row. Depending on how Mike puts the magnet on the table, it is either attracted to the previous one (forming a group of multiple magnets linked together) or repelled by it (then Mike lays this magnet at some distance to the right from the previous one). We assume that a sole magnet not linked to others forms a group of its own.

// Mike arranged multiple magnets in a row. Determine the number of groups that the magnets formed.
// Input

// The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
// Output

// On the single line of the output print the number of groups of magnets.

func main() {
	solveTheProblem()
}

func solveTheProblem() {
	var n int // number of magnets
	fmt.Scan(&n)

	// this problem has a test case with 100k magnets, so we need to use bufio to reduce the number of IO ops
	// as the 1 second time limit can be exceeded very easily
	bufStdin := bufio.NewReader(os.Stdin)

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

	fmt.Print(howManyGroups(magnets))
}

func howManyGroups(magnets []int) int {
	// by default there is one group since a positive number of magnets can be arranged into a single connected group
	nGroups := 1

	// we look at all consecutive pairs of magnets, and if they face each other with the same poles
	// then the magnets repel and a new "group" is created
	for i := 0; i < len(magnets)-1; i++ {
		// we look at magnets at positions i and i+1

		curMag := magnets[i]
		nextMag := magnets[i+1]

		// the right pole of magnet i is adjcaent to the left pole of magnet i+1
		// if they are the same, the 2 magnets repel and a new group beginning with nextMag is formed
		if curMag != nextMag {
			nGroups++
		}
	}

	return nGroups
}

package main

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

// https://codeforces.com/problemset/problem/344/A
// A. Magnets
// time limit per test
// 1 second
// memory limit per test
// 256 megabytes
// input
// standard input
// output
// standard output

// Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the opposite poles will attract each other.

// Mike starts by laying one magnet horizontally on the table. During each following step Mike adds one more magnet horizontally to the right end of the row. Depending on how Mike puts the magnet on the table, it is either attracted to the previous one (forming a group of multiple magnets linked together) or repelled by it (then Mike lays this magnet at some distance to the right from the previous one). We assume that a sole magnet not linked to others forms a group of its own.

// Mike arranged multiple magnets in a row. Determine the number of groups that the magnets formed.
// Input

// The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
// Output

// On the single line of the output print the number of groups of magnets.

func main() {
	solveTheProblem()
}

func solveTheProblem() {
	var n int // number of magnets
	fmt.Scan(&n)

	// this problem has a test case with 100k magnets, so we need to use bufio to reduce the number of IO ops
	// as the 1 second time limit can be exceeded very easily
	bufStdin := bufio.NewReaderSize(os.Stdin, 1<<16)

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

	fmt.Print(howManyGroups(magnets))
}

func howManyGroups(magnets []int) int {
	// by default there is one group since a positive number of magnets can be arranged into a single connected group
	nGroups := 1

	// we look at all consecutive pairs of magnets, and if they face each other with the same poles
	// then the magnets repel and a new "group" is created
	for i := 0; i < len(magnets)-1; i++ {
		// we look at magnets at positions i and i+1

		curMag := magnets[i]
		nextMag := magnets[i+1]

		// the right pole of magnet i is adjcaent to the left pole of magnet i+1
		// if they are the same, the 2 magnets repel and a new group beginning with nextMag is formed
		if curMag != nextMag {
			nGroups++
		}
	}

	return nGroups
}

package main

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

// https://codeforces.com/problemset/problem/344/A
// A. Magnets
// time limit per test
// 1 second
// memory limit per test
// 256 megabytes
// input
// standard input
// output
// standard output

// Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the opposite poles will attract each other.

// Mike starts by laying one magnet horizontally on the table. During each following step Mike adds one more magnet horizontally to the right end of the row. Depending on how Mike puts the magnet on the table, it is either attracted to the previous one (forming a group of multiple magnets linked together) or repelled by it (then Mike lays this magnet at some distance to the right from the previous one). We assume that a sole magnet not linked to others forms a group of its own.

// Mike arranged multiple magnets in a row. Determine the number of groups that the magnets formed.
// Input

// The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
// Output

// On the single line of the output print the number of groups of magnets.

func main() {
	solveTheProblem()
}

func solveTheProblem() {
	var n int // number of magnets
	fmt.Scan(&n)

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

	magnets := make([]int, n)
	for i := 0; i < n; i++ {
		_ = stdin.Scan()
		str := stdin.Text()
		magnets[i], _ = strconv.Atoi(str)
	}

	fmt.Print(howManyGroups(magnets))
}

func howManyGroups(magnets []int) int {
	// by default there is one group since a positive number of magnets can be arranged into a single connected group
	nGroups := 1

	// we look at all consecutive pairs of magnets, and if they face each other with the same poles
	// then the magnets repel and a new "group" is created
	for i := 0; i < len(magnets)-1; i++ {
		// we look at magnets at positions i and i+1

		curMag := magnets[i]
		nextMag := magnets[i+1]

		// the right pole of magnet i is adjcaent to the left pole of magnet i+1
		// if they are the same, the 2 magnets repel and a new group beginning with nextMag is formed
		if curMag != nextMag {
			nGroups++
		}
	}

	return nGroups
}

package main

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

// https://codeforces.com/problemset/problem/344/A
// комментарии к решению
// Островки считаются как непохожесть последнему проверенному магниту
// т.е. 101010: 10 == 10 == 10 => 1 остров
// 10011001: 10 != 01 != 10 != 01 => 4 острова
// для исключение повторного просчёта надо сдвигаться вправо на 2 символа
// вместо одного после проверки каждого магнита
func taskSolution(a []byte) (res int) {
	last := ""
	for i := 1; i < len(a); i += 1 {
		switch {
		case a[i-1] == '0' && a[i] == '1':
			if last != "01" {
				res += 1
				last = "01"
			}
			i += 1
		case a[i-1] == '1' && a[i] == '0':
			if last != "10" {
				res += 1
				last = "10"
			}
			i += 1
		}
	}
	return res
}

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(inRaw))
}

package main

// https://codeforces.com/problemset/problem/344/A

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

func taskSolution(a []byte) int {
	last := 0
	res := 1
	for last < len(a) && a[last] != '0' && a[last] != '1' {
		last += 1
	}
	for i := last + 1; i < len(a); i += 1 {
		// find end of magnet
		for i < len(a) && (a[i] == '0' || a[i] == '1') {
			i += 1
		}
		// skip spaces
		for i < len(a) && a[i] != '0' && a[i] != '1' {
			i += 1
		}
		if i < len(a) && a[i] != a[last] {
			res += 1
			last = i
		}
	}
	return res
}

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

var (
	rw   *bufio.ReadWriter = bufio.NewReadWriter(bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout))
)

func nextString() string {
	token := []byte{}
	for {
		c, err := rw.ReadByte()
		if err != nil || c == ' ' || c == '\n' {
			return string(token)
		} else if c == '\r' {
			_, _ = rw.ReadByte()
			return string(token)
		} else {
			token = append(token, c)
		}
	}
}

func nextInt() int {
	ans, _ := strconv.Atoi(nextString())
	return ans
}

func main() {
	defer rw.Flush()
	n := nextInt()
	last := nextInt()
	count := 1
	for i := 1; i < n; i++ {
		cur := nextInt()
		if last != cur {
			count++
			last = cur
		}
	}
	fmt.Fprintln(rw, count)
}

package main

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

func main() {
	reader := bufio.NewScanner(os.Stdin)
	var n int
	fmt.Scanf("%d", &n)
	var start string
	res := 0
	for reader.Scan() {
		cur := reader.Text()
		if cur != start {
			start = cur
			res += 1
		}
	}
	fmt.Println(res)
}

package main

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

func main() {
	var d, n, cnt, last int

	scr := bufio.NewReader(os.Stdin)
	ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &n)

	for i := 0; i < n; i++ {
		fmt.Fscanln(scr, &d)
		if i >= 1 && last != d {
			cnt++
		}
		last = d
	}

	fmt.Fprintln(ocr, cnt+1)
	ocr.Flush()

}

package main

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

func main() {
	var n int
	var input string
	var last strings.Builder

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &n)
	last.WriteString("")
	count := 0
	//fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		//fmt.Scanf("%s\n", &input)
		scanner.Scan()
		input = scanner.Text()
		if input != last.String() {
			count++
			last.Reset()
			last.WriteString(input)
		}
	}
	c := count
	fmt.Println(c)
}

//124 ms
// func main() {
// 	var n int
// 	var input string
// 	var last strings.Builder

// 	in := bufio.NewReader(os.Stdin)
// 	fmt.Fscan(in, &n)
// 	last.WriteString("")
// 	count := 0
// 	//fmt.Scanf("%d\n", &n)
// 	for i := 0; i < n; i++ {
// 		//fmt.Scanf("%s\n", &input)
// 		fmt.Fscan(in, &input)
// 		if input != last.String() {
// 			count++
// 			last.Reset()
// 			last.WriteString(input)
// 		}
// 	}
// 	c := count
// 	fmt.Println(c)
// }

package main

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

func main() {
	var n int
	var input string
	var last strings.Builder

	in := bufio.NewReader(os.Stdin)

	fmt.Fscan(in, &n)

	last.WriteString("")
	count := 0
	//fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		//fmt.Scanf("%s\n", &input)
		fmt.Fscan(in, &input)
		if input != last.String() {
			count++
			last.Reset()
			last.WriteString(input)
		}
	}
	c := count
	fmt.Println(c)
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)

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

func main() {
	var number, i int = 0, 1
	_, _ = fmt.Scanln(&number)
	var oned = make([]int, number, number+3)

	if number == 1 {
		_, _ = fmt.Scanln(&oned[0])
		fmt.Print("1")
		os.Exit(0)
	}
	count := 1
	_, _ = fmt.Scanln(&oned[0])
	for i = 1; i < number; i++ {
		scanf("%d\n", &oned[i])
		if oned[i] != oned[i-1] {
			count++
		}
	}

	fmt.Println(count)

}

// A. Magnets
/*
Mad scientist Mike entertains himself by arranging rows of dominoes.
He doesn't need dominoes, though: he uses rectangular magnets instead.
Each magnet has two poles, positive (a "plus") and negative (a "minus").
If two magnets are put together at a close distance, then the like poles will
repel each other and the opposite poles will attract each other.

Mike starts by laying one magnet horizontally on the table. During each
following step Mike adds one more magnet horizontally to the right end of the
row. Depending on how Mike puts the magnet on the table, it is either
attracted to the previous one (forming a group of multiple magnets linked
together) or repelled by it (then Mike lays this magnet at some distance to
the right from the previous one). We assume that a sole magnet not linked to
others forms a group of its own.

Mike arranged multiple magnets in a row. Determine the number of groups
that the magnets formed.

Input
The first line of the input contains an integer n (1 ≤ n ≤ 100000) —
the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n)
contains either characters "01", if Mike put the i-th magnet in the
"plus-minus" position, or characters "10", if Mike put the magnet in the
"minus-plus" position.

Output
On the single line of the output print the number of groups of magnets.

Examples
Input
6
10
10
10
01
10
10

Output
3

Input
4
01
01
10
10

Output
2

Note
The first testcase corresponds to the figure. The testcase has three groups
consisting of three, one and two magnets.

The second testcase has two groups, each consisting of two magnets.
*/
package main

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

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

	input2, _ := reader.ReadString('\n')
	prev, _ := strconv.Atoi(strings.TrimSpace(input2))
	groups := 1
	for i := 1; i < n; i++ {
		input3, _ := reader.ReadString('\n')
		v, _ := strconv.Atoi(strings.TrimSpace(input3))

		if prev != v {
			groups++
		}
		prev = v
	}
	fmt.Print(groups)
}

package main

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

func main(){
    var (
        n,res,i int
    )
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Scan()
    n,_=strconv.Atoi(scanner.Text())
    arr := make([]int,n)
    for i=0;i<n;i++{
        scanner.Scan()
        arr[i],_=strconv.Atoi(scanner.Text())
    }
    res=1
    for i=1;i<n;i++{
        if arr[i-1]!=arr[i]{
            res++
        }
    }
    fmt.Println(res)
}

package main

import (
	"bufio"
	"flag"
	"fmt"
	"io"
	"log"
	"os"
	"runtime/pprof"
	"strconv"
)

func run(s *InOut) {
	n := s.Next()

	p, c  := s.NextStr(), 1
	for i := 1; i < n; i++ {
		x := s.NextStr()
		if p != x {
			c++
		}
		p = x
	}
	s.Println(c)
}

func main() {
	flag.Parse()
	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}
	s := NewInOut(os.Stdin, os.Stdout)
	defer s.Flush()

	run(s)
}

var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")

type InOut struct {
	*bufio.Reader
	*bufio.Writer
}

func NewInOut(r io.Reader, w io.Writer) *InOut {
	return &InOut{bufio.NewReader(r), bufio.NewWriter(w)}
}

// Get Next Integer
func (s *InOut) Next() (r int) {
	b, _ := s.ReadByte()
	p := 1
	for (b < '0' || '9' < b) && b != '-' {
		b, _ = s.ReadByte()
	}
	if b == '-' {
		p = -1
		b, _ = s.ReadByte()
	}
	for '0' <= b && b <= '9' {
		r = 10*r + int(b-'0')
		b, _ = s.ReadByte()
	}
	return r * p
}

func (s *InOut) NextInt64() (r int64) {
	b, _ := s.ReadByte()
	p := int64(1)
	for (b < '0' || '9' < b) && b != '-' {
		b, _ = s.ReadByte()
	}
	if b == '-' {
		p = -1
		b, _ = s.ReadByte()
	}
	for '0' <= b && b <= '9' {
		r = 10*r + int64(b-'0')
		b, _ = s.ReadByte()
	}
	return r * p
}

// Get Next Line String
func (s *InOut) NextLine() (r string) {
	b, _ := s.ReadByte()
	for b == '\r' || b == '\n' {
		b, _ = s.ReadByte()
	}
	buf := make([]byte, 0)
	for ; b != '\r' && b != '\n'; b, _ = s.ReadByte() {
		buf = append(buf, b)
	}
	return string(buf)
}

// Get Next String using delimiter whitespace
func (s *InOut) NextStr() (r string) {
	return string(s.NextBytes())
}

// Get Next String using delimiter whitespace
func (s *InOut) NextBytes() (r []byte) {
	b, _ := s.ReadByte()
	for b == '\n' || b == ' ' {
		b, _ = s.ReadByte()
	}
	buf := make([]byte, 0)
	for ; b != '\n' && b != ' '; b, _ = s.ReadByte() {
		buf = append(buf, b)
	}
	return buf
}

// Print Strings using the suitable way to change type
func (s *InOut) Print(os ...interface{}) {
	for _, o := range os {
		switch o.(type) {
		case byte:
			s.WriteByte(o.(byte))
		case string:
			s.WriteString(o.(string))
		case int:
			s.WriteString(strconv.Itoa(o.(int)))
		case int64:
			s.WriteString(strconv.FormatInt(o.(int64), 10))
		default:
			s.WriteString(fmt.Sprint(o))
		}
	}
}

// Print Strings using the suitable way to change type with new line
func (s *InOut) Println(os ...interface{}) {
	for _, o := range os {
		s.Print(o)
	}
	s.Print("\n")
}

// Print immediately with new line (for debug)
func (s *InOut) PrintlnNow(o interface{}) {
	fmt.Println(o)
}

package main

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

func main() {
	io := newIo()
	n := io.nextInt()

	var cnt, pre int
	for range make([]struct{}, n) {
		now := io.nextInt()

		if now != pre {
			cnt++
		}
		pre = now
	}
	fmt.Println(cnt)
}

type _io struct {
	reader    *bufio.Reader
	tokens    []string
	nextToken int
}

func newIo() *_io {
	return &_io{
		reader: bufio.NewReader(os.Stdin),
	}
}

func (_io *_io) nextLine() string {
	var buffer []byte
	for {
		line, isPrefix, _ := _io.reader.ReadLine()
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (_io *_io) next() string {
	for _io.nextToken >= len(_io.tokens) {
		line := _io.nextLine()
		_io.tokens = strings.Fields(line)
		_io.nextToken = 0
	}
	r := _io.tokens[_io.nextToken]
	_io.nextToken++
	return r
}

func (_io *_io) nextInt() int {
	i, _ := strconv.Atoi(_io.next())
	return i
}

package main

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

func main() {
	var scanner *bufio.Scanner
	var lines []string
	var previous string
	var groups int = 0

	scanner = bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		lines = append(lines, scanner.Text())
	}

	for i, magnet := range lines[1:] {
		if i == 0 {
			previous = magnet
			groups++
		} else {
			if magnet != previous {
				groups++
			}

			previous = magnet
		}
	}

	fmt.Println(groups)
}

package main

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

func main() {
	var n int
	fmt.Scan(&n)
	var groups, prevX, x int
	scanner := bufio.NewScanner(os.Stdin)

	for i := 0; i < n; i++ {
		// fmt.Scan(&x)
		scanner.Scan()
		x = toInt(scanner.Bytes())
		if x != prevX {
			groups++
		}
		prevX = x
	}
	fmt.Println(groups)
}
func toInt(buf []byte) (n int) {
	for _, v := range buf {
		n = n*10 + int(v-'0')
	}
	return
}

package main

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

func main() {
	var n int
	fmt.Scan(&n)
	var cnt int
	r := bufio.NewScanner(os.Stdin)
	var prev string
	var m int
	for r.Scan() {
		t := r.Text()
		if t != prev {
			prev = t
			cnt++
		}
		m++
		if m >= n {
			break
		}
	}
	fmt.Print(cnt)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]string, n)
	cnt := 1
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		if i > 1 && a[i] != a[i-1] {
			cnt++
		}
	}
	fmt.Print(cnt)
}

package main

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

func main() {
	var n int
	fmt.Scan(&n)
	var cnt int
	r := bufio.NewScanner(os.Stdin)
	var prev string
	var m int
	for r.Scan() {
		m++
		if m >= n {
			break
		}
		t := r.Text()
		if t != prev {
			prev = t
			cnt++
		}
	}
	fmt.Print(cnt)
}

package main

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

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

    magnets := make([]string, n, n)
    /*bs := bufio.NewScanner(os.Stdin)
    for i := 0; i < n; i++ {
        bs.Scan()
        magnets[i] = bs.Text()
    }*/

    reader := bufio.NewReader(os.Stdin)
    for i := 0; i < n; i++ {
        bytes, _, _ := reader.ReadLine()
        magnets[i] = string(bytes)
    }

    group := 1
    pre := magnets[0]
    for i := 1; i < n; i++ {
        if pre != magnets[i] {
            pre = magnets[i]
            group += 1
        }
    }

    fmt.Println(group)
}

package main

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

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

    magnets := make([]string, n, n)
    /*bs := bufio.NewScanner(os.Stdin)
    for i := 0; i < n; i++ {
        bs.Scan()
        magnets[i] = bs.Text()
    }*/

    reader := bufio.NewReader(os.Stdin)
    for i := 0; i < n; i++ {
        magnets[i], _ = reader.ReadString('\n')
    }

    group := 1
    pre := magnets[0]
    for i := 1; i < n; i++ {
        if pre != magnets[i] {
            pre = magnets[i]
            group += 1
        }
    }

    fmt.Println(group)
}

package main

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

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

    magnets := make([]string, n, n)
    bs := bufio.NewScanner(os.Stdin)
    for i := 0; i < n; i++ {
        bs.Scan()
        magnets[i] = bs.Text()
    }

    group := 1
    pre := magnets[0]
    for i := 1; i < n; i++ {
        if pre != magnets[i] {
            pre = magnets[i]
            group += 1
        }
    }

    fmt.Println(group)
}

package main

import "fmt"

func main() {
	numberOfGroups := 0
	var numberOfMagnets int
	fmt.Scan(&numberOfMagnets)
	var previousMagnet, currentMagnet int
	for index := 1; index < numberOfMagnets; index++ {
		fmt.Scan(&currentMagnet)
		if currentMagnet != previousMagnet {
			numberOfGroups++
		}
		previousMagnet = currentMagnet
	}
	fmt.Println(numberOfGroups)
}

package main

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

func main() {
	var numberOfMagnets int
	var numberOfGroups int
	fmt.Scan(&numberOfMagnets)
	r := bufio.NewScanner(os.Stdin)
	var previousMagnet string
	for index := 0; index < numberOfMagnets; index++ {
		currentMagnet := r.Text()
		if currentMagnet != previousMagnet {
			previousMagnet = currentMagnet
			numberOfGroups++
		}
	}
	fmt.Println(numberOfGroups)
}

package main

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

func main() {
	var line string
	var flag bool
	var n, summ int
	reader := bufio.NewReader(os.Stdin)
	fmt.Scanf("%d", &n)
	line, _ = reader.ReadString('\n')
	line = strings.TrimSpace(line)
	if line == "10" {
		flag = true
	}
	for i := 1; i < n; i++ {
		line, _ = reader.ReadString('\n')
		line = strings.TrimSpace(line)
		if line == "10" {
			if !flag {
				summ++
			}
			flag = true
		} else {
			if flag {
				summ++
			}
			flag = false
		}
	}
	fmt.Println(summ + 1)
}

package main

// https://codeforces.com/problemset/problem/344/A

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

func taskSolution(a []byte) (ans int) {
	for i, last := 1, 0; i < len(a); i += 3 {
		// skip spaces
		for i < len(a) && a[i] != '0' && a[i] != '1' {
			i += 1
		}
		if i < len(a) && a[i] != a[last] {
			ans += 1
			last = i
		}
	}
	return 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 (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	var start string
	fmt.Scanln(&start)
	fmt.Println(start)
	res := 1
	for i := 1; i < n; i++ {
		var cur string
		fmt.Scanln(&cur)
		fmt.Println(cur)
		if cur != start {
			start = cur
			res += 1
		}
	}
	fmt.Println(res)
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	var start string
	fmt.Scanln(&start)
	res := 1
	for i := 1; i < n; i++ {
		var cur string
		fmt.Scanln(&cur)
		if cur != start {
			start = cur
			res += 1
		}
	}
	fmt.Println(res)
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	var start string
	fmt.Scanln(&start)
	res := 1
	for i := 1; i < n; i++ {
		var cur string
		fmt.Scanln(&cur)
		fmt.Println(cur)
		if cur != start {
			start = cur
			res += 1
		}
	}
	fmt.Println(res)
}

package main

import (
	"fmt"
)

func main() {
	var d, n, cnt, last int

	fmt.Scanln(&n)

	for i := 0; i < n; i++ {
		fmt.Scanln(&d)
		if i > 1 && last != d {
			cnt++
		}
		last = d
	}

	fmt.Println(cnt + 1)

}

package main

import "fmt"

func main() {
	var number int
	_, _ = fmt.Scanln(&number)
	var oned = make([]int, number)

	if number == 1 {
		_, _ = fmt.Scanln(&oned[0])
		fmt.Print("1")
	}
	count := 0
	for i:=1; i<number;i++ {
		_, _ = fmt.Scan(&oned[i])
		if oned[i] != oned[i-1] {
			count++
		}
	}
	if count > 0 {
		fmt.Println(count)
	}

}

package main

import "fmt"

func main() {
	var number int
	_, _ = fmt.Scanln(&number)
	var oned = make([]int, number)

	if number == 1 {
		_, _ = fmt.Scanln(&oned[0])
		fmt.Print("1")
	}
	count := 0
	for i:=1; i<number;i++ {
		_, _ = fmt.Scan(&oned[i])
		if oned[i] != oned[i-1] {
			count++
		}
	}
	fmt.Println(count)

}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)

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

func main() {
	var number, i uint = 0, 0
	_, _ = fmt.Scanln(&number)
	var oned = make([]int, number)

	if number == 1 {
		_, _ = fmt.Scanln(&oned[0])
		fmt.Print("1")
		os.Exit(0)
	}
	count := 1
	_, _ = fmt.Scanln(&oned[0])
	for i = 1; i < number; i++ {
		scanf("%d", &oned[i])
		if oned[i] != oned[i-1] {
			count++
		}
	}

	fmt.Println(count)

}

package main

import(
    "fmt"
)

func main(){
    var (
        n,res int
    )
    fmt.Scan(&n)
    arr := make([]int,n)
    for i:=0;i<n;i++{
        fmt.Scanf("%d",&arr[i])
    }
    res=1
    for i:=1;i<n;i++{
        if arr[i-1]!=arr[i]{
            res++
        }
    }
    fmt.Println(res)
}

package main

import(
    "fmt"
)

func main(){
    var (
        n,res,i int64
    )
    fmt.Scanf("%d",&n)
    arr := make([]int64,n)
    for i=0;i<n;i++{
        fmt.Scanf("%d",&arr[i])
    }
    res=1
    for i=1;i<n;i++{
        if arr[i-1]!=arr[i]{
            res++
        }
    }
    fmt.Println(res)
}

package main

import(
    "fmt"
)

func main(){
    var (
        n,temp,res,val int
    )
    fmt.Scan(&n)
    fmt.Scan(&temp)
    res=1
    for i:=0;i<n-1;i++{
        fmt.Scan(&val)
        if val != temp{
            res++
            temp=res
        }
    }
    fmt.Println(res-1)
}


Everybody knows that opposites attract. That is the key principle of the "Perfect Matching" dating agency. The "Perfect Matching" matchmakers have classified each registered customer by his interests and assigned to the i-th client number ti ( - 10 ≤ ti ≤ 10). Of course, one number can be assigned to any number of customers."Perfect Matching" wants to advertise its services and publish the number of opposite couples, that is, the couples who have opposite values of t. Each couple consists of exactly two clients. The customer can be included in a couple an arbitrary number of times. Help the agency and write the program that will find the sought number by the given sequence t1, t2, ..., tn. For example, if t = (1,  - 1, 1,  - 1), then any two elements ti and tj form a couple if i and j have different parity. Consequently, in this case the sought number equals 4.Of course, a client can't form a couple with him/herself.

The first line of the input data contains an integer n (1 ≤ n ≤ 105) which represents the number of registered clients of the "Couple Matching". The second line contains a sequence of integers t1, t2, ..., tn ( - 10 ≤ ti ≤ 10), ti — is the parameter of the i-th customer that has been assigned to the customer by the result of the analysis of his interests.

Print the number of couples of customs with opposite t. The opposite number for x is number  - x (0 is opposite to itself). Couples that only differ in the clients' order are considered the same. Note that the answer to the problem can be large enough, so you must use the 64-bit integer type for calculations. Please, do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specificator.

NoteIn the first sample the couples of opposite clients are: (1,2), (1,5) и (3,4).In the second sample any couple of clients is opposite.

package main

import (
	"fmt"
	//"sort"
)

func main() {
	var a,i,z,w int64
	var x [22]int64
	fmt.Scan(&a)
	for i=1;i<=a;i++ {
		fmt.Scan(&z)
		w+=x[10-z]
		x[z+10]++
	}
	fmt.Println(w)
}

package main

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

var scanner *bufio.Scanner

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

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

  n := getI()
  count := map[int]int64{}
  total := int64(0)
  for i := 0; i < n; i++ {
    x := getI()
    total += count[-x]
    count[x]++
  }
  writer.WriteString(fmt.Sprintf("%d\n", total))
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    var n,zero int
    var neg, pos [11]int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        scanner.Scan()
        a, _ := strconv.Atoi(scanner.Text())
        if a < 0 {
            neg[-a]++
        } else if a > 0 {
            pos[a]++
        } else {
            zero++
        }
    }
    ans := (int64(zero)*int64(zero-1))/2
    for i := 1; i <= 10; i++ {
        ans += int64(neg[i])*int64(pos[i])
    }
    fmt.Println(ans)
}

package main

import "fmt"

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

	var m = make(map[int64]int64)
	for i := 0; i < n; i++ {
		var x int64
		fmt.Scan(&x)
		m[x]++
	}

	var a int64
	for k, v := range m {
		if k < 0 {
			continue
		} else if k == 0 {
			a += (v * (v - 1)) / 2
		} else {
			v2, ok := m[-k]
			if ok {
				a += v * v2
			}
		}
	}

	fmt.Println(a)
}

package main

import (
	"fmt"
	//"sort"
)

func main() {
	var a,i,z,w int64
	var x [22]int64
	fmt.Scan(&a)
	for i=0;i<=a;i++ {
		fmt.Scan(&z)
		w+=x[10-z]
		x[z+10]++
	}
	fmt.Println(w)
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    var n,zero int
    var neg, pos [11]int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        scanner.Scan()
        a, _ := strconv.Atoi(scanner.Text())
        if a < 0 {
            neg[-a]++
        } else if a > 0 {
            pos[a]++
        } else {
            zero++
        }
    }
    ans := int64((zero*(zero-1))/2)
    for i := 1; i <= 10; i++ {
        ans += int64(neg[i])*int64(pos[i])
    }
    fmt.Println(ans)
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    var n,zero int
    var neg, pos [11]int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        scanner.Scan()
        a, _ := strconv.Atoi(scanner.Text())
        if a < 0 {
            neg[-a]++
        } else if a > 0 {
            pos[a]++
        } else {
            zero++
        }
    }
    ans := (zero*(zero-1))/2
    for i := 1; i <= 10; i++ {
        ans += neg[i]*pos[i]
    }
    fmt.Println(ans)
}

package main

import "fmt"

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

	var m = make(map[int]int)
	for i := 0; i < n; i++ {
		var x int
		fmt.Scan(&x)
		m[x]++
	}

	var a = 0
	for k, v := range m {
		if k < 0 {
			continue
		} else if k == 0 {
			a += (v * (v - 1)) / 2
		} else {
			v2, ok := m[-k]
			if ok {
				a += v * v2
			}
		}
	}

	fmt.Println(a)
}


You are given an array $$$a$$$ of $$$n$$$ elements. You can apply the following operation to it any number of times:  Select some subarray from $$$a$$$ of even size $$$2k$$$ that begins at position $$$l$$$ ($$$1\le l \le l+2\cdot{k}-1\le n$$$, $$$k \ge 1$$$) and for each $$$i$$$ between $$$0$$$ and $$$k-1$$$ (inclusive), assign the value $$$a_{l+k+i}$$$ to $$$a_{l+i}$$$. For example, if $$$a = [2, 1, 3, 4, 5, 3]$$$, then choose $$$l = 1$$$ and $$$k = 2$$$, applying this operation the array will become $$$a = [3, 4, 3, 4, 5, 3]$$$.Find the minimum number of operations (possibly zero) needed to make all the elements of the array equal.

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 2 \cdot 10^4$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2 \cdot 10^5$$$) — the length of the array. The second line of each test case consists of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq n$$$) — the elements of the array $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

Print $$$t$$$ lines, each line containing the answer to the corresponding test case — the minimum number of operations needed to make equal all the elements of the array with the given operation.

NoteIn the first test, all elements are equal, therefore no operations are needed.In the second test, you can apply one operation with $$$k=1$$$ and $$$l=1$$$, set $$$a_1 := a_2$$$, and the array becomes $$$[1, 1]$$$ with $$$1$$$ operation.In the third test, you can apply one operation with $$$k=1$$$ and $$$l=4$$$, set $$$a_4 := a_5$$$, and the array becomes $$$[4, 4, 4, 4, 4]$$$.In the fourth test, you can apply one operation with $$$k=1$$$ and $$$l=3$$$, set $$$a_3 := a_4$$$, and the array becomes $$$[4, 2, 3, 3]$$$, then you can apply another operation with $$$k=2$$$ and $$$l=1$$$, set $$$a_1 := a_3$$$, $$$a_2 := a_4$$$, and the array becomes $$$[3, 3, 3, 3]$$$.In the fifth test, there is only one element, therefore no operations are needed.

package main

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

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

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

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

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

		z := a[n-1]
		size := 1
		var c int
		for i := n - 2; i >= 0; {
			if a[i] == z {
				size++
				i--
			} else {
				i -= size
				size *= 2
				c++
			}
		}

		fmt.Fprintln(out, c)
	}
}

package main

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

const mod = 998244353
const mx = 3000

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	var n int
	fmt.Fscan(in,&n)
	arr := make([]int,n)
	for i := 0;i < n;i++{
		fmt.Fscan(in,&arr[i])
	}
	ans := 0
	for i := n - 2;i >= 0;{
		if arr[i] != arr[n - 1]{
			ans++
			i = i - (n - i - 1)
			continue
		}else{
			i--
		}
	}
	fmt.Fprintln(out,ans)
}

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

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

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

// generated by 1e9y at 27-01-2022
// template version: 2022-01-11

package main

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

// 0000.A
func solve(n int, input []int) int {
	if n == 1 {
		return 0
	}

	t := input[n-1]
	ans := 0
	size := 1
	// Println(n, input)
	i := n - 2
	for i >= 0 {
		// Println(i, size, ans)
		if input[i] == t {
			size++
			i--
		} else {
			ans++
			i -= size
			size *= 2
		}
	}

	return ans
}

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

	t := ReadInt(in)
	for i := 0; i < t; i++ {
		n := ReadInt(in)
		input := ReadIntSlice(in)
		Output(solve(n, input))
	}
}

// helpers for convenient input reading

func ReadInt(in *bufio.Reader) int {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	n, _ := strconv.Atoi(line)
	return n
}

func ReadLine(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	return line
}

func ReadLineParts(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	parts := strings.Split(line, " ")
	return parts
}

func ReadIntSlice(in *bufio.Reader) []int {
	parts := ReadLineParts(in)
	slice := make([]int, len(parts))
	for i, n := range parts {
		slice[i] = MustAtoi(n)
	}
	return slice
}

func ReadInt64Slice(in *bufio.Reader) []int64 {
	parts := ReadLineParts(in)
	slice := make([]int64, len(parts))
	for i, n := range parts {
		slice[i] = MustParseInt(n, 10, 64)
	}
	return slice
}

func ReadUint64Slice(in *bufio.Reader) []uint64 {
	parts := ReadLineParts(in)
	slice := make([]uint64, len(parts))
	for i, n := range parts {
		slice[i] = MustParseUint(n, 10, 64)
	}
	return slice
}

func MustAtoi(s string) int {
	v, _ := strconv.Atoi(s)
	return v
}

func MustParseInt(s string, base, bitSize int) int64 {
	v, _ := strconv.ParseInt(s, base, bitSize)
	return v
}

func MustParseUint(s string, base, bitSize int) uint64 {
	v, _ := strconv.ParseUint(s, base, bitSize)
	return v
}

func SkipLine(in *bufio.Reader) {
	_, _ = in.ReadString('\n')
}

// helper for convenient answer output

func Output(v interface{}) {
	switch v.(type) {
	case bool:
		if v == true {
			Println("YES")
		} else {
			Println("NO")
		}
	default:
		Println(v)
	}
}

//nolint
package main

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

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

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func print(a ...interface{})            { fmt.Fprint(writer, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func main() {
	defer writer.Flush()

	var t, n int
	scan(&t)
	for i := 0; i < t; i++ {
		scan(&n)
		a := make([]int, n)
		for j := n - 1; j >= 0; j-- {
			scan(&a[j])
		}

		rs := 0
		tp := 1
	OUT:
		for {
			var i int
			for i = tp; i < n && a[i] == a[0]; i++ {
			}
			if i >= n {
				println(rs)
				break OUT
			}
			rs++
			tp = i * 2
		}
	}
}

package main

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

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

func flush()                            { out.Flush() }
func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }
func assert(f bool) {
	if !f {
		panic("gg")
	}
}

// ----------------------------- TEMPLATE END ----------------------------------

func main() {
	defer flush()

	var ntc int
	scan(&ntc)
	for t := 0; t < ntc; t++ {
		var n int
		scan(&n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			scan(&a[i])
		}
		x := a[n-1]
		reach := n - 1
		ans := 0
		for i := n - 1; i >= 0; i-- {
			if a[i] == x || i >= reach {
				continue
			} else {
				ans++
				reach = i - (n - i - 1) + 1
			}
		}
		printf("%d\n", ans)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		var n int
		fmt.Fscan(in, &n)

		arr := make([]int, n)
		for i := range arr {
			fmt.Fscan(in, &arr[i])
		}

		god := arr[n-1]
		res := 0
		for i := n - 2; i >= 0; {
			for ; i >= 0 && arr[i] == god; i-- {
			}
			if i >= 0 && arr[i] != god {
				res++
				i -= n - 1 - i
			}
		}

		fmt.Fprintln(out, res)
	}
}

package main

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

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

	t := readInt(in)
	b := strings.Builder{}
	for i := 0; i < t; i++ {
		str := solve(in)
		b.WriteString(str + "\n")
	}
	fmt.Println(b.String())
}

func solve(in *bufio.Reader) string {
	readInt(in)
	arr := readArrInt(in)
	res := 0

	for {
		c := lastCount(arr)
		if c == len(arr) {
			break
		}
		res++
		changeArr(arr, c)
	}

	return strconv.Itoa(res)
}

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

func changeArr(arr []int, count int) {
	n := len(arr)
	for i := max(0, n - 2*count); i < n - count; i++ {
		arr[i] = arr[i+count]
	}
}

func lastCount(arr []int) int {
	res := 0
	n := len(arr) - 1
	for i := n; i >= 0; i-- {
		if arr[i] != arr[n] {
			return res
		}
		res++
	}
	return res
}

func findMax(arr []int, start int) int {
	min := start
	for i := start; i < len(arr); i++ {
		if arr[i] > arr[min] {
			min = i
		}
	}
	return min
}

func findMin(arr []int, start int) int {
	min := start
	for i := start; i < len(arr); i++ {
		if arr[i] < arr[min] {
			min = i
		}
	}
	return min
}

func readInt(in *bufio.Reader) int {
nStr, _ := in.ReadString('\n')
nStr = strings.ReplaceAll(nStr, "\r", "")
nStr = strings.ReplaceAll(nStr, "\n", "")
n, _ := strconv.Atoi(nStr)
return n
}

func readLineNumbs(in *bufio.Reader) []string {
line, _ := in.ReadString('\n')
line = strings.ReplaceAll(line, "\r", "")
line = strings.ReplaceAll(line, "\n", "")
numbs := strings.Split(line, " ")
return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

package main

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

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

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

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

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

		z := a[n-1]
		var c int
		for i := n - 2; i >= 0; i-- {
			if a[i] != z {
				// fmt.Println("Mismatched: ", i, limit)
				i -= n - i - 1
				c++
			}
		}

		fmt.Fprintln(out, c)
	}
}

package main

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

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

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

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

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

		diff := func(arr []int) int {
			m := make(map[int]int)
			var max int
			for i := 0; i < len(arr); i++ {
				m[arr[i]]++
				if m[arr[i]] > max {
					max = m[arr[i]]
				}
			}

			return len(arr) - max
		}

		var c int
		for len(a) > 1 {
			d := diff(a)
			if d <= bits.Len(uint(len(a)-1)) {
				c += d
				break
			}

			c++
			a = a[len(a)/2:]
		}

		if bits.Len(uint(n-1)) < c {
			fmt.Fprintln(out, bits.Len(uint(n-1)))
		} else {
			fmt.Fprintln(out, c)
		}
	}
}

package main

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

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

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

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

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

		diff := func(arr []int) int {
			m := make(map[int]int)
			var max int
			for i := 0; i < len(arr); i++ {
				m[arr[i]]++
				if m[arr[i]] > max {
					max = m[arr[i]]
				}
			}

			return len(arr) - max
		}

		var c int
		for len(a) > 1 {
			d := diff(a)
			// fmt.Println(d, bits.Len(uint(len(a)-1)))
			if d <= 1 || d < bits.Len(uint(len(a)-1)) {
				c += d
				break
			}

			c++
			a = a[len(a)/2:]
		}

		fmt.Fprintln(out, c)
	}
}

package main

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

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

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

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

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

		diff := func(arr []int) int {
			m := make(map[int]int)
			var max int
			for i := 0; i < len(arr); i++ {
				m[arr[i]]++
				if m[arr[i]] > max {
					max = m[arr[i]]
				}
			}

			return len(arr) - max
		}

		var c int
		for len(a) >= 2 {
			d := diff(a)
			// fmt.Println(d, bits.Len(uint(len(a)-1)))
			if d == 0 || d < bits.Len(uint(len(a)-1)) {
				c += d
				break
			}

			c++
			a = a[len(a)/2:]
		}

		fmt.Fprintln(out, c)
	}
}

package main

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

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

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

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

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

		diff := func(arr []int) int {
			m := make(map[int]int)
			var max int
			for i := 0; i < len(arr); i++ {
				m[arr[i]]++
				if m[arr[i]] > max {
					max = m[arr[i]]
				}
			}

			return len(arr) - max
		}

		var c int
		for len(a) >= 2 {
			d := diff(a)
			// fmt.Println(d, bits.Len(uint(len(a)-1)))
			if d < bits.Len(uint(len(a)-1)) {
				c += d
				break
			}

			c++
			a = a[len(a)/2:]
		}

		fmt.Fprintln(out, c)
	}
}

package main

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

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

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

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

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

		diff := func(arr []int) int {
			m := make(map[int]int)
			var max int
			for i := 0; i < len(arr); i++ {
				m[arr[i]]++
				if m[arr[i]] > max {
					max = m[arr[i]]
				}
			}

			return len(arr) - max
		}

		var c int
		for len(a) >= 2 {
			d := diff(a)
			// fmt.Println(d, bits.Len(uint(len(a)-1)))
			if d <= bits.Len(uint(len(a)-1)) {
				c += d
				break
			}

			c++
			a = a[len(a)/2:]
		}

		fmt.Fprintln(out, c)
	}
}

package main

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

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

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

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

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

		diff := func(arr []int) int {
			m := make(map[int]int)
			var max int
			for i := 0; i < len(arr); i++ {
				m[arr[i]]++
				if m[arr[i]] > max {
					max = m[arr[i]]
				}
			}

			return len(arr) - max
		}

		var c int
		for len(a) >= 2 {
			d := diff(a)
			if d <= 1 {
				c += d
				break
			}

			c++
			a = a[len(a)/2:]
		}

		fmt.Fprintln(out, c)
	}
}

package main

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

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

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

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

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

		diff := func(arr []int) int {
			m := make(map[int]int)
			for i := 0; i < len(arr); i++ {
				m[arr[i]]++
			}

			return len(m) - 1
		}

		var c int
		for len(a) >= 2 {
			d := diff(a)
			if d <= 1 {
				c += d
				break
			}

			c++
			a = a[len(a)/2:]
		}

		fmt.Fprintln(out, c)
	}
}

package main

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

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

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

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

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

		var d int
		for i := 0; i < n-1; i++ {
			if a[i] != a[i+1] {
				d++
			}
		}

		var c int
		for {
			var req bool
			for i := 1; i < n; i++ {
				if a[i] != a[i-1] {
					req = true
					break
				}
			}

			if !req {
				break
			}

			chain := 1
			for i := n - 1; i >= 1; i-- {
				if a[i] != a[i-1] {
					break
				}
				chain++
			}

			for i := 0; i < chain; i++ {
				pos := n - (chain * 2) + i
				if pos < 0 {
					continue
				}
				a[pos] = a[n-1]
			}

			c++
		}

		if d <= 1 {
			fmt.Fprintln(out, d)
		} else {
			fmt.Fprintln(out, c)
		}
	}
}

package main

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

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

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

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

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

		chain := 1
		for i := n - 1; i >= 1; i-- {
			if a[i] != a[i-1] {
				break
			}
			chain++
		}

		var c int
		for {
			var switched bool
			req := n - chain
			if req <= 0 {
				break
			}

			for i := 0; i < n-chain; i++ {
				if a[i] != a[n-1] {
					switched = true
					break
				}

			}

			if !switched {
				break
			}
			chain *= 2
			c++
		}

		var d int
		for i := 0; i < n-1; i++ {
			if a[i] != a[i+1] {
				d++
			}
		}

		if d <= 1 {
			fmt.Fprintln(out, d)
		} else {
			fmt.Fprintln(out, c)
		}
	}
}

package main

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

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

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

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

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

		chain := 1
		for i := n - 1; i >= 1; i-- {
			if a[i] != a[i-1] {
				break
			}
			chain++
		}

		var c int
		for {
			var switched bool
			req := n - chain
			if req <= 0 {
				break
			}

			for i := 0; i < n-chain; i++ {
				if a[i] != a[n-1] {
					switched = true
					break
				}

			}

			if !switched {
				break
			}
			chain *= 2
			c++
		}

		fmt.Fprintln(out, c)
	}
}

package main

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

const mod = 998244353
const mx = 3000

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	var n int
	fmt.Fscan(in,&n)
	arr := make([]int,n)
	for i := 0;i < n;i++{
		fmt.Fscan(in,&arr[i])
	}
	ans := 0
	for i := n - 2;i >= 0;{
		if arr[i] != arr[n - 1]{
			ans++
			i = i - (n - i)
			continue
		}else{
			i--
		}
	}
	fmt.Fprintln(out,ans)
}

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

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

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

package main

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

const mod = 998244353
const mx = 3000

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	var n int
	fmt.Fscan(in,&n)
	arr := make([]int,n)
	for i := 0;i < n;i++{
		fmt.Fscan(in,&arr[i])
	}
	ans := 0
	for i := n - 2;i >= 0;{
		if arr[i] != arr[n - 1]{
			ans++
		}
		i = i - (n - i)
	}
	fmt.Fprintln(out,ans)
}

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

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

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

package main

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

const mod = 998244353
const mx = 3000

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	var n int
	fmt.Fscan(in,&n)
	arr := make([]int,n)
	for i := 0;i < n;i++{
		fmt.Fscan(in,&arr[i])
	}
	idx := n - 2
	ans := 0
	for i := 0;idx >= 0;i++{
		cnt := 1 << i
		find := false
		for j := max(0,idx - cnt + 1);j <= idx;j++{
			if arr[j] != arr[n - 1]{
				find = true
				break
			}
		}
		if find {
			ans++
		}
		idx = idx - cnt
	}
	fmt.Fprintln(out,ans)
}

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

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

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

// generated by 1e9y at 27-01-2022
// template version: 2022-01-11

package main

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

// 0000.A
func solve(n int, input []int) int {
	if n == 1 {
		return 0
	}

	t := input[n-1]
	ans := 0
	size := 1
	for i := n - 2; i >= 0; i-- {
		if input[i] == t {
			size++
		} else {
			ans++
			i -= size
			size += 2
		}
	}

	// count := map[int]struct{}{}
	// for i := 1; i < n; i++ {
	// 	if input[n-i-1] != t {
	// 		count[i>>1] = struct{}{}
	// 	}
	// }

	// return len(count)
	return ans
}

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

	t := ReadInt(in)
	for i := 0; i < t; i++ {
		n := ReadInt(in)
		input := ReadIntSlice(in)
		Output(solve(n, input))
	}
}

// helpers for convenient input reading

func ReadInt(in *bufio.Reader) int {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	n, _ := strconv.Atoi(line)
	return n
}

func ReadLine(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	return line
}

func ReadLineParts(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	parts := strings.Split(line, " ")
	return parts
}

func ReadIntSlice(in *bufio.Reader) []int {
	parts := ReadLineParts(in)
	slice := make([]int, len(parts))
	for i, n := range parts {
		slice[i] = MustAtoi(n)
	}
	return slice
}

func ReadInt64Slice(in *bufio.Reader) []int64 {
	parts := ReadLineParts(in)
	slice := make([]int64, len(parts))
	for i, n := range parts {
		slice[i] = MustParseInt(n, 10, 64)
	}
	return slice
}

func ReadUint64Slice(in *bufio.Reader) []uint64 {
	parts := ReadLineParts(in)
	slice := make([]uint64, len(parts))
	for i, n := range parts {
		slice[i] = MustParseUint(n, 10, 64)
	}
	return slice
}

func MustAtoi(s string) int {
	v, _ := strconv.Atoi(s)
	return v
}

func MustParseInt(s string, base, bitSize int) int64 {
	v, _ := strconv.ParseInt(s, base, bitSize)
	return v
}

func MustParseUint(s string, base, bitSize int) uint64 {
	v, _ := strconv.ParseUint(s, base, bitSize)
	return v
}

func SkipLine(in *bufio.Reader) {
	_, _ = in.ReadString('\n')
}

// helper for convenient answer output

func Output(v interface{}) {
	switch v.(type) {
	case bool:
		if v == true {
			Println("YES")
		} else {
			Println("NO")
		}
	default:
		Println(v)
	}
}

// generated by 1e9y at 27-01-2022
// template version: 2022-01-11

package main

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

// 0000.A
func solve(n int, input []int) int {
	if n == 1 {
		return 0
	}

	t := input[n-1]

	count := map[int]struct{}{}
	for i := 1; i < n; i++ {
		if input[n-i-1] != t {
			count[i>>1] = struct{}{}
		}
		// Print(i>>1, " ")
	}

	return len(count)
}

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

	t := ReadInt(in)
	for i := 0; i < t; i++ {
		n := ReadInt(in)
		input := ReadIntSlice(in)
		Output(solve(n, input))
	}
}

// helpers for convenient input reading

func ReadInt(in *bufio.Reader) int {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	n, _ := strconv.Atoi(line)
	return n
}

func ReadLine(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	return line
}

func ReadLineParts(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	parts := strings.Split(line, " ")
	return parts
}

func ReadIntSlice(in *bufio.Reader) []int {
	parts := ReadLineParts(in)
	slice := make([]int, len(parts))
	for i, n := range parts {
		slice[i] = MustAtoi(n)
	}
	return slice
}

func ReadInt64Slice(in *bufio.Reader) []int64 {
	parts := ReadLineParts(in)
	slice := make([]int64, len(parts))
	for i, n := range parts {
		slice[i] = MustParseInt(n, 10, 64)
	}
	return slice
}

func ReadUint64Slice(in *bufio.Reader) []uint64 {
	parts := ReadLineParts(in)
	slice := make([]uint64, len(parts))
	for i, n := range parts {
		slice[i] = MustParseUint(n, 10, 64)
	}
	return slice
}

func MustAtoi(s string) int {
	v, _ := strconv.Atoi(s)
	return v
}

func MustParseInt(s string, base, bitSize int) int64 {
	v, _ := strconv.ParseInt(s, base, bitSize)
	return v
}

func MustParseUint(s string, base, bitSize int) uint64 {
	v, _ := strconv.ParseUint(s, base, bitSize)
	return v
}

func SkipLine(in *bufio.Reader) {
	_, _ = in.ReadString('\n')
}

// helper for convenient answer output

func Output(v interface{}) {
	switch v.(type) {
	case bool:
		if v == true {
			Println("YES")
		} else {
			Println("NO")
		}
	default:
		Println(v)
	}
}

//nolint
package main

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

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

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func print(a ...interface{})            { fmt.Fprint(writer, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func main() {
	defer writer.Flush()

	var t, n int
	scan(&t)
	for i := 0; i < t; i++ {
		scan(&n)
		a := make([]int, n)
		for j := 0; j < n; j++ {
			scan(&a[j])
		}

		// update by the optimal path, right --> left
		rs := 0
		for tp := 1; tp <= n-1; tp *= 2 {
			if !checkEqual(a, tp) {
				rs++
			}
		}
		println(rs)
	}
}

func checkEqual(a []int, idx int) bool {
	n := len(a)
	tp := n - idx
	isEqual := true
	for i := 0; i < idx && tp-i-1 >= 0 && tp+i < n; i++ {
		if a[tp-i-1] != a[tp+i] {
			isEqual = false
		}
		a[tp-i-1] = a[tp+i]
	}
	return isEqual
}

package main

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

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

func flush()                            { out.Flush() }
func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }
func assert(f bool) {
	if !f {
		panic("gg")
	}
}

// ----------------------------- TEMPLATE END ----------------------------------

func main() {
	defer flush()

	var ntc int
	scan(&ntc)
	for t := 0; t < ntc; t++ {
		var n int
		scan(&n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			scan(&a[i])
		}
		x := a[n-1]
		reach := n - 1
		ans := 0
		for i := n - 1; i >= 0; i-- {
			if a[i] == x || i >= reach {
				continue
			} else {
				ans++
				reach = i - (n - i) + 1
			}
		}
		printf("%d\n", ans)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		var n int
		fmt.Fscan(in, &n)

		arr := make([]int, n)
		for i := range arr {
			fmt.Fscan(in, &arr[i])
		}

		god := arr[n-1]
		priests := 1
		hasShit := false
		res := 0
		for i := n - 2; i >= 0; {
			for j := 0; j < priests && i >= 0; j++ {
				if arr[i] != god {
					hasShit = true
				}
				i--
			}
			if hasShit {
				res++
				priests = n - 1 - i
			}
			hasShit = false
		}

		fmt.Fprintln(out, res)
	}
}


You are given an undirected unrooted tree, i.e. a connected undirected graph without cycles.You must assign a nonzero integer weight to each vertex so that the following is satisfied: if any vertex of the tree is removed, then each of the remaining connected components has the same sum of weights in its vertices.

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$3 \leq n \leq 10^5$$$) — the number of vertices of the tree. The next $$$n-1$$$ lines of each case contain each two integers $$$u, v$$$ ($$$1 \leq u,v \leq n$$$) denoting that there is an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the given edges form a tree. The sum of $$$n$$$ for all test cases is at most $$$10^5$$$.

For each test case, you must output one line with $$$n$$$ space separated integers $$$a_1, a_2, \ldots, a_n$$$, where $$$a_i$$$ is the weight assigned to vertex $$$i$$$. The weights must satisfy $$$-10^5 \leq a_i \leq 10^5$$$ and $$$a_i \neq 0$$$. It can be shown that there always exists a solution satisfying these constraints. If there are multiple possible solutions, output any of them.

NoteIn the first case, when removing vertex $$$1$$$ all remaining connected components have sum $$$5$$$ and when removing vertex $$$3$$$ all remaining connected components have sum $$$2$$$. When removing other vertices, there is only one remaining connected component so all remaining connected components have the same sum.

package main

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

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

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

type Graph struct {
	edges [][]int
}

func NewGraph(size int) *Graph {
	return &Graph{edges: make([][]int, size)}
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(v int, g *Graph, depth int, marked []bool, result []int) {
	marked[v] = true
	s := 0
	for _, u := range g.edges[v] {
		if marked[u] {
			continue
		}
		s++
		dfs(u, g, depth+1, marked, result)
	}
	if v == 0 {
		result[v] = s
	} else if depth%2 == 0 {
		result[v] = s + 1
	} else {
		result[v] = -s - 1
	}
}

func solve(istream *bufio.Reader) {
	n := readInt(istream)
	g := NewGraph(n)
	for i := 0; i < n-1; i++ {
		tmp := readArrInt(istream)
		u, v := tmp[0]-1, tmp[1]-1
		g.AddEdge(u, v)
	}
	marked := make([]bool, n)
	result := make([]int, n)
	dfs(0, g, 0, marked, result)
	for _, e := range result {
		fmt.Printf("%d ", e)
	}
	fmt.Println()
}

func main() {
	istream := bufio.NewReader(os.Stdin)
	t := readInt(istream)
	for i := 0; i < t; i++ {
		solve(istream)
	}
}

package main

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

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

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

	c := 0
	fmt.Fscan(in, &c)

	for ; c > 0; c-- {
		n := 0
		fmt.Fscan(in, &n)
		d := make([]int, n+1)
		edge := make([][]int, n+1)
		u, v := 0, 0
		for i := 1; i < n; i++ {
			fmt.Fscan(in, &u, &v)
			d[u]++
			d[v]++
			edge[u] = append(edge[u], v)
			edge[v] = append(edge[v], u)
		}
		ans := make([]int, n+1)
		vis := make(map[int]bool, n)
		que, max := make([]int, 1), -1
		for i, v := range d {
			if v > max {
				max = v
				que[0] = i
			}
		}
		color := 1 //黑色染+d 白色染-d
		//bfs + 黑白染色
		for len(que) > 0 {
			k := len(que)
			for i := 0; i < k; i++ {
				cur := que[0]
				que = que[1:]
				if vis[cur] {
					continue
				}
				vis[cur] = true
				ans[cur] = color * d[cur]
				for _, u := range edge[cur] {
					que = append(que, u)
				}
			}
			color *= -1
		}
		ans = ans[1:]
		for _, v := range ans {
			fmt.Fprint(out, v, " ")
		}
		out.Flush()
		fmt.Println()
	}
}

package main

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

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

	var T, n, v, w int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		g := make([][]int, n)
		for i := 1; i < n; i++ {
			Fscan(in, &v, &w)
			v--
			w--
			g[v] = append(g[v], w)
			g[w] = append(g[w], v)
		}
		a := make([]int, n)
		var f func(v, fa, c int)
		f = func(v, fa, c int) {
			a[v] = len(g[v]) * c
			for _, w := range g[v] {
				if w != fa {
					f(w, v, -c)
				}
			}
		}
		f(0, -1, 1)
		for _, v := range a {
			Fprint(out, v, " ")
		}
		Fprintln(out)
	}
}

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

package main

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

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}
func readInt64(in *bufio.Reader) int64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.ParseInt(nStr, 10, 64)
	return n
}
func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

var tr [][]int
var ans []int
var vis []bool

func add(i, j int) {
	tr[i] = append(tr[i], j)
	tr[j] = append(tr[j], i)
}
func dfs(now, cnt int) {
	if cnt == 0 {
		ans[now] *= -1
	}
	vis[now] = true
	for i := range tr[now] {
		if vis[tr[now][i]] == false {
			dfs(tr[now][i], (cnt+1)%2)
		}

	}
}
func main() {
	ip := bufio.NewReader(os.Stdin)
	t := readInt(ip)
	for t > 0 {
		t--
		n := readInt(ip)
		ans = make([]int, n)
		vis = make([]bool, n)
		tr = make([][]int, n)
		for i := 0; i < n-1; i++ {
			tmp := readArrInt(ip)
			ans[tmp[0]-1]++
			ans[tmp[1]-1]++
			add(tmp[0]-1, tmp[1]-1)
		}
		dfs(0, 0)
		for i := range ans {
			fmt.Print(ans[i], " ")
		}
		fmt.Println("")
	}
}

package main

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

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

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

type Graph struct {
	edges [][]int
}

func NewGraph(size int) *Graph {
	return &Graph{edges: make([][]int, size)}
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(v int, g *Graph, depth int, marked []bool, result []int) {
	marked[v] = true
	s := 0
	for _, u := range g.edges[v] {
		if marked[u] {
			continue
		}
		s++
		dfs(u, g, depth+1, marked, result)
	}
	if depth%2 == 0 {
		result[v] = s + 1
	} else {
		result[v] = -s - 1
	}
}

func solve(istream *bufio.Reader) {
	n := readInt(istream)
	g := NewGraph(n)
	for i := 0; i < n-1; i++ {
		tmp := readArrInt(istream)
		u, v := tmp[0]-1, tmp[1]-1
		g.AddEdge(u, v)
	}
	marked := make([]bool, n)
	result := make([]int, n)
	dfs(0, g, 0, marked, result)
	for _, e := range result {
		fmt.Printf("%d ", e)
	}
	fmt.Println()
}

func main() {
	istream := bufio.NewReader(os.Stdin)
	t := readInt(istream)
	for i := 0; i < t; i++ {
		solve(istream)
	}
}


The city administration of IT City decided to fix up a symbol of scientific and technical progress in the city's main square, namely an indicator board that shows the effect of Moore's law in real time.Moore's law is the observation that the number of transistors in a dense integrated circuit doubles approximately every 24 months. The implication of Moore's law is that computer performance as function of time increases exponentially as well.You are to prepare information that will change every second to display on the indicator board. Let's assume that every second the number of transistors increases exactly 1.000000011 times.

The only line of the input contains a pair of integers n (1000 ≤ n ≤ 10 000) and t (0 ≤ t ≤ 2 000 000 000) — the number of transistors in the initial time and the number of seconds passed since the initial time.

Output one number — the estimate of the number of transistors in a dence integrated circuit in t seconds since the initial time. The relative error of your answer should not be greater than 10 - 6.

package main

import (
	"fmt"
	"math"
)

const diffTransistors float64 = 1.000000011

func main() {
	var n, t int

	fmt.Scanf("%d %d", &n, &t)
	fmt.Println(float64(n) * math.Pow(diffTransistors, float64(t)))
}

package main
import "fmt"
import "math"
func main() {
    var a, b float64
    fmt.Scanf("%f %f\n", &a, &b)
    fmt.Println(a*math.Pow(1.000000011,b))
}

// Codeforces 630 B, with podskazki, done
package main

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

var n,t int64
var est float64
var cf = 1.000000011

func miconv(s string) int64 {
    i,err := strconv.Atoi(s)
    if err != nil {
        fmt.Println("error in converting " + s)
    }
    iret := int64(i)
    return iret
}

func main() {
    // reading n
    in    := bufio.NewReader(os.Stdin)
    s,err := in.ReadString('\n')
    if err != nil {
        fmt.Println("first read failure", err)
    }
    ss := strings.Split(strings.Trim(s," \n\r")," ")
    n = miconv(ss[0])
    t = miconv(ss[1])

    // calculate cf
    est = float64(n)
    for t>0 {
        if (t & 1) == 1 {
            est = est * cf
        }
        cf = cf*cf
        t = t/2
    }

	// print result
	fmt.Printf("%.12f\n", est)
}

package main

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

func readFloat(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	raw := scanner.Text()
	result, _ := strconv.ParseFloat(strings.Trim(raw, " \n\r"), 64)
	return result

}

func solve(in io.Reader, out io.Writer) {
	reader := bufio.NewScanner(in)
	reader.Split(bufio.ScanWords)

	fmt.Fprintln(out, readFloat(reader)*math.Pow(1.000000011, readFloat(reader)))
}

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

package main

import (
	"fmt"
	"math"
)

func main() {
	var p, t float64
	fmt.Scan(&p, &t)

	fmt.Println(p * math.Pow(1.000000011, t))
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var n, t float64
	fmt.Scanf("%f %f", &n, &t)

	fmt.Println(n * math.Pow(1.000000011, t))
}

package main

import "fmt"

const diffTransistors float64 = 1.000000011

func main() {
	var n, t int

	fmt.Scanf("%d %d", &n, &t)
	fmt.Println(float64(n) + float64(t) * diffTransistors)
}


New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) — the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros.

For each test case, print the answer on it — the number of minutes before the New Year.

package main

import (
    "fmt"
)

func main() {
    var n int
    fmt.Scan(&n)
    var q1, q2 int
    for i := 0; i < n; i++ {
        fmt.Scan(&q1, &q2)
        fmt.Println(((23 - q1) * 60) + (60 - q2))
    }
}

package main

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

func main() {
	var t, h, m int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	time := 24 * 60
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &h, &m)
		fmt.Println(time - h*60 - m)
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var h, m int
		fmt.Scan(&h, &m)
		fmt.Println(24*60 - h*60 - m)
	}
}

package main

import "fmt"

func main() {
	var t, h, m int
	_, _ = fmt.Scan(&t)
	for ; t > 0; t-- {
		_, _ = fmt.Scan(&h, &m)
		fmt.Println(1440 - (h * 60 + m))
	}
}

package main

import ("fmt")

func calculate(h int,m int){
	var rem_hrs int =  24 - h
	var rem_mins int = m
	//fmt.Printf("Hours %v Minutes %v\n",h,m)
	//fmt.Printf("Rem_Hours %v Rem_Minutes %v\n",rem_hrs,rem_mins)
	var answer int = ((60*rem_hrs) - rem_mins)
	fmt.Println(answer)
}

func main(){
	var t int
	fmt.Scanln(&t)
	for i:=0;i<t;i++{
		var hours int
		var minutes int
		fmt.Scan(&hours,&minutes)
		//fmt.Scanln(&minutes)
		calculate(hours,minutes)
	}
}

package main

import ("fmt")

func main() {
	var len,hour,min int
	fmt.Scan(&len)
	for i := 0; i < len; i++ {
		fmt.Scan(&hour,&min)
		fmt.Println((1440-((hour*60)+min)))
	}

}

package main

import "fmt"

const newYearMinutes int = 1440
const oneHourToMinute int = 60

func main() {
	var testCases, hours, hoursInMinutes, minutes, answer int
	var answerArray[] int

	fmt.Scanln(&testCases)

	for i := 0; i < testCases; i++ {
		fmt.Scanln(&hours, &minutes)
		hoursInMinutes = hours * oneHourToMinute + minutes
		answer = newYearMinutes - hoursInMinutes
		answerArray = append(answerArray, answer)
	}

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

package main

import "fmt"

func main(){
	t:=0
	fmt.Scanf("%d\n",&t)
	for ;t>0;t--{
		h,m:=0,0
		fmt.Scanf("%d %d\n",&h,&m)
		ans:=60-m
		ans+=(60*(24-h-1))
		fmt.Println(ans)
	}
}

package main

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

// Complete the arrayManipulation function below.
func arrayManipulation(n int32, queries [][]int32) int64 {
	arr := make([]int64, n)
	for _, q := range queries {
		a, b, k := q[0]-1, q[1]-1, q[2]
		arr[a] += int64(k)
		if b+1 < n {
			arr[b+1] -= int64(k)
		}
	}
	ret := int64(0)
	s := int64(0)
	for _, v := range arr {
		s += v
		if s > ret {
			ret = s
		}
	}
	return ret
}

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

	t, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	inDay := int64(24 * 60)
	for ; t > 0; t-- {
		line := strings.Split(readLine(reader), " ")
		h, err := strconv.ParseInt(line[0], 10, 64)
		checkError(err)
		m, err := strconv.ParseInt(line[1], 10, 64)
		checkError(err)
		passed := h*60 + m
		fmt.Println(inDay - passed)
	}
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

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

package main

import "fmt"

func main() {
    var n int
    fmt.Scanln(&n)
    for i := 0; i < n; i++ {
        h := 0
        m := 0
        fmt.Scanln(&h, &m)
        fmt.Println((23-h)*60 + (60 - m))
    }
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var h, m int
		fmt.Scan(&h, &m)
		fmt.Println(60*24 - (h*60 + m))
	}
}

//HOWDY! IT'S ME! A HARD BLACKISH DICK MOVE!
package main

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

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

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

//str := PrintlnInts(X...)

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

func main() {
	for t := ReadInt(); t > 0; t-- {
		h, m := ReadInt2()
		fmt.Println(24*60 - h*60 - m)
	}
}

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

func min(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	min := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] < min {
			min = args[i]
		}
	}
	return min
}

func max(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	max := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] > max {
			max = args[i]
		}
	}
	return max
}

func _gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return _gcd(b, a%b)
}

func gcd(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	gcd := args[0]
	for i := 1; i < len(args); i++ {
		gcd = _gcd(gcd, args[i])
	}
	return gcd
}

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

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

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9))
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

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

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

func readInt_64() int64 {
	return readIntNbits(64)
}

func ReadInt2_64() (int64, int64) {
	return readInt_64(), readInt_64()
}

func ReadInt3_64() (int64, int64, int64) {
	return readInt_64(), readInt_64(), readInt_64()
}

func readInt() int {
	return int(readIntNbits(32))
}

func readIntNbits(n int) int64 {
	i, err := strconv.ParseInt(ReadString(), 0, n)
	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
}

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

// PrintIntsLine returns integers string delimited by a space.
func PrintlnInts(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)
}

package main

import (
	"fmt"
)

func main() {
	var h, m, t int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%d %d\n", &h, &m)
		fmt.Println(1440 - h*60 - m)
	}
}

package main

import "fmt"

func main() {
	/*a_car := Car{
		data : 50,
		name : "Yash",
	}

	fmt.Printf("Data is %d and name is %s",a_car.data,a_car.name)

	age := 20
	for age>0 {
		fmt.Println(age)
		age--
	}
	*/
	var t int
	fmt.Scanf("%d\n",&t)

	for t>0 {
		var h,m int
		fmt.Scanf("%d %d\n",&h,&m);
		ans := 0
		ans += 60-m
		ans +=(23-h)*60
		fmt.Println(ans)
		t--;
	}
}

package main

import "fmt"

func main() {
	var tests int
	fmt.Scan(&tests)
	for tests > 0 {
		tests--
		var hours, minutes int
		fmt.Scan(&hours, &minutes)
		var ans int
		ans = (24 - hours - 1) * 60 + (60 - minutes)
		fmt.Println(ans)
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var t int
	fmt.Fscanln(reader, &t)
	var hours, minutes, mins_before_new_year int
	for i := 0; i < t; i++ {
		fmt.Fscanln(reader, &hours, &minutes)
		mins_before_new_year = (60 - minutes) + (24 - (hours + 1)) * 60
		fmt.Fprintln(writer, mins_before_new_year)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, h, m int
	fmt.Scan(&t)
	answers := make([]int, t)
	for i := 0; i < t; i++ {
		fmt.Scan(&h, &m)
		answers[i] = 60*24 - 60*h - m
	}
	for i := 0; i < t; i++ {
		fmt.Println(answers[i])
	}
}

package main

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

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

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

	testCount, _ := strconv.Atoi(input)
	dayMin := 1440

	var timeList []string
	var hour, min, result int

	for i := 0; i < testCount; i++ {
		scanner.Scan()
		input = scanner.Text()

		timeList = strings.Split(input, " ")

		hour, _ = strconv.Atoi(timeList[0])
		min, _ = strconv.Atoi(timeList[1])

		result = dayMin - (hour*60 + min)

		fmt.Println(result)
	}
}

package main

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

func main() {
	const maxHour = 23
	const maxMinute = 60
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	numTestCases := scanner.Text()
	countOfTestCases, _ := strconv.Atoi(numTestCases)

	for i := 0; i < countOfTestCases; i++ {
		scanner.Scan()
		text := scanner.Text()
		str := strings.Split(text, " ")
		currentHour, _ := strconv.Atoi(str[0])
		currentMinute, _ := strconv.Atoi(str[1])

		hourDiff := maxHour - currentHour
		minuteDiff := maxMinute - currentMinute

		fmt.Println(hourDiff*60 + minuteDiff)
	}
}

package main

import "fmt"

func main() {
  t := 0
  fmt.Scan(&t)
  for i := 0; i < t; i++ {
    var a, b int
    fmt.Scan(&a, &b)
    fmt.Println(24 * 60 - a * 60 - b)
  }
}

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 main() {

	var T int
	scanf("%d \n", &T)

	minutes := 1440
	results := []int{}
	for i:=0; i<T; i++ {
		var h, m int
		scanf("%d %d \n", &h, &m)
		value := h * 60 + m
		results = append(results, minutes - value)

	}

	for _, v := range results {
		fmt.Println(v)
	}

}

package main

import "fmt"

func main() {
	var t, h, m int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		fmt.Scan(&h, &m)
		fmt.Println(1440 - h*60 - m)
	}
}

package main

import (
	"fmt"
)

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

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

func main(){
	var t int
	fmt.Scanln(&t)
	var h, m int
	for i := 0;i < t;i++  {
		fmt.Scanln(&h, &m)
		fmt.Println((24 - h )*60 - m)
	}
}

package main

import "fmt"

func main(){
 var n int
 fmt.Scan(&n)
var arr [9999] int
	 for i:=0;i<n ;i++  {
	 	var a,b int
fmt.Scan(&a)
fmt.Scan(&b)
	 	arr[i]=1440-(a*60+b)
	}
	for i:=0; i<n;i++  {
		if arr[i]>60 {
			fmt.Println(arr[i])

		}else {
			fmt.Println(arr[i])
		}
	}
	}

package main

import (
    "fmt"
)

func solve() (ans int) {
    var h, m int
    fmt.Scanf("%d %d\n", &h, &m)
    ans = (24 - h) * 60 - m
    if ans == 24 * 60 {
        ans = 0
    }
    return
}

func main() {
    var t int
    fmt.Scanf("%d\n", &t)
    for i := 0; i < t; i++ {
        fmt.Printf("%d\n", solve())
    }
}

package main

import (
	"fmt"
)

func main() {
	var T int
	fmt.Scanln(&T)
	for t := 0; t < T; t++ {
		var h, m int
		fmt.Scanln(&h, &m)
		fmt.Println(24*60 - h*60 - m)
	}
}

package main

import "fmt"

func main(){
    var n int
    fmt.Scan(&n)
    for i := 0; i < n ; i++ {
        var h, m int
        fmt.Scan(&h, &m)
        fmt.Println((23 - h) * 60 + 60  - m)
    }
}

package main

import (
	"fmt"
)

func main() {
	var h, m, t int
	fmt.Scanf("%d", &t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%d %d", &h, &m)
		fmt.Println(1440 - h*60 - m)
	}
}

package main

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

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

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

	testCount, _ := strconv.Atoi(input)
	dayMin := 1440

	var timeList []string
	var hour, min, result int

	for i := testCount; i < testCount; i++ {
		scanner.Scan()
		input = scanner.Text()

		timeList = strings.Split(input, " ")

		hour, _ = strconv.Atoi(timeList[0])
		min, _ = strconv.Atoi(timeList[1])

		result = dayMin - (hour*60 + min)

		fmt.Println(result)
	}
}

package main

import "fmt"

func main() {
  t := 0
  fmt.Scanf("%d", &t)
  for i := 0; i < t; i++ {
    var a, b int
    fmt.Scanf("%d%d", &a, &b)
    fmt.Printf("%d\n", 3600 - a * 60 - b)
  }
}

package main

import "fmt"

func main() {
  t := 0
  fmt.Scanf("%d", &t)
  for i := 0; i < t; i++ {
    var a, b int
    fmt.Scanf("%d %d", &a, &b)
    fmt.Printf("%d\n", 24 * 60 - a * 60 - b)
  }
}

package main

import "fmt"

func main() {
  t := 0
  fmt.Scanf("%d", &t)
  for i := 0; i < t; i++ {
    var a, b int
    fmt.Scanf("%d%d", &a, &b)
    fmt.Printf("%d\n", 24 * 60 - a * 60 - b)
  }
}

package main

import (
    "fmt"
)

func solve() (ans int) {
    var h, m int
    fmt.Scanf("%d%d", &h, &m)
    ans = (24 - h) * 60 - m
    if ans == 24 * 60 {
        ans = 0
    }
    return
}

func main() {
    var t int
    fmt.Scanf("%d", &t)
    for i := 0; i < t; i++ {
        fmt.Printf("%d\n", solve())
    }
}