Daniel has a string s, consisting of lowercase English letters and period signs (characters '.'). Let's define the operation of replacement as the following sequence of steps: find a substring ".." (two consecutive periods) in string s, of all occurrences of the substring let's choose the first one, and replace this substring with string ".". In other words, during the replacement operation, the first two consecutive periods are replaced by one. If string s contains no two consecutive periods, then nothing happens.Let's define f(s) as the minimum number of operations of replacement to perform, so that the string does not have any two consecutive periods left.You need to process m queries, the i-th results in that the character at position xi (1 ≤ xi ≤ n) of string s is assigned value ci. After each operation you have to calculate and output the value of f(s).Help Daniel to process all queries.

The first line contains two integers n and m (1 ≤ n, m ≤ 300 000) the length of the string and the number of queries. The second line contains string s, consisting of n lowercase English letters and period signs. The following m lines contain the descriptions of queries. The i-th line contains integer xi and ci (1 ≤ xi ≤ n, ci — a lowercas English letter or a period sign), describing the query of assigning symbol ci to position xi.

Print m numbers, one per line, the i-th of these numbers must be equal to the value of f(s) after performing the i-th assignment.

NoteNote to the first sample test (replaced periods are enclosed in square brackets).The original string is ".b..bz....". after the first query f(hb..bz....) = 4    ("hb[..]bz...."  →  "hb.bz[..].."  →  "hb.bz[..]."  →  "hb.bz[..]"  →  "hb.bz.") after the second query f(hbс.bz....) = 3    ("hbс.bz[..].."  →  "hbс.bz[..]."  →  "hbс.bz[..]"  →  "hbс.bz.") after the third query f(hbс.bz..f.) = 1    ("hbс.bz[..]f."  →  "hbс.bz.f.")Note to the second sample test.The original string is ".cc.". after the first query: f(..c.) = 1    ("[..]c."  →  ".c.") after the second query: f(....) = 3    ("[..].."  →  "[..]."  →  "[..]"  →  ".") after the third query: f(.a..) = 1    (".a[..]"  →  ".a.") after the fourth query: f(aa..) = 1    ("aa[..]"  →  "aa.")

package main

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

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

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

	n, m := nextInt(), nextInt()
	cntOp := 0
	length := 0

	s := make([]uint8, n+2)
	s[0] = 'a'
	s[n+1] = 'a'
	scanner.Split(bufio.ScanBytes)
	next()
	for i := 0; i < n; i++ {
		c := next()

		if c != "." {
			if length > 1 {
				cntOp += length - 1
			}
			length = 0
		} else {
			length++
		}
		// println(length, cntOp)
		s[i+1] = uint8(c[0])
	}

	if length > 1 {
		cntOp += length - 1
	}

	// println(cntOp, string(s), s)
	scanner.Split(bufio.ScanWords)
	for ; m > 0; m-- {
		// println(next())
		pos, c := nextInt(), uint8(next()[0])
		// println(pos, string(c), c)

		if (s[pos] == '.' && c == '.') || (isAlpha(s[pos]) && isAlpha(c)) {
			println(cntOp)
			continue
		}

		s[pos] = c
		if s[pos-1] == '.' && s[pos+1] == '.' {
			if s[pos] == '.' {
				cntOp += 2
			} else {
				cntOp -= 2
			}
		} else if s[pos-1] == '.' || s[pos+1] == '.' {
			if s[pos] == '.' {
				cntOp += 1
			} else {
				cntOp -= 1
			}
		}
		// println(string(s))
		println(cntOp)
	}
}

func isAlpha(c uint8) bool {
	if c >= 'a' && c <= 'z' {
		return true
	}

	return false
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

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

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

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

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

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

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

  line, _ := reader.ReadString('\n')
  var n, q int
  fmt.Sscanf(line, "%d %d", &n, &q)
  line, _ = reader.ReadString('\n')
  s := make([]byte, n + 2)
  periods, spans := 0, 0
  for i := 1; i <= n; i++ {
    ch := line[i - 1]
    s[i] = ch
    if ch == '.' {
      periods++
      if s[i - 1] != '.' {
        spans++
      }
    }
  }
  for i := 0; i < q; i++ {
    line, _ = reader.ReadString('\n')
    var pos int
    var ch byte
    fmt.Sscanf(line, "%d %c", &pos, &ch)
    left, right := s[pos - 1], s[pos + 1]
    if s[pos] == '.' {
      if ch != '.' {
        periods--
        if left != '.' && right != '.' {
          spans--
        }
        if left == '.' && right == '.' {
          spans++
        }
      }
    } else {
      if ch == '.' {
        periods++
        if left != '.' && right != '.' {
          spans++
        }
        if left == '.' && right == '.' {
          spans--
        }
      }
    }
    writer.WriteString(fmt.Sprintf("%d\n", periods - spans))
    s[pos] = ch
  }
}

package main

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

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

  line, _ := reader.ReadString('\n')
  var n, q int
  fmt.Sscanf(line, "%d %d", &n, &q)
  line, _ = reader.ReadString('\n')
  s := make([]byte, n + 2)
  periods, spans := 0, 0
  for i := 1; i <= n; i++ {
    ch := line[i - 1]
    s[i] = ch
    if ch == '.' {
      periods++
      if s[i - 1] != '.' {
        spans++
      }
    }
  }
  for i := 0; i < q; i++ {
    line, _ = reader.ReadString('\n')
    var ch byte
    var pos int
    fmt.Sscanf(line, "%d %c", &pos, &ch)
    left, right := s[pos - 1], s[pos + 1]
    if s[pos] == '.' {
      if ch != '.' {
        periods--
        if left != '.' && right != '.' {
          spans--
        }
        if left == '.' && right == '.' {
          spans++
        }
      }
    } else {
      if ch == '.' {
        periods++
        if left != '.' && right != '.' {
          spans++
        }
        if left == '.' && right == '.' {
          spans--
        }
      }
    }
    writer.WriteString(fmt.Sprintf("%d\n", periods - spans))
    s[pos] = ch
  }
}

package main

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

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

	var n, q, p, dot, seg int
	var s, c []byte
	Fscan(in, &n, &q, &s)
	for i, b := range s {
		if b == '.' {
			dot++
			if i == 0 || s[i-1] != '.' {
				seg++
			}
		}
	}
	s = append([]byte{0}, append(s, 0)...)
	for ; q > 0; q-- {
		Fscan(in, &p, &c)
		if s[p] == '.' != (c[0] == '.') {
			d := -1
			if c[0] == '.' {
				d = 1
			}
			dot += d
			if s[p-1] != '.' && s[p+1] != '.' {
				seg += d
			} else if s[p-1] == '.' && s[p+1] == '.' {
				seg -= d
			}
			s[p] = c[0]
		}
		Fprintln(out, dot-seg)
	}
}

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

    package main
    import(
        "fmt"
        "bufio"
        "os"
        "strconv"
        "strings"
        // "reflect"
    )

    type Input struct{
        scanner *bufio.Scanner
        isWord bool
    }

    func (int *Input) init(){
        if in.scanner == nil {
            in.scanner = bufio.NewScanner(os.Stdin)
            in.isWord = false
        }
    }

    func (in *Input) scanInt() int{
        in.init()
        in.scanner.Scan()
        var i int
        i,_ = strconv.Atoi(in.scanner.Text())
        return i
    }

    func (in *Input) scanStrByte(length int) string{

        in.isWord = false
        in.init();
        in.scanner.Split(bufio.ScanBytes)

        s := make([]byte, length+2)

        for i := 0; i < length; i++{
            in.scanner.Scan();
            s[i] = in.scanner.Text()[0]
        }

        return string(s)

    }

    func (in *Input) scanStr() string{
        in.init()
        if !in.isWord{
                in.scanner.Split(bufio.ScanWords)
                in.isWord = true
        }

        in.scanner.Scan()
        return in.scanner.Text()
    }

    func (in *Input) scanIntArray() []int{
        in.init()
        strArray := strings.Split(in.scanStr(), " ");
        length := len(strArray)

        var intArray []int
        for i := 0; i < length; i++ {
            v,_ := strconv.Atoi(strArray[i])
            intArray = append(intArray, v)
        }

        return intArray
    }

    var in Input

    var ar[300005] int
    func main(){

        var inputAr [2]int
        inputAr[0],_ = strconv.Atoi(in.scanStr())
        // inputAr[0] = x
        inputAr[1],_ = strconv.Atoi(in.scanStr())
        in.scanStrByte(1)

        str := in.scanStrByte(inputAr[0])

        strLen := inputAr[0]

        totDot := 0
        totSeg := 0

        dot := "."
        // if(strLen > 1000){
        //     fmt.Println("Hello")
        //     fmt.Println(reflect.ValueOf(str).Kind())
        //     fmt.Println(str)
        //     return
        // }

        for i := 0; i < strLen; i++{
            if str[i] == dot[0]{
                ar[i+1] = 1
                totDot++

                if i == 0 {
                    totSeg++
                } else if str[i-1] != dot[0] {
                    totSeg++
                }

            } else {
                ar[i+1] = 0
            }
        }

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

        // fmt.Println(str)
        for i := 0; i < inputAr[1]; i++{

            var mStr [2]string
            mStr[0] = in.scanStr()
            mStr[1] = in.scanStr()
            // fmt.Println(mStr)

            // mStr := strings.Split(in.scanStr(), " ")
            // fmt.Println(mStr)
            ind,_ := strconv.Atoi(mStr[0])
            if mStr[1][0] == dot[0]{
                if(ar[ind] != 1){
                    totDot++
                    ar[ind] = 1
                    //decrease segment
                    if ar[ind-1] == 1 && ar[ind+1] == 1{
                        totSeg--
                    } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                            totSeg++
                    }

                }
            } else{
                if ar[ind] == 1{
                    totDot--
                    ar[ind] = 0

                    if ar[ind-1] == 1 && ar[ind+1] == 1{
                        totSeg++
                    } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                            totSeg--
                    }
                }
            }

            fmt.Println((totDot - totSeg))
            // fmt.Fprintln(writer, (totDot - totSeg))
        }

    }

// Author: sighduck
// URL: https://codeforces.com/problemset/problem/570/C

package main

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

type Query struct {
	Position int
	Letter   string
}

func getAdjacent(arr []string, index int, n int) int {
	count := 0
	if index-1 >= 0 && arr[index-1] == "." {
		count += 1
	}
	if index+1 < n && arr[index+1] == "." {
		count += 1
	}
	return count
}

func Solve(n int, m int, s string, queries []Query) []int {
	arr := strings.Split(s, "")
	replacements := 0
	for i := 0; i < n-1; i++ {
		if arr[i] == "." && arr[i+1] == "." {
			replacements += 1
		}
	}
	answers := make([]int, m)
	for i, query := range queries {
		adjCount := getAdjacent(arr, query.Position-1, n)
		if arr[query.Position-1] == "." && query.Letter != "." {
			replacements -= adjCount
		}
		if arr[query.Position-1] != "." && query.Letter == "." {
			replacements += adjCount
		}
		arr[query.Position-1] = query.Letter
		answers[i] = replacements
	}
	return answers
}

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

	var n, m int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	var s string
	fmt.Fscanf(reader, "%s\n", &s)
	queries := make([]Query, m)
	for i := 0; i < m; i++ {
		fmt.Fscanf(reader, "%d %s\n", &queries[i].Position, &queries[i].Letter)
	}

	answers := Solve(n, m, s, queries)
	for _, elem := range answers {
		fmt.Fprintf(writer, "%d\n", elem)
	}
}

package main

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

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

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

	n, m := nextInt(), nextInt()
	cntOp := 0
	length := 0

	s := make([]uint8, n+2)
	s[0] = 'a'
	s[n+1] = 'a'
	scanner.Split(bufio.ScanBytes)
	next()
	for i := 0; i < n; i++ {
		c := next()

		if c != "." {
			if length > 1 {
				cntOp += length - 1
			}
			length = 0
		} else {
			length++
		}
		// println(length, cntOp)
		s[i+1] = uint8(c[0])
	}

	if length > 1 {
		cntOp += length - 1
	}

	scanner.Split(bufio.ScanWords)
	// println(cntOp, string(s), s)
	for ; m > 0; m-- {
		// println(next())
		pos, c := nextInt(), uint8(next()[0])
		s[pos] = c
		// println(pos, string(c), c)
		if s[pos-1] == '.' && s[pos+1] == '.' {
			if s[pos] == '.' {
				cntOp += 2
			} else {
				cntOp -= 2
			}
		} else if s[pos-1] == '.' || s[pos+1] == '.' {
			if s[pos] == '.' {
				cntOp += 1
			} else {
				cntOp -= 1
			}
		}
		// println(string(s))
		println(cntOp)
	}
}

func isAlpha(c uint8) bool {
	if c >= 'a' && c <= 'z' {
		return true
	}

	return false
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

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

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

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

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main
import(
    "fmt"
    "bufio"
    "os"
    "strconv"
    "strings"
    // "reflect"
)

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStrByte(length int) string{

    in.init();
    in.scanner.Split(bufio.ScanBytes)

    s := make([]byte, length+2)

    for i := 0; i < length; i++{
        in.scanner.Scan();
        s[i] = in.scanner.Text()[0]
    }

    return string(s)

}

func (in *Input) scanStr() string{
    in.init()
    in.scanner.Split(bufio.ScanWords)
    in.scanner.Scan()
    return in.scanner.Text()
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){

    var inputAr [2]int
    fmt.Scan(&inputAr[0])
    fmt.Scan(&inputAr[1])

    str := in.scanStrByte(inputAr[0])

    strLen := inputAr[0]

    totDot := 0
    totSeg := 0

    dot := "."
    // if(strLen > 1000){
    //     fmt.Println("Hello")
    //     fmt.Println(reflect.ValueOf(str).Kind())
    //     fmt.Println(str)
    //     return
    // }

    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

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

    for i := 0; i < inputAr[1]; i++{

        var mStr [2]string
        mStr[0] = in.scanStr()
        mStr[1] = in.scanStr()

        // mStr := strings.Split(in.scanStr(), " ")
        // fmt.Println(mStr)
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Println((totDot - totSeg))
        // fmt.Fprintln(writer, (totDot - totSeg))
    }

}

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

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStr() string{
    in.init()
    in.scanner.Scan()
    return in.scanner.Text()
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){
    // fmt.Println(ar)
    inputAr := in.scanIntArray()
    str := in.scanStr()
    strLen := inputAr[0]

    totDot := 0
    totSeg := 0

    dot := "."
    if(strLen > 1000){
        fmt.Println("Hello")
        return
    }
    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

    if(strLen > 1000){
        fmt.Println("Hello")
        return
    }

    for i := 0; i < inputAr[1]; i++{
        mStr := strings.Split(in.scanStr(), " ")
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Println(totDot - totSeg)
    }

}

package main
import(
    "fmt"
    "bufio"
    "os"
    "strconv"
    "strings"
    "reflect"
)

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStr() string{
    // in.init()
    //
    // rd := bufio.NewReader(os.Stdin);
    // bt := make([]byte, 500000);
    // rd.Read(bt)
    // return string(bt)

    var str string
    fmt.Scan(&str)
    return str

    //in.scanner.Scan()
    //return in.scanner.Text()
}

func (in *Input) scanStr2() string{
    // in.init()
    // in.scanner.Scan()
    // return in.scanner.Text()
    var str string
    fmt.Scan(&str)
    return str
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr2(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){

    // fmt.Println(in.scanStr())
    // rd := bufio.NewReader(os.Stdin)
    // // rd.ReadLine()
    // line, hasMoreLine, err := rd.ReadLine()
    // rd.ReadLine()
    // fmt.Println(line, hasMoreLine, err)
    // fmt.Println(string(bt))
    // var test string
    // fmt.Scanln(&test)
    // fmt.Println(test)

    // inputAr := in.scanIntArray()
    // str := in.scanStr()
    var inputAr [2]int
    fmt.Scan(&inputAr[0])
    fmt.Scan(&inputAr[1])

    str := in.scanStr()

    strLen := inputAr[0]

    totDot := 0
    totSeg := 0

    dot := "."
    if(strLen > 1000){
        fmt.Println("Hello")
        fmt.Println(reflect.ValueOf(str).Kind())
        fmt.Println(str)
        return
    }

    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

    if(strLen > 1000){
        fmt.Println("Hello")
        return
    }

    for i := 0; i < inputAr[1]; i++{
        var mStr [2]string
        fmt.Scan(&mStr[0])
        fmt.Scan(&mStr[1])

        // mStr := strings.Split(in.scanStr2(), " ")
        // fmt.Println(mStr)
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Println(totDot - totSeg)
    }

}

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

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStr() string{
    in.init()
    in.scanner.Scan()
    return in.scanner.Text()
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){
    // fmt.Println(ar)
    inputAr := in.scanIntArray()
    str := in.scanStr()
    strLen := inputAr[0]

    totDot := 0
    totSeg := 0
    if(strLen > 1000){
        fmt.Println("Hello")
        return
    }
    dot := "."
    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

    for i := 0; i < inputAr[1]; i++{
        mStr := strings.Split(in.scanStr(), " ")
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Println(totDot - totSeg)
    }

}

package main
import(
    "fmt"
    "bufio"
    "os"
    "strconv"
    "strings"
    // "reflect"
)

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStrByte(length int) string{

    in.init();
    in.scanner.Split(bufio.ScanBytes)

    s := make([]byte, length+2)

    for i := 0; i < length; i++{
        in.scanner.Scan();
        s[i] = in.scanner.Text()[0]
    }

    return string(s)

}

func (in *Input) scanStr() string{
    in.init()
    in.scanner.Split(bufio.ScanWords)
    in.scanner.Scan()
    return in.scanner.Text()
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){

    var inputAr [2]int
    inputAr[0],_ = strconv.Atoi(in.scanStr())
    // inputAr[0] = x
    inputAr[1],_ = strconv.Atoi(in.scanStr())

    str := in.scanStrByte(inputAr[0])

    strLen := inputAr[0]

    totDot := 0
    totSeg := 0

    dot := "."
    // if(strLen > 1000){
    //     fmt.Println("Hello")
    //     fmt.Println(reflect.ValueOf(str).Kind())
    //     fmt.Println(str)
    //     return
    // }

    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

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

    for i := 0; i < inputAr[1]; i++{

        var mStr [2]string
        mStr[0] = in.scanStr()
        mStr[1] = in.scanStr()

        // mStr := strings.Split(in.scanStr(), " ")
        // fmt.Println(mStr)
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Println((totDot - totSeg))
        // fmt.Fprintln(writer, (totDot - totSeg))
    }

}

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

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStr() string{
    in.init()
    in.scanner.Scan()
    return in.scanner.Text()
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){
    // fmt.Println(ar)
    inputAr := in.scanIntArray()
    str := in.scanStr()
    strLen := inputAr[0]

    totDot := 0
    totSeg := 0

    dot := "."
    if(strLen > 1000){
        fmt.Println("Hello", str)
        return
    }
    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

    if(strLen > 1000){
        fmt.Println("Hello")
        return
    }

    for i := 0; i < inputAr[1]; i++{
        mStr := strings.Split(in.scanStr(), " ")
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Println(totDot - totSeg)
    }

}

package main
import(
    "fmt"
    "bufio"
    "os"
    "strconv"
    "strings"
    "reflect"
)

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStr() string{
    in.init()
    in.scanner.Scan()
    return in.scanner.Text()
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){
    // t := &Input{}
    // fmt.Println(reflect.ValueOf(t).Kind())

    // fmt.Println(ar)
    inputAr := in.scanIntArray()
    str := in.scanStr()
    strLen := inputAr[0]

    totDot := 0
    totSeg := 0

    dot := "."
    if(strLen > 1000){
        fmt.Println("Hello")
        fmt.Println(reflect.ValueOf(str).Kind())
        fmt.Println(str)
        return
    }
    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

    if(strLen > 1000){
        fmt.Println("Hello")
        return
    }

    for i := 0; i < inputAr[1]; i++{
        mStr := strings.Split(in.scanStr(), " ")
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Println(totDot - totSeg)
    }

}

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

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStr() string{
    in.init()
    in.scanner.Scan()
    return in.scanner.Text()
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){
    // fmt.Println(ar)
    inputAr := in.scanIntArray()
    str := in.scanStr()
    strLen := inputAr[0]

    totDot := 0
    totSeg := 0

    dot := "."
    if(strLen > 1000){
        fmt.Println("Hello", strLen)
        return
    }
    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

    if(strLen > 1000){
        fmt.Println("Hello")
        return
    }

    for i := 0; i < inputAr[1]; i++{
        mStr := strings.Split(in.scanStr(), " ")
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Println(totDot - totSeg)
    }

}

package main
import(
    "fmt"
    "bufio"
    "os"
    "strconv"
    "strings"
    // "reflect"
)

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStrByte(length int) string{

    in.init();
    in.scanner.Split(bufio.ScanBytes)

    s := make([]byte, length+2)

    for i := 0; i < length; i++{
        in.scanner.Scan();
        s[i] = in.scanner.Text()[0]
    }

    return string(s)

}

func (in *Input) scanStr() string{
    in.init()
    in.scanner.Split(bufio.ScanWords)
    in.scanner.Scan()
    return in.scanner.Text()
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){

    var inputAr [2]int
    fmt.Scan(&inputAr[0])
    fmt.Scan(&inputAr[1])

    str := in.scanStrByte(inputAr[0])

    strLen := inputAr[0]

    totDot := 0
    totSeg := 0

    dot := "."
    // if(strLen > 1000){
    //     fmt.Println("Hello")
    //     fmt.Println(reflect.ValueOf(str).Kind())
    //     fmt.Println(str)
    //     return
    // }

    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

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

    for i := 0; i < inputAr[1]; i++{

        var mStr [2]string
        mStr[0] = in.scanStr()
        mStr[1] = in.scanStr()

        // mStr := strings.Split(in.scanStr(), " ")
        // fmt.Println(mStr)
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Fprintln(writer, (totDot - totSeg))
    }

}

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

type Input struct{
    scanner *bufio.Scanner
}

func (int *Input) init(){
    if in.scanner == nil {
        in.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (in *Input) scanInt() int{
    in.init()
    in.scanner.Scan()
    var i int
    i,_ = strconv.Atoi(in.scanner.Text())
    return i
}

func (in *Input) scanStr() string{
    in.init()
    in.scanner.Scan()
    return in.scanner.Text()
}

func (in *Input) scanIntArray() []int{
    in.init()
    strArray := strings.Split(in.scanStr(), " ");
    length := len(strArray)

    var intArray []int
    for i := 0; i < length; i++ {
        v,_ := strconv.Atoi(strArray[i])
        intArray = append(intArray, v)
    }

    return intArray
}

var in Input

var ar[300005] int
func main(){
    // fmt.Println(ar)
    inputAr := in.scanIntArray()
    str := in.scanStr()
    strLen := inputAr[0]

    totDot := 0
    totSeg := 0

    dot := "."
    if(strLen > 1000){
        fmt.Println("Hello")
        fmt.Println(len(str))
        return
    }
    for i := 0; i < strLen; i++{
        if str[i] == dot[0]{
            ar[i+1] = 1
            totDot++

            if i == 0 {
                totSeg++
            } else if str[i-1] != dot[0] {
                totSeg++
            }

        } else {
            ar[i+1] = 0
        }
    }

    if(strLen > 1000){
        fmt.Println("Hello")
        return
    }

    for i := 0; i < inputAr[1]; i++{
        mStr := strings.Split(in.scanStr(), " ")
        ind,_ := strconv.Atoi(mStr[0])
        if mStr[1][0] == dot[0]{
            if(ar[ind] != 1){
                totDot++
                ar[ind] = 1
                //decrease segment
                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg--
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg++
                }

            }
        } else{
            if ar[ind] == 1{
                totDot--
                ar[ind] = 0

                if ar[ind-1] == 1 && ar[ind+1] == 1{
                    totSeg++
                } else if ar[ind-1] == 0 && ar[ind+1] == 0{
                        totSeg--
                }
            }
        }

        fmt.Println(totDot - totSeg)
    }

}


Petya and Vasya are tossing a coin. Their friend Valera is appointed as a judge. The game is very simple. First Vasya tosses a coin x times, then Petya tosses a coin y times. If the tossing player gets head, he scores one point. If he gets tail, nobody gets any points. The winner is the player with most points by the end of the game. If boys have the same number of points, the game finishes with a draw.At some point, Valera lost his count, and so he can not say exactly what the score is at the end of the game. But there are things he remembers for sure. He remembers that the entire game Vasya got heads at least a times, and Petya got heads at least b times. Moreover, he knows that the winner of the game was Vasya. Valera wants to use this information to know every possible outcome of the game, which do not contradict his memories.

The single line contains four integers x, y, a, b (1 ≤ a ≤ x ≤ 100, 1 ≤ b ≤ y ≤ 100). The numbers on the line are separated by a space.

In the first line print integer n — the number of possible outcomes of the game. Then on n lines print the outcomes. On the i-th line print a space-separated pair of integers ci, di — the number of heads Vasya and Petya got in the i-th outcome of the game, correspondingly. Print pairs of integers (ci, di) in the strictly increasing order. Let us remind you that the pair of numbers (p1, q1) is less than the pair of numbers (p2, q2), if p1 < p2, or p1 = p2 and also q1 < q2.

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

func main() {
	var x,y,a,b int
	n:=0
	out := bufio.NewWriter(os.Stdout)

	fmt.Scan(&x,&y,&a,&b)
	for i:=a;i<=x;i++{
		for j:=b;j<=y;j++ {
			if i>j {
				n++
			}
		}
	}
	fmt.Println(n)
	for i:=a;i<=x;i++{
		for j:=b;j<=y;j++ {
			if i>j {
				//fmt.Println(i,j)
				out.WriteString(strconv.Itoa(i))
				//fmt.Println()
				out.Flush()
				fmt.Print(" ")
				out.WriteString(strconv.Itoa(j))
				out.Flush()
				fmt.Println()
			}
		}
	}
	out.Flush()
}

package main

import "fmt"

type Outcome struct {
    p,q int
}

func main() {
    var x,y,a,b int
    var ans [10000]Outcome
    fmt.Scan(&x,&y,&a,&b)
    cnt := 0
    for i := a; i <= x; i++ {
        for j := b; (j <= y) && (j < i); j++ {
            ans[cnt].p = i
            ans[cnt].q = j
            cnt++
        }
    }
    fmt.Println(cnt)
    for i := 0; i < cnt; i++ {
        fmt.Println(ans[i].p,ans[i].q)
    }
}

package main

import "fmt"

type Outcome struct {										// membuat fungsi struct
    p,q int												    // variabel p dan q dengan jenis int
}

func main() {
    var x,y,a,b int										// variabel x,y,a,b berjenis int
    var ans [10000]Outcome								// var ans [10000]berjenis struct Outcome
    fmt.Scan(&x,&y,&a,&b)								// mengambil input
    cnt := 0											// membuar variabel cnt dan diisi nilai 0
    for i := a; i <= x; i++ {							// looping
        for j := b; (j <= y) && (j < i); j++ {			// looping ke 2
            ans[cnt].p = i								// ans[cnt].p sama dengan i
            ans[cnt].q = j								// ans[cnt].q  sama dengan j
            cnt++										// cnt ditambah terus
        }
    }
    fmt.Println(cnt)								   // cetak hasil cnt
    for i := 0; i < cnt; i++ {							// looping ke 3
        fmt.Println(ans[i].p,ans[i].q)					// cetak hasil ans[i].p dan ans[i].q
    }
}

package main

import "fmt"

type pair struct{
	first, second int
}

func main() {
	var x, y, a, b int
	var pairs []pair
	fmt.Scanf("%d %d %d %d\n", &x, &y, &a, &b)
	for i := a ; i <= x; i++ {
		for j := b; j <= y; j++ {
			if i > j {
				pairs = append(pairs, pair{first: i, second: j})
			}
		}
	}

	fmt.Println(len(pairs))
	for _, p := range pairs {
		fmt.Println(p.first, p.second)
	}
}

// 242A-mic
package main

import (
    "fmt"
)

func main() {
    var x, y, a, b, o int
    fmt.Scan(&x, &y, &a, &b)
    if b > a {
        a = b + 1
    }

    for i := a; i <= x; i++ {
        for j := b; j < i; j++ {
            if j > y {
                break
            }
            o++
        }
    }
    fmt.Print(o)
    for i := a; i <= x; i++ {
        for j := b; j < i; j++ {
            if j > y {
                break
            }
            fmt.Println()
            fmt.Print(i)
            fmt.Print(" ")
            fmt.Print(j)
        }
    }
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	text, _, _ := reader.ReadLine()

	val := strings.Split(string(text), " ")
	var val2 [4]int64

	var res []string

	val2[0], _ = strconv.ParseInt(val[0], 10, 0)
	val2[1], _ = strconv.ParseInt(val[1], 10, 0)
	val2[2], _ = strconv.ParseInt(val[2], 10, 0)
	val2[3], _ = strconv.ParseInt(val[3], 10, 0)
	//res = append(res, 0)
	i := int(val2[2])
	j := int(val2[3])
	ii := int(val2[0])
	jj := int(val2[1])

	for ; i <= ii; i++ {
		for j = int(val2[3]); j <= jj; j++ {
			if i > j {
				res = append(res, strconv.Itoa(i)+" "+strconv.Itoa(j))
			}

		}

	}

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

}


Janusz is a businessman. He owns a company "Januszex", which produces games for teenagers. Last hit of Januszex was a cool one-person game "Make it one". The player is given a sequence of $$$n$$$ integers $$$a_i$$$.It is allowed to select any subset of them, and the score is equal to the greatest common divisor of selected elements. The goal is to take as little elements as it is possible, getting the score $$$1$$$. Now Janusz wonders, for given sequence, how much elements should the player choose?

The first line contains an only integer $$$n$$$ ($$$1 \le n \le 300\,000$$$) — the number of integers in the sequence. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 300\,000$$$).

If there is no subset of the given sequence with gcd equal to $$$1$$$, output -1. Otherwise, output exactly one integer — the size of the smallest subset with gcd equal to $$$1$$$.

NoteIn the first example, selecting a subset of all numbers gives a gcd of $$$1$$$ and for all smaller subsets the gcd is greater than $$$1$$$.In the second example, for all subsets of numbers the gcd is at least $$$2$$$.

package main

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

var in = bufio.NewReaderSize(os.Stdin, 2<<16)

const (
	max = int(3e5)
	mod = 1e9 + 7
	maxAns = 7
)

var c [max + 1][maxAns + 1]int

func init() {
	c[0][0] = 1
	for i := 1; i < len(c); i++ {
		c[i][0] = 1
		for j := 1; j < len(c[i]); j++ {
			c[i][j] = (c[i-1][j-1] + c[i-1][j]) % mod
		}
	}
}

func main() {
	var n int
	fmt.Fscan(in, &n)
	a := make([]int, n)
	cnt := make([]int, max+1)
	for i := range a {
		fmt.Fscan(in, &a[i])
		cnt[a[i]]++
	}
	for i := 1; i <= max / 2; i++ {
		for j := i * 2; j <= max; j += i {
			cnt[i] += cnt[j]
		}
	}

	for ans := 1; ans <= maxAns; ans++ {
		dp := make([]int, max+1)
		for j := max; j >= 1; j-- {
			dp[j] = c[cnt[j]][ans]
			for k := j * 2; k <= max; k += j {
				dp[j] = (dp[j] + mod - dp[k]) % mod
			}
		}
		if dp[1] != 0 {
			fmt.Println(ans)
			return
		}
	}
	fmt.Println(-1)
}

package main

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

var in = bufio.NewReaderSize(os.Stdin, 2<<16)

const (
	max = int(3e5)
	mod = 1e9 + 7
	maxAns = 7
)

var c [max + 1][maxAns + 1]int

func init() {
	c[0][0] = 1
	for i := 1; i < len(c); i++ {
		c[i][0] = 1
		for j := 1; j < len(c[i]); j++ {
			c[i][j] = (c[i-1][j-1] + c[i-1][j]) % mod
		}
	}
}

func main() {
	var n int
	fmt.Fscan(in, &n)
	a := make([]int, n)
	cnt := make([]int, max+1)
	for i := range a {
		fmt.Scan(&a[i])
		cnt[a[i]]++
	}
	for i := 1; i <= max / 2; i++ {
		for j := i * 2; j <= max; j += i {
			cnt[i] += cnt[j]
		}
	}

	for ans := 1; ans <= maxAns; ans++ {
		dp := make([]int, max+1)
		for j := max; j >= 1; j-- {
			dp[j] = c[cnt[j]][ans]
			for k := j * 2; k <= max; k += j {
				dp[j] = (dp[j] + mod - dp[k]) % mod
			}
		}
		if dp[1] != 0 {
			fmt.Println(ans)
			return
		}
	}
	fmt.Println(-1)
}