package main

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

var a [40005]int
var b [40005]int
var c [100005]int

func main() {
	n := ReadInt()
	m := ReadInt()
	k := ReadInt()
	cnt := 0
	var ans int64
	for i := 1; i <= n; i++ {
		a[i] = ReadInt()
	}
	for i := 1; i <= m; i++ {
		b[i] = ReadInt()
	}
	for i := 1; i*i <= k; i++ {
		if k%i == 0 {
			c[cnt] = i
			cnt++
			if i == k/i {
				continue
			}
			c[cnt] = k / i
			cnt++
		}
	}
	for i := 0; i < cnt; i++ {
		tmp := 0
		var x, y int64
		for j := 1; j <= n; j++ {
			if a[j] == 1 {
				tmp++
			} else {
				tmp = 0
			}
			if tmp == c[i] {
				tmp--
				x++
			}
		}
		tmp = 0
		for j := 1; j <= m; j++ {
			if b[j] == 1 {
				tmp++
			} else {
				tmp = 0
			}
			if tmp == k/c[i] {
				tmp--
				y++
			}
		}
		ans += x * y
	}
	fmt.Println(ans)
}

////////////////////////////////////

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

var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup

func ReadString() string {
	in.Scan()
	return in.Text()
}
func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}
func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.ParseInt(intStr, 10, 32)
	return int(i)
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	//set output
	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(write *bufio.Writer) {
		defer outWg.Done()
		defer write.Flush()

		for line := range out {
			write.WriteString(line + "\n")
		}
	}(writer)
}

package main

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

type vc struct {
	v, c int
}

func getDivs(k int) []int {
	a := make([]int, 0)
	for i := 1; i*i <= k; i++ {
		if k%i == 0 {
			a = append(a, i)
		}
	}

	return a
}

func getCount(vcs []vc, div int) int {
	n := len(vcs)
	//fmt.Println("#######", vcs, div)

	if div > vcs[n-1].v {
		//fmt.Println(vcs[n-1].v)
		return 0
	}

	s := 0
	e := n - 1

	for s < e {
		m := (s + e) / 2

		if vcs[m].v < div {
			s = m + 1
		} else {
			e = m
		}
	}

	cnt := 0

	for i := e; i < n; i++ {
		cnt += vcs[i].c * (vcs[i].v - div + 1)
	}

	//fmt.Println("#######->->", vcs[e], div, cnt)

	return cnt
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

	in := func() int {
		sc.Scan()
		i, _ := strconv.Atoi(sc.Text())
		return i
	}

	n, m, k := in(), in(), in()

	a := make([]int, n)
	b := make([]int, m)

	for i := range a {
		a[i] = in()
	}

	for i := range b {
		b[i] = in()
	}

	mvc := make(map[int]int)

	cnt := 0

	for i := range a {
		if a[i] == 0 {
			if cnt != 0 {
				mvc[cnt]++
				cnt = 0
			}
		} else {
			cnt++
		}
	}

	if a[n-1] == 1 {
		mvc[cnt]++
	}

	if len(mvc) == 0 {
		fmt.Println(0)
		return
	}

	avc := make([]vc, len(mvc))
	var i int = 0
	for v, c := range mvc {
		avc[i].v = v
		avc[i].c = c
		i++
	}

	mvc = make(map[int]int)

	cnt = 0

	for i := range b {
		if b[i] == 0 {
			if cnt != 0 {
				mvc[cnt]++
				cnt = 0
			}
		} else {
			cnt++
		}
	}

	if b[m-1] == 1 {
		mvc[cnt]++
	}

	if len(mvc) == 0 {
		fmt.Println(0)
		return
	}

	bvc := make([]vc, len(mvc))
	i = 0

	for v, c := range mvc {
		bvc[i].v = v
		bvc[i].c = c
		i++
	}

	sort.Slice(avc, func(i, j int) bool {
		return avc[i].v < avc[j].v
	})

	sort.Slice(bvc, func(i, j int) bool {
		return bvc[i].v < bvc[j].v
	})

	// fmt.Println(avc)
	// fmt.Println(bvc)

	divs := getDivs(k)

	// fmt.Println(divs)

	cnt2 := int64(0)

	for _, div := range divs {
		div2 := k / div
		cnt2 += int64(getCount(avc, div) * getCount(bvc, div2))

		if div != div2 {
			cnt2 += int64(getCount(bvc, div) * getCount(avc, div2))
		}
	}

	fmt.Println(cnt2)

}

package main

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

func main() {
	var n, m, k int64
	fmt.Scanf("%d %d %d\n", &n, &m, &k)
	reader := bufio.NewReader(os.Stdin)
	ans := readLine(reader)
	an := strings.Split(string(ans), " ")
	bms := readLine(reader)
	bm := strings.Split(string(bms), " ")
	ma := make(map[int64]int64)
	mb := make(map[int64]int64)
	current := int64(0)
	sr := getgdcOfK(k)
	for i := int64(0); i < n; i++ {
		x, _ := strconv.Atoi(an[i])
		if x == 0 {
			addMap(&ma, current, sr)
			current = 0
			continue
		}
		current++
	}
	// fmt.Println(ma, current, sr)
	addMap(&ma, current, sr)
	current = 0
	for i := int64(0); i < m; i++ {
		x, _ := strconv.Atoi(bm[i])
		if x == 0 {
			addMap(&mb, current, sr)
			current = 0
			continue
		}
		current++
	}
	addMap(&mb, current, sr)
	// fmt.Println(ma)
	// fmt.Println(mb)
	result := int64(0)
	for ak, av := range ma {
		bk := k / ak
		bv := mb[bk]
		result += av * bv
	}
	fmt.Println(result)
}

func addMap(m *map[int64]int64, n int64, sr []int64) {
	for i := 0; i < len(sr); i++ {
		if n < sr[i] {
			return
		}
		// fmt.Println(m, n, sr[i])
		v := (*m)[sr[i]]
		v += n - sr[i] + 1
		(*m)[sr[i]] = v
	}
}

func getgdcOfK(k int64) []int64 {
	gap := math.Sqrt(float64(k))
	slice := make([]int64, 0)
	for i := int64(1); i <= int64(gap); i++ {
		if k%i == 0 {
			slice = append(slice, i)
		}
	}
	length := len(slice)
	for i := length - 1; i >= 0; i-- {
		if k/slice[i] != slice[i] {
			slice = append(slice, k/slice[i])
		}
	}
	// fmt.Println(slice, k)
	return slice
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			// fmt.Println(string(result))
			break
		}
	}
	return result
}

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

package main

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

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

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

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

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

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

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

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

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

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

var (
	n, m, k int
	A, B    []int
	R, C    []int

	cr, cc []int
)

func main() {
	n, m, k = ReadInt3()
	A = ReadIntSlice(n)
	B = ReadIntSlice(m)

	comp, cnts := RunLengthEncoding(A)
	for i := 0; i < len(comp); i++ {
		if comp[i] == 1 {
			R = append(R, cnts[i])
		}
	}
	comp, cnts = RunLengthEncoding(B)
	for i := 0; i < len(comp); i++ {
		if comp[i] == 1 {
			C = append(C, cnts[i])
		}
	}
	PrintfDebug("R: %v\n", R)
	PrintfDebug("C: %v\n", C)

	cr, cc = make([]int, 50000), make([]int, 50000)
	for i := 0; i < len(R); i++ {
		for j := 1; j <= R[i]; j++ {
			cr[j] += R[i] - j + 1
		}
	}
	for i := 0; i < len(C); i++ {
		for j := 1; j <= C[i]; j++ {
			cc[j] += C[i] - j + 1
		}
	}

	ans := int64(0)
	for i := 1; i <= 40000; i++ {
		if k%i == 0 && k/i <= 40000 {
			ans += int64(cr[i]) * int64(cc[k/i])
		}
	}
	fmt.Println(ans)
}

// RunLengthEncoding returns encoded slice of an input.
func RunLengthEncoding(S []int) ([]int, []int) {
	runes := []int{}
	lengths := []int{}

	l := 0
	for i := 0; i < len(S); i++ {
		// 1文字目の場合保持
		if i == 0 {
			l = 1
			continue
		}

		if S[i-1] == S[i] {
			// 直前の文字と一致していればインクリメント
			l++
		} else {
			// 不一致のタイミングで追加し、長さをリセットする
			runes = append(runes, S[i-1])
			lengths = append(lengths, l)
			l = 1
		}
	}
	runes = append(runes, S[len(S)-1])
	lengths = append(lengths, l)

	return runes, lengths
}

// RunLengthDecoding decodes RLE results.
func RunLengthDecoding(S []int, L []int) []int {
	if len(S) != len(L) {
		panic("S, L are not RunLengthEncoding results")
	}

	res := []int{}

	for i := 0; i < len(S); i++ {
		for j := 0; j < L[i]; j++ {
			res = append(res, S[i])
		}
	}

	return res
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

package main

import "fmt"
import "os"
import "bufio"
import "strings"
import "strconv"

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    capacity := 5000 * 1024
    scanner.Buffer(make([]byte, capacity), capacity)

    scanner.Scan()
    line := scanner.Text()
    parts := strings.Split(line, " ")
    n, _ := strconv.ParseInt(parts[0], 10, 64)
    m, _ := strconv.ParseInt(parts[1], 10, 64)
    k, _ := strconv.ParseInt(parts[2], 10, 64)

    scanner.Scan()
    line = scanner.Text()
    parts = strings.Split(line, " ")
    a := make([]int64, n)
    for j := int64(0); j < n; j++ {
        a[j], _ = strconv.ParseInt(parts[j], 10, 64)
    }

    scanner.Scan()
    line = scanner.Text()
    parts = strings.Split(line, " ")
    b := make([]int64, m)
    for j := int64(0); j < m; j++ {
        b[j], _ = strconv.ParseInt(parts[j], 10, 64)
    }

    //~ fmt.Println(k, a, b)
    fs := factorize(n, m, k)
    //~ fmt.Println(fs)

    count := int64(0)
    for _, f := range fs {
        count_f := count_subsequences(a, f.rows) *
            count_subsequences(b, f.cols)
        //~ fmt.Println(f.rows, f.cols, count_f)
        count += count_f
    }
    fmt.Println(count)
}

type factors struct {
    rows, cols int64
}

func factorize(n, m, k int64) []factors {
    fs := make([]factors, 0)
    for rows := int64(1); rows <= n; rows++ {
        if k % rows == 0 && k / rows <= m {
            fs = append(fs, factors {rows, k / rows})
        }
    }
    return fs
}

func count_subsequences(a []int64, x int64) int64 {
    count := int64(0)
    start := int64(-1)
    for i := int64(0); i < int64(len(a)); i++ {
        if a[i] == 0 {
            if start != -1 {
                seq_len := i - start
                seq_count := seq_len - (x - 1)
                if seq_count > 0 {
                    count += seq_count
                }
                start = -1
            }
        } else {
            if start == -1 {
                start = i
            }
        }
    }

    if start != -1 {
        seq_len := int64(len(a)) - start
        seq_count := seq_len - (x - 1)
        if seq_count > 0 {
            count += seq_count
        }
        start = -1
    }

    return count
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1323B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	makeSum := func(n int) ([]int, []int) {
		sum1 := 0
		times := make([]int, n+1)
		for i := 0; i < n; i++ {
			var v int
			if Fscan(in, &v); v == 1 {
				sum1++
			} else {
				if sum1 > 0 {
					times[sum1]++
				}
				sum1 = 0
			}
		}
		if sum1 > 0 {
			times[sum1]++
		}
		sumLen := make([]int, n+1)
		sumTimes := make([]int, n+1)
		for i := 1; i <= n; i++ {
			sumLen[i] = sumLen[i-1] + times[i]*i
			sumTimes[i] = sumTimes[i-1] + times[i]
		}
		return sumLen, sumTimes
	}

	var n, m, k int
	Fscan(in, &n, &m, &k)
	sumLenA, sumTimesA := makeSum(n)
	sumLenB, sumTimesB := makeSum(m)
	ans := int64(0)
	for x := n; x > 0; x-- {
		if k%x == 0 {
			y := k / x
			if y > m {
				break
			}
			cx := int64(sumLenA[n] - sumLenA[x-1] - (sumTimesA[n]-sumTimesA[x-1])*(x-1))
			cy := int64(sumLenB[m] - sumLenB[y-1] - (sumTimesB[m]-sumTimesB[y-1])*(y-1))
			ans += cx * cy
		}
	}
	Fprint(_w, ans)
}

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

package main

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

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

	var n, m, k int
	Fscan(in, &n, &m, &k)
	a := make([]int, n)
	suma := make([]int, n+1)
	cnta := make([]int, n+1)
	for i := range a {
		Fscan(in, &a[i])
		if a[i] == 1 {
			suma[i+1] = suma[i] + 1
		} else {
			if suma[i] > 0 {
				cnta[suma[i]]++
			}
		}
	}
	if suma[n] > 0 {
		cnta[suma[n]]++
	}
	sumcnta := make([]int, n+1)
	lensuma := make([]int,n+1)
	for i := 1; i <= n; i++ {
		sumcnta[i]=sumcnta[i-1]+cnta[i]
		lensuma[i]=lensuma[i-1]+cnta[i]*i
	}

	b := make([]int, m)
	sumb := make([]int, m+1)
	cntb := make([]int, m+1)
	for i := range b {
		Fscan(in, &b[i])
		if b[i] == 1 {
			sumb[i+1] = sumb[i] + 1
		} else {
			if sumb[i] > 0 {
				cntb[sumb[i]]++
			}
		}
	}
	if sumb[m] > 0 {
		cntb[sumb[m]]++
	}
	sumcntb := make([]int, m+1)
	lensumb := make([]int,m+1)
	for i := 1; i <= m; i++ {
		sumcntb[i]=sumcntb[i-1]+cntb[i]
		lensumb[i]=lensumb[i-1]+cntb[i]*i
	}

	ans := int64(0)
	for x := n;x>0;x-- {
		if k%x==0 {
			y := k/x
			if y>m {
				break
			}
			cx := int64(lensuma[n]-lensuma[x-1])
			tmp := int64(sumcnta[n]-sumcnta[x-1])
			cx-=tmp*int64(x-1)

			cy := int64(lensumb[m]-lensumb[y-1])
			tmp2 := int64(sumcntb[m]-sumcntb[y-1])
			cy-=tmp2*int64(y-1)
			ans+=cx*cy
		}
	}
	Fprintln(out, ans)

}

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

package main

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

func getInts() []int64 {
	//assumes POSITIVE INTEGERS. Check v for '-' if you have negative.
	var buf []byte
	buf, _ = ioutil.ReadAll(os.Stdin)
	var ints []int64
	num := int64(0)
	found := false
	for _, v := range buf {
		if '0' <= v && v <= '9' {
			num = 10*num + int64(v-'0') //could use bitshifting here.
			found = true
		} else if found {
			ints = append(ints, num)
			found = false
			num = 0
		}
	}
	if found {
		ints = append(ints, num)
		found = false
		num = 0
	}
	return ints
}

func stat(aa []int64) map[int]int {
	ans := make(map[int]int)
	ones := 0
	for _, x := range aa {
		if x == 1 {
			ones++
		} else {
			if ones != 0 {
				ans[ones]++
			}
			ones = 0
		}
	}
	if ones != 0 {
		ans[ones]++
	}

	return ans
}

func main() {
	ii := getInts()

	n, m, k := int(ii[0]), int(ii[1]), int(ii[2])
	ii = ii[3:]

	aa := ii[:n]
	ii = ii[n:]

	bb := ii[:m]
	ii = ii[m:]

	solve := func(alen, blen int) (res int64) {
		if alen*blen < k {
			return 0
		}
		for al := 1; al <= alen; al++ {
			bl := k / al
			if bl > blen {
				continue
			}
			if bl*al != k {
				continue
			}
			res += int64(alen-al+1) * int64(blen-bl+1)
		}
		return res
	}

	astat := stat(aa)
	bstat := stat(bb)

	ans := int64(0)

	for alen, acount := range astat {
		for blen, bcount := range bstat {
			s := solve(alen, blen)
			ans += s * int64(acount) * int64(bcount)
		}
	}

	fmt.Println(ans)
}

package main

import (
    "fmt"
    "sort"
)

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

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

func calculate(a1, a2, s int64) int64 {
  var result int64
  for s1 := int64(1); s1 <= min(s, a1); s1++ {
    if s % s1 != 0 { continue }

    s2 := s/s1

    if (s2 > a2) {continue}

    // fmt.Println(s1, s2, a1, a2)

    result += (a1 - s1 + 1)*(a2 - s2 +1)

  }

  return result
}

func main() {
  var n1, n2, s int64
  fmt.Scanf("%d %d %d\n", &n1, &n2, &s)

  a1 := make([]bool, n1)
  a2 := make([]bool, n2)
  for i := range a1 {
      var temp int64
      fmt.Scanf("%d", &temp)
      a1[i] = (temp == 1)
  }
  fmt.Scanf("%n")

  for i := range a2 {
      var temp int64
      fmt.Scanf("%d", &temp)
      a2[i] = (temp == 1)
  }

//   fmt.Println(a1, a2)

  m1 := make(map[int64]int64)
  m2 := make(map[int64]int64)
  is_interval := false
  start := int64(-1)
  for i, item := range a1 {
    if is_interval == true && item == false {
      m1[int64(i)-start]+=1
      start = -1
      is_interval = false
    } else if item == true && is_interval == false {
      start = int64(i)
      is_interval = true
    }
  }

  if is_interval == true {
    m1[int64(len(a1)) - start]+=1
  }

  is_interval = false
  start = -1

  for i, item := range a2 {
    if is_interval == true && item == false {
      m2[int64(i)-start]+=1
      start = -1
      is_interval = false
    } else if item == true && is_interval == false {
      start = int64(i)
      is_interval = true
    }
  }

  if is_interval == true {
    m2[int64(len(a2)) - start]+=1
  }

  keys_m1 := make([]int64, 0,int64(len(m1)))
  for k := range m1 {
	keys_m1 = append(keys_m1, int64(k))
  }
  sort.Slice(keys_m1, func(i, j int) bool { return keys_m1[i] < keys_m1[j] })

  keys_m2 := make([]int64, 0, int64(len(m2)))
  for k := range m2 {
	keys_m2 = append(keys_m2, k)
  }
  sort.Slice(keys_m2, func(i, j int) bool { return keys_m2[i] < keys_m2[j] })

  if len(m1) == 0 || len(m2) == 0 {
    fmt.Println(0)
    return
  }

  if s == 1 {
      var sum1, sum2 int64
      for k1, v1 := range m1 {
          sum1+=k1*v1
      }
      for k2, v2 := range m2 {
          sum2+=k2*v2
      }
      fmt.Println(sum1*sum2)
      return
  }

//   fmt.Println(m1, m2, s)

  result := int64(0)
  for _, k1 := range keys_m1 {
    ind2 := sort.Search(len(keys_m2), func(i int) bool { return keys_m2[i]*k1 >= int64(s) })

    if (ind2 > len(keys_m2)) {
      break
    }

    for i_k2 := ind2; i_k2 < len(keys_m2); i_k2++ {
      k2 := keys_m2[i_k2]
      result+=calculate(k1, k2, int64(s))*m1[k1]*m2[k2]
    }

  }

  fmt.Println(result)

}

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}
func NextInt64() int64 {
	bytes := NextBytes()
	i, err := Atoi64(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func Atoi64(b []byte) (int64, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	var n int64
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int64(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

func reverseInts(a []int) {
	for l, r := 0, len(a)-1; l < r; l, r = l+1, r-1 {
		a[l], a[r] = a[r], a[l]
	}
}

func unique(a []int) int {
	newLen := 0
	n := len(a)
	for i := 0; i < n; i++ {
		if newLen == 0 || a[i] != a[newLen-1] {
			a[newLen] = a[i]
			newLen++
		}
	}
	return newLen
}

func find(la, lb []int, k1, k2 int) int64 {
	// stderr("trying", k1, k2)
	i1 := sort.SearchInts(la, k1)
	i2 := sort.SearchInts(lb, k2)
	if i1 == len(la) || i2 == len(lb) {
		return 0
	}
	// stderr("found", i1, i2)
	return int64((len(la) - i1) * (len(lb) - i2))
}

func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	// inf, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(inf, 1000010)

	n, m, k := NextInt(), NextInt(), NextInt()

	a := make([]int, n)
	la := make([]int, n)
	b := make([]int, m)
	lb := make([]int, m)
	for i := 0; i < n; i++ {
		a[i] = NextInt()
	}

	for i := 0; i < m; i++ {
		b[i] = NextInt()
	}

	for i, l := n-1, 0; i >= 0; i-- {
		if a[i] == 1 {
			l++
		} else {
			l = 0
		}
		la[i] = l
	}

	for i, l := m-1, 0; i >= 0; i-- {
		if b[i] == 1 {
			l++
		} else {
			l = 0
		}
		lb[i] = l
	}

	sort.Ints(la)
	sort.Ints(lb)

	// stderr("inputs", la, "\n", lb)

	var res int64
	for k1 := 1; k1*k1 <= k; k1++ {
		if k%k1 == 0 {
			res += find(la, lb, k1, k/k1)
			if k1 != k/k1 {
				res += find(la, lb, k/k1, k1)
			}
		}
	}
	fmt.Fprintln(out, res)

}

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}
func NextInt64() int64 {
	bytes := NextBytes()
	i, err := Atoi64(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func Atoi64(b []byte) (int64, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	var n int64
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int64(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

func reverseInts(a []int) {
	for l, r := 0, len(a)-1; l < r; l, r = l+1, r-1 {
		a[l], a[r] = a[r], a[l]
	}
}

func unique(a []int) int {
	newLen := 0
	n := len(a)
	for i := 0; i < n; i++ {
		if newLen == 0 || a[i] != a[newLen-1] {
			a[newLen] = a[i]
			newLen++
		}
	}
	return newLen
}

func find(la, lb []int, k1, k2 int) int {
	// stderr("trying", k1, k2)
	i1 := sort.SearchInts(la, k1)
	i2 := sort.SearchInts(lb, k2)
	if i1 == len(la) || i2 == len(lb) {
		return 0
	}
	// stderr("found", i1, i2)
	return (len(la) - i1) * (len(lb) - i2)
}

func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	// inf, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(inf, 1000010)

	n, m, k := NextInt(), NextInt(), NextInt()

	a := make([]int, n)
	la := make([]int, n)
	b := make([]int, m)
	lb := make([]int, m)
	for i := 0; i < n; i++ {
		a[i] = NextInt()
	}

	for i := 0; i < m; i++ {
		b[i] = NextInt()
	}

	for i, l := n-1, 0; i >= 0; i-- {
		if a[i] == 1 {
			l++
		} else {
			l = 0
		}
		la[i] = l
	}

	for i, l := m-1, 0; i >= 0; i-- {
		if b[i] == 1 {
			l++
		} else {
			l = 0
		}
		lb[i] = l
	}

	sort.Ints(la)
	sort.Ints(lb)

	// stderr("inputs", la, "\n", lb)

	res := 0
	for k1 := 1; k1*k1 <= k; k1++ {
		if k%k1 == 0 {
			res += find(la, lb, k1, k/k1)
			if k1 != k/k1 {
				res += find(la, lb, k/k1, k1)
			}
		}
	}
	fmt.Fprintln(out, res)

}

package main

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

type vc struct {
	v, c int
}

func getDivs(k int) []int {
	a := make([]int, 0)
	for i := 1; i*i <= k; i++ {
		if k%i == 0 {
			a = append(a, i)
		}
	}

	return a
}

func getCount(vcs []vc, div int) int {
	n := len(vcs)

	if div > vcs[n-1].v {
		return 0
	}

	s := 0
	e := n - 1

	for s < e {
		m := (s + e) / 2

		if vcs[m].v == div {
			return vcs[m].c
		} else if vcs[m].v < div {
			s = m + 1
		} else {
			e = m
		}
	}

	cnt := 0

	for i := e; i < n; i++ {
		cnt += vcs[e].c * (vcs[e].v - div + 1)
	}

	return cnt
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

	in := func() int {
		sc.Scan()
		i, _ := strconv.Atoi(sc.Text())
		return i
	}

	n, m, k := in(), in(), in()

	a := make([]int, n)
	b := make([]int, m)

	for i := range a {
		a[i] = in()
	}

	for i := range b {
		b[i] = in()
	}

	mvc := make(map[int]int)

	cnt := 0

	for i := range a {
		if a[i] == 0 {
			if cnt != 0 {
				mvc[cnt]++
				cnt = 0
			}
		} else {
			cnt++
		}
	}

	if a[n-1] == 1 {
		mvc[cnt]++
	}

	avc := make([]vc, len(mvc))
	var i int = 0
	for v, c := range mvc {
		avc[i].v = v
		avc[i].c = c
		i++
	}

	mvc = make(map[int]int)

	cnt = 0

	for i := range b {
		if b[i] == 0 {
			if cnt != 0 {
				mvc[cnt]++
				cnt = 0
			}
		} else {
			cnt++
		}
	}

	if b[m-1] == 1 {
		mvc[cnt]++
	}

	bvc := make([]vc, len(mvc))
	i = 0

	for v, c := range mvc {
		bvc[i].v = v
		bvc[i].c = c
		i++
	}

	sort.Slice(avc, func(i, j int) bool {
		return avc[i].v < avc[j].v
	})

	sort.Slice(bvc, func(i, j int) bool {
		return bvc[i].v < bvc[j].v
	})

	//fmt.Println(avc)
	//fmt.Println(bvc)

	divs := getDivs(k)

	cnt = 0

	for _, div := range divs {
		div2 := k / div
		cnt += getCount(avc, div) * getCount(bvc, div2)

		if div != div2 {
			cnt += getCount(bvc, div) * getCount(avc, div2)
		}
	}

	fmt.Println(cnt)

}

package main

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

type vc struct {
	v, c int
}

func getDivs(k int) []int {
	a := make([]int, 0)
	for i := 1; i*i <= k; i++ {
		if k%i == 0 {
			a = append(a, i)
		}
	}

	return a
}

func getCount(vcs []vc, div int) int {
	n := len(vcs)
	//fmt.Println("#######", vcs, div)

	if div > vcs[n-1].v {
		//fmt.Println(vcs[n-1].v)
		return 0
	}

	s := 0
	e := n - 1

	for s < e {
		m := (s + e) / 2

		if vcs[m].v < div {
			s = m + 1
		} else {
			e = m
		}
	}

	cnt := 0

	for i := e; i < n; i++ {
		cnt += vcs[i].c * (vcs[i].v - div + 1)
	}

	//fmt.Println("#######->->", vcs[e], div, cnt)

	return cnt
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

	in := func() int {
		sc.Scan()
		i, _ := strconv.Atoi(sc.Text())
		return i
	}

	n, m, k := in(), in(), in()

	a := make([]int, n)
	b := make([]int, m)

	for i := range a {
		a[i] = in()
	}

	for i := range b {
		b[i] = in()
	}

	mvc := make(map[int]int)

	cnt := 0

	for i := range a {
		if a[i] == 0 {
			if cnt != 0 {
				mvc[cnt]++
				cnt = 0
			}
		} else {
			cnt++
		}
	}

	if a[n-1] == 1 {
		mvc[cnt]++
	}

	avc := make([]vc, len(mvc))
	var i int = 0
	for v, c := range mvc {
		avc[i].v = v
		avc[i].c = c
		i++
	}

	mvc = make(map[int]int)

	cnt = 0

	for i := range b {
		if b[i] == 0 {
			if cnt != 0 {
				mvc[cnt]++
				cnt = 0
			}
		} else {
			cnt++
		}
	}

	if b[m-1] == 1 {
		mvc[cnt]++
	}

	bvc := make([]vc, len(mvc))
	i = 0

	for v, c := range mvc {
		bvc[i].v = v
		bvc[i].c = c
		i++
	}

	sort.Slice(avc, func(i, j int) bool {
		return avc[i].v < avc[j].v
	})

	sort.Slice(bvc, func(i, j int) bool {
		return bvc[i].v < bvc[j].v
	})

	// fmt.Println(avc)
	// fmt.Println(bvc)

	divs := getDivs(k)

	// fmt.Println(divs)

	cnt = 0

	for _, div := range divs {
		div2 := k / div
		cnt += getCount(avc, div) * getCount(bvc, div2)

		if div != div2 {
			cnt += getCount(bvc, div) * getCount(avc, div2)
		}
	}

	fmt.Println(cnt)

}

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

package main

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

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

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

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

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

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

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

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

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

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

var (
	n, m, k int
	A, B    []int
	R, C    []int

	cr, cc []int
)

func main() {
	n, m, k = ReadInt3()
	A = ReadIntSlice(n)
	B = ReadIntSlice(m)

	comp, cnts := RunLengthEncoding(A)
	for i := 0; i < len(comp); i++ {
		if comp[i] == 1 {
			R = append(R, cnts[i])
		}
	}
	comp, cnts = RunLengthEncoding(B)
	for i := 0; i < len(comp); i++ {
		if comp[i] == 1 {
			C = append(C, cnts[i])
		}
	}
	PrintfDebug("R: %v\n", R)
	PrintfDebug("C: %v\n", C)

	cr, cc = make([]int, 50000), make([]int, 50000)
	for i := 0; i < len(R); i++ {
		for j := 1; j <= R[i]; j++ {
			cr[j] += R[i] - j + 1
		}
	}
	for i := 0; i < len(C); i++ {
		for j := 1; j <= C[i]; j++ {
			cc[j] += C[i] - j + 1
		}
	}

	ans := 0
	for i := 1; i <= 40000; i++ {
		if k%i == 0 && k/i <= 40000 {
			ans += cr[i] * cc[k/i]
		}
	}
	fmt.Println(ans)
}

// RunLengthEncoding returns encoded slice of an input.
func RunLengthEncoding(S []int) ([]int, []int) {
	runes := []int{}
	lengths := []int{}

	l := 0
	for i := 0; i < len(S); i++ {
		// 1文字目の場合保持
		if i == 0 {
			l = 1
			continue
		}

		if S[i-1] == S[i] {
			// 直前の文字と一致していればインクリメント
			l++
		} else {
			// 不一致のタイミングで追加し、長さをリセットする
			runes = append(runes, S[i-1])
			lengths = append(lengths, l)
			l = 1
		}
	}
	runes = append(runes, S[len(S)-1])
	lengths = append(lengths, l)

	return runes, lengths
}

// RunLengthDecoding decodes RLE results.
func RunLengthDecoding(S []int, L []int) []int {
	if len(S) != len(L) {
		panic("S, L are not RunLengthEncoding results")
	}

	res := []int{}

	for i := 0; i < len(S); i++ {
		for j := 0; j < L[i]; j++ {
			res = append(res, S[i])
		}
	}

	return res
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

package main

import "fmt"
import "os"
import "bufio"
import "strings"
import "strconv"

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    capacity := 5000 * 1024
    scanner.Buffer(make([]byte, capacity), capacity)

    scanner.Scan()
    line := scanner.Text()
    parts := strings.Split(line, " ")
    n, _ := strconv.Atoi(parts[0])
    m, _ := strconv.Atoi(parts[1])
    k, _ := strconv.Atoi(parts[2])

    scanner.Scan()
    line = scanner.Text()
    parts = strings.Split(line, " ")
    a := make([]int, n)
    for j := 0; j < n; j++ {
        a[j], _ = strconv.Atoi(parts[j])
    }

    scanner.Scan()
    line = scanner.Text()
    parts = strings.Split(line, " ")
    b := make([]int, m)
    for j := 0; j < m; j++ {
        b[j], _ = strconv.Atoi(parts[j])
    }

    //~ fmt.Println(k, a, b)
    fs := factorize(n, m, k)
    //~ fmt.Println(fs)

    count := 0
    for _, f := range fs {
        count_f := count_subsequences(a, f.rows) *
            count_subsequences(b, f.cols)
        //~ fmt.Println(f.rows, f.cols, count_f)
        count += count_f
    }
    fmt.Println(count)
}

type factors struct {
    rows, cols int
}

func factorize(n, m, k int) []factors {
    fs := make([]factors, 0)
    for rows := 1; rows <= n; rows++ {
        if k % rows == 0 && k / rows <= m {
            fs = append(fs, factors {rows, k / rows})
        }
    }
    return fs
}

func count_subsequences(a []int, x int) int {
    count := 0
    start := -1
    for i := 0; i < len(a); i++ {
        if a[i] == 0 {
            if start != -1 {
                seq_len := i - start
                seq_count := seq_len - (x - 1)
                if seq_count > 0 {
                    count += seq_count
                }
                start = -1
            }
        } else {
            if start == -1 {
                start = i
            }
        }
    }

    if start != -1 {
        seq_len := len(a) - start
        seq_count := seq_len - (x - 1)
        if seq_count > 0 {
            count += seq_count
        }
        start = -1
    }

    return count
}

package main

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

func getInts() []int64 {
	//assumes POSITIVE INTEGERS. Check v for '-' if you have negative.
	var buf []byte
	buf, _ = ioutil.ReadAll(os.Stdin)
	var ints []int64
	num := int64(0)
	found := false
	for _, v := range buf {
		if '0' <= v && v <= '9' {
			num = 10*num + int64(v-'0') //could use bitshifting here.
			found = true
		} else if found {
			ints = append(ints, num)
			found = false
			num = 0
		}
	}
	if found {
		ints = append(ints, num)
		found = false
		num = 0
	}
	return ints
}

func stat(aa []int64) []int {
	var ans []int
	ones := 0
	for _, x := range aa {
		if x == 1 {
			ones++
		} else {
			if ones != 0 {
				ans = append(ans, ones)
			}
			ones = 0
		}
	}
	if ones != 0 {
		ans = append(ans, ones)
	}

	return ans
}

func main() {
	ii := getInts()

	n, m, k := int(ii[0]), int(ii[1]), int(ii[2])
	ii = ii[3:]

	aa := ii[:n]
	ii = ii[n:]

	bb := ii[:m]
	ii = ii[m:]

	astat := stat(aa)
	bstat := stat(bb)

	solve := func(alen, blen int) (res int) {
		if alen*blen < k {
			return 0
		}
		for al := 1; al <= alen; al++ {
			bl := k / al
			if bl > blen {
				continue
			}
			if bl * al != k {
				continue
			}
			res += (alen - al + 1) * (blen - bl + 1)
		}
		return res
	}

	type rect struct {
		alen, blen int
	}

	cache := make(map[rect]int)

	ans := 0

	for _, alen := range astat {
		for _, blen := range bstat {
			c, has := cache[rect{alen: alen, blen: blen}]
			if has {
				ans += c
				continue
			}
			c = solve(alen, blen)
			cache[rect{alen: alen, blen: blen}] = c
			ans += c
		}
	}

	fmt.Println(ans)
}

package main

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

// Get all prime factors of a given number n
func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

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

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func allFactors(k int, f func(x, y int)) {
	factors := PrimeFactors(k)

	fmap := make(map[int]int)
	for _, f := range factors {
		fmap[f]++
	}

	values := make([]int, 0, len(fmap))
	counts := make([]int, 0, len(fmap))
	for f, c := range fmap {
		values = append(values, f)
		counts = append(counts, c)
	}

	var ff func(x, y int, values, counts []int)
	ff = func(x, y int, values, counts []int) {
		if len(counts) == 0 {
			return
		}
		if len(counts) > 1 {
			ff(x, y, values[1:], counts[1:])
		}
		for i := 0; i < counts[0]; i++ {
			x *= values[0]
			y /= values[0]
			f(x, y)
			if len(counts) > 1 {
				ff(x, y, values[1:], counts[1:])
			}
		}
	}
	f(1, k)
	ff(1, k, values, counts)
}

func getInts() []int64 {
	//assumes POSITIVE INTEGERS. Check v for '-' if you have negative.
	var buf []byte
	buf, _ = ioutil.ReadAll(os.Stdin)
	var ints []int64
	num := int64(0)
	found := false
	for _, v := range buf {
		if '0' <= v && v <= '9' {
			num = 10*num + int64(v-'0') //could use bitshifting here.
			found = true
		} else if found {
			ints = append(ints, num)
			found = false
			num = 0
		}
	}
	if found {
		ints = append(ints, num)
		found = false
		num = 0
	}
	return ints
}

func stat(aa []int64) []int {
	ans := make([]int, len(aa)+1)
	ones := 0
	for _, x := range aa {
		if x == 1 {
			ones++
			for i := 1; i <= ones; i++ {
				ans[i]++
			}
		} else {
			ones = 0
		}
	}
	return ans
}

func main() {
	/*
	allFactors(128*3*7*7, func(x, y int) {
		fmt.Println(x, y)
	})
	return
	*/

	ii := getInts()

	n, m, k := ii[0], ii[1], ii[2]
	ii = ii[3:]

	aa := ii[:n]
	ii = ii[n:]

	bb := ii[:m]
	ii = ii[m:]

	astat := stat(aa)
	bstat := stat(bb)

	ans := 0

	f := func(alen, blen int) {
		if alen > len(aa) {
			return
		}
		if blen > len(bb) {
			return
		}
		ans += astat[alen] * bstat[blen]
	}

	allFactors(int(k), f)

	fmt.Println(ans)
}

package main

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

// Get all prime factors of a given number n
func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

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

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func getInts() []int64 {
	//assumes POSITIVE INTEGERS. Check v for '-' if you have negative.
	var buf []byte
	buf, _ = ioutil.ReadAll(os.Stdin)
	var ints []int64
	num := int64(0)
	found := false
	for _, v := range buf {
		if '0' <= v && v <= '9' {
			num = 10*num + int64(v-'0') //could use bitshifting here.
			found = true
		} else if found {
			ints = append(ints, num)
			found = false
			num = 0
		}
	}
	if found {
		ints = append(ints, num)
		found = false
		num = 0
	}
	return ints
}

func stat(aa []int64) []int {
	ans := make([]int, len(aa)+1)
	ones := 0
	for _, x := range aa {
		if x == 1 {
			ones++
			for i := 1; i <= ones; i++ {
				ans[i]++
			}
		} else {
			ones = 0
		}
	}
	return ans
}

func main() {
	ii := getInts()

	n, m, k := ii[0], ii[1], ii[2]
	ii = ii[3:]

	aa := ii[:n]
	ii = ii[n:]

	bb := ii[:m]
	ii = ii[m:]

	astat := stat(aa)
	bstat := stat(bb)

	factors := PrimeFactors(int(k))

	fmap := make(map[int]int)
	for _, f := range factors {
		fmap[f]++
	}

	ans := 0

	used := make(map[int]int)
	visited := make(map[int]bool)
	width := 1

	var ff func()
	ff = func() {
		if width > int(m) {
			return
		}
		height := int(k) / width
		//fmt.Println(used, width, height)

		if height <= int(n) {
			ans += astat[height] * bstat[width]
		}

		for f, c := range fmap {

			if visited[f] {
				continue
			}
			visited[f] = true
			cc := 0
			for used[f] < c {
				used[f]++
				width *= f

				cc++

				ff()

			}

			for h := 0; h < cc; h++ {
				used[f]--
				width /= f
			}

			visited[f] = false
		}
	}
	ff()

	fmt.Println(ans)

}

package main

import (
    "fmt"
    "sort"
)

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

func calculate(a1, a2, s int) int {
  result := 0
  for s1 := 1; s1 <= min(s, a1); s1++ {
    if s % s1 != 0 { continue }

    s2 := s/s1

    if (s2 > a2) {continue}

    // fmt.Println(s1, s2, a1, a2)

    result += (a1 - s1 + 1)*(a2 - s2 +1)

  }

  return result
}

func main() {
  var n1, n2, s int64
  fmt.Scanf("%d %d %d\n", &n1, &n2, &s)
  a1 := make([]bool, n1)
  a2 := make([]bool, n2)
  for i := range a1 {
      var temp int
      fmt.Scanf("%d", &temp)
      a1[i] = (temp == 1)
  }
  fmt.Scanf("%n")

  for i := range a2 {
      var temp int
      fmt.Scanf("%d", &temp)
      a2[i] = (temp == 1)
  }

//   fmt.Println(a1, a2)

  m1 := make(map[int]int)
  m2 := make(map[int]int)
  is_interval := false
  start := -1
  for i, item := range a1 {
    if is_interval == true && item == false {
      m1[i-start]+=1
      start = -1
      is_interval = false
    } else if item == true && is_interval == false {
      start = i
      is_interval = true
    }
  }

  if is_interval == true {
    m1[len(a1) - start]+=1
  }

  is_interval = false
  start = -1

  for i, item := range a2 {
    if is_interval == true && item == false {
      m2[i-start]+=1
      start = -1
      is_interval = false
    } else if item == true && is_interval == false {
      start = i
      is_interval = true
    }
  }

  if is_interval == true {
    m2[len(a2) - start]+=1
  }

  keys_m1 := make([]int, 0, len(m1))
  for k := range m1 {
	keys_m1 = append(keys_m1, k)
  }
  sort.Ints(keys_m1)

  keys_m2 := make([]int, 0, len(m2))
  for k := range m2 {
	keys_m2 = append(keys_m2, k)
  }
  sort.Ints(keys_m2)

  if len(m1) == 0 || len(m2) == 0 {
    fmt.Println(0)
    return
  }

  if s == 1 {
      var sum1, sum2 int
      for k1, v1 := range m1 {
          sum1+=k1*v1
      }
      for k2, v2 := range m2 {
          sum2+=k2*v2
      }
      fmt.Println(sum1*sum2)
      return
  }

  result := 0
  for _, k1 := range keys_m1 {
    ind2 := sort.Search(len(keys_m2), func(i int) bool { return keys_m2[i]*k1 >= int(s) })

    if (ind2 == len(keys_m2)) {
      break
    }

    for i_k2 := ind2; i_k2 < len(keys_m2); i_k2++ {
      k2 := keys_m2[i_k2]
      result+=calculate(k1, k2, int(s))*m1[k1]*m2[k2]
    }

  }

  fmt.Println(result)

}

package main

import (
    "fmt"
    "sort"
)

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

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

func calculate(a1, a2, s int64) int64 {
  var result int64
  for s1 := int64(1); s1 <= min(s, a1); s1++ {
    if s % s1 != 0 { continue }

    s2 := s/s1

    if (s2 > a2) {continue}

    // fmt.Println(s1, s2, a1, a2)

    result += (a1 - s1 + 1)*(a2 - s2 +1)

  }

  return result
}

func main() {
  var n1, n2, s int64
  fmt.Scanf("%d %d %d\n", &n1, &n2, &s)

  a1 := make([]bool, n1)
  a2 := make([]bool, n2)
  for i := range a1 {
      var temp int64
      fmt.Scanf("%d", &temp)
      a1[i] = (temp == 1)
  }
  fmt.Scanf("%n")

  for i := range a2 {
      var temp int64
      fmt.Scanf("%d", &temp)
      a2[i] = (temp == 1)
  }

//   fmt.Println(a1, a2)

  m1 := make(map[int64]int64)
  m2 := make(map[int64]int64)
  is_interval := false
  start := int64(-1)
  for i, item := range a1 {
    if is_interval == true && item == false {
      m1[int64(i)-start]+=1
      start = -1
      is_interval = false
    } else if item == true && is_interval == false {
      start = int64(i)
      is_interval = true
    }
  }

  if is_interval == true {
    m1[int64(len(a1)) - start]+=1
  }

  is_interval = false
  start = -1

  for i, item := range a2 {
    if is_interval == true && item == false {
      m2[int64(i)-start]+=1
      start = -1
      is_interval = false
    } else if item == true && is_interval == false {
      start = int64(i)
      is_interval = true
    }
  }

  if is_interval == true {
    m2[int64(len(a2)) - start]+=1
  }

  keys_m1 := make([]int64, 0,int64(len(m1)))
  for k := range m1 {
	keys_m1 = append(keys_m1, int64(k))
  }
  sort.Slice(keys_m1, func(i, j int) bool { return keys_m1[i] < keys_m1[j] })

  keys_m2 := make([]int64, 0, int64(len(m2)))
  for k := range m2 {
	keys_m2 = append(keys_m2, k)
  }
  sort.Slice(keys_m2, func(i, j int) bool { return keys_m2[i] < keys_m2[j] })

  if len(m1) == 0 || len(m2) == 0 {
    fmt.Println(0)
    return
  }

  if s == 1 {
      var sum1, sum2 int64
      for k1, v1 := range m1 {
          sum1+=k1*v1
      }
      for k2, v2 := range m2 {
          sum2+=k2*v2
      }
      fmt.Println(sum1*sum2)
      return
  }

  result := int64(0)
  for _, k1 := range keys_m1 {
    ind2 := sort.Search(len(keys_m2), func(i int) bool { return keys_m2[i]*k1 >= int64(s) })

    if (ind2 == len(keys_m2)) {
      break
    }

    for i_k2 := ind2; i_k2 < len(keys_m2); i_k2++ {
      k2 := keys_m2[i_k2]
      result+=calculate(k1, k2, int64(s))*m1[k1]*m2[k2]
    }

  }

  fmt.Println(result)

}

package main

import (
    "fmt"
    "sort"
)

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

func calculate(a1, a2, s int) int {
  result := 0
  for s1 := 1; s1 <= min(s/2, a1); s1++ {
    if s % s1 != 0 { continue }

    s2 := s/s1

    if (s2 > a2) {continue}

    // fmt.Println(s1, s2, a1, a2)

    result += (a1 - s1 + 1)*(a2 - s2 +1)

  }

  return result
}

func main() {
  var n1, n2, s int64
  fmt.Scanf("%d %d %d\n", &n1, &n2, &s)
  a1 := make([]bool, n1)
  a2 := make([]bool, n2)
  for i := range a1 {
      var temp int
      fmt.Scanf("%d", &temp)
      a1[i] = (temp == 1)
  }
  fmt.Scanf("%n")

  for i := range a2 {
      var temp int
      fmt.Scanf("%d", &temp)
      a2[i] = (temp == 1)
  }

//   fmt.Println(a1, a2)

  m1 := make(map[int]int)
  m2 := make(map[int]int)
  is_interval := false
  start := -1
  for i, item := range a1 {
    if is_interval == true && item == false {
      m1[i-start]+=1
      start = -1
      is_interval = false
    } else if item == true && is_interval == false {
      start = i
      is_interval = true
    }
  }

  if is_interval == true {
    m1[len(a1) - start]+=1
  }

  is_interval = false
  start = -1

  for i, item := range a2 {
    if is_interval == true && item == false {
      m2[i-start]+=1
      start = -1
      is_interval = false
    } else if item == true && is_interval == false {
      start = i
      is_interval = true
    }
  }

  if is_interval == true {
    m2[len(a2) - start]+=1
  }

  keys_m1 := make([]int, 0, len(m1))
  for k := range m1 {
	keys_m1 = append(keys_m1, k)
  }
  sort.Ints(keys_m1)

  keys_m2 := make([]int, 0, len(m2))
  for k := range m2 {
	keys_m2 = append(keys_m2, k)
  }
  sort.Ints(keys_m2)

  if len(m1) == 0 || len(m2) == 0 {
    fmt.Println(0)
    return
  }

  if s == 1 {
      var sum1, sum2 int
      for k1, v1 := range m1 {
          sum1+=k1*v1
      }
      for k2, v2 := range m2 {
          sum2+=k2*v2
      }
      fmt.Println(sum1*sum2)
      return
  }

  result := 0
  for _, k1 := range keys_m1 {
    ind2 := sort.Search(len(keys_m2), func(i int) bool { return keys_m2[i]*k1 >= int(s) })

    if (ind2 == len(keys_m2)) {
      break
    }

    for i_k2 := ind2; i_k2 < len(keys_m2); i_k2++ {
      k2 := keys_m2[i_k2]
      result+=calculate(k1, k2, int(s))*m1[k1]*m2[k2]
    }

  }

  fmt.Println(result)

}

package main

import (
    "fmt"
    "sort"
)

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

func calculate(a1, a2, s int) int {
  result := 0
  for s1 := 1; s1 <= min(s/2, a1); s1++ {
    if s % s1 != 0 { continue }

    s2 := s/s1

    if (s2 > a2) {continue}

    // fmt.Println(s1, s2, a1, a2)

    result += (a1 - s1 + 1)*(a2 - s2 +1)

  }

  return result
}

func main() {
  var n1, n2, s int64
  fmt.Scanf("%d %d %d\n", &n1, &n2, &s)
  a1 := make([]bool, n1)
  a2 := make([]bool, n2)
  for i := range a1 {
      var temp int
      fmt.Scanf("%d", &temp)
      a1[i] = (temp == 1)
  }
  for i := range a2 {
      var temp int
      fmt.Scanf("%d", &temp)
      a2[i] = (temp == 1)
  }

  m1 := make(map[int]int)
  m2 := make(map[int]int)
  is_interval := false
  start := -1
  for i, item := range a1 {
    if is_interval == true && item == false {
      m1[i-start]+=1
      start = -1
      is_interval = false
    } else if item == true && is_interval == false {
      start = i
      is_interval = true
    }
  }

  if is_interval == true {
    m1[len(a1) - start]+=1
  }

  is_interval = false
  start = -1

  for i, item := range a2 {
    if is_interval == true && item == false {
      m2[i-start]+=1
      start = -1
      is_interval = false
    } else if item == true && is_interval == false {
      start = i
      is_interval = true
    }
  }

  if is_interval == true {
    m2[len(a2) - start]+=1
  }

  keys_m1 := make([]int, 0, len(m1))
  for k := range m1 {
	keys_m1 = append(keys_m1, k)
  }
  sort.Ints(keys_m1)

  keys_m2 := make([]int, 0, len(m2))
  for k := range m2 {
	keys_m2 = append(keys_m2, k)
  }
  sort.Ints(keys_m2)

  if len(m1) == 0 || len(m2) == 0 {
    fmt.Println(0)
    return
  }

  if s == 1 {
      var sum1, sum2 int
      for k1, v1 := range m1 {
          sum1+=k1*v1
      }
      for k2, v2 := range m2 {
          sum2+=k2*v2
      }
      fmt.Println(sum1*sum2)
      return
  }

  result := 0
  for _, k1 := range keys_m1 {
    ind2 := sort.Search(len(keys_m2), func(i int) bool { return keys_m2[i]*k1 >= int(s) })

    if (ind2 == len(keys_m2)) {
      break
    }

    for i_k2 := ind2; i_k2 < len(keys_m2); i_k2++ {
      k2 := keys_m2[i_k2]
      result+=calculate(k1, k2, int(s))*m1[k1]*m2[k2]
    }

  }

  fmt.Println(result)

}

package main

import (
    "fmt"
    "sort"
)

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

func calculate(a1, a2, s int64) int64 {
  var result int64
  for s1 := int64(1); s1 <= min(s, a1); s1++ {
    if s % s1 != 0 { continue }

    s2 := s/s1

    if (s2 > a2) {continue}

    // fmt.Println(s1, s2, a1, a2)

    result += (a1 - s1 + 1)*(a2 - s2 +1)

  }

  return result
}

func main() {
  var n1, n2, s int64
  fmt.Scanf("%d %d %d\n", &n1, &n2, &s)
  a1 := make([]bool, n1)
  a2 := make([]bool, n2)
  for i := range a1 {
      var temp int64
      fmt.Scanf("%d", &temp)
      a1[i] = (temp == 1)
  }
  fmt.Scanf("%n")

  for i := range a2 {
      var temp int64
      fmt.Scanf("%d", &temp)
      a2[i] = (temp == 1)
  }

//   fmt.Println(a1, a2)

  m1 := make(map[int64]int64)
  m2 := make(map[int64]int64)
  is_interval := false
  start := int64(-1)
  for i, item := range a1 {
    if is_interval == true && item == false {
      m1[int64(i)-start]+=1
      start = -1
      is_interval = false
    } else if item == true && is_interval == false {
      start = int64(i)
      is_interval = true
    }
  }

  if is_interval == true {
    m1[int64(len(a1)) - start]+=1
  }

  is_interval = false
  start = -1

  for i, item := range a2 {
    if is_interval == true && item == false {
      m2[int64(i)-start]+=1
      start = -1
      is_interval = false
    } else if item == true && is_interval == false {
      start = int64(i)
      is_interval = true
    }
  }

  if is_interval == true {
    m2[int64(len(a2)) - start]+=1
  }

  keys_m1 := make([]int64, 0,int64(len(m1)))
  for k := range m1 {
	keys_m1 = append(keys_m1, int64(k))
  }
  sort.Slice(keys_m1, func(i, j int) bool { return keys_m1[i] < keys_m1[j] })

  keys_m2 := make([]int64, 0, int64(len(m2)))
  for k := range m2 {
	keys_m2 = append(keys_m2, k)
  }
  sort.Slice(keys_m2, func(i, j int) bool { return keys_m2[i] < keys_m2[j] })

  if len(m1) == 0 || len(m2) == 0 {
    fmt.Println(0)
    return
  }

  if s == 1 {
      var sum1, sum2 int64
      for k1, v1 := range m1 {
          sum1+=k1*v1
      }
      for k2, v2 := range m2 {
          sum2+=k2*v2
      }
      fmt.Println(sum1*sum2)
      return
  }

  result := int64(0)
  for _, k1 := range keys_m1 {
    ind2 := sort.Search(len(keys_m2), func(i int) bool { return keys_m2[i]*k1 >= int64(s) })

    if (ind2 == len(keys_m2)) {
      break
    }

    for i_k2 := ind2; i_k2 < len(keys_m2); i_k2++ {
      k2 := keys_m2[i_k2]
      result+=calculate(k1, k2, int64(s))*m1[k1]*m2[k2]
    }

  }

  fmt.Println(result)

}

package main

import (
    "fmt"
    "sort"
)

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

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

func calculate(a1, a2, s int64) int64 {
  var result int64
  for s1 := int64(1); s1 <= min(s, a1); s1++ {
    if s % s1 != 0 { continue }

    s2 := s/s1

    if (s2 > a2) {continue}

    // fmt.Println(s1, s2, a1, a2)

    result += (a1 - s1 + 1)*(a2 - s2 +1)

  }

  return result
}

func main() {
  var n1, n2, s int64
  fmt.Scanf("%d %d %d\n", &n1, &n2, &s)

  if n1 == 1 || n2 == 1 {
      a1 := make([]bool, max(n1, n2))
      for i := range a1 {
          var temp int64
          fmt.Scanf("%d", &temp)
          a1[i] = (temp == 1)
      }

      m1 := make(map[int64]int64)

      is_interval := false
      start := int64(-1)
      for i, item := range a1 {
        if is_interval == true && item == false {
          m1[int64(i)-start]+=1
          start = -1
          is_interval = false
        } else if item == true && is_interval == false {
          start = int64(i)
          is_interval = true
        }
      }

      if is_interval == true {
        m1[int64(len(a1)) - start]+=1
      }

      result := int64(0)

      for k, v := range(m1) {
        if k >= s {
          result += (s - k + 1)*v
        }
      }

      fmt.Println(result)

      return

  }

  a1 := make([]bool, n1)
  a2 := make([]bool, n2)
  for i := range a1 {
      var temp int64
      fmt.Scanf("%d", &temp)
      a1[i] = (temp == 1)
  }
  fmt.Scanf("%n")

  for i := range a2 {
      var temp int64
      fmt.Scanf("%d", &temp)
      a2[i] = (temp == 1)
  }

//   fmt.Println(a1, a2)

  m1 := make(map[int64]int64)
  m2 := make(map[int64]int64)
  is_interval := false
  start := int64(-1)
  for i, item := range a1 {
    if is_interval == true && item == false {
      m1[int64(i)-start]+=1
      start = -1
      is_interval = false
    } else if item == true && is_interval == false {
      start = int64(i)
      is_interval = true
    }
  }

  if is_interval == true {
    m1[int64(len(a1)) - start]+=1
  }

  is_interval = false
  start = -1

  for i, item := range a2 {
    if is_interval == true && item == false {
      m2[int64(i)-start]+=1
      start = -1
      is_interval = false
    } else if item == true && is_interval == false {
      start = int64(i)
      is_interval = true
    }
  }

  if is_interval == true {
    m2[int64(len(a2)) - start]+=1
  }

  keys_m1 := make([]int64, 0,int64(len(m1)))
  for k := range m1 {
	keys_m1 = append(keys_m1, int64(k))
  }
  sort.Slice(keys_m1, func(i, j int) bool { return keys_m1[i] < keys_m1[j] })

  keys_m2 := make([]int64, 0, int64(len(m2)))
  for k := range m2 {
	keys_m2 = append(keys_m2, k)
  }
  sort.Slice(keys_m2, func(i, j int) bool { return keys_m2[i] < keys_m2[j] })

  if len(m1) == 0 || len(m2) == 0 {
    fmt.Println(0)
    return
  }

  if s == 1 {
      var sum1, sum2 int64
      for k1, v1 := range m1 {
          sum1+=k1*v1
      }
      for k2, v2 := range m2 {
          sum2+=k2*v2
      }
      fmt.Println(sum1*sum2)
      return
  }

  result := int64(0)
  for _, k1 := range keys_m1 {
    ind2 := sort.Search(len(keys_m2), func(i int) bool { return keys_m2[i]*k1 >= int64(s) })

    if (ind2 == len(keys_m2)) {
      break
    }

    for i_k2 := ind2; i_k2 < len(keys_m2); i_k2++ {
      k2 := keys_m2[i_k2]
      result+=calculate(k1, k2, int64(s))*m1[k1]*m2[k2]
    }

  }

  fmt.Println(result)

}


package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	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 min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

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

func fun() {
	var n int64
	scanf("%d\n", &n)
	arr := make([]int64, n)
	for i := range arr {
		if i == int(n-1) {
			scanf("%d\n", &arr[i])
		} else {
			scanf("%d ", &arr[i])
		}
	}
	sort.Slice(arr, func(i, j int) bool {
		return arr[i] > arr[j]
	})
	mn := arr[0]
	ans := int64(0)
	for i, v := range arr {
		mn = min(mn, v)
		ans = max(ans, min(mn, int64(i+1)))
	}
	printf("%d\n", ans)
}

func main() {
	// Flush stdout
	defer writer.Flush()

	var n int
	scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		fun()
	}
}

package main

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

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

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

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var k, n int
	scanf("%d\n", &k)
	for ; k > 0; k-- {
		scanf("%d\n", &n)
		var a [1001]int
		for i := 0; i < n; i++ {
			var ai int
			scanf("%d", &ai)
			a[ai]++
			if i == n-1{
				scanf("\n")
			}
		}
		count := 0
		for i := n; i > 0; i-- {
			count += a[i]
			if count >= i {
				if k != 1{
					printf("%d\n", i)
				} else {
					printf("%d", i)
				}
				break
			}
		}
	}
}

package main

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

/*********** 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+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// 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 int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

/*********** DP sub-functions ***********/

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

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

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

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

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

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

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

	return string(res)
}

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

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

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

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

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

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

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var k int
var n int
var A []int

func main() {
	k = ReadInt()

	for tc := 0; tc < k; tc++ {
		n = ReadInt()
		A = ReadIntSlice(n)
		solve()
	}
}

func solve() {
	cnt := [1005]int{}
	for i := 0; i < n; i++ {
		cnt[A[i]]++
	}

	sums := make([]int, 1005)
	for i := 1000; i >= 0; i-- {
		sums[i] = sums[i+1] + cnt[i]
	}
	// fmt.Println(sums[:6])

	for i := 1000; i >= 0; i-- {
		if sums[i] >= i {
			fmt.Println(i)
			return
		}
	}
}

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

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

package main

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

const (
	MAX_INT int64 = math.MaxInt64
	MIN_INT int64 = math.MinInt64
)

func main() {

	for t := ScanInt64(); t > 0; t-- {
		n := ScanInt64()
		a := ScanInt64Slice(int(n))

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

		r := int64(0)
		for i := n - 1; i >= 0; i-- {
			if a[i] > r {
				r++
			} else {
				break
			}
		}
		fmt.Println(r)
	}
	close(out)
	outWg.Wait()
}

//4 3 1 4 5
//1 3 4 4 5

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

var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup

func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(writer *bufio.Writer) {
		defer outWg.Done()
		defer writer.Flush()

		for line := range out {
			writer.WriteString(line + "\n")
		}
	}(writer)
}

func ScanWord() string {
	in.Scan()
	return in.Text()
}

func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}

func ScanInt64() int64 {
	intStr := ScanWord()
	i, err := strconv.ParseInt(intStr, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func Max(args ...int64) int64 {
	maxVal := MIN_INT
	for _, v := range args {
		if v > maxVal {
			maxVal = v
		}
	}
	return maxVal
}

func Min(args ...int64) int64 {
	minVal := MAX_INT
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
	}
	return minVal
}

func LCM(a, b int64) int64 {
	return a / GCD(a, b) * b
}

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

func iToS(v int64) string {
	return strconv.FormatInt(v, 10)
}

package main

import (
	"fmt"
	"sort"
)

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

	iterResults := make([]int, k)
	for j := 0; j < k; j++ {
		fmt.Scanf("%d\n", &n)

		a := make([]int, n)

		for i := 0; i < n; i++ {
			fmt.Scanf("%d", &tmp)
			a[i] = tmp
		}

		iterResults[j] = handle(a)
		fmt.Scanf("\n")
	}

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

func handle(a []int) int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	width := 0
	heigth := 0

	for i := 0; i < len(a); i++ {
		heigth = a[i]
		width++
		if heigth < width {
			return width - 1
		} else if heigth == width {
			return width
		}
	}

	return 0
}

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

package main

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

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

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

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var k, n int
	scanf("%d\n", &k)
	for ; k > 0; k-- {
		scanf("%d\n", &n)
		var a [1001]int
		for i := 0; i < n; i++ {
			var ai int
			scanf("%d", &ai)
			a[ai]++
		}
		count := 0
		for i:=n;i>0;i--{
			count += a[i]
			if count>= i{
				printf("%d\n", i)
				break
			}
		}

	}
}


package main

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

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var n int
	var seg [101]bool
	fmt.Fscanf(reader, "%d\n", &n)
	var l, r int
	fmt.Fscanf(reader, "%d %d\n", &l, &r)
	for i := l; i < r; i++ {
		seg[i] = true
	}
	for i := 0; i < n-1; i++ {
		fmt.Fscanf(reader, "%d %d\n", &l, &r)
		for j := l; j < r; j++ {
			seg[j] = false
		}
	}
	ans := 0
	for i := 0; i <= 100; i++ {
		if seg[i] {
			ans++
		}
	}
	fmt.Printf("%d", ans)
}

package main

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

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

func main() {
	// defer func(start time.Time) {
	// 	fmt.Println(time.Since(start))
	// }(time.Now())

	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	segments := make([]bool, 100)
	count := 0

	l, r := nextInt(), nextInt()
	min, max := l, r

	for i:=l; i<r; i++ {
		segments[i] = true
	}

	for i:=1; i<n; i++ {
		l, r = nextInt(), nextInt()
		if l >= max || r <= min {
			continue
		}

		if l < min {
			l = min
		}

		if r > max {
			r = max
		}

		for j:=l; j<r; j++ {
			segments[j] = false
		}
	}

	for i:=min; i<max; i++ {
		if segments[i] {
			count++
		}
	}

	fmt.Println(count)
}

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

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

package main

import (
	"fmt"
)

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

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

func main() {
	var (
		n, i, j, a, b, ai, bi, ans int32
		x                          []int8
	)

	fmt.Scan(&n)
	fmt.Scan(&a)
	fmt.Scan(&b)
	x = make([]int8, b, b)

	for i = 1; i < n; i++ {
		fmt.Scan(&ai)
		fmt.Scan(&bi)
		ai = max(a, ai)
		bi = min(b, bi)
		for j = ai; j < bi; j++ {
			x[j] = 1
		}
	}

	//	fmt.Println(x[a:b])

	for i = a; i < b; i++ {
		ans += int32(1 - x[i])
	}

	fmt.Println(ans)

}

/*********************************************************************************
*     File Name           :     A.go
*     Created By          :     YIMMON, yimmon.zhuang@gmail.com
*     Creation Date       :     [2014-03-08 17:33]
*     Last Modified       :     [2014-03-08 17:39]
*     Description         :
**********************************************************************************/

package main

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

func main() {
    scanner.Split(bufio.ScanWords)

    var (
        n, l, r, s, e int
        arr           [100]bool
    )
    scanner.NextInts(&n, &s, &e)
    for i := 1; i < n; i++ {
        scanner.NextInts(&l, &r)
        for j := l; j < r; j++ {
            arr[j] = true
        }
    }
    var ans = 0
    for i := s; i < e; i++ {
        if arr[i] == false {
            ans++
        }
    }
    fmt.Println(ans)
}

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) Next() string {
    if !self.Scan() {
        panic(self.Err())
    }
    return self.Text()
}

func (self *Scanner) NextInt() int {
    x, err := strconv.Atoi(self.Next())
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) NextInts(arg ...*int) {
    for _, p := range arg {
        *p = self.NextInt()
    }
}


// A. Infinity Gauntlet
/*
You took a peek on Thanos wearing Infinity Gauntlet. In the Gauntlet there is a place for six Infinity Gems:

    the Power Gem of purple color,
    the Time Gem of green color,
    the Space Gem of blue color,
    the Soul Gem of orange color,
    the Reality Gem of red color,
    the Mind Gem of yellow color.

Using colors of Gems you saw in the Gauntlet determine the names of absent Gems.

Input
In the first line of input there is one integer 𝑛 (0≤𝑛≤6) — the number of Gems in Infinity Gauntlet.

In next 𝑛 lines there are colors of Gems you saw. Words used for colors are: purple, green, blue, orange, red, yellow. It is guaranteed that all the colors are distinct. All colors are given in lowercase English letters.

Output
In the first line output one integer 𝑚 (0≤𝑚≤6) — the number of absent Gems.

Then in 𝑚 lines print the names of absent Gems, each on its own line. Words used for names are: Power, Time, Space, Soul, Reality, Mind. Names can be printed in any order. Keep the first letter uppercase, others lowercase.

Examples
Input
4
red
purple
yellow
orange

Output
2
Space
Time

Input
0

Output
6
Time
Mind
Soul
Power
Reality
Space

Note
In the first sample Thanos already has Reality, Power, Mind and Soul Gems, so he needs two more: Time and Space.

In the second sample Thanos doesn't have any Gems, so he needs all six.
*/
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))

	fmt.Println(6 - n)

	gems := map[string]string{"purple": "Power", "green": "Time", "blue": "Space", "orange": "Soul", "red": "Reality", "yellow": "Mind"}
	i := map[string]int{}
	for ; n > 0; n-- {
		input2, _ := reader.ReadString('\n')
		v := strings.TrimSpace(input2)
		i[v]++
	}

	for k, v := range gems {
		if _, ok := i[k]; !ok {
			fmt.Println(v)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n int
	hash := map[string]bool{
		"purple": true,
		"green":  true,
		"blue":   true,
		"orange": true,
		"red":    true,
		"yellow": true,
	}
	gemName := map[string]string{
		"purple": "Power",
		"green":  "Time",
		"blue":   "Space",
		"orange": "Soul",
		"red":    "Reality",
		"yellow": "Mind",
	}

	fmt.Scanf("%d\n", &n)
	i := 0
	for i < n {
		var gem string
		fmt.Scanf("%s\n", &gem)
		hash[gem] = false
		i++
	}

	fmt.Println(6 - n)
	if n == 6 {
		return
	}
	for gem, exist := range hash {
		if exist {
			fmt.Println(gemName[gem])
		}
	}
}

package main

import (
  "fmt"
)

func main()  {
  var keys = map[string] string{
    "purple": "Power",
    "green": "Time",
    "blue": "Space",
    "orange": "Soul",
    "red": "Reality",
    "yellow": "Mind",
  }
  var num int

  fmt.Scanf("%d\n", &num)

  for i := 0;  i < num ; i++{
    var text string
    fmt.Scanf("%s\n",&text)
    delete(keys, text)
  }

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

}

package main

import (
	"fmt"
)

var gen map[string]string = map[string]string{
	"red":"Reality",
	"purple":"Power",
	"blue":"Space",
	"orange":"Soul",
	"yellow":"Mind",
	"green":"Time",
}

func main () {
	var n int

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

	for i:=0 ;i < n ;i ++ {
		var color string
		fmt.Scanf("%s\n",&color)
		delete(gen , color)

	}

	fmt.Println(len(gen))

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

package main

import "fmt"

func main() {
	var n int
	var s string
	fmt.Scan(&n)
	gem := map[string]string{
		"purple": "Power",
		"green":  "Time",
		"blue":   "Space",
		"orange": "Soul",
		"red":    "Reality",
		"yellow": "Mind",
	}
	for ; n > 0; n-- {
		fmt.Scan(&s)
		delete(gem, s)
	}
	fmt.Println(len(gem))
	for _, v := range gem {
		fmt.Println(v)
	}
}

package main

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

func main() {
	// prepare necessary params
	var n int
	var color string
	stdin := bufio.NewReader(os.Stdin)
	colors := map[string]string{
		"purple": "Power",
		"green":  "Time",
		"blue":   "Space",
		"orange": "Soul",
		"red":    "Reality",
		"yellow": "Mind",
	}
	// scan input
	fmt.Fscanf(stdin, "%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(stdin, "%s\n", &color)
		// delete existing color from map
		delete(colors, color)
	}
	// print output
	fmt.Println(len(colors))
	for _, gem := range colors {
		fmt.Println(gem)
	}
}

package main

import . "fmt"

var (
	n int
	s string
)
var gem = map[string]string{
	"purple"	: "Power",
	"green"		: "Time",
	"blue"		: "Space",
	"orange"	: "Soul",
	"red"		: "Reality",
	"yellow"	: "Mind",
}
var bol = map[string]bool{
	"purple": false,
	"green" : false,
	"blue" 	: false,
	"orange": false,
	"red"	: false,
	"yellow":false,
}

func main(){
	Scanln(&n)
	for i:=0; i<n;i++ {
		Scanln(&s)
		bol[s] = true
	}

	Println(6-n)
	for k := range bol {
		if !bol[k] {
			Println(gem[k])
		}
	}
}

package main

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

func solve() {
	n := readInt()
	obj := map[string]string{
		"purple": "Power",
		"green":  "Time",
		"blue":   "Space",
		"orange": "Soul",
		"red":    "Reality",
		"yellow": "Mind",
	}
	values := make(map[string]int, 0)
	for i := 0; i < n; i++ {
		values[obj[readString()]]++
	}
	res := make([]string, 0)
	for _, v := range obj {
		if _, ok := values[v]; ok {
		} else {
			res = append(res, v)
		}
	}
	fmt.Println(len(res))
	sort.Strings(res)
	for i := 0; i < len(res); i++ {
		fmt.Println(res[i])
	}
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

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

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

// IO

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main
import "fmt"

func main(){

	var m map[string]string
	m = make(map[string]string)

	m["purple"] = "Power"
	m["green"] = "Time"
	m["blue"] = "Space"
	m["orange"] = "Soul"
	m["red"] = "Reality"
	m["yellow"] = "Mind"

	var n int
	fmt.Scan(&n)

	i := 0

	var isExists map[string]bool
	isExists = make(map[string]bool)

	isExists["Power"] = false
	isExists["Time"] = false
	isExists["Space"] = false
	isExists["Soul"] = false
	isExists["Reality"] = false
	isExists["Mind"] = false

	for i < n {
		var s string
		fmt.Scan(&s)
		isExists[m[s]] = true
		i ++
	}

	var cnt int

	for _, v := range isExists {
		if v == false {
			cnt ++
		}
	}

	fmt.Println(cnt)

	for k, v := range isExists {
		if v == false {
			fmt.Println(k)
		}
	}

 }

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var count = 6
	n := int(readOneInt64(reader))
	m := map[string]bool{
		"purple": false,
		"green":  false,
		"blue":   false,
		"orange": false,
		"red":    false,
		"yellow": false,
	}
	for i := 0; i < n; i++ {
		s := readOneString(reader)
		m[s] = true
		count--
	}
	mm := map[string]string{
		"Power":   "purple",
		"Time":    "green",
		"Space":   "blue",
		"Soul":    "orange",
		"Reality": "red",
		"Mind":    "yellow",
	}
	fmt.Println(count)
	for k, v := range m {
		if v == false {
			for k2, v2 := range mm {
				if v2 == k {
					fmt.Println(k2)
				}
			}
		}
	}
}

func readOneInt64(r *bufio.Reader) (n int64) {
	bytes, _ := r.ReadBytes('\n')
	n, _ = strconv.ParseInt(string(bytes[:len(bytes)-2]), 10, 64)
	return
}

func readInt64Slice(r *bufio.Reader, n int) (slice []int64) {
	var bytes []byte
	slice = make([]int64, n)
	n--
	for i := 0; i < n; i++ {
		bytes, _ = r.ReadBytes(' ')
		slice[i], _ = strconv.ParseInt(string(bytes[:len(bytes)-1]), 10, 64)
	}
	slice[n] = readOneInt64(r)
	return
}

func readOneString(r *bufio.Reader) string {
	bytes, _ := r.ReadBytes('\n')
	return string(bytes[:len(bytes)-2])
}

func abs(i int) int {
	if i < 0 {
		return i * -1
	}
	return i
}

package main

import (
	"fmt"
)

var colors = map[string]string{
	"purple": "Power",
	"green":  "Time",
	"blue":   "Space",
	"orange": "Soul",
	"red":    "Reality",
	"yellow": "Mind",
}

func main() {
	var n int
	var str string
	var gems = map[string]bool{
		"Time":    true,
		"Mind":    true,
		"Soul":    true,
		"Power":   true,
		"Reality": true,
		"Space":   true,
	}
	fmt.Scan(&n)
	fmt.Println(6 - n)
	for i := 0; i < n; i++ {
		fmt.Scan(&str)
		gems[colors[str]] = false
	}
	for v, k := range gems {
		if k {
			fmt.Println(v)
		}
	}
}

package main
import (
	"fmt"
)

func in_StrArray(arr []string, key string)bool{
	for _,i := range arr{
		if key == i{
			return true
		}
	}
	return false
}

func main(){
	var n_stones int
	//fmt.Print("Number OF Stones Seen: ")
	fmt.Scanln(&n_stones)
	//fmt.Print("Colour OF Stones Seen: ")
	var stonesPresent []string

	var i_Stones = map[string]string{
		"blue": "Space",
		"red": "Reality",
		"yellow": "Mind",
		"orange": "Soul",
		"purple": "Power",
		"green": "Time",
	}

	for i := 0; i < n_stones; i++{
		var temp string
		fmt.Scanln(&temp)
		stonesPresent = append(stonesPresent, i_Stones[temp])
	}

	fmt.Println(len(i_Stones)-len(stonesPresent))
	for _,types := range i_Stones{
		if ! in_StrArray(stonesPresent, types){
			fmt.Println(types)
		}
	}
}

package main

import (
	"fmt"
)

var (
	k     int
	i     int
	s     [6]string
	flag  bool
	count int
	s1    string
	s2    string
)

func main() {
	mieba := map[string]string{

		"green":  "Time",
		"yellow": "Mind",
		"orange": "Soul",
		"purple": "Power",
		"red":    "Reality",
		"blue":   "Space"}
	count = 0
	fmt.Scan(&k)
	for i = 0; i < k; i++ {
		fmt.Scan(&s[i])
	}
	for s1, s2 = range mieba {
		flag = false
		for i = 0; i < k; i++ {
			if s[i] == s1 {
				flag = true
			}
		}
		if flag == false {
			count++
		}
	}
	fmt.Println(count)
	for s1, s2 = range mieba {
		flag = false
		for i = 0; i < k; i++ {
			if s[i] == s1 {
				flag = true
			}
		}
		if flag == false {
			fmt.Println(s2)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var r = map[string]string{
		"purple":"Power",
		"green":"Time",
		"blue":"Space",
		"orange":"Soul",
		"red":"Reality",
		"yellow":"Mind",
	}
	var n int

	fmt.Scan(&n)
	for i:=0;i<n;i++{
		var m string
		fmt.Scan(&m)
		delete(r,m)
	}
	fmt.Println(len(r))
	for _,v := range(r){
		fmt.Println(v)
	}
}

package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string{
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main(){
	m := map[string]string{"purple": "Power", "green": "Time", "blue": "Space", "orange" : "Soul", "red": "Reality", "yellow": "Mind"}

	sc.Split(bufio.ScanWords)

	n := nextInt()
	for i:=0; i< n; i++{
		l := nextLine()
		delete(m, l)
	}

	fmt.Printf("%d\n", len(m))
	for _, v:= range m{
		fmt.Printf("%s\n", v)
	}

}

package main

import "fmt"

func main() {
	var n int
	var a = map[string]string{
		"purple": "Power",
		"green": "Time",
		"blue": "Space",
		"orange": "Soul",
		"red": "Reality",
		"yellow": "Mind",
	}
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scanf("%s\n", &s)
		delete(a, s)
	}
	fmt.Println(len(a))
	for _, v := range a {
		fmt.Println(v)
	}
}

package main

import (
	"fmt"
)

func main() {
	var n int
	hash := map[string]bool{
		"purple": true,
		"green":  true,
		"blue":   true,
		"orange": true,
		"red":    true,
		"yellow": true,
	}
	gemName := map[string]string{
		"purple": "Power",
		"green":  "Time",
		"blue":   "Space",
		"orange": "Soul",
		"red":    "Reality",
		"yellow": "Mind",
	}

	fmt.Scanf("%d", &n)
	i := 0
	for i < n {
		var gem string
		fmt.Scanf("%s", &gem)
		hash[gem] = false
		i++
	}

	fmt.Println(6 - n)
	for gem, exist := range hash {
		if exist {
			fmt.Println(gemName[gem])
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n int
	hash := map[string]bool{
		"purple": true,
		"green":  true,
		"blue":   true,
		"orange": true,
		"red":    true,
		"yellow": true,
	}
	gemName := map[string]string{
		"purple": "Power",
		"green":  "Time",
		"blue":   "Space",
		"orange": "Soul",
		"red":    "Reality",
		"yellow": "Mind",
	}

	fmt.Scanf("%d", &n)
	i := 0
	for i < n {
		var gem string
		fmt.Scanf("%s", &gem)
		hash[gem] = false
		i++
	}

	fmt.Println(6 - n)
	if n == 6 {
		return
	}
	for gem, exist := range hash {
		if exist {
			fmt.Println(gemName[gem])
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n int
	hash := map[string]bool{
		"purple": true,
		"green":  true,
		"blue":   true,
		"orange": true,
		"red":    true,
		"yellow": true,
	}
	gemName := map[string]string{
		"purple": "Power",
		"green":  "Time",
		"blue":   "Space",
		"orange": "Soul",
		"red":    "Reality",
		"yellow": "Mind",
	}

	fmt.Scanf("%d", &n)
	fmt.Println(6 - n)
	i := 0
	for i < n {
		var gem string
		fmt.Scanf("%s", &gem)
		hash[gem] = false
		i++
	}

	for gem, exist := range hash {
		if exist {
			fmt.Println(gemName[gem])
		}
	}
}

package main

import (
  "fmt"

)

func main()  {
  var keys = map[string] string{
    "purple": "Power",
    "green": "Time",
    "blue": "Space",
    "orange": "Soul",
    "red": "Reality",
    "yellow": "Mind",
  }
  var num int
  var text string
  fmt.Scanf("%d", &num)

  for i := 0;  i < num ; i++{
    fmt.Scanf("%s\n",&text)
    delete(keys, text)

  }

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

}

package main

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

func main()  {
  var keys = map[string] string{
    "purple": "Power",
    "green": "Time",
    "blue": "Space",
    "orange": "Soul",
    "red": "Reality",
    "yellow": "Mind",
  }
  var num int
  reader := bufio.NewReader(os.Stdin)
  fmt.Scanf("%d", &num)

  for i := 0;  i < num ; i++{
    text, _ := reader.ReadString('\n')
    text = strings.TrimSuffix(text, "\n")

    delete(keys, text)

  }

  fmt.Println("\n")
  for _ ,v := range keys {
    fmt.Println(v)
  }

}

package main

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

func main()  {
  var keys = map[string] string{
    "purple": "Power",
    "green": "Time",
    "blue": "Space",
    "orange": "Soul",
    "red": "Reality",
    "yellow": "Mind",
  }
  var num int
  reader := bufio.NewReader(os.Stdin)
  fmt.Scanf("%d", &num)

  for i := 0;  i < num ; i++{
    text, _ := reader.ReadString('\n')
    text = strings.TrimSuffix(text, "\n")

    delete(keys, text)

  }

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

}

package main
import (
	"fmt"
)

func in_StrArray(arr []string, key string)bool{
	for _,i := range arr{
		if key == i{
			return true
		}
	}
	return false
}

func main(){
	var n_stones int
	fmt.Print("Number OF Stones Seen: ")
	fmt.Scanln(&n_stones)
	fmt.Print("Colour OF Stones Seen: ")
	var stonesPresent []string

	var i_Stones = map[string]string{
		"blue": "Space",
		"red": "Reality",
		"yellow": "Mind",
		"orange": "Soul",
		"purple": "Power",
		"green": "Time",
	}

	for i := 0; i < n_stones; i++{
		var temp string
		fmt.Scanln(&temp)
		stonesPresent = append(stonesPresent, i_Stones[temp])
	}

	fmt.Printf(":: NOW HE JUST NEEDS %d STONES ::\n", len(i_Stones)-len(stonesPresent))
	for _,types := range i_Stones{
		if ! in_StrArray(stonesPresent, types){
			fmt.Println(types)
		}
	}
}

package main

import (
	"fmt"
)

var (
	k     int
	i     int
	s     [6]string
	flag  bool
	count int
	s1    string
	s2    string
)

func main() {
	mieba := map[string]string{

		"green":  "Time",
		"yellow": "Mind",
		"orange": "Soul",
		"purple": "Power",
		"red":    "Reality",
		"blue":   "Spcae"}
	count = 0
	fmt.Scan(&k)
	for i = 0; i < k; i++ {
		fmt.Scan(&s[i])
	}
	for s1, s2 = range mieba {
		flag = false
		for i = 0; i < k; i++ {
			if s[i] == s1 {
				flag = true
			}
		}
		if flag == false {
			count++
		}
	}
	fmt.Println(count)
	for s1, s2 = range mieba {
		flag = false
		for i = 0; i < k; i++ {
			if s[i] == s1 {
				flag = true
			}
		}
		if flag == false {
			fmt.Println(s2)
		}
	}
}