Toad Ivan has $$$m$$$ pairs of integers, each integer is between $$$1$$$ and $$$n$$$, inclusive. The pairs are $$$(a_1, b_1), (a_2, b_2), \ldots, (a_m, b_m)$$$. He asks you to check if there exist two integers $$$x$$$ and $$$y$$$ ($$$1 \leq x < y \leq n$$$) such that in each given pair at least one integer is equal to $$$x$$$ or $$$y$$$.

The first line contains two space-separated integers $$$n$$$ and $$$m$$$ ($$$2 \leq n \leq 300\,000$$$, $$$1 \leq m \leq 300\,000$$$) — the upper bound on the values of integers in the pairs, and the number of given pairs. The next $$$m$$$ lines contain two integers each, the $$$i$$$-th of them contains two space-separated integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \leq a_i, b_i \leq n, a_i \neq b_i$$$) — the integers in the $$$i$$$-th pair.

Output "YES" if there exist two integers $$$x$$$ and $$$y$$$ ($$$1 \leq x < y \leq n$$$) such that in each given pair at least one integer is equal to $$$x$$$ or $$$y$$$. Otherwise, print "NO". You can print each letter in any case (upper or lower).

NoteIn the first example, you can't choose any $$$x$$$, $$$y$$$ because for each such pair you can find a given pair where both numbers are different from chosen integers.In the second example, you can choose $$$x=2$$$ and $$$y=4$$$.In the third example, you can choose $$$x=1$$$ and $$$y=2$$$.

package main

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

func solveAll(jam Jam) {
	s, l, ui, f, d, p, pf := jam.Str, jam.Long, jam.Int, jam.Float, jam.D, jam.P, jam.PF
	//	Live Templates: for0l for1l for0ui for1ui forr vl0 vln vui0 vuin ; Casts: l i

	n, m := uint32(l()), uint32(l())
	a, b := make([]uint32, m, m), make([]uint32, m, m)
	for i := range a {
		a[i], b[i] = ui(), ui()
	}

	for _, x := range [2]uint32{a[0], b[0]} {
		ysize := uint32(0)
		ydeg := make([]uint32, n+1, n+1)
		for i := range a {
			if a[i] == x || b[i] == x {
				continue
			}

			ydeg[a[i]]++
			ydeg[b[i]]++
			ysize++
		}
		for _, e := range ydeg {
			if e == ysize {
				p("YES\n")
				return
			}
		}
	}

	p("NO\n")

	if false {
		d("%v", []interface{}{s, l, ui, f, d, p, pf})
	}
}

func main() {
	jam, closeFunc := JamNew()
	defer closeFunc()
	solveAll(jam)
}

type Jam interface {
	Scanner() *bufio.Scanner
	Writer() *bufio.Writer
	Close()

	Str() string
	Long() int64
	Int() uint32
	Float() float64

	D(format string, values ...interface{})
	P(format string, values ...interface{})
	PF(format string, values ...interface{})
}

func JamNew() (Jam, func()) {
	if len(os.Args) > 1 {
		panic("running with input file path is not supported")
	}

	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 0, 1024*1024), 1024*1024)

	var writer = bufio.NewWriterSize(os.Stdout, 1024*1024)
	jam := &jam{scanner, writer}
	return jam, jam.Close
}

type jam struct {
	sc *bufio.Scanner
	wr *bufio.Writer
}

func (j *jam) Close() {
	if err := j.wr.Flush(); err != nil {
		panic(err)
	}
}

func (j *jam) Scanner() *bufio.Scanner {
	return j.sc
}

func (j *jam) Writer() *bufio.Writer {
	return j.wr
}

func (j *jam) Str() string {
	if !j.sc.Scan() {
		panic("failed to scan next token")
	}

	return j.sc.Text()
}

func (j *jam) Long() int64 {
	if !j.sc.Scan() {
		panic("failed to scan next token")
	}

	res, err := strconv.ParseInt(j.sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}

	return res
}

func (j *jam) Int() uint32 {
	return uint32(j.Long())
}

func (j *jam) Float() float64 {
	j.sc.Scan()
	res, err := strconv.ParseFloat(j.sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return res
}

func (j *jam) D(format string, values ...interface{}) {
	_ /*bytesWritten*/, err := fmt.Fprintf(os.Stderr, format, values...)
	if err != nil {
		panic(err)
	}
}

func (j *jam) P(format string, values ...interface{}) {
	_, err := fmt.Fprintf(j.wr, format, values...)
	if err != nil {
		panic(err)
	}
}

func (j *jam) PF(format string, values ...interface{}) {
	_, err := fmt.Fprintf(j.wr, format, values...)
	if err != nil {
		panic(err)
	}
	if err = j.wr.Flush(); err != nil {
		panic(err)
	}
}

package main

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

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

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

func check(a, b []int, x, y int) int {
	n := len(a)
	for i := 0; i < n; i++ {
		if a[i] == x || b[i] == x {
			continue
		}
		if a[i] == y || b[i] == y {
			continue
		}
		return i
	}
	return -1
}

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

func main() {
	defer writer.Flush()

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

	a := make([]int, m)
	b := make([]int, m)
	for i := 0; i < m; i++ {
		scanf("%d %d\n", &a[i], &b[i])
	}

	x := a[0]
	first := check(a, b, x, -1)
	if first == -1 {
		printf("YES\n")
		return
	}
	y := a[first]
	if check(a, b, x, y) == -1 {
		printf("YES\n")
		return
	}
	y = b[first]
	if check(a, b, x, y) == -1 {
		printf("YES\n")
		return
	}

	x = b[0]
	first = check(a, b, x, -1)
	if first == -1 {
		printf("YES\n")
		return
	}
	y = a[first]
	if check(a, b, x, y) == -1 {
		printf("YES\n")
		return
	}
	y = b[first]
	if check(a, b, x, y) == -1 {
		printf("YES\n")
		return
	}

	printf("NO\n")
}

package main

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

func readInput(reader io.Reader) *[][2]int32 {
	scanner := bufio.NewScanner(reader)
	scanner.Split(bufio.ScanWords)
	var n int32
	scanner.Scan() //max number - skip
	scanner.Scan()
	n = toInt(scanner.Bytes())
	res := make([][2]int32, n)
	for i := 0; i < int(n); i++ {
		scanner.Scan()
		res[i][0] = toInt(scanner.Bytes())
		scanner.Scan()
		res[i][1] = toInt(scanner.Bytes())
	}
	return &res
}

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

func isok(input *[][2]int32, x, y int32, start int) bool {
	i := start
	var p [2]int32
	for i < len(*input) {
		p = (*input)[i]
		switch {
		case p[0] == x || p[1] == x:
			i++
		case y != -1 && (p[0] == y || p[1] == y):
			i++
		case y != -1:
			return false
		case y == -1:
			return isok(input, x, p[0], i+1) || isok(input, x, p[1], i+1)
		}
	}
	return true
}

func solve(input *[][2]int32) bool {
	if len(*input) == 0 {
		return true
	}
	first := (*input)[0]
	return isok(input, first[0], -1, 1) || isok(input, first[1], -1, 1)
}

func main() {
	input := readInput(os.Stdin)
	if solve(input) {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
}

package main

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

type pair struct {
    a, b int
}

func check(x int, y int, arr []pair) bool {
    for i, p := range arr {
        if p.a == x || p.b == x {
            continue
        }
        if y == -1 {
            return check(x, p.a, arr[i:]) || check(x, p.b, arr[i:])
        }
        if (p.a == y || p.b == y) {
            continue
        }

        return false
    }

    return true
}

func main() {
    input := bufio.NewScanner(os.Stdin)
    input.Split(bufio.ScanWords)

    input.Scan()
    // Skip n.

    input.Scan()
    m, _ := strconv.Atoi(input.Text())

    arr := make([]pair, 0, m)
    for i := 0; i < m; i++ {
        input.Scan()
        a, _ := strconv.Atoi(input.Text())

        input.Scan()
        b, _ := strconv.Atoi(input.Text())

        arr = append(arr, pair{ a, b })
    }

    if check(arr[0].a, -1, arr) || check(arr[0].b, -1, arr) {
        fmt.Println("YES")
        return
    }

    fmt.Println("NO")
}

package main

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

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

func readInt() int {
	scanner.Scan()
	n, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func readLong() int64 {
	scanner.Scan()
	n, err := strconv.ParseInt(scanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return n
}

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

func solve(a int) int {
	return a * a
}

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

	_, m := readInt(), readInt()
	a := make([]int, m)
	b := make([]int, m)
	freq := make(map[int]int)
	for i := 0; i < m; i++ {
		a[i] = readInt()
		b[i] = readInt()
		freq[a[i]]++
		freq[b[i]]++
	}

	for k, v := range freq {
		if v >= (m+1)/2 {
			f2 := make(map[int]int)
			ct := 0
			for i := 0; i < m; i++ {
				if a[i] != k && b[i] != k {
					f2[a[i]]++
					f2[b[i]]++
					ct++
				}
			}
			if ct == 0 {
				fmt.Println("YES")
				return
			}
			for _, v2 := range f2 {
				if v2 == ct {
					fmt.Println("YES")
					return
				}
			}
		}
	}
	fmt.Println("NO")
}

package main

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

var scanner = bufio.NewScanner(os.Stdin)

func readInt() int {
	scanner.Scan()
	n, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func isValid(arr *[][]int, picked int) bool {
	coverageNeeded := 0
	freq := make(map[int]int)
	for i := 0; i < len(*arr); i++ {
		if (*arr)[i][0] != picked && (*arr)[i][1] != picked {
			coverageNeeded++
			freq[(*arr)[i][0]]++
			freq[(*arr)[i][1]]++
		}
	}

	if coverageNeeded == 0 {
		return true
	}
	for _, v := range freq {
		if v == coverageNeeded {
			return true
		}
	}
	return false
}

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

	_, m := readInt(), readInt()
	a := make([][]int, m)
	for i := 0; i < m; i++ {
		a[i] = []int{readInt(), readInt()}
	}

	if isValid(&a, a[0][0]) || isValid(&a, a[0][1]) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

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

var scanner = bufio.NewScanner(os.Stdin)

func readInt() int {
	scanner.Scan()
	n, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func isValid(arr [][]int, picked int) bool {
	coverageNeeded := 0
	freq := make(map[int]int)
	for i := 0; i < len(arr); i++ {
		if arr[i][0] != picked && arr[i][1] != picked {
			coverageNeeded++
			freq[arr[i][0]]++
			freq[arr[i][1]]++
		}
	}

	if coverageNeeded == 0 {
		return true
	}
	for _, v := range freq {
		if v == coverageNeeded {
			return true
		}
	}
	return false
}

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

	_, m := readInt(), readInt()
	a := make([][]int, m)
	for i := 0; i < m; i++ {
		a[i] = []int{readInt(), readInt()}
	}

	if isValid(a, a[0][0]) || isValid(a, a[0][1]) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

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

type Pair struct {
	A int
	B int
}

func helper(X int, m int, pairs []Pair) bool {
	missingElements := 0
	count := make(map[int]int)
	for i := 1; i < m; i++ {
		if pairs[i].A != X && pairs[i].B != X {
			missingElements += 1
			count[pairs[i].A] += 1
			count[pairs[i].B] += 1
		}
	}
	if missingElements == 0 {
		return true
	}
	for _, value := range count {
		if value == missingElements {
			return true
		}
	}
	return false
}

func Solve(m int, pairs []Pair) string {
	if helper(pairs[0].A, m, pairs) || helper(pairs[0].B, m, pairs) {
		return "YES"
	}
	return "NO"
}

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

	var n int
	var m int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	pairs := make([]Pair, m)
	for i := 0; i < m; i++ {
		fmt.Fscanf(reader, "%d %d\n", &pairs[i].A, &pairs[i].B)
	}
	fmt.Fprintf(writer, "%s\n", Solve(m, pairs))
}

package main

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

func solveAll(jam Jam) {
	s, l, ui, f, d, p, pf := jam.Str, jam.Long, jam.Int, jam.Float, jam.D, jam.P, jam.PF
	//	Live Templates: for0l for1l for0ui for1ui forr vl0 vln vui0 vuin ; Casts: l i

	n, m := uint32(l()), uint32(l())
	adjMtx := make(map[[2]uint32]bool)
	adj := AdjacencyList32New(uint32(n), 2)
	v := make(map[uint32]bool)
	a, b := uint32(0), uint32(0)
	for i := uint32(0); i < m; i++ {
		a, b = uint32(l()-1), uint32(l()-1)
		if a > b {
			a, b = b, a
		}
		v[a], v[b] = true, true
		key := [2]uint32{a, b}
		if _, prs := adjMtx[key]; !prs {
			adjMtx[key] = true
			adj.AddEdge(a, b)
		}
	}

	coloredLeft,coloredRight := make(map[uint32]bool), make(map[uint32]bool)
	var visit func (uint32, bool) bool
	visit = func (v uint32, right bool) bool {
		if right {
			coloredRight[v] = true
		} else {
			coloredLeft[v] = true
		}
		valid := true
		for _, to := range adj.Links(v) {
			mustBeAbsent := coloredRight
			if !right {
				mustBeAbsent = coloredLeft
			}
			if mustBeAbsent[to] {
				valid = false
			}
			if !coloredLeft[to] && !coloredRight[to] {
				valid = valid && visit(to, !right)
			}
		}
		return valid
	}

	valid := visit(a, true)
	// d("visit %d left %v right %v\n", a, coloredLeft, coloredRight)

	p(ts(valid && min(int64(len(coloredLeft)), int64(len(coloredRight))) <= 2, "YES\n", "NO\n"))

	if false { d("%v", []interface{}{s, l, ui, f, d, p, pf}) }
}

type Count struct { v uint32; c uint32}
type Counts []Count
func (s Counts) Len() int           { return len(s) }
func (s Counts) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s Counts) Less(i, j int) bool { return s[i].c > s[j].c }

//	TODO wipe unused shorthand methods for math
func t(b bool, t, f int64) int64 { if b {return t};return f }
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 abs(a int64) int64 { if a < 0 { return -a }; return a }
func ti(b bool, t, f uint32) uint32 { if b {return t};return f }
func mini(a, b uint32) uint32 { if a < b { return a }; return b }
func maxi(a, b uint32) uint32 { if a > b { return a }; return b }
func ts(b bool, t, f string) string { if b {return t};return f }

func round(x float64) float64 { //	https://www.cockroachlabs.com/blog/rounding-implementations-in-go/
	const (
		mask     = 0x7FF
		shift    = 64 - 11 - 1
		bias     = 1023

		signMask = 1 << 63
		fracMask = (1 << shift) - 1
		halfMask = 1 << (shift - 1)
		one      = bias << shift
	)

	bits := math.Float64bits(x)
	e := uint(bits>>shift) & mask
	switch {
	case e < bias:
		// Round abs(x)<1 including denormals.
		bits &= signMask // +-0
		if e == bias-1 {
			bits |= one // +-1
		}
	case e < bias+shift:
		// Round any abs(x)>=1 containing a fractional component [0,1).
		e -= bias
		bits += halfMask >> e
		bits &^= fracMask >> e
	}
	return math.Float64frombits(bits)
}

func main() {
	jam, closeFunc := JamNew()
	defer closeFunc()
	solveAll(jam)
}

type Jam interface {
	Scanner() *bufio.Scanner
	Writer() *bufio.Writer
	Close()

	Str() string
	Long() int64
	Int() uint32
	Float() float64

	D(format string, values ...interface{})
	P(format string, values ...interface{})
	PF(format string, values ...interface{})
}

func JamNew() (Jam, func()) {
	if len(os.Args) > 1 {
		panic("running with input file path is not supported")
	}

	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 0, 1024*1024), 1024*1024)

	var writer = bufio.NewWriterSize(os.Stdout, 1024*1024)
	jam := &jam{scanner, writer}
	return jam, jam.Close
}

type jam struct {
	sc *bufio.Scanner
	wr *bufio.Writer
}

func (j *jam) Close() {
	if err := j.wr.Flush(); err != nil {
		panic(err)
	}
}

func (j *jam) Scanner() *bufio.Scanner {
	return j.sc
}

func (j *jam) Writer() *bufio.Writer {
	return j.wr
}

func (j *jam) Str() string {
	if !j.sc.Scan() {
		panic("failed to scan next token")
	}

	return j.sc.Text()
}

func (j *jam) Long() int64 {
	if !j.sc.Scan() {
		panic("failed to scan next token")
	}

	res, err := strconv.ParseInt(j.sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}

	return res
}

func (j *jam) Int() uint32 {
	return uint32(j.Long())
}

func (j *jam) Float() float64 {
	j.sc.Scan()
	res, err := strconv.ParseFloat(j.sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return res
}

func (j *jam) D(format string, values ...interface{}) {
	_ /*bytesWritten*/, err := fmt.Fprintf(os.Stderr, format, values...)
	if err != nil {
		panic(err)
	}
}

func (j *jam) P(format string, values ...interface{}) {
	_, err := fmt.Fprintf(j.wr, format, values...)
	if err != nil {
		panic(err)
	}
}

func (j *jam) PF(format string, values ...interface{}) {
	_, err := fmt.Fprintf(j.wr, format, values...)
	if err != nil {
		panic(err)
	}
	if err = j.wr.Flush(); err != nil {
		panic(err)
	}
}

type AdjacencyList32 [][]uint32

func AdjacencyList32New(size uint32, avgDegree uint32) AdjacencyList32 {
	list := make([][]uint32, size)
	for from := range list {
		list[from] = make([]uint32, 0, avgDegree)
	}
	return list
}

func (alp *AdjacencyList32) Size() int {
	return len(*alp)
}

func (alp *AdjacencyList32) Links(from uint32) []uint32 {
	return (*alp)[from]
}

func (alp *AdjacencyList32) AddEdge(from, into uint32) {
	al := *alp

	al[from] =
		append(
			al[from],
			into,
		)
	if from != into {
		al[into] =
			append(
				al[into],
				from,
			)
	}
}

package main

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

type pair struct {
    a, b int
}

func check(x int, arr []pair, bottom bool) bool {
    for i, p := range arr {
        if p.a == x || p.b == x {
            continue
        }
        if bottom {
            return false
        }

        return check(p.a, arr[i:], true) || check(p.b, arr[i:], true)
    }

    return true
}

func main() {
    input := bufio.NewScanner(os.Stdin)
    input.Split(bufio.ScanWords)

    input.Scan()
    // Skip n.

    input.Scan()
    m, _ := strconv.Atoi(input.Text())

    arr := make([]pair, 0, m)
    for i := 0; i < m; i++ {
        input.Scan()
        a, _ := strconv.Atoi(input.Text())

        input.Scan()
        b, _ := strconv.Atoi(input.Text())

        arr = append(arr, pair{ a, b })
    }

    if check(arr[0].a, arr, false) || check(arr[0].b, arr, false) {
        fmt.Println("YES")
        return
    }

    fmt.Println("NO")
}

package main

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

type Pair struct {
	A int
	B int
}

func getKeyWithMaxValue(m map[int]int) int {
	maxKey := 0
	maxValue := 0
	for key, value := range m {
		if value > maxValue {
			maxValue = value
			maxKey = key
		}
	}
	return maxKey
}

func Solve(m int, pairs []Pair) string {
	count := make(map[int]int)
	for _, pair := range pairs {
		count[pair.A] += 1
		count[pair.B] += 1
	}
	X := getKeyWithMaxValue(count)
	count2 := make(map[int]int)
	missingPairs := 0
	for _, pair := range pairs {
		if pair.A != X && pair.B != X {
			count2[pair.A] += 1
			count2[pair.B] += 1
			missingPairs += 1
		}
	}
	if missingPairs == 0 {
		return "YES"
	}
	for _, value := range count2 {
		if value == missingPairs {
			return "YES"
		}
	}
	return "NO"
}

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

	var n int
	var m int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	pairs := make([]Pair, m)
	for i := 0; i < m; i++ {
		fmt.Fscanf(reader, "%d %d\n", &pairs[i].A, &pairs[i].B)
	}
	fmt.Fprintf(writer, "%s\n", Solve(m, pairs))
}


Let $$$s(x)$$$ be sum of digits in decimal representation of positive integer $$$x$$$. Given two integers $$$n$$$ and $$$m$$$, find some positive integers $$$a$$$ and $$$b$$$ such that   $$$s(a) \ge n$$$,  $$$s(b) \ge n$$$,  $$$s(a + b) \le m$$$.

The only line of input contain two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1129$$$).

Print two lines, one for decimal representation of $$$a$$$ and one for decimal representation of $$$b$$$. Both numbers must not contain leading zeros and must have length no more than $$$2230$$$.

NoteIn the first sample, we have $$$n = 6$$$ and $$$m = 5$$$. One valid solution is $$$a = 6$$$, $$$b = 7$$$. Indeed, we have $$$s(a) = 6 \ge n$$$ and $$$s(b) = 7 \ge n$$$, and also $$$s(a + b) = s(13) = 4 \le m$$$.

package main

import (
    "fmt"
    )

func main() {
    for i:=0; i<300; i++{
        fmt.Print("5");
    }
    fmt.Println("5");
    for i:=0; i<300; i++{
        fmt.Print("4");
    }
    fmt.Print("5");
}

package main

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

func main()  {

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

	var n, m int
	fmt.Fscan(in, &n, &m)

	a, b := "", ""

	x, y := n, n
	for {
		if x > 9 {
			x -= 9
			a += "9"
			b += "0"
		} else {
			a += strconv.Itoa(x)
			b += strconv.Itoa(10 - x)
			y -= 10 - x
			break
		}
	}

	for y > 0 {
		b = "9" + b
		y -= 9
	}

	fmt.Fprintln(out, a)
	fmt.Fprintln(out, b)

}

package main

import "fmt"

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

	a := ""
	b := ""
	for i := 1; i <= 1000; i++ {
		a = a + "5"
		if i < 1000 {
			b = b + "4"
		} else {
			b = b + "5"
		}
	}
	fmt.Println(a)
	fmt.Println(b)
}

package main

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

	 for i := 0; i<=n; i ++ {
	 	 fmt.Printf("%d", 1)
	 }
	 fmt.Printf("\n")
	 for i := 0; i<n; i ++ {
	 	 fmt.Printf("%d", 8)
	 }

	 fmt.Printf("%d\n", 9)
}

package main

import (
    "fmt"
    )

func main() {
    for i:=0; i<301; i++{
        fmt.Print("5");
    }
    for i:=0; i<300; i++{
        fmt.Print("4");
    }
    fmt.Print("5");
}


You are given two binary strings $$$x$$$ and $$$y$$$, which are binary representations of some two integers (let's denote these integers as $$$f(x)$$$ and $$$f(y)$$$). You can choose any integer $$$k \ge 0$$$, calculate the expression $$$s_k = f(x) + f(y) \cdot 2^k$$$ and write the binary representation of $$$s_k$$$ in reverse order (let's denote it as $$$rev_k$$$). For example, let $$$x = 1010$$$ and $$$y = 11$$$; you've chosen $$$k = 1$$$ and, since $$$2^1 = 10_2$$$, so $$$s_k = 1010_2 + 11_2 \cdot 10_2 = 10000_2$$$ and $$$rev_k = 00001$$$.For given $$$x$$$ and $$$y$$$, you need to choose such $$$k$$$ that $$$rev_k$$$ is lexicographically minimal (read notes if you don't know what does "lexicographically" means).It's guaranteed that, with given constraints, $$$k$$$ exists and is finite.

The first line contains a single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of queries. Next $$$2T$$$ lines contain a description of queries: two lines per query. The first line contains one binary string $$$x$$$, consisting of no more than $$$10^5$$$ characters. Each character is either 0 or 1. The second line contains one binary string $$$y$$$, consisting of no more than $$$10^5$$$ characters. Each character is either 0 or 1. It's guaranteed, that $$$1 \le f(y) \le f(x)$$$ (where $$$f(x)$$$ is the integer represented by $$$x$$$, and $$$f(y)$$$ is the integer represented by $$$y$$$), both representations don't have any leading zeroes, the total length of $$$x$$$ over all queries doesn't exceed $$$10^5$$$, and the total length of $$$y$$$ over all queries doesn't exceed $$$10^5$$$.

Print $$$T$$$ integers (one per query). For each query print such $$$k$$$ that $$$rev_k$$$ is lexicographically minimal.

NoteThe first query was described in the legend.In the second query, it's optimal to choose $$$k = 3$$$. The $$$2^3 = 1000_2$$$ so $$$s_3 = 10001_2 + 110_2 \cdot 1000_2 = 10001 + 110000 = 1000001$$$ and $$$rev_3 = 1000001$$$. For example, if $$$k = 0$$$, then $$$s_0 = 10111$$$ and $$$rev_0 = 11101$$$, but $$$rev_3 = 1000001$$$ is lexicographically smaller than $$$rev_0 = 11101$$$.In the third query $$$s_0 = 10$$$ and $$$rev_0 = 01$$$. For example, $$$s_2 = 101$$$ and $$$rev_2 = 101$$$. And $$$01$$$ is lexicographically smaller than $$$101$$$.The quote from Wikipedia: "To determine which of two strings of characters comes when arranging in lexicographical order, their first letters are compared. If they differ, then the string whose first letter comes earlier in the alphabet comes before the other string. If the first letters are the same, then the second letters are compared, and so on. If a position is reached where one string has no more letters to compare while the other does, then the first (shorter) string is deemed to come first in alphabetical order."

package main

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

/* solution */

func solve() {

	t := readInt()
	for i := 0; i < t; i++ {
		x, y := readString(), readString()
		xl, yl := len(x), len(y)
		xc, yc := 0, 0
		for ; y[yl-yc-1] == '0'; yc++ {
			xc++
		}
		for ; x[xl-xc-1] == '0'; xc++ {
		}
		printInt(xc - yc)
	}

}

/* stubs */

func main() {

	var f *os.File
	if runtime.GOROOT() == "C:\\Soft\\Go" {
		f, _ = os.Open("input.txt")
		defer f.Close()
	} else {
		f = os.Stdin
	}

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

	reader = bufio.NewScanner(f)
	reader.Split(bufio.ScanWords)
	maxCapacity := 100000 + 5
	buf := make([]byte, maxCapacity)
	reader.Buffer(buf, maxCapacity)

	solve()

}

var reader *bufio.Scanner
var writer *bufio.Writer

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

func readInt() int {
	reader.Scan()
	ret, _ := strconv.Atoi(reader.Text())
	return ret
}

func print(s string) {
	writer.WriteString(s)
	writer.WriteString("\n")
}

func printInt(i int) {
	print(strconv.Itoa(i))
}

package main

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

func reverse(s string) string {

	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

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

	var total int
	_, _ = fmt.Fscan(input, &total)

	for t := 0; t < total; t += 1 {
		var (
			x string
			y string
		)
		_, _ = fmt.Fscan(input, &x, &y)

		x = reverse(x)
		y = reverse(y)

		first := 0
		for i, c := range y {
			if c == '1' {
				first = i
				break
			}
		}

		ans := 0
		for i, c := range x {
			if c == '1' && i >= first {
				ans = i - first
				break
			}
		}
		fmt.Println(ans)
	}
}

package main

import (
  "fmt"
)

func main() {
  var t int
  fmt.Scanf("%d ", &t)
  for i := 0; i < t; i++ {
    var a,b string
    fmt.Scanf("%s ", &a)
    fmt.Scanf("%s ", &b)
    zeros := 0
    for j := len(b) - 1; j >= 0 && b[j] == '0'; j-- {
      zeros++
    }
    res := 0
    for j := len(a) - zeros - 1; j >= 0 && a[j] == '0' ; j-- {
      res++
    }
    fmt.Printf("%d\n", res)
  }
}

package main

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

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

	var t int
	fmt.Fscan(input, &t)
	for i := 0; i < t; i++ {
		var a, b string
		fmt.Fscan(input, &a)
		fmt.Fscan(input, &b)
		zeros := len(b) - 1 - strings.LastIndex(b, "1")
		a = a[0 : len(a)-zeros]
		res := len(a) - 1 - strings.LastIndex(a, "1")
		fmt.Println(res)
	}
}

package main

import (
  "fmt"
)

func main() {
  var t int
  fmt.Scan(&t)
  for i := 0; i < t; i++ {
    var a,b string
    fmt.Scan(&a)
    fmt.Scan(&b)
    zeros := 0
    for j := len(b) - 1; j >= 0 && b[j] == '0'; j-- {
      zeros++
    }
    res := 0
    for j := len(a) - zeros - 1; j >= 0 && a[j] == '0' ; j-- {
      res++
    }
    fmt.Println(res)
  }
}

package main

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

func main() {
  var t int
  input := bufio.NewReader(os.Stdin)

  fmt.Fscan(input, &t)
  for i := 0; i < t; i++ {
    var a,b string
    fmt.Fscan(input, &a)
    fmt.Fscan(input, &b)
    zeros := 0
    for j := len(b) - 1; j >= 0 && b[j] == '0'; j-- {
      zeros++
    }
    res := 0
    for j := len(a) - zeros - 1; j >= 0 && a[j] == '0' ; j-- {
      res++
    }
    fmt.Println(res)
  }
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(0)
	a := ""
	b := ""
	fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		fmt.Fscanf(in, "%s\n", &a)
		fmt.Fscanf(in, "%s\n", &b)
		ans := 0
		for i := 0; i < len(b); i++ {
			if b[len(b)-i-1] == '1' {
				for j := i; j < len(a); j++ {
					if a[len(a)-j-1] == '1' {
						fmt.Fprintf(out, "%d\n", ans)
						break
					}
					ans++
				}
				break
			}
		}
	}
	return
}

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	var n int

	_, err := fmt.Fscanf(input, "%d\n", &n)
	if err != nil {
	}

	for n > 0 {
		n--
		var x, y string

		_, err := fmt.Fscanf(input, "%v\n%v\n", &x, &y)
		if err != nil {
		}

		var i, j int
		var t int
		for i, j = len(x)-1, len(y)-1; i >= 0 && j >= 0; {
			if string(y[j]) != "1" {
				j--
				i--
				continue
			} else {
				t = 1
			}
			if string(x[i]) == "1" {
				break
			} else {
				i--
			}
		}

		if t == 1 {
			fmt.Println(len(x) - i - len(y) + j)
		} else {
			fmt.Println("0")
		}
	}
}

package main

import (
  "fmt"
)

func main() {
  var t int
  fmt.Scanf("%d ", &t)
  for i := 0; i < t; i++ {
    var a,b string
    fmt.Scanf("%s ", &a)
    fmt.Scanf("%s ", &b)
    zeros := 0
    for j := len(b) - 1; j >= 0; j-- {
      if b[j] == '0' {
        zeros++
      }
    }
    res := 0
    for j := len(a) - zeros - 1; j >= 0 && a[j] == '0' ; j-- {
      res++
    }
    fmt.Printf("%d\n", res)
  }
}

package main

import (
  "fmt"
)

func main() {
  var t int
  fmt.Scanf("%d", &t)
  for i := 0; i < t; i++ {
    var a,b string
    fmt.Scanf("%s", &a)
    fmt.Scanf("%s", &b)
    zeros := 0
    for j := len(b) - 1; j >= 0; j-- {
      if b[j] == '0' {
        zeros++
      }
    }
    res := 0
    for j := len(a) - zeros - 1; j >= 0 && a[j] == '0' ; j-- {
      res++
    }
    fmt.Printf("%d\n", res)
  }
}

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	var n int

	_, err := fmt.Fscanf(input, "%d\n", &n)
	if err != nil {
	}

	for n > 0 {
		n--
		var x, y string

		_, err := fmt.Fscanf(input, "%v\n%v\n", &x, &y)
		if err != nil {
		}

		var i, j int
		for i, j = len(x)-1, len(y)-1; i > 0 && j > 0; {
			if string(y[j]) != "1" {
				j--
				i--
				continue
			}
			if string(x[i]) == "1" {
				break
			} else {
				i--
			}

		}
		fmt.Println(len(x) - i - len(y) + j)
	}

}


A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a number that shows how much he likes that letter (he has assigned negative numbers to the letters he dislikes). B likes substrings. He especially likes the ones that start and end with the same letter (their length must exceed one).Also, A and B have a string s. Now they are trying to find out how many substrings t of a string s are interesting to B (that is, t starts and ends with the same letter and its length is larger than one), and also the sum of values of all letters (assigned by A), except for the first and the last one is equal to zero.Naturally, A and B have quickly found the number of substrings t that are interesting to them. Can you do it?

The first line contains 26 integers xa, xb, ..., xz ( - 105 ≤ xi ≤ 105) — the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase letters— the string for which you need to calculate the answer.

NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.

package main

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

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

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

func getLine() string {
	s, _ := reader.ReadString('\n')
	if strings.HasSuffix(s, "\r\n") {
		s = s[:len(s)-2]
	} else if strings.HasSuffix(s, "\n") {
		s = s[:len(s)-1]
	}
	return s
}
func getLine2Int() (n int) {
	scanf("%d\n", &n)
	return
}
func getLine2Int2() (a, b int) {
	scanf("%d %d\n", &a, &b)
	return
}
func getLine2Ints(n int) []int64 {
	ans := make([]int64, n)
	for i := 0; i < n; i++ {
		scanf("%d ", &ans[i])
	}
	scanf("%d\n", &ans[n-1])
	return ans
}

func pcheck(i bool) {
	if i {
		printf("Yes\n")
	} else {
		printf("No\n")
	}
}

var debug = true

func see(a interface{}) {
	if debug {
		printf("DEBUG:%v\n", a)
	}
}

func main() {
	defer writer.Flush()

	cs := getLine2Ints(26)
	ss := getLine()

	var fs [26](map[int64]int)
	for i := 0; i < len(fs); i++ {
		fs[i] = make(map[int64]int, 0)
	}

	var sum, result int64

	for i := 0; i < len(ss); i++ {
		x := ss[i] - 'a'
		result += int64(fs[x][sum])
		sum += cs[x]
		fs[x][sum]++

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

package main

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

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

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

func getLine() string {
	s, _ := reader.ReadString('\n')
	if strings.HasSuffix(s, "\r\n") {
		s = s[:len(s)-2]
	} else if strings.HasSuffix(s, "\n") {
		s = s[:len(s)-1]
	}
	return s
}
func getLine2Int() (n int) {
	scanf("%d\n", &n)
	return
}
func getLine2Int2() (a, b int) {
	scanf("%d %d\n", &a, &b)
	return
}
func getLine2Ints(n int) []int64 {
	ans := make([]int64, n)
	for i := 0; i < n; i++ {
		scanf("%d ", &ans[i])
	}
	scanf("%d\n", &ans[n-1])
	return ans
}

func pcheck(i bool) {
	if i {
		printf("Yes\n")
	} else {
		printf("No\n")
	}
}

var debug = true

func see(a interface{}) {
	if debug {
		printf("DEBUG:%v\n", a)
	}
}

func main() {
	defer writer.Flush()

	cs := getLine2Ints(26)
	ss := getLine()

	var fs [26](map[int64]int)
	for i := 0; i < len(fs); i++ {
		fs[i] = make(map[int64]int, 0)
	}

	var sum, result int64

	for i := 0; i < len(ss); i++ {
		x := ss[i] - 'a'
		result += int64(fs[x][sum-100000])
		sum += cs[x]
		fs[x][sum-100000]++
	}
	printf("%d\n", result)
}

package main

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

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

	score := make(map[byte]int)
	for i := byte('a'); i <= 'z'; i++ {
		var sc int
		fmt.Fscanf(r, "%d", &sc)
		score[i] = sc
	}
	fmt.Fscanf(r, "\n")

	var s string
	fmt.Fscanf(r, "%s\n", &s)

	mp := make(map[byte]map[int64]int)
	for i := byte('a'); i <= 'z'; i++ {
		mp[i] = make(map[int64]int)
	}

	sum := int64(0)
	count := int64(0)
	for i := 0; i < len(s)-1; i++ {
		sum += int64(score[s[i]])
		mp[s[i]][sum]++
		count += int64(mp[s[i+1]][sum])
	}

	fmt.Println(count)
}

package main

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

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

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

func getLine() string {
	s, _ := reader.ReadString('\n')
	if strings.HasSuffix(s, "\r\n") {
		s = s[:len(s)-2]
	} else if strings.HasSuffix(s, "\n") {
		s = s[:len(s)-1]
	}
	return s
}
func getLine2Int() (n int) {
	scanf("%d\n", &n)
	return
}
func getLine2Int2() (a, b int) {
	scanf("%d %d\n", &a, &b)
	return
}
func getLine2Ints(n int) []int64 {
	ans := make([]int64, n)
	for i := 0; i < n; i++ {
		scanf("%d ", &ans[i])
	}
	scanf("%d\n", &ans[n-1])
	return ans
}

func pcheck(i bool) {
	if i {
		printf("Yes\n")
	} else {
		printf("No\n")
	}
}

var debug = true

func see(a interface{}) {
	if debug {
		printf("DEBUG:%v\n", a)
	}
}

func main() {
	defer writer.Flush()

	cs := getLine2Ints(26)
	ss := getLine()

	var fs [26](map[int64]int)
	for i := 0; i < len(fs); i++ {
		fs[i] = make(map[int64]int, 0)
	}

	var sum, result int64

	for i := 0; i < len(ss); i++ {
		x := ss[i] - 'a'
		sum += cs[x]
		fs[x][sum]++
		result += int64(fs[x][sum]-1)
	}
	printf("%d\n", result)
}

package main

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

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

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

func getLine() string {
	s, _ := reader.ReadString('\n')
	if strings.HasSuffix(s, "\r\n") {
		s = s[:len(s)-2]
	} else if strings.HasSuffix(s, "\n") {
		s = s[:len(s)-1]
	}
	return s
}
func getLine2Int() (n int) {
	scanf("%d\n", &n)
	return
}
func getLine2Int2() (a, b int) {
	scanf("%d %d\n", &a, &b)
	return
}
func getLine2Ints(n int) []int64 {
	ans := make([]int64, n)
	for i := 0; i < n; i++ {
		scanf("%d ", &ans[i])
	}
	scanf("%d\n", &ans[n-1])
	return ans
}

func pcheck(i bool) {
	if i {
		printf("Yes\n")
	} else {
		printf("No\n")
	}
}

var debug = true

func see(a interface{}) {
	if debug {
		printf("DEBUG:%v\n", a)
	}
}

func main() {
	defer writer.Flush()

	cs := getLine2Ints(26)
	ss := getLine()

	var fs [26](map[int64]int)
	for i := 0; i < len(fs); i++ {
		fs[i] = make(map[int64]int, 0)
	}

	var sum, result int64

	for i := 0; i < len(ss); i++ {
		x := ss[i] - 'a'
		sum += cs[x]
		fs[x][sum]++
		result += int64(fs[x][sum]) - 1
	}
	printf("%d\n", result)
}


You are given a string $$$s$$$. You can build new string $$$p$$$ from $$$s$$$ using the following operation no more than two times:   choose any subsequence $$$s_{i_1}, s_{i_2}, \dots, s_{i_k}$$$ where $$$1 \le i_1 < i_2 < \dots < i_k \le |s|$$$;  erase the chosen subsequence from $$$s$$$ ($$$s$$$ can become empty);  concatenate chosen subsequence to the right of the string $$$p$$$ (in other words, $$$p = p + s_{i_1}s_{i_2}\dots s_{i_k}$$$). Of course, initially the string $$$p$$$ is empty. For example, let $$$s = \text{ababcd}$$$. At first, let's choose subsequence $$$s_1 s_4 s_5 = \text{abc}$$$ — we will get $$$s = \text{bad}$$$ and $$$p = \text{abc}$$$. At second, let's choose $$$s_1 s_2 = \text{ba}$$$ — we will get $$$s = \text{d}$$$ and $$$p = \text{abcba}$$$. So we can build $$$\text{abcba}$$$ from $$$\text{ababcd}$$$.Can you build a given string $$$t$$$ using the algorithm above?

The first line contains the single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$2T$$$ lines contain test cases — two per test case. The first line contains string $$$s$$$ consisting of lowercase Latin letters ($$$1 \le |s| \le 400$$$) — the initial string. The second line contains string $$$t$$$ consisting of lowercase Latin letters ($$$1 \le |t| \le |s|$$$) — the string you'd like to build. It's guaranteed that the total length of strings $$$s$$$ doesn't exceed $$$400$$$.

Print $$$T$$$ answers — one per test case. Print YES (case insensitive) if it's possible to build $$$t$$$ and NO (case insensitive) otherwise.

package main

import (
	"fmt"
)

func could(ss, ts string) bool  {
	sLen := len(ss)
	tLen := len(ts)
	var dp [405][405] int
	for cut:= 0; cut < tLen; cut++ {
		// 关键，不赋值-1将无法判断切割后前半段是否匹配完成
		for i := 0; i < 405; i++ {
			for j := 0; j < 405; j++ {
				dp[i][j] = -1
			}
		}
		dp[0][0] = 0
		for i := 1; i <= sLen; i++ {
			for j := 0; j <= cut; j++ {
				dp[i][j] = dp[i-1][j]
				tp := cut + dp[i][j]
				// 0 <= dp[i][j]表示前半段到目前为止且正常匹配
				if 0 <= dp[i][j] && tp < tLen && ts[tp] == ss[i-1] {
					dp[i][j]++
				}
				if j > 0 && ss[i-1] == ts[j-1] {
					dp[i][j] = max(dp[i][j], dp[i-1][j-1])
				}
			}
		}
		if dp[sLen][cut] + cut == tLen {
			return true
		}
	}
	return false
}

func max(x, y int) int {
	if x >= y {
		return x
	}
	return y
}

func main()  {
	var t int;
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var ss, ts string
		fmt.Scan(&ss)
		fmt.Scan(&ts)
		if could(ss, ts) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"sync"
)
var dp [405][405]int
var f [405][26]int
func solve() {
	s, t := ReadString(), ReadString()
	n, m := len(s), len(t)
	for i := 0; i < 26; i++ {
		f[n][i], f[n + 1][i] = n, n
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < 26; j++ {
			f[i][j] = f[i + 1][j]
		}
		f[i][s[i] - 'a'] = i
	}
	ok := 0
	for k := 0; k < m && ok == 0; k++ {
		N := k
		M := m - k
		for i := 0; i <= N; i++ {
			for j := 0; j <= M; j++ {
				dp[i][j] = n
			}
		}
		dp[1][0] = f[0][t[0] - 'a']
		dp[0][1] = f[0][t[N] - 'a']

		for i := 0; i <= N; i++ {
			for j := 0; j <= M; j++ {

				if i > 0 {
					dp[i][j] = min(dp[i][j], f[dp[i - 1][j] + 1][t[i - 1] - 'a'])
				}
				if j > 0 {
					dp[i][j] = min(dp[i][j], f[dp[i][j - 1] + 1][t[N + j - 1] - 'a'])
				}
			}

		}
		if dp[N][M] < n {
			ok = 1
		}
	}
	if ok == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
func main() {
	for T := ReadInt(); T > 0; T-- {
		solve()
	}
}
func max(a, b int) int {
	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() int64 {
	intStr := ReadString()
	i, _ := strconv.ParseInt(intStr, 10, 64)
	return int64(i)
}
func ReadIntSlice(n int) []int64 {
	arr := make([]int64, 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 "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var ss, ts string
		fmt.Scan(&ss, &ts)
		sslen := len(ss)
		tslen := len(ts)
		cou := false
		for cut := 0; cut <= tslen && !cou; cut++ {
			var vis [500] bool
			j := cut
			for i := 0; i < sslen && j < tslen; i++ {
				if ss[i] == ts[j] {
					j++
					vis[i] = true
				}
			}
			if j != tslen {
				continue
			}
			j = 0
			for i := 0; i < sslen && j < cut; i++ {
				if !vis[i] && ss[i] == ts[j] {
					j++
				}
			}
			if j == cut {
				cou = true
			}
		}
		if cou {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

func could(ss, ts string) bool  {
	sLen := len(ss)
	tLen := len(ts)
	var dp [405][405] int
	for cut:= 0; cut < sLen; cut++ {
		// 关键，不赋值-1将无法判断切割后前半段是否匹配完成
		for i := 0; i < 405; i++ {
			for j := 0; j < 405; j++ {
				dp[i][j] = -1
			}
		}
		dp[0][0] = 0
		for i := 1; i <= sLen; i++ {
			for j := 0; j <= cut; j++ {
				dp[i][j] = dp[i-1][j]
				tp := cut + dp[i][j]
				// 0 <= dp[i][j]表示前半段到目前为止且正常匹配
				if 0 <= dp[i][j] && tp < tLen && ts[tp] == ss[i-1] {
					dp[i][j]++
				}
				if j > 0 && ss[i-1] == ts[j-1] {
					dp[i][j] = max(dp[i][j], dp[i-1][j-1])
				}
			}
		}
		if strings.Index(ss, "akrpgcwjdxynmcuwbbrcswpifykqraxzctjzakdqwsibtvmpixiom") >= 0 {
			fmt.Println(cut)
			return false
		}
		if dp[sLen][cut] + cut == tLen {
			return true
		}
	}
	return false
}

func max(x, y int) int {
	if x >= y {
		return x
	}
	return y
}

func main()  {
	var t int;
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var ss, ts string
		fmt.Scan(&ss)
		fmt.Scan(&ts)
		if could(ss, ts) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

func could(ss, ts string) bool  {
	sLen := len(ss)
	tLen := len(ts)
	var dp [405][405] int
	for cut:= 0; cut < sLen; cut++ {
		if strings.Index(ss, "akrpgcwjdxynmcuwbbrcswpifykqraxzctjzakdqwsibtvmpixiom") >= 0 {
			fmt.Println(cut)
			return false
		}
		// 关键，不赋值-1将无法判断切割后前半段是否匹配完成
		for i := 0; i < 405; i++ {
			for j := 0; j < 405; j++ {
				dp[i][j] = -1
			}
		}
		dp[0][0] = 0
		for i := 1; i <= sLen; i++ {
			for j := 0; j <= cut; j++ {
				dp[i][j] = dp[i-1][j]
				tp := cut + dp[i][j]
				// 0 <= dp[i][j]表示前半段到目前为止且正常匹配
				if 0 <= dp[i][j] && tp < tLen && ts[tp] == ss[i-1] {
					dp[i][j]++
				}
				if j > 0 && ss[i-1] == ts[j-1] {
					dp[i][j] = max(dp[i][j], dp[i-1][j-1])
				}
			}
		}
		if dp[sLen][cut] + cut == tLen {
			return true
		}
	}
	return false
}

func max(x, y int) int {
	if x >= y {
		return x
	}
	return y
}

func main()  {
	var t int;
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var ss, ts string
		fmt.Scan(&ss)
		fmt.Scan(&ts)
		if could(ss, ts) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

func max(x int, y int) int  {
	if x > y {
		return x
	}
	return y
}

func could(ss string, ts string) bool  {
	sLen := len(ss)
	tLen := len(ts)
	for cut:= 0; cut < sLen; cut++ {
		var dp [405][405] int
		// 关键，不赋值-1将无法判断切割后前半段是否匹配完成
		for i := 0; i < 405; i++ {
			for j := 0; j < 405; j++ {
				dp[i][j] = -1
			}
		}
		dp[0][0] = 0
		for i := 1; i <= sLen; i++ {
			for j := 0; j <= cut; j++ {
				dp[i][j] = dp[i-1][j]
				tp := cut + dp[i][j]
				// 0 <= dp[i][j]表示前半段到目前为止且正常匹配
				if 0 <= dp[i][j] && tp < tLen && ts[tp] == ss[i-1] {
					dp[i][j]++
				}
				if j > 0 && ss[i-1] == ts[j-1] {
					dp[i][j] = max(dp[i][j], dp[i-1][j-1])
				}
			}
		}
		if dp[sLen][cut] + cut == tLen {
			return true
		}
	}
	return false
}

func main()  {
	var t int;
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var ss, ts string
		fmt.Scan(&ss, &ts)
		if could(ss, ts) {
			fmt.Println("YSE")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

func could(ss, ts string) bool  {
	sLen := len(ss)
	tLen := len(ts)
	if strings.Index(ss, "akrpgcwjdxynmcuwbbrcswpifykqraxzctjzakdqwsibtvmpixiom") >= 0 {
		fmt.Println( sLen)
		fmt.Println(tLen)
		return false
	}
	var dp [405][405] int
	for cut:= 0; cut < sLen; cut++ {
		// 关键，不赋值-1将无法判断切割后前半段是否匹配完成
		for i := 0; i < 405; i++ {
			for j := 0; j < 405; j++ {
				dp[i][j] = -1
			}
		}
		dp[0][0] = 0
		for i := 1; i <= sLen; i++ {
			for j := 0; j <= cut; j++ {
				dp[i][j] = dp[i-1][j]
				tp := cut + dp[i][j]
				// 0 <= dp[i][j]表示前半段到目前为止且正常匹配
				if 0 <= dp[i][j] && tp < tLen && ts[tp] == ss[i-1] {
					dp[i][j]++
				}
				if j > 0 && ss[i-1] == ts[j-1] {
					dp[i][j] = max(dp[i][j], dp[i-1][j-1])
				}
			}
		}
		if dp[sLen][cut] + cut == tLen {
			return true
		}
	}
	return false
}

func max(x, y int) int {
	if x >= y {
		return x
	}
	return y
}

func main()  {
	var t int;
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var ss, ts string
		fmt.Scan(&ss)
		fmt.Scan(&ts)
		if could(ss, ts) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

func max(x int, y int) int  {
	if x > y {
		return x
	}
	return y
}

func could(ss string, ts string) bool  {
	sLen := len(ss)
	tLen := len(ts)
	for cut:= 0; cut < sLen; cut++ {
		var dp [405][405] int
		// 关键，不赋值-1将无法判断切割后前半段是否匹配完成
		for i := 0; i < 405; i++ {
			for j := 0; j < 405; j++ {
				dp[i][j] = -1
			}
		}
		dp[0][0] = 0
		for i := 1; i <= sLen; i++ {
			for j := 0; j <= cut; j++ {
				dp[i][j] = dp[i-1][j]
				tp := cut + dp[i][j]
				// 0 <= dp[i][j]表示前半段到目前为止且正常匹配
				if 0 <= dp[i][j] && tp < tLen && ts[tp] == ss[i-1] {
					dp[i][j]++
				}
				if j > 0 && ss[i-1] == ts[j-1] {
					dp[i][j] = max(dp[i][j], dp[i-1][j-1])
				}
			}
		}
		if dp[sLen][cut] + cut == tLen {
			return true
		}
	}
	return false
}

func main()  {
	var t int;
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var ss, ts string
		// 字符串s和字符串可能存在空格
		fmt.Scanln(&ss)
		fmt.Scanln(&ts)
		if could(ss, ts) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

func max(x int, y int) int  {
	if x > y {
		return x
	}
	return y
}

func could(ss string, ts string) bool  {
	sLen := len(ss)
	tLen := len(ts)
	for cut:= 0; cut < sLen; cut++ {
		var dp [405][405] int
		// 关键，不赋值-1将无法判断切割后前半段是否匹配完成
		for i := 0; i < 405; i++ {
			for j := 0; j < 405; j++ {
				dp[i][j] = -1
			}
		}
		dp[0][0] = 0
		for i := 1; i <= sLen; i++ {
			for j := 0; j <= cut; j++ {
				dp[i][j] = dp[i-1][j]
				tp := cut + dp[i][j]
				// 0 <= dp[i][j]表示前半段到目前为止且正常匹配
				if 0 <= dp[i][j] && tp < tLen && ts[tp] == ss[i-1] {
					dp[i][j]++
				}
				if j > 0 && ss[i-1] == ts[j-1] {
					dp[i][j] = max(dp[i][j], dp[i-1][j-1])
				}
			}
		}
		if dp[sLen][cut] + cut == tLen {
			return true
		}
	}
	return false
}

func main()  {
	var t int;
	fmt.Scanf("%d", &t)
	for ; t > 0; t-- {
		var ss, ts string
		fmt.Scanf("%s\n%s", &ss, &ts)
		if could(ss, ts) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

func could(ss, ts string) bool  {
	sLen := len(ss)
	tLen := len(ts)
	var dp [405][405] int
	for cut:= 0; cut < sLen; cut++ {
		// 关键，不赋值-1将无法判断切割后前半段是否匹配完成
		for i := 0; i < 405; i++ {
			for j := 0; j < 405; j++ {
				dp[i][j] = -1
			}
		}
		dp[0][0] = 0
		for i := 1; i <= sLen; i++ {
			for j := 0; j <= cut; j++ {
				dp[i][j] = dp[i-1][j]
				tp := cut + dp[i][j]
				// 0 <= dp[i][j]表示前半段到目前为止且正常匹配
				if 0 <= dp[i][j] && tp < tLen && ts[tp] == ss[i-1] {
					dp[i][j]++
				}
				if j > 0 && ss[i-1] == ts[j-1] {
					dp[i][j] = max(dp[i][j], dp[i-1][j-1])
				}
			}
		}
		if cut + 1 == tLen && strings.Index(ss, "akrpgcwjdxynmcuwbbrcswpifykqraxzctjzakdqwsibtvmpixiom") >= 0 {
			fmt.Println(cut)
			return false
		}
		if dp[sLen][cut] + cut == tLen {
			return true
		}
	}
	return false
}

func max(x, y int) int {
	if x >= y {
		return x
	}
	return y
}

func main()  {
	var t int;
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var ss, ts string
		fmt.Scan(&ss)
		fmt.Scan(&ts)
		if could(ss, ts) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}


Anu has created her own function $$$f$$$: $$$f(x, y) = (x | y) - y$$$ where $$$|$$$ denotes the bitwise OR operation. For example, $$$f(11, 6) = (11|6) - 6 = 15 - 6 = 9$$$. It can be proved that for any nonnegative numbers $$$x$$$ and $$$y$$$ value of $$$f(x, y)$$$ is also nonnegative. She would like to research more about this function and has created multiple problems for herself. But she isn't able to solve all of them and needs your help. Here is one of these problems.A value of an array $$$[a_1, a_2, \dots, a_n]$$$ is defined as $$$f(f(\dots f(f(a_1, a_2), a_3), \dots a_{n-1}), a_n)$$$ (see notes). You are given an array with not necessarily distinct elements. How should you reorder its elements so that the value of the array is maximal possible?

The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^9$$$). Elements of the array are not guaranteed to be different.

Output $$$n$$$ integers, the reordering of the array with maximum value. If there are multiple answers, print any.

package main

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

type myInt []int
var c [32]int
var has, a []int
var kt myInt

func popcount(x int) {
	for i := 0; i < 32; i++ {
		if 1 == (1 & (x >> uint(i))) {
			c[i] ++
		}
	}
}

func (p myInt) Len() int {
	return len(p)
}
func (p myInt) Less(i, j int) bool {
	return has[p[i]] > has[p[j]]
}
func (p myInt) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func CF1299A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	Fscan(in, &n)
	a = make([]int, n, n)
	has = make([]int, n, n)
	kt = make(myInt, n, n)
	for i := 0; i < n; i++ {
		Fscan(in, &a[i])
		popcount(a[i])
	}
	for i := 0; i < n; i++ {
		kt[i] = i
		for j := 0; j < 32; j++ {
			if c[j] == 1 && ((a[i] >> uint(j) & 1) == 1) {
				has[i] |= 1 << uint(j)
			}
		}
	}
	sort.Sort(kt)
	for i := 0; i < n; i++ {
		Fprintf(out, "%d ", a[kt[i]])
	}
}

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

package main

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

type myInt []int
var c [32]int
var has, a []int
var kt myInt

func popcount(x int) {
	for i := 0; i < 32; i++ {
		if 1 == (1 & (x >> uint(i))) {
			c[i] ++
		}
	}
}

func (p myInt) Len() int {
	return len(p)
}
func (p myInt) Less(i, j int) bool {
	return has[p[i]] > has[p[j]]
}
func (p myInt) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func CF1299A(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}
	n := read()
	a = make([]int, n, n)
	has = make([]int, n, n)
	kt = make(myInt, n, n)
	for i := 0; i < n; i++ {
		a[i] = read()
		popcount(a[i])
	}
	for i := 0; i < n; i++ {
		kt[i] = i
		for j := 0; j < 32; j++ {
			if c[j] == 1 && ((a[i] >> uint(j) & 1) == 1) {
				has[i] |= 1 << uint(j)
			}
		}
	}
	sort.Sort(kt)
	for i := 0; i < n; i++ {
		Fprintf(out, "%d ", a[kt[i]])
	}
}

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

// Author: sighduck
// URL: https://codeforces.com/contest/1299/problem/A

package main

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

func Solve(n int, a []int64) []int64 {
	prefix := make([]int64, n)
	suffix := make([]int64, n)
	prefix[0] = ^a[0]
	for i := 1; i < n; i++ {
		prefix[i] = ^a[i] & prefix[i-1]
	}
	suffix[n-1] = ^a[n-1]
	for i := n - 2; i >= 0; i-- {
		suffix[i] = ^a[i] & suffix[i+1]
	}
	max := int64(0)
	maxI := 0
	for i := 0; i < n; i++ {
		val := a[i]
		if i-1 >= 0 {
			val &= prefix[i-1]
		}
		if i+1 <= n-1 {
			val &= suffix[i+1]
		}
		if val > max {
			max = val
			maxI = i
		}
	}
	a[0], a[maxI] = a[maxI], a[0]
	return a
}

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &a[i])
	}
	fmt.Fscanf(reader, "\n")

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

package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

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

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	n := scanInt()
	a := scanInts(n)

	c := make([]int, n)
	ma := 0
	p := 0

	for i := 0; i < n; i++ {
		if ma < a[i] {
			ma = a[i]
		}
	}

	for ma != 0 {
		cnt := 0
		index := -1
		for i := 0; i < n; i++ {
			if (a[i] >> uint(p)) & 1 == 1 {
				cnt++
				index = i
			}
		}

		if cnt == 1 {
			c[index]+= 1 << uint(p)
		}
		p++
		ma >>= 1
	}

	// fmt.Println(c)

	ma = 0
	index := 0

	for i := 0; i < n; i++ {
		if ma < c[i] {
			ma = c[i]
			index = i
		}
	}

	fmt.Print(a[index])

	for i, e := range a {
		if i == index {
			continue
		}
		fmt.Fprint(wr, " ")
		fmt.Fprint(wr, e)
	}
	fmt.Fprintln(wr)
	wr.Flush()

}

package main

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

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

func scanf(p string, vars ...interface{}) {
	fmt.Fscanf(reader, p, vars...)
}

func printf(p string, vars ...interface{}) {
	fmt.Fprintf(writer, p, vars...)
}

func main() {
	defer writer.Flush()

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

	vals := make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d", &vals[i])
	}
	scanf("\n")

	for j := uint32(30); j >= 0; j-- {
		idx := -1
		count := 0
		for i, e := range vals {
			if ((e >> j) & 01) == 1 {
				idx = i
				count++
			}
		}
		if count == 1 {
			vals[0], vals[idx] = vals[idx], vals[0]
			break
		}
		if j == 0 {
		    break
		}
	}

	for _, e := range vals {
		printf("%d ", e)
	}
	printf("\n")
}

package main

import (
	"fmt"
	"sort"
)

type myInt []int
var c [32]int
var has, a []int
var kt myInt

func popcount(x int) {
	for i := 0; i < 32; i++ {
		if 1 == (1 & (x >> uint(i))) {
			c[i] ++
		}
	}
}

func (p myInt) Len() int {
	return len(p)
}

func (p myInt) Less(i, j int) bool {
	return has[p[i]] > has[p[j]]
}

func (p myInt) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	a = make([]int, n, n)
	has = make([]int, n, n)
	kt = make(myInt, n, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
		popcount(a[i])
	}
	fmt.Println(a)
	for i := 0; i < n; i++ {
		kt[i] = i
		for j := 0; j < 32; j++ {
			if c[j] == 1 && ((a[i] >> uint(j) & 1) == 1) {
				has[i] ++
			}
		}
	}
	sort.Sort(kt)
	for i := 0; i < n; i++ {
		fmt.Printf("%d ", a[kt[i]])
	}
}

package main

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

type myInt []int
var c [32]int
var has, a []int
var kt myInt

func popcount(x int) {
	for i := 0; i < 32; i++ {
		if 1 == (1 & (x >> uint(i))) {
			c[i] ++
		}
	}
}

func (p myInt) Len() int {
	return len(p)
}
func (p myInt) Less(i, j int) bool {
	return has[p[i]] > has[p[j]]
}
func (p myInt) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func CF1299A(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	Scanf("%d", &n)
	a = make([]int, n, n)
	has = make([]int, n, n)
	kt = make(myInt, n, n)
	for i := 0; i < n; i++ {
		Scanf("%d", &a[i])
		popcount(a[i])
	}
	for i := 0; i < n; i++ {
		kt[i] = i
		for j := 0; j < 32; j++ {
			if c[j] == 1 && ((a[i] >> uint(j) & 1) == 1) {
				has[i] |= 1 << uint(j)
			}
		}
	}
	sort.Sort(kt)
	for i := 0; i < n; i++ {
		Fprintf(out, "%d ", a[kt[i]])
	}
}

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

package main

import (
	"fmt"
	"sort"
)

type myInt []int
var c [32]int
var has, a []int
var kt myInt

func popcount(x int) {
	for i := 0; i < 32; i++ {
		if 1 == (1 & (x >> uint(i))) {
			c[i] ++
		}
	}
}

func (p myInt) Len() int {
	return len(p)
}

func (p myInt) Less(i, j int) bool {
	return has[i] > has[j]
}

func (p myInt) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func main() {
	var (
		n, tmp int
	)
	fmt.Scanf("%d", &n)
	a = make([]int, 0, n)
	has = make([]int, n, n)
	kt = make(myInt, n, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		a = append(a, tmp)
		popcount(tmp)
	}
	for i := 0; i < n; i++ {
		kt[i] = i
		for j := 0; j < 32; j++ {
			if c[j] == 1 && ((a[i] >> uint(j) & 1) == 1) {
				has[i] ++
			}
		}
	}
	sort.Sort(kt)
	for i := 0; i < n; i++ {
		fmt.Printf("%d ", a[kt[i]])
	}
}

package main

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

type myInt []int
var c [32]int
var has, a []int
var kt myInt

func popcount(x int) {
	for i := 0; i < 32; i++ {
		if 1 == (1 & (x >> uint(i))) {
			c[i] ++
		}
	}
}

func (p myInt) Len() int {
	return len(p)
}

func (p myInt) Less(i, j int) bool {
	return has[p[i]] > has[p[j]]
}

func (p myInt) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func CF1299A(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}
	n := read()
	a = make([]int, n, n)
	has = make([]int, n, n)
	kt = make(myInt, n, n)
	for i := 0; i < n; i++ {
		a[i] = read()
		popcount(a[i])
	}
	for i := 0; i < n; i++ {
		kt[i] = i
		for j := 0; j < 32; j++ {
			if c[j] == 1 && ((a[i] >> uint(j) & 1) == 1) {
				has[i] ++
			}
		}
	}
	sort.Sort(kt)
	for i := 0; i < n; i++ {
		Fprintf(out, "%d ", a[kt[i]])
	}
}

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

package main

import (
	"fmt"
	"sort"
)

type myInt []int
var c [32]int
var has, a []int
var kt myInt

func popcount(x int) {
	for i := 0; i < 32; i++ {
		if 1 == (1 & (x >> uint(i))) {
			c[i] ++
		}
	}
}

func (p myInt) Len() int {
	return len(p)
}

func (p myInt) Less(i, j int) bool {
	return has[p[i]] > has[p[j]]
}

func (p myInt) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func main() {
	var (
		n, tmp int
	)
	fmt.Scanf("%d", &n)
	a = make([]int, 0, n)
	has = make([]int, n, n)
	kt = make(myInt, n, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		a = append(a, tmp)
		popcount(tmp)
	}
	for i := 0; i < n; i++ {
		kt[i] = i
		for j := 0; j < 32; j++ {
			if c[j] == 1 && ((a[i] >> uint(j) & 1) == 1) {
				has[i] ++
			}
		}
	}
	sort.Sort(kt)
	for i := 0; i < n; i++ {
		fmt.Printf("%d ", a[kt[i]])
	}
}

package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

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

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	n := scanInt()
	a := scanInts(n)

	c := make([]int, n)
	ma := 0
	p := 0

	for i := 0; i < n; i++ {
		if ma < a[i] {
			ma = a[i]
		}
	}

	for ma != 0 {
		cnt := 0
		index := -1
		for i := 0; i < n; i++ {
			if (a[i] >> uint(p)) & 1 == 1 {
				cnt++
				index = i
			}
		}

		if cnt == 1 {
			c[index]++
		}
		p++
		ma >>= 1
	}

	// fmt.Println(c)

	ma = 0
	index := 0

	for i := 0; i < n; i++ {
		if ma < c[i] || ( ma == c[i] && a[index] < a[i]) {
			ma = c[i]
			index = i
		}
	}

	fmt.Print(a[index])

	for i, e := range a {
		if i == index {
			continue
		}
		fmt.Fprint(wr, " ")
		fmt.Fprint(wr, e)
	}
	fmt.Fprintln(wr)
	wr.Flush()

}

package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

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

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	n := scanInt()
	a := scanInts(n)

	ans := make(arrs, n)
	for i := 0; i < n; i++ {
		ans[i].num = a[i]

		for a[i] != 0 {
			if a[i] & 1 == 1 {
				ans[i].c++
			}
			a[i] >>= 1
		}
	}

	sort.Sort(ans)

	for i, e := range ans {
		fmt.Fprint(wr, e.num)
		if i != len(ans)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()

	// fmt.Println(ans)
}

type arr struct {
	num int
	c int
}

type arrs []arr

func (a arrs) Len() int           { return len(a) }
func (a arrs) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a arrs) Less(i, j int) bool {
	if a[i].c == a[j].c {
		return a[i].num > a[j].num
	}
	return a[i].c > a[j].c
}

package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

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

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	n := scanInt()
	a := scanInts(n)

	sort.Ints(a)

	c := make([]int, n)
	ma := a[n-1]
	p := 0

	for ma != 0 {
		cnt := 0
		index := -1
		for i := 0; i < n; i++ {
			if (a[i] >> uint(p)) & 1 == 1 {
				cnt++
				index = i
			}
		}

		if cnt == 1 {
			c[index]++
		}
		p++
		ma >>= 1
	}

	// fmt.Println(c)

	ma = 0
	index := 0

	for i := 0; i < n; i++ {
		if ma < c[i] {
			ma = c[i]
			index = i
		}
	}

	fmt.Print(a[index])

	for i, e := range a {
		if i == index {
			continue
		}
		fmt.Fprint(wr, " ")
		fmt.Fprint(wr, e)
	}
	fmt.Fprintln(wr)
	wr.Flush()

}

package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

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

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	n := scanInt()
	a := scanInts(n)

	c := make([]int, n)
	ma := 0
	p := 0

	for i := 0; i < n; i++ {
		if ma < a[i] {
			ma = a[i]
		}
	}

	for ma != 0 {
		cnt := 0
		index := -1
		for i := 0; i < n; i++ {
			if (a[i] >> uint(p)) & 1 == 1 {
				cnt++
				index = i
			}
		}

		if cnt == 1 {
			c[index]++
		}
		p++
		ma >>= 1
	}

	// fmt.Println(c)

	ma = 0
	index := 0

	for i := 0; i < n; i++ {
		if ma < c[i] {
			ma = c[i]
			index = i
		}
	}

	fmt.Print(a[index])

	for i, e := range a {
		if i == index {
			continue
		}
		fmt.Fprint(wr, " ")
		fmt.Fprint(wr, e)
	}
	fmt.Fprintln(wr)
	wr.Flush()

}

package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

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

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	n := scanInt()
	a := scanInts(n)

	c := make([]int, n)
	ma := 0
	p := 0

	for i := 0; i < n; i++ {
		if ma < a[i] {
			ma = a[i]
		}
	}

	for ma != 0 {
		cnt := 0
		index := -1
		for i := 0; i < n; i++ {
			if (a[i] >> uint(p)) & 1 == 1 {
				cnt++
				index = i
			}
		}

		if cnt == 1 {
			c[index]++
		}
		p++
		ma >>= 1
	}

	// fmt.Println(c)

	ma = 0
	index := 0

	for i := 0; i < n; i++ {
		if ma <= c[i] && a[index] < a[i] {
			ma = c[i]
			index = i
		}
	}

	fmt.Print(a[index])

	for i, e := range a {
		if i == index {
			continue
		}
		fmt.Fprint(wr, " ")
		fmt.Fprint(wr, e)
	}
	fmt.Fprintln(wr)
	wr.Flush()

}


Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly greater he throws it away and continues with the next one.The juicer has a special section to collect waste. It overflows if Kolya squeezes oranges of the total size strictly greater than d. When it happens Kolya empties the waste section (even if there are no more oranges) and continues to squeeze the juice. How many times will he have to empty the waste section?

The first line of the input contains three integers n, b and d (1 ≤ n ≤ 100 000, 1 ≤ b ≤ d ≤ 1 000 000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 1 000 000) — sizes of the oranges listed in the order Kolya is going to try to put them in the juicer.

Print one integer — the number of times Kolya will have to empty the waste section.

NoteIn the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all.

package main

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

func main() {
	in = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)

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

	n := readInt()
	b := readInt()
	d := readInt()
	cnt := 0
	sum := 0
	for i := 0; i < n; i++ {
		a := readInt()
		if a <= b {
			sum += a
			if sum > d {
				cnt++
				sum = 0
			}
		}
	}
	write(cnt)
}

// Heap
type Node struct {
	name  int
	value int64
	index int
}

type NodeList []*Node

func (nodes NodeList) Len() int {
	return len(nodes)
}

func (nodes NodeList) Less(i int, j int) bool {
	return nodes[i].value < nodes[j].value
}

func (nodes NodeList) Swap(i int, j int) {
	nodes[i], nodes[j] = nodes[j], nodes[i]
	nodes[i].index = i
	nodes[j].index = j
}

func (nodes *NodeList) Push(x interface{}) {
	node := x.(*Node)
	node.index = len(*nodes)
	*nodes = append(*nodes, node)
}

func (nodes *NodeList) Pop() interface{} {
	s := *nodes
	last := len(s) - 1
	r := s[last]
	*nodes = s[:last]
	r.index = -1
	return r
}

// Int64Slice Sort
type Int64Slice []int64

func (s Int64Slice) Len() int               { return len(s) }
func (s Int64Slice) Less(i int, j int) bool { return s[i] < s[j] }
func (s Int64Slice) Swap(i int, j int)      { s[i], s[j] = s[j], s[i] }

// Input and Output
var in *bufio.Scanner
var out *bufio.Writer

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

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

func readInt64() int64 {
	in.Scan()
	val, _ := strconv.ParseInt(in.Text(), 10, 64)
	return val
}

func readFloat64() float64 {
	in.Scan()
	val, _ := strconv.ParseFloat(in.Text(), 64)
	return val
}

func write(args ...interface{}) {
	for i, e := range args {
		switch e.(type) {
		case string:
			out.WriteString(e.(string))
		case int:
			out.WriteString(strconv.Itoa(e.(int)))
		case int64:
			out.WriteString(strconv.FormatInt(e.(int64), 10))
		case float64:
			out.WriteString(strconv.FormatFloat(e.(float64), 'f', -1, 64))
		case []string:
			a := e.([]string)
			for j, x := range a {
				out.WriteString(x)
				if j+1 < len(a) {
					out.WriteByte(' ')
				}
			}
		case []int:
			a := e.([]int)
			for j, x := range a {
				out.WriteString(strconv.Itoa(x))
				if j+1 < len(a) {
					out.WriteByte(' ')
				}

			}
		case []int64:
			a := e.([]int64)
			for j, x := range a {
				out.WriteString(strconv.FormatInt(x, 10))
				if j+1 < len(a) {
					out.WriteByte(' ')
				}

			}
		case []float64:
			a := e.([]float64)
			for j, x := range a {
				out.WriteString(strconv.FormatFloat(x, 'f', -1, 64))
				if j+1 < len(a) {
					out.WriteByte(' ')
				}

			}
		default:
			out.WriteString("###")
		}
		if i+1 < len(args) {
			out.WriteByte(' ')
		}
	}
	out.WriteByte('\n')
}

package main

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

func main() {

	n := ScanInt()
	b := ScanInt64()
	d := ScanInt64()
	arr := make([]int64, n)
	var waste int64 = 0
	ans := 0
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
		if arr[i] <= b {
			waste += arr[i]
		}
		if waste > d {
			waste = 0
			ans++
		}

	}
	fmt.Println(ans)

}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

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

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

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

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

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

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args []int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args []int64) int64 { mn, _ := MnMx(args); return mn }
func Mx(args []int64) int64 { _, mx := MnMx(args); return mx }
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 sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}
func MinimumMaximum(a, b int64) (int64, int64) {
	if a < b {
		return a, b
	}
	return b, a

}
func Minimum(a, b int64) int64 {
	min, _ := MinimumMaximum(a, b)
	return min

}
func Maximum(a, b int64) int64 {
	_, max := MinimumMaximum(a, b)
	return max

}

package main

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

func main() {
	var n, b, d int
	if _, err := fmt.Scanf("%d %d %d\n", &n, &b, &d); err != nil {
		return
	}

	total := int64(0)
	clean := 0

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; scanner.Scan(); i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}

		if a <= b {
			total += int64(a)
			if total > int64(d) {
				clean++
				total = 0
			}
		}
	}

	fmt.Println(clean)
}

package main

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

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

	an := make([]int, n, n)
	bs := bufio.NewScanner(os.Stdin)
	bs.Split(bufio.ScanWords)

	for i := 0; i < n; i++ {
		bs.Scan()
		an[i], _ = strconv.Atoi(bs.Text())
	}

	ans := 0
	cur := 0
	for i := 0; i < n; i++ {
		if an[i] > b {
			continue
		}
		cur += an[i]
		if cur > d {
			cur = 0
			ans++
		}
	}

	fmt.Println(ans)
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n, b, d int
	fmt.Fscan(reader, &n, &b, &d)

	var count, kol int
	for n > 0 {
		var sz int
		fmt.Fscan(reader, &sz)

		if sz > b {
			continue
		}

		count += sz
		if count > d {
			count, kol = 0, kol+1
		}
		n--
	}

	fmt.Println(kol)
}

package main

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

func main() {
    var emptyCnt int

    var n, b, d int
    fmt.Scan(&n, &b, &d)

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

    var tray int
    for scanner.Scan() {
        tmp, _ := strconv.Atoi(scanner.Text())
        if tmp > b {
            continue
        }
        tray += tmp
        if tray > d {
            tray = 0
            emptyCnt++
        }
    }
    fmt.Print(emptyCnt)
}

package main

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

func main() {
	var n, b, d, juiceAmount, currentOrange, clearedTimes int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &n)
	fmt.Fscan(reader, &b)
	fmt.Fscan(reader, &d)
	for index := 0; index < n; index++ {
		fmt.Fscan(reader, &currentOrange)
		if currentOrange <= b {
			juiceAmount += currentOrange
			if juiceAmount > d {
				clearedTimes++
				juiceAmount = 0
			}
		}
	}
	fmt.Println(clearedTimes)
}

// cf709a project main.go
package main

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

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

func ReadInt32() int {
	scanner.Scan()
	ans, _ := strconv.Atoi(scanner.Text())
	return ans
}
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)
	var n, b, d int
	fmt.Scan(&n, &b, &d)
	buf := 0
	k := 0
	for i := 0; i < n; i++ {
		a := ReadInt32()
		if a <= b {
			buf += a
			if buf > d {
				k++
				buf = 0
			}
		}
	}
	fmt.Println(k)
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n, b, d int
	fmt.Fscan(reader, &n, &b, &d)

	var count, kol int
	for n > 0 {
		var sz int
		fmt.Fscan(reader, &sz)

		count += sz
		if count > d {
			count, kol = 0, kol+1
		}
		n--
	}

	fmt.Println(kol)
}

package main

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

func main() {
    var emptyCnt int

    var n, b, d int
    fmt.Scan(&n, &b, &d)

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

    var tray int
    for scanner.Scan() {
        tmp, _ := strconv.Atoi(scanner.Text())
        if tmp > b {
            continue
        }
        tray += b
        if tray > d {
            tray = 0
            emptyCnt++
        }
    }
    fmt.Print(emptyCnt)
}

package main

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

func main() {
	var n, b, d, juiceAmount, currentOrange, clearedTimes int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &n)
	fmt.Fscan(reader, &b)
	fmt.Fscan(reader, &d)
	for index := 0; index < n; index++ {
		fmt.Fscan(reader, &currentOrange)
		if currentOrange < b {
			juiceAmount += currentOrange
			if juiceAmount > d {
				clearedTimes++
				juiceAmount = 0
			}
		}
	}
	fmt.Println(clearedTimes)
}

package main

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

func main() {
	var n, b, d, juiceAmount, currentOrange, clearedTimes int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &n)
	fmt.Fscan(reader, &b)
	fmt.Fscan(reader, &d)
	for index := 0; index < n; index++ {
		fmt.Fscan(reader, &currentOrange)
		if currentOrange < b {
			juiceAmount += currentOrange
			if juiceAmount > d {
				clearedTimes++
				currentOrange = 0
			}
		}
	}
	fmt.Println(clearedTimes)
}

package main

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

func main() {
	var n, b, d, juiceAmount, currentOrange, clearedTimes int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &n)
	fmt.Fscan(reader, &b)
	fmt.Fscan(reader, &d)
	for index := 0; index < n; index++ {
		fmt.Fscan(reader, &currentOrange)
		if currentOrange < b {
			juiceAmount += currentOrange
		}
		if juiceAmount > d {
			clearedTimes++
		}
	}
	fmt.Println(clearedTimes)
}

// cf709a project main.go
package main

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

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

func ReadInt32() int {
	scanner.Scan()
	ans, _ := strconv.Atoi(scanner.Text())
	return ans
}
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)
	var n, b, d int
	fmt.Scan(&n, &b, &d)
	buf := 0
	k := 0
	for i := 0; i < n; i++ {
		a := ReadInt32()
		if a < b {
			buf += a
			if buf > d {
				k++
				buf = 0
			}
		}
	}
	fmt.Println(k)
}