package main

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

type BfsNode struct {
	Node, Count int
}

func dfs(node int, adj [][]int) int {
	seen := make([]bool, len(adj))
	maxCount := 0
	var bestNode int

	var dfsInner func(int, int)
	dfsInner = func(node int, count int) {
		seen[node] = true
		count += 1

		for _, neighbour := range adj[node] {
			if seen[neighbour] {
				continue
			}

			// update furthest node
			if count > maxCount {
				maxCount = count
				bestNode = neighbour
			}

			dfsInner(neighbour, count)
		}
	}

	// call recursive inner
	dfsInner(node, 0)
	return bestNode
}

func path(a int, b int, adj [][]int) []int {
	// run dfs from a
	seen := make([]bool, len(adj))
	path := make([]int, 0, 2) // source and destination

	var dfsInner func(int) bool
	dfsInner = func(node int) bool {
		seen[node] = true

		if node == b {
			path = append(path, node)
			return true
		}

		for _, neighbour := range adj[node] {
			if seen[neighbour] {
				continue
			}

			if dfsInner(neighbour) {
				path = append(path, node)
				return true
			}
		}

		return false
	}

	dfsInner(a)
	return path
}

func bfs(node int, adj [][]int) (int, int) {
	seen := make([]bool, len(adj))
	q := []BfsNode{BfsNode{node, 0}}
	count := 0

	for len(q) > 0 {
		cur := q[0]
		q = q[1:]
		if seen[cur.Node] {
			continue
		}
		node = cur.Node
		count = cur.Count
		seen[node] = true

		for _, neighbour := range adj[node] {
			if seen[neighbour] {
				continue
			}

			q = append(q, BfsNode{neighbour, count + 1})
		}
	}

	return node, count
}

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

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

	adj := make([][]int, n+1)
	for i := 0; i < n; i++ {
		adj[i+1] = make([]int, 0)
	}

	for i := 0; i < n-1; i++ {
		scanner.Scan()
		a, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		b, _ := strconv.Atoi(scanner.Text())

		adj[a] = append(adj[a], b)
		adj[b] = append(adj[b], a)
	}

	// find first leaf by dfs
	leaf := dfs(1, adj)
	// find opposite node to leaf
	opp := dfs(leaf, adj)

	// get the diameter path
	diam := path(leaf, opp, adj)

	// run bfs from diameter nodes to find the furthest node from all
	// use a new virtual node for multiple source
	adj = append(adj, diam)
	third, dist := bfs(n+1, adj)

	// if the diameter spans the whole tree, bfs will give us one of the ends
	// so just pick any node that isn't one of those two
	for third == leaf || third == opp {
		third += 1
		if third > n {
			third = 1
		}
	}

	// edges on diameter = nodes - 1
	// distance from diameter - virtual node
	ans := len(diam) + dist - 2
	if ans >= n {
		ans = n - 1 // can't be any larger than the number of edges!
	}

	fmt.Println(ans)
	fmt.Println(leaf, opp, third)
}

package main

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

var stdin_bytes []byte

func read_int() int {
    if len(stdin_bytes) == 0 {
        stdin_bytes, _ = ioutil.ReadAll(os.Stdin)
    }
    for !('0' <= stdin_bytes[0] && stdin_bytes[0] <= '9') {
        stdin_bytes = stdin_bytes[1:]
    }
    x := 0
    for '0' <= stdin_bytes[0] && stdin_bytes[0] <= '9' {
        x = 10 * x + int(stdin_bytes[0] - '0')
        stdin_bytes = stdin_bytes[1:]
    }
    return x
}

func read_tree() [][]int {
    num_nodes := read_int()
    graph := make([][]int, num_nodes)
    for i := 0; i < (num_nodes - 1); i++ {
        n1 := read_int() - 1
        n2 := read_int() - 1
        graph[n1] = append(graph[n1], n2)
        graph[n2] = append(graph[n2], n1)
    }
    return graph
}

func bfs(graph [][]int, start_node int) []int {
    distances := make([]int, len(graph))
    for i := 0; i < len(graph); i++ {
        distances[i] = -1;
    }
    distances[start_node] = 0;
    queue := make([]int, 0, len(graph))
    queue = append(queue, start_node)
    for len(queue) > 0 {
        current_node := queue[0]
        queue = queue[1:]
        for _, neighbor := range graph[current_node] {
            if distances[neighbor] == -1 {
                distances[neighbor] = distances[current_node] + 1;
                queue = append(queue, neighbor)
            }
        }
    }
    return distances
}

func max_distance_node(distances []int, exclude_nodes []int) (
            node int, distance int) {
    best_node, max_distance := -1, -1
    for node, distance := range distances {
        if max_distance == -1 || distance > max_distance {
            excluded := false
            for _, excluded_node := range(exclude_nodes) {
                if node == excluded_node {
                    excluded = true
                    break
                }
            }
            if !excluded {
                best_node, max_distance = node, distance
            }
        }
    }
    return best_node, max_distance
}

func sum_distances(distances_a []int, distances_b []int) []int {
    distances_sum := make([]int, len(distances_a))
    for i, da := range(distances_a) {
        distances_sum[i] = da + distances_b[i]
    }
    return distances_sum
}

func main() {
    //~ start := time.Now()
    tree := read_tree()
    //~ fmt.Printf("read: %s\n", time.Since(start))
    //~ start = time.Now()
    //~ fmt.Println(tree)
    distances_0 := bfs(tree, 0)
    node_a, _ := max_distance_node(distances_0, []int{})
    distances_a := bfs(tree, node_a)
    node_b, dist_a_b := max_distance_node(distances_a, []int{})
    distances_b := bfs(tree, node_b)
    distances_sum := sum_distances(distances_a, distances_b)
    node_c, dist_c_ab := max_distance_node(distances_sum,
                                           []int{node_a, node_b})
    num_edges := (dist_a_b + dist_c_ab) / 2
    //~ fmt.Printf("compute: %s\n", time.Since(start))
    fmt.Println(num_edges)
    fmt.Println(node_a + 1, node_b + 1, node_c + 1)
}

package main

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

type edge struct {
    u int
    v int
}

var stdin_bytes []byte

func read_int() int {
    if len(stdin_bytes) == 0 {
        stdin_bytes, _ = ioutil.ReadAll(os.Stdin)
    }
    for !('0' <= stdin_bytes[0] && stdin_bytes[0] <= '9') {
        stdin_bytes = stdin_bytes[1:]
    }
    x := 0
    for '0' <= stdin_bytes[0] && stdin_bytes[0] <= '9' {
        x = 10 * x + int(stdin_bytes[0] - '0')
        stdin_bytes = stdin_bytes[1:]
    }
    return x
}

func read_edges() (num_nodes int, edges []edge) {
    num_nodes = read_int()
    edges = make([]edge, num_nodes - 1)
    for i := 0; i < (num_nodes - 1); i++ {
        u, v := read_int() - 1, read_int() - 1
        edges[i] = edge {u, v}
    }
    return num_nodes, edges
}

func compute_degrees(num_nodes int, edges []edge) []int {
    degrees := make([]int, num_nodes)
    for _, e := range edges {
        degrees[e.u] += 1
        degrees[e.v] += 1
    }
    return degrees
}

func build_graph(degrees []int, edges []edge) [][]int {
    start := 0
    starts := make([]int, len(degrees))
    for node, degree := range degrees {
        starts[node] = start
        start += degree
    }
    ends := make([]int, len(degrees))
    copy(ends, starts)
    //~ fmt.Println(degrees, starts, ends)
    graph := make([]int, 2 * len(degrees))
    for _, e := range edges {
        graph[ends[e.u]] = e.v
        ends[e.u] += 1
        graph[ends[e.v]] = e.u
        ends[e.v] += 1
    }
    graph_sliced := make([][]int, len(degrees))
    for node, start := range starts {
        end := ends[node]
        graph_sliced[node] = graph[start:end]
    }
    return graph_sliced
}

func bfs(graph [][]int, start_node int) []int {
    distances := make([]int, len(graph))
    for i := 0; i < len(graph); i++ {
        distances[i] = -1;
    }
    distances[start_node] = 0;
    queue := make([]int, 0, len(graph))
    queue = append(queue, start_node)
    for len(queue) > 0 {
        current_node := queue[0]
        queue = queue[1:]
        for _, neighbor := range graph[current_node] {
            if distances[neighbor] == -1 {
                distances[neighbor] = distances[current_node] + 1;
                queue = append(queue, neighbor)
            }
        }
    }
    return distances
}

func max_distance_node(distances []int, exclude_nodes []int) (
            node int, distance int) {
    best_node, max_distance := -1, -1
    for node, distance := range distances {
        if max_distance == -1 || distance > max_distance {
            excluded := false
            for _, excluded_node := range(exclude_nodes) {
                if node == excluded_node {
                    excluded = true
                    break
                }
            }
            if !excluded {
                best_node, max_distance = node, distance
            }
        }
    }
    return best_node, max_distance
}

func sum_distances(distances_a []int, distances_b []int) []int {
    distances_sum := make([]int, len(distances_a))
    for i, da := range(distances_a) {
        distances_sum[i] = da + distances_b[i]
    }
    return distances_sum
}

func main() {
    //~ start := time.Now()
    num_nodes, edges := read_edges()
    //~ fmt.Println(num_nodes, edges)
    degrees := compute_degrees(num_nodes, edges)
    tree := build_graph(degrees, edges)
    //~ fmt.Printf("read: %s\n", time.Since(start))
    //~ start = time.Now()
    //~ fmt.Println(tree)
    distances_0 := bfs(tree, 0)
    node_a, _ := max_distance_node(distances_0, []int{})
    distances_a := bfs(tree, node_a)
    node_b, dist_a_b := max_distance_node(distances_a, []int{})
    distances_b := bfs(tree, node_b)
    distances_sum := sum_distances(distances_a, distances_b)
    node_c, dist_c_ab := max_distance_node(distances_sum,
                                           []int{node_a, node_b})
    num_edges := (dist_a_b + dist_c_ab) / 2
    //~ fmt.Printf("compute: %s\n", time.Since(start))
    fmt.Println(num_edges)
    fmt.Println(node_a + 1, node_b + 1, node_c + 1)
}

package main

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

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

	var n int
	fmt.Fscanf(r, "%d\n", &n)

	t := make(map[int][]int)
	for i := 0; i < n-1; i++ {
		var u, v int
		fmt.Fscanf(r, "%d %d\n", &u, &v)
		t[u] = append(t[u], v)
		t[v] = append(t[v], u)
	}

	a, b, c, d := findBest3Points(t)
	fmt.Printf("%d\n%d %d %d\n", d, a, b, c)
}

type T struct {
	t    map[int][]int
	dist map[int]int
	par  map[int]int
}

func newTree(tree map[int][]int) *T {
	t := new(T)
	t.t = tree
	t.dist = make(map[int]int)
	t.par = make(map[int]int)
	return t
}

func (t *T) init() {
	t.dist = make(map[int]int)
	t.par = make(map[int]int)
}

func findBest3Points(tree map[int][]int) (int, int, int, int) {
	t := newTree(tree)

	r, _ := t.dfs(1, 0)
	leaf, diam := t.dfs(r, 0)

	inChain := make(map[int]bool)

	cur := leaf
	for cur != r {
		inChain[cur] = true
		cur = t.par[cur]
	}
	inChain[r] = true

	furthest, x := 0, t.par[leaf]

	cur = leaf
	for cur != r {
		for _, ch := range t.t[cur] {
			if inChain[ch] {
				continue
			}
			y, d := t.dfs(ch, cur)
			if furthest < d+1 {
				furthest = d + 1
				x = y
			}
		}
		cur = t.par[cur]
	}

	return r, leaf, x, diam + furthest
}

func (t *T) dfs(r, p int) (int, int) {
	t.par[r] = p

	longest, x := 0, r
	for _, ch := range t.t[r] {
		if ch != p {
			leaf, d := t.dfs(ch, r)
			if longest < d+1 {
				longest = d + 1
				x = leaf
			}
		}
	}

	return x, longest
}

package main

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

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

	var n, v, w, u, maxD, ans int
	Fscan(in, &n)
	g := make([][]int, n)
	for i := 0; i < n-1; i++ {
		Fscan(in, &v, &w)
		v--
		w--
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	var f func(v, fa, d int)
	f = func(v, fa, d int) {
		if d > maxD {
			maxD = d
			u = v
		}
		for _, w := range g[v] {
			if w != fa {
				f(w, v, d+1)
			}
		}
	}
	maxD = -1
	f(0, -1, 0)
	dv := u
	maxD = -1
	f(dv, -1, 0)
	dw := u

	onPath := make([]bool, n)
	var f2 func(v, fa int) bool
	f2 = func(v, fa int) bool {
		if v == dw {
			onPath[v] = true
			return true
		}
		for _, w := range g[v] {
			if w != fa {
				if f2(w, v) {
					onPath[v] = true
					ans++
					return true
				}
			}
		}
		return false
	}
	f2(dv, -1)

	maxD = 0
	u = -1
	f = func(v, fa, d int) {
		if d > maxD {
			maxD = d
			u = v
		}
		for _, w := range g[v] {
			if w != fa {
				if onPath[w] {
					f(w, v, 0)
				} else {
					f(w, v, d+1)
				}
			}
		}
	}
	f(dv, -1, 0)
	if u == -1 {
		if dv > dw {
			dv, dw = dw, dv
		}
		u = 0
		if dv == 0 {
			u = 1
		}
		if dw == 1 {
			u = 2
		}
	}
	Fprintln(out, ans+maxD)
	Fprintln(out, dv+1, dw+1, u+1)
}

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

package main

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

type BfsNode struct {
	Node, Count int
}

func dfs(node int, adj [][]int) int {
	seen := make([]bool, len(adj))
	maxCount := 0
	var bestNode int

	var dfsInner func(int, int)
	dfsInner = func(node int, count int) {
		seen[node] = true
		count += 1

		for _, neighbour := range adj[node] {
			if seen[neighbour] {
				continue
			}

			// update furthest node
			if count > maxCount {
				maxCount = count
				bestNode = neighbour
			}

			dfsInner(neighbour, count)
		}
	}

	// call recursive inner
	dfsInner(node, 0)
	return bestNode
}

func path(a int, b int, adj [][]int) []int {
	// run dfs from a
	seen := make([]bool, len(adj))
	path := make([]int, 0, 2) // source and destination

	var dfsInner func(int) bool
	dfsInner = func(node int) bool {
		seen[node] = true

		if node == b {
			path = append(path, node)
			return true
		}

		for _, neighbour := range adj[node] {
			if seen[neighbour] {
				continue
			}

			if dfsInner(neighbour) {
				path = append(path, node)
				return true
			}
		}

		return false
	}

	dfsInner(a)
	return path
}

func bfs(node int, adj [][]int) (int, int) {
	seen := make([]bool, len(adj))
	q := []BfsNode{BfsNode{node, 0}}
	count := 0

	for len(q) > 0 {
		cur := q[0]
		q = q[1:]
		if seen[cur.Node] {
			continue
		}
		node = cur.Node
		count = cur.Count
		seen[node] = true

		for _, neighbour := range adj[node] {
			if seen[neighbour] {
				continue
			}

			q = append(q, BfsNode{neighbour, count + 1})
		}
	}

	return node, count
}

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

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

	adj := make([][]int, n+1)
	for i := 0; i < n; i++ {
		adj[i+1] = make([]int, 0)
	}

	for i := 0; i < n-1; i++ {
		scanner.Scan()
		a, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		b, _ := strconv.Atoi(scanner.Text())

		adj[a] = append(adj[a], b)
		adj[b] = append(adj[b], a)
	}

	// find first leaf by dfs
	leaf := dfs(1, adj)
	// find opposite node to leaf
	opp := dfs(leaf, adj)

	// get the diameter path
	diam := path(leaf, opp, adj)

	// run bfs from diameter nodes to find the furthest node from all
	// use a new virtual node for multiple source
	adj = append(adj, diam)
	third, dist := bfs(n+1, adj)

	// edges on diameter = nodes - 1
	// distance from diameter - virtual node
	ans := len(diam) + dist - 2
	if ans >= n {
		ans = n - 1 // can't be any larger than the number of edges!
	}

	fmt.Println(ans)
	fmt.Println(leaf, opp, third)
}

package main

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

var stdin_bytes []byte

func read_int() int {
    if len(stdin_bytes) == 0 {
        stdin_bytes, _ = ioutil.ReadAll(os.Stdin)
    }
    for !('0' <= stdin_bytes[0] && stdin_bytes[0] <= '9') {
        stdin_bytes = stdin_bytes[1:]
    }
    x := 0
    for '0' <= stdin_bytes[0] && stdin_bytes[0] <= '9' {
        x = 10 * x + int(stdin_bytes[0] - '0')
        stdin_bytes = stdin_bytes[1:]
    }
    return x
}

func read_tree() [][]int {
    num_nodes := read_int()
    graph := make([][]int, num_nodes)
    for i := 0; i < (num_nodes - 1); i++ {
        n1 := read_int() - 1
        n2 := read_int() - 1
        graph[n1] = append(graph[n1], n2)
        graph[n2] = append(graph[n2], n1)
    }
    return graph
}

func bfs(graph [][]int, start_node int) []int {
    distances := make([]int, len(graph))
    for i := 0; i < len(graph); i++ {
        distances[i] = -1;
    }
    distances[start_node] = 0;
    queue := make([]int, 0, len(graph))
    queue = append(queue, start_node)
    for len(queue) > 0 {
        current_node := queue[0]
        queue = queue[1:]
        for _, neighbor := range graph[current_node] {
            if distances[neighbor] == -1 {
                distances[neighbor] = distances[current_node] + 1;
                queue = append(queue, neighbor)
            }
        }
    }
    return distances
}

func max_distance_node(distances []int, exclude_nodes []int) (
            node int, distance int) {
    best_node, max_distance := -1, -1
    for node, distance := range distances {
        if max_distance == -1 || distance > max_distance {
            excluded := false
            for _, excluded_node := range(exclude_nodes) {
                if node == excluded_node {
                    excluded = true
                    break
                }
            }
            if !excluded {
                best_node, max_distance = node, distance
            }
        }
    }
    return best_node, max_distance
}

func sum_distances(distances_a []int, distances_b []int) []int {
    distances_sum := make([]int, len(distances_a))
    for i, da := range(distances_a) {
        distances_sum[i] = da + distances_b[i]
    }
    return distances_sum
}

func main() {
    //~ start := time.Now()
    tree := read_tree()
    //~ fmt.Printf("read: %s\n", time.Since(start))
    //~ start = time.Now()
    //~ fmt.Println(tree)
    distances_0 := bfs(tree, 0)
    node_a, _ := max_distance_node(distances_0, []int{})
    distances_a := bfs(tree, node_a)
    node_b, dist_a_b := max_distance_node(distances_a, []int{})
    distances_b := bfs(tree, node_b)
    distances_sum := sum_distances(distances_a, distances_b)
    node_c, dist_c_ab := max_distance_node(distances_sum,
                                           []int{node_a, node_b})
    num_edges := (dist_a_b + dist_c_ab) / 2
    //~ fmt.Printf("compute: %s\n", time.Since(start))
    fmt.Println(num_edges)
    fmt.Println(node_a, node_b, node_c)
}


package main

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

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

	solve := func() (ans int) {
		var n, x int
		Fscan(in, &n, &x)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		sort.Ints(a)
		ans = x
		vis := make([]bool, 400)
	o:

		for {
			for _, v := range a {
				if vis[v] {
					  continue
				}

				if v <= ans {
					vis[v]=true
					ans++
					continue o
				}
			}
			break
		}
		for _, v := range a {
			vis[v]=true
		}
		for i:=ans+1;vis[i];i++{
			ans=i
		}

		return ans
	}

	var t int
	Fscan(in, &t)
	for _case := 1; _case <= t; _case++ {
		Fprintln(out, solve())
	}
}

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

package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

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

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

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

var sc = newScanner()

func main() {
	for t := scanInt(); t > 0; t-- {
		n, x := scanInt(), scanInt()
		a := scanInts(n)
		b := make([]bool, 1000)
		for i := 0; i < n; i++ {
			b[a[i]] = true
		}

		res := 0
		for i := 1; i < len(b); i++ {
			if b[i] {
				res = i
			} else if x > 0 {
				res = i
				x--
			} else {
				break
			}
		}
		fmt.Println(res)
	}
}

package main

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

var r__ *bufio.Reader = bufio.NewReader(os.Stdin)
var w__ *bufio.Writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{})  { fmt.Fscanf(r__, f, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(w__, f, a...) }
func fflush()                           { w__.Flush() }

func solve() {
	var n, x int
	var data [102]bool
	scanf("%d %d\n", &n, &x)

	for i := 0; i < n; i++ {
		var curr int
		scanf("%d", &curr)
		data[curr] = true
	}
	scanf("\n")

	i := 0
	for {
		i++

		if i > 100 {

			x--

			if x > 0 {
				continue

			} else {
				break
			}
		}

		curr := data[i]

		if !curr {
			data[i] = true
			x--

			if x == 0 {
				for data[i+1] {
					i = i + 1

				}
				break
			}

		} else {

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

}

func main() {
	defer fflush()

	var T, i uint64
	scanf("%d\n", &T)
	for i = 0; i < T; i++ {
		solve()
	}

}

package main

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

func main() {

	t := ScanInt()
	for ; t > 0; t-- {
		n := ScanInt()
		k := ScanInt()
		isUsed := make([]bool, 1000)
		for i := 0; i < n; i++ {
			isUsed[ScanInt()] = true
		}
		i := 1
		for ; k > 0; i++ {
			if isUsed[i] {
				continue
			}
			k--
		}
		for ; ; i++ {
			if !isUsed[i] {
				break
			}
		}
		fmt.Println(i-1)

	}
}

/*********************** 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"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
	"sync"
)

func main() {

	t := ScanInt()
	for ; t > 0; t-- {
		n := ScanInt()
		k := ScanInt()
		isUsed := make([]bool, 1000)
		for i := 0; i < n; i++ {
			isUsed[ScanInt()] = true
		}
		i := 1
		for ; ; i++ {
			if isUsed[i] {
				continue
			} else if k == 0 {
				break
			}
			k--
		}
		fmt.Println(i - 1)

	}
}

/*********************** 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"
	"sort"
	"strconv"
	"strings"
)

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 scanAllStr() (string, error) {
	str, err := reader.ReadString('\n')
	if err != nil {
		return "", err
	}
	return strings.TrimRight(str, "\n\r"), nil
}

func main() {
	var casesNumb byte
	scanf("%d\n", &casesNumb)

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

		strA, err := scanAllStr()
		if err != nil {
			panic(err)
		}

		aStrArr := strings.Split(strA, " ")
		a := make([]int, len(aStrArr))
		for i, strA := range aStrArr {
			var err error
			a[i], err = strconv.Atoi(strA)
			if err != nil {
				fmt.Println(err)
				panic(err)
			}
		}
		sort.Ints(a)

		previous := 0
		v := 0
		for _, place := range a {
			if place == previous {
				continue
			}
			if place-1 > previous+x {
				v = previous + x
				break
			}
			x -= place - previous - 1
			previous = place
		}
		if v == 0 {
			v = previous + x
		}

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

	writer.Flush()
}

package main

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

const MaxV = 201

var(
	achieve [MaxV]bool
)

func solve() {
	n, x := scanInt(), scanInt()
	for i := 1; i <= n + x; i++ {
		achieve[i] = false
	}
	for i := 1; i <= n; i++ {
		ranking := scanInt()
		achieve[ranking] = true
	}
	for k := n + x; k > 0; k-- {
		v := 0
		for i := 1; i <= k; i++ {
			if achieve[i] == false {
				v++
			}
		}
		if v <= x {
			_, _ = printFmt(k)
			return
		}
	}
}

func main() {
	T := scanInt()
	for ; T > 0; T-- {
		solve()
	}
}
/*********************** I/O ***********************/

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

func init() {
	printFmt = fmt.Println

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

	channelType = 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 channelType {
			_, _ = writer.WriteString(line + "\n")
		}
	}()
}

func scanString() string {in.Scan(); return in.Text() }
func scanInt() int {i, _ := strconv.Atoi(scanString()); return i}
func scanInt64() int64 {i, _ := strconv.ParseInt(scanString(), 10, 64); return i}
func scanStringSlice(n int) []string {s := make([]string, n); for i := 0; i < n; i++ {s[i] = scanString()}; 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 stringEquivalent(v interface{}) string {return fmt.Sprintf("%v", v)}
func spaceSeperatedStringFromArray(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 spaceSeperatedStringFromArray64(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 minMaxFromArray(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 minElementFromArray(args ...int64) int64 { mn, _ := minMaxFromArray(args...); return mn }
func maxElementFromArray(args ...int64) int64 { _, mx := minMaxFromArray(args...); return mx }
func lcmCalculation(a, b int64) int64 {return a / gcdCalculation(a, b) * b}
func gcdCalculation(a, b int64) int64 {if a == 0 {return b}; return gcdCalculation(b%a, a)}
func sortInt64Slice(a []int64) {sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })}
func absoluteValue(x int64) int64 {if x < 0 {return -x}; return x}
func min(args ...int) int { mn, _ := MnMx(args...); return mn }
func max(args ...int) int { _, mx := MnMx(args...); return mx }
func MnMx(args ...int) (int, int) {
	minVal, maxVal := math.MaxInt32, math.MinInt32
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}

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

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)
	T := NextInt()

	a := make([]int, 100010)
	for t := 0; t < T; t++ {
		n, x := NextInt(), NextInt()

		for i := 0; i < n; i++ {
			a[i] = NextInt()
		}
		sort.Ints(a[:n])
		last := 0
		for i := 0; i < n; i++ {
			// stderr("i", i, a[i], last, x)
			if a[i] == last+1 {
				last = a[i]
			} else if a[i] > last {
				t := min(max(a[i]-last-1, 0), x)
				x -= t
				last += t
				if a[i] == last+1 {
					last++
				}
				if last != a[i] {
					break
				}
			}
		}
		if x > 0 {
			last += x
		}
		fmt.Fprintln(out, last)
	}

}

package main

import "fmt"

func main() {
	var t, n, x int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		fmt.Scan(&n, &x)
		arr := make([]int, n)
		flag := make(map[int]bool)
		for j := 0; j < n; j++ {
			fmt.Scan(&arr[j])
			flag[arr[j]] = true
		}
		for j := n + x; j >= 0; j-- {
			var v int
			for k := 1; k <= j; k++ {
				if flag[k] == false {
					v++
				}
			}
			if v <= x {
				fmt.Printf("%d\n", j)
				break
			}
		}
	}
}

package main

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

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

	var t, n, x int
	fmt.Fscanf(in, "%d\n", &t)
	for ;t>0;t-- {
		fmt.Fscanf(in, "%d %d\n",&n, &x)
		a := make([]int,n)
		for i := 0 ; i < n ; i ++ {
			fmt.Fscanf(in, "%d",&a[i])
		}
		fmt.Fscanf(in,"\n")
		b := make([]int,202)
		for i := 0 ; i < n ; i ++{
			b[a[i]] = 1
		}
		output := 0
		for i := 1 ; i < 202 ; i ++ {
			if b[i] == 0 {
				b[i] = 1
				x --
			}
			if x == -1 {
				output = i - 1
				break
			}
		}
		fmt.Println(output)
	}

}

package main

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

func main() {
	// scanner := bufio.NewScanner(os.Stdin)
	var T int
	fmt.Scan(&T)
	for ; T>0; T-- {
		solve()
	}
}
func solve() {
	var n,x int;
		fmt.Scan(&n,&x);
		hm:=make(map[int]bool);
		arr:=make([]int,n)
		for i:=0;i<n;i++ {
			fmt.Scan(&arr[i])
			hm[arr[i]]=true
		}
		for i:=n+x;i>0;i--{
			var v int;
			for j:=1;j<=i;j++ {
				if(hm[j]==false){
					v++
				}
			}
			if(v<=x){
				fmt.Printf("%d \n",i)
				return;
			}
		}
}

package main
import "fmt"

func main() {
	var T, n, x, aux int
	fmt.Scan(&T)

	for ;T > 0; T-- {
		cont := 0
		bucket := make([]int, 205)
		fmt.Scan(&n, &x)

		for i := 0; i < n; i++ {
			fmt.Scan(&aux)
			bucket[aux]++
		}

		for i, v := range bucket {
			if cont == x && bucket[i] == 0 {
				fmt.Println(i-1)
				break
			}
			if i != 0 && v == 0 {
				cont++
				bucket[i] = 1
			}
		}
	}
}

package main

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

var r__ *bufio.Reader = bufio.NewReader(os.Stdin)
var w__ *bufio.Writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{})  { fmt.Fscanf(r__, f, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(w__, f, a...) }
func fflush()                           { w__.Flush() }

func solve() {
	var n, x int
	var data [102]bool
	scanf("%d %d\n", &n, &x)

	for i := 0; i < n; i++ {
		var curr int
		scanf("%d", &curr)
		data[curr] = true
	}
	scanf("\n")

	i := 0
	for {
		i++

		if i > 100 {

			x--

			if x > 0 {
				continue

			} else {
				break
			}
		}

		curr := data[i]

		if !curr {
			data[i] = true
			x--

			if x == 0 {
				if data[i+1] {
					i = i + 1
					break
				}
				break
			}

		} else {

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

}

func main() {
	defer fflush()

	var T, i uint64
	scanf("%d\n", &T)
	for i = 0; i < T; i++ {
		solve()
	}

}


package main

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

type Element struct {
	Val int
	Idx int
}

type Elements []Element

func (e Elements) Len() int {
	return len(e)
}

func (e Elements) Less(i, j int) bool {
	return e[i].Val <= e[j].Val
}

func (e Elements) Swap(i, j int) {
	e[i], e[j] = e[j], e[i]
}

func main() {
	iFile, _ := os.OpenFile("input.txt", os.O_RDWR|os.O_CREATE, 0777)
	oFile, _ := os.OpenFile("output.txt", os.O_RDWR|os.O_CREATE, 0777)
	reader := bufio.NewReader(iFile)
	writer := bufio.NewWriter(oFile)
	defer writer.Flush()

	var n, k, temp int
	fmt.Fscanf(reader, "%d %d\n", &n, &k)
	a := make([]Element, 0)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &temp)
		a = append(a, Element{Val: temp, Idx: i + 1})
	}
	fmt.Fscanf(reader, "\n")
	sort.Sort(Elements(a))
	fmt.Fprintf(writer, "%d\n", a[n-k].Val)
	for i := n - k; i < n; i++ {
		if i == (n - 1) {
			fmt.Fprintf(writer, "%d\n", a[i].Idx)
		} else {
			fmt.Fprintf(writer, "%d ", a[i].Idx)
		}
	}
}

package main

import "os"
import "bufio"
import "strconv"
import "sort"

func main(){
	var n, k int
	inp, _ := os.Open("input.txt")
	defer inp.Close()
	r := bufio.NewScanner(inp)
	r.Split(bufio.ScanWords)
	out, _ := os.Create("output.txt")
	defer out.Close()
	w := bufio.NewWriter(out)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	r.Scan()
	k, _ = strconv.Atoi(r.Text())
	a := make([]int, n)
	b := make([]int, n)
	for i:=0; i<n; i++ {
		r.Scan()
		a[i], _ = strconv.Atoi(r.Text())
		b[i] = a[i]
	}
	sort.Ints(a)
	w.WriteString(strconv.Itoa(a[n-k])+"\n")
	c := 0
	for j:=0; j<n; j++ {
		if b[j] >= a[n-k] {
			if c < k {
				w.WriteString(strconv.Itoa(j+1)+" ")
				c += 1
			} else {
				break
			}
		}
	}
	w.WriteString("\n")
	w.Flush()
}

package main

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

func main() {
    var n,k,i,j int
    input, _ := os.Open("input.txt")
    defer input.Close()
    scanner := bufio.NewScanner(input)
    scanner.Split(bufio.ScanWords)
    output, _ := os.Create("output.txt")
    defer output.Close()
    writer := bufio.NewWriter(output)
    scanner.Scan()
    aa, _ := strconv.Atoi(scanner.Text())
    n=aa
    scanner.Scan()
    bb, _ := strconv.Atoi(scanner.Text())
    k=bb
    a:=make([]int,n)
    b:=make([]int,n)
    for i=0;i<n;i++ {
    	scanner.Scan()
    	bb, _ := strconv.Atoi(scanner.Text())
    	a[i]=bb
    	b[i]=a[i]
    }
    sort.Ints(b)
    var min int
    min = b[n-k]
    writer.WriteString(strconv.Itoa(min)+"\n")
    for i=n-k;i<n;i++ {
    	for j=0;j<n;j++ {
    		if a[j]==b[i] {
    		    writer.WriteString(strconv.Itoa(j+1)+" ")
    		    a[j]=-1
    		    break
    		}
    	}
    }
    writer.WriteString("\n")
    writer.Flush()
}

package main

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

type Light struct {
    lvl, in int
}

type LightSlice []Light

func (l LightSlice) Len() int { return len(l) }
func (l LightSlice) Swap(i,j int) { l[i], l[j] = l[j], l[i] }
func (l LightSlice) Less(i,j int) bool { return l[i].lvl > l[j].lvl }

func main() {
    input, _ := os.Open("input.txt")
    defer input.Close()
    output, _ := os.Create("output.txt")
    defer output.Close()

    scanner := bufio.NewScanner(input)
    scanner.Split(bufio.ScanWords)
    writer := bufio.NewWriter(output)

    ScanInts := func(a... *int) {
        for i := 0; i < len(a); i++ {
            scanner.Scan()
            *(a[i]), _ = strconv.Atoi(scanner.Text())
        }
    }

    var n,k int
    ScanInts(&n,&k)
    l := make(LightSlice,n)
    for i := 0; i < n; i++ {
        ScanInts(&l[i].lvl)
        l[i].in = i+1
    }
    sort.Sort(l)
    writer.WriteString(strconv.Itoa(l[k-1].lvl)+"\n")
    for i := 0; i < k; i++ {
        writer.WriteString(strconv.Itoa(l[i].in))
        if i == k-1 { writer.WriteRune('\n') } else { writer.WriteRune(' ') }
    }
    writer.Flush()
}

package main

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

type Element struct {
	Val int
	Idx int
}

type Elements []Element

func (e Elements) Len() int {
	return len(e)
}

func (e Elements) Less(i, j int) bool {
	return e[i].Val <= e[j].Val
}

func (e Elements) Swap(i, j int) {
	e[i], e[j] = e[j], e[i]
}

func main() {
	iFile, _ := os.OpenFile("input.txt", os.O_RDWR|os.O_CREATE, 0777)
	oFile, _ := os.OpenFile("output.txt", os.O_RDWR|os.O_CREATE, 0777)
	reader := bufio.NewReader(iFile)
	writer := bufio.NewWriter(oFile)
	defer writer.Flush()

	var n, k, temp int
	fmt.Fscanf(reader, "%d %d\n", &n, &k)
	a := make([]Element, 0)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &temp)
		a = append(a, Element{Val: temp, Idx: i})
	}
       fmt.Fscanf(reader, "\n")
	sort.Sort(Elements(a))
	fmt.Fprintf(writer, "%d\n", a[n-k].Val)
	for i := n - k; i < n; i++ {
		if i == (n - 1) {
			fmt.Fprintf(writer, "%d\n", a[i].Idx+1)
		} else {
			fmt.Fprintf(writer, "%d ", a[i].Idx+1)
		}
	}
}

// 234B-mic
package main

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

func main() {
	var n, k, i int
	in, _ := os.Open("input.txt")
	defer in.Close()
	sc := bufio.NewScanner(in)
	sc.Split(bufio.ScanWords)
	ou, _ := os.Create("output.txt")
	defer ou.Close()
	wr := bufio.NewWriter(ou)
	sc.Scan()
	nn, _ := strconv.Atoi(sc.Text())
	n = nn
	sc.Scan()
	kk, _ := strconv.Atoi(sc.Text())
	k = kk
	var a, b []int
	for i = 1; i <= n; i++ {
		sc.Scan()
		aaa, _ := strconv.Atoi(sc.Text())
		a = append(a, aaa)
		b = append(b, aaa)
	}
	sort.Sort(sort.IntSlice(b))
	x := k
	wr.WriteString(strconv.Itoa(b[n-k]) + "\n")
	for i = n - x; i < n; i++ {
		for j := 0; j < n; j++ {
			if a[j] == b[i] {
				wr.WriteString(strconv.Itoa(j+1) + " ")
				a[j] = -1234567
				break
			}
		}
	}
	wr.Flush()
}

package main

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

type Element struct {
	Val int
	Idx int
}

type Elements []Element

func (e Elements) Len() int {
	return len(e)
}

func (e Elements) Less(i, j int) bool {
	return e[i].Val <= e[j].Val
}

func (e Elements) Swap(i, j int) {
	e[i], e[j] = e[j], e[i]
}

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

	var n, k, temp int
	fmt.Fscanf(reader, "%d %d\n", &n, &k)
	a := make([]Element, 0)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &temp)
		a = append(a, Element{Val: temp, Idx: i})
	}
	//sort.Sort(Elements(a))
	fmt.Println(a, n, k)
}

package main

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

type Element struct {
	Val int
	Idx int
}

type Elements []Element

func (e Elements) Len() int {
	return len(e)
}

func (e Elements) Less(i, j int) bool {
	return e[i].Val <= e[j].Val
}

func (e Elements) Swap(i, j int) {
	e[i], e[j] = e[j], e[i]
}

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

	var n, k, temp int
	fmt.Fscanf(reader, "%d %d\n", &n, &k)
	a := make([]Element, 0)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &temp)
		a = append(a, Element{Val: temp, Idx: i + 1})
	}
}

package main

import "os"
import "bufio"
import "strconv"
import "sort"

func main(){
	var n, k int
	inp, _ := os.Open("input.txt")
	defer inp.Close()
	r := bufio.NewScanner(inp)
	r.Split(bufio.ScanWords)
	out, _ := os.Create("output.txt")
	defer out.Close()
	w := bufio.NewWriter(out)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	r.Scan()
	k, _ = strconv.Atoi(r.Text())
	a := make([]int, n)
	b := make([]int, 101)
	for i:=0; i<n; i++ {
		r.Scan()
		a[i], _ = strconv.Atoi(r.Text())
		b[a[i]] = i+1
	}
	sort.Ints(a)
	w.WriteString(strconv.Itoa(a[n-k])+"\n")
	for j:=n-k; j<n; j++ {
		w.WriteString(strconv.Itoa(b[a[j]])+" ")
	}
	w.WriteString("\n")
	w.Flush()
}

package main

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

func main() {
    var n,k,i,j int
    input, _ := os.Open("input.txt")
    defer input.Close()
    scanner := bufio.NewScanner(input)
    scanner.Split(bufio.ScanWords)
    output, _ := os.Create("output.txt")
    defer output.Close()
    writer := bufio.NewWriter(output)
    scanner.Scan()
    aa, _ := strconv.Atoi(scanner.Text())
    n=aa
    scanner.Scan()
    bb, _ := strconv.Atoi(scanner.Text())
    k=bb
    a:=make([]int,n)
    b:=make([]int,n)
    for i=0;i<n;i++ {
    	scanner.Scan()
    	bb, _ := strconv.Atoi(scanner.Text())
    	a[i]=bb
    	b[i]=a[i]
    }
    sort.Ints(b)
    var min int
    min = b[n-k]
    writer.WriteString(strconv.Itoa(min)+"\n")
    for i=n-k;i<n;i++ {
    	for j=0;j<n;j++ {
    		if a[j]==b[i] {
    		    writer.WriteString(strconv.Itoa(j)+" ")
    		    a[j]=-1
    		    break
    		}
    	}
    }
    writer.WriteString("\n")
    writer.Flush()
}

// 234B-mic
package main

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

func main() {
	var n, k, i int
	in, _ := os.Open("input.txt")
	defer in.Close()
	sc := bufio.NewScanner(in)
	sc.Split(bufio.ScanWords)
	ou, _ := os.Create("output.txt")
	defer ou.Close()
	wr := bufio.NewWriter(ou)
	sc.Scan()
	nn, _ := strconv.Atoi(sc.Text())
	n = nn
	sc.Scan()
	kk, _ := strconv.Atoi(sc.Text())
	k = kk
	var a, b []int
	for i = 1; i <= n; i++ {
		sc.Scan()
		aaa, _ := strconv.Atoi(sc.Text())
		a = append(a, aaa)
		b = append(b, aaa)
	}
	sort.Sort(sort.IntSlice(b))
	x := k
	wr.WriteString(strconv.Itoa(b[n-k+1]) + "\n")
	for i = n - x; i < n; i++ {
		for j := 0; j < n; j++ {
			if a[j] == b[i] {
				wr.WriteString(strconv.Itoa(j+1) + " ")
				a[j] = -1234567
				break
			}
		}
	}
	wr.Flush()
}

// 234B-mic
package main

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

func main() {
	var n, k, i int
	input, _ := os.Open("input.txt")
	defer input.Close()
	scanner := bufio.NewScanner(input)
	scanner.Split(bufio.ScanWords)
	output, _ := os.Create("output.txt")
	defer output.Close()
	writer := bufio.NewWriter(output)
	scanner.Scan()
	aa, _ := strconv.Atoi(scanner.Text())
	n = aa
	scanner.Scan()
	bb, _ := strconv.Atoi(scanner.Text())
	k = bb
	a := make([]int, 1001)
	b := make([]int, 1001)
	for i = 1; i <= n; i++ {
		scanner.Scan()
		aaa, _ := strconv.Atoi(scanner.Text())
		a[i] = aaa
		b[i] = a[i]
	}
	sort.Sort(sort.IntSlice(b))
	x := k
	writer.WriteString(strconv.Itoa(b[n-k+1]) + "\n")
	for i = 1; i <= n && x > 0; i++ {
		if a[i] >= b[n-k+1] {
			writer.WriteString(strconv.Itoa(i) + " ")
			x--
		}
	}
}

// 234B-mic
package main

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

func main() {
	var n, k, i int
	input, _ := os.Open("input.txt")
	defer input.Close()
	scanner := bufio.NewScanner(input)
	scanner.Split(bufio.ScanWords)
	output, _ := os.Create("output.txt")
	defer output.Close()
	writer := bufio.NewWriter(output)
	scanner.Scan()
	aa, _ := strconv.Atoi(scanner.Text())
	n = aa
	scanner.Scan()
	bb, _ := strconv.Atoi(scanner.Text())
	k = bb
	//var a, b []int
	a := make([]int, n+1)
	b := make([]int, n+1)
	for i = 1; i <= n; i++ {
		scanner.Scan()
		aaa, _ := strconv.Atoi(scanner.Text())
		//a = append(a, aaa)
		//b = append(b, aaa)
		a[i] = aaa
		b[i] = a[i]
	}
	sort.Sort(sort.IntSlice(b))
	x := k
	writer.WriteString(strconv.Itoa(b[n-k+1]) + "\n")
	for i = 1; i <= n && x > 0; i++ {
		if a[i] > b[n-k] {
			writer.WriteString(strconv.Itoa(i) + " ")
			x--
		}
	}
	writer.Flush()
}

// 234B-mic
package main

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

func main() {
	var n, k, i int
	input, _ := os.Open("input.txt")
	defer input.Close()
	scanner := bufio.NewScanner(input)
	scanner.Split(bufio.ScanWords)
	output, _ := os.Create("output.txt")
	defer output.Close()
	writer := bufio.NewWriter(output)
	scanner.Scan()
	aa, _ := strconv.Atoi(scanner.Text())
	n = aa
	scanner.Scan()
	bb, _ := strconv.Atoi(scanner.Text())
	k = bb
	var a, b []int
	//a := make([]int, n)
	//b := make([]int, n)
	for i = 1; i <= n; i++ {
		scanner.Scan()
		aaa, _ := strconv.Atoi(scanner.Text())
		a = append(a, aaa)
		b = append(b, aaa)
		//a[i] = aaa
		//b[i] = a[i]
	}
	sort.Sort(sort.IntSlice(b))
	x := k
	writer.WriteString(strconv.Itoa(b[n-k]) + "\n")
	for i = 1; i < n && x > 0; i++ {
		if a[i] >= b[n-k] {
			writer.WriteString(strconv.Itoa(i) + " ")
			x--
		}
	}
	writer.Flush()
}

package main

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

type Element struct {
	Val int
	Idx int
}

type Elements []Element

func (e Elements) Len() int {
	return len(e)
}

func (e Elements) Less(i, j int) bool {
	return e[i].Val <= e[j].Val
}

func (e Elements) Swap(i, j int) {
	e[i], e[j] = e[j], e[i]
}

func main() {
	iFile, _ := os.Open("input.txt")
	oFile, _ := os.Open("output.txt")
	reader := bufio.NewReader(iFile)
	writer := bufio.NewWriter(oFile)
	defer writer.Flush()

	var n, k, temp int
	fmt.Fscanf(reader, "%d %d\n", &n, &k)
	a := make([]Element, 0)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &temp)
		a = append(a, Element{Val: temp, Idx: i})
	}
	sort.Sort(Elements(a))
	fmt.Fprintf(writer, "%d\n", a[n-k].Val)
	for i := n - k; i < n; i++ {
		if i == (n - 1) {
			fmt.Fprintf(writer, "%d\n", a[i].Idx+1)
		} else {
			fmt.Fprintf(writer, "%d ", a[i].Idx+1)
		}
	}
}


package main

import (
    "fmt"
    "math"
)

func prime(n int) bool {
    if n == 2 {
        return true
    }

    if n%2 == 0 {
        return false
    }

    limit := int(math.Sqrt(float64(n)))
    for i := 3; i <= limit; i++ {
        if n%i == 0 {
            return false
        }
    }
    return true
}

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

    q := make([]int, 0)
    for i := 2; i <= n; i++ {
        if !prime(i) {
            continue
        }
        for p := i; p <= n; p *= i {
            q = append(q, p)
        }
    }

    fmt.Println(len(q))
    for _, e := range q {
        fmt.Print(" ", e)
    }
    fmt.Println()
}

package main

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

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

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

	n := nextInt()
	primes := make([]bool, 1005)
	ans := make([]int, 0)
	primes[1] = true

	for i := 2; i < len(primes); i++ {
		if !primes[i] {
			for j := i * i; j < len(primes); j += i {
				primes[j] = true
			}
		}
	}

	// println(primes)

	for i := 1; i <= n; i++ {
		a := 1

		if !primes[i] {
			for a <= n/i {
				a *= i
				ans = append(ans, a)
			}
		}
	}

	println(len(ans))
	for i := range ans {
		print(ans[i], " ")
	}
	println()
}

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

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

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

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

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

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

package main

import "fmt"
func main() {
    var n  int
    var a []int
    fmt.Scanf("%d",&n)
    for i:= 2; i <= n; i++{
        b := true
        for j:= 2; j < i; j++{
            if i % j == 0{
                b = false
            }
        }
        if b {
             for k := i; k <= n; k *= i{
                 a = append(a,k)
             }
        }
    }
    fmt.Println(len(a))
    for i:= 0; i < len(a); i++{
        fmt.Printf("%v ",a[i])
    }
}

package main

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

const (
	maxn int = 1000 + 5
)

var (
	n, m  int
	prime [maxn]bool
)

func abc() {
	for i := 0; i < maxn; i++ {
		prime[i] = true
	}

	for i := 2; i < maxn; i++ {
		// fmt.Print(i, " ")
		if !prime[i] {
			continue
		}
		for j := i * 2; j < maxn; j += i {
			// fmt.Print(j, " ")
			prime[j] = false
		}
	}
}
func main() {
	// file, _ := os.Open("input.txt")
	file := os.Stdin
	f := bufio.NewReader(file)
	fmt.Fscanf(f, "%d", &n)
	abc()
	res := 0
	res_ar := make([]int, 0)
	for i := 2; i <= n; i++ {
		if prime[i] {
			tmp := i
			for tmp <= n {
				res++
				res_ar = append(res_ar, tmp)
				tmp *= i
			}
		}
	}
	fmt.Println(res)
	for i := 0; i < len(res_ar); i++ {
		fmt.Print(res_ar[i], " ")
	}
}

package main

import (
	"fmt"
)

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

	if n == 1 {
		fmt.Println(0)
		return
	} else if n == 2 {
		fmt.Println(1)
		fmt.Println(2)
		return
	}

	not_prime := make([]bool, n+1)
	not_prime[1] = true
	not_prime[2] = false
	not_prime[3] = false
	for i := 2; i <= n; i++ {
		for j := 2; j <= n; j++ {
			if i*j <= n {
				not_prime[i*j] = true
			} else {
				break
			}
		}
	}

	questions := 0
	is_question := make([]bool, n+1)
	for i := 1; i <= n; i++ {
		if !not_prime[i] {
			p := i
			for p <= n {
				if !is_question[p] {
					is_question[p] = true
					questions++
				}
				p *= i
			}
		}
	}

	fmt.Println(questions)
	for i := 1; i <= n; i++ {
		if is_question[i] {
			fmt.Printf("%d ", i)
		}
	}
	fmt.Printf("\n")
}

package main

import (
	"fmt"
)

var (
	N int
	Prime []int
	Res int
	ResArr []int
)

func FindPrime() {
	for i:=0; i < 1000; i++ {
		Prime = append(Prime, 1)
	}
	Prime[0] = 0
	for i:=2; i <= 1000; i++ {
		if Prime[i-1] == 1 {
			for j:=i*2; j <=1000; j+=i {
				Prime[j-1] = 0
			}
		}
	}
}

func main() {
	FindPrime()
	fmt.Scan(&N)
	if N == 1 {
		fmt.Printf("%d", 0)
	} else {
		for i:=2; i <= N; i++ {
			if Prime[i-1] == 1 {
				j:=i;
				for j <= N {
					Res++;
					ResArr = append(ResArr, j)
					j*=i;
				}
			}
		}
		fmt.Printf("%d\n", Res)
		for _, val := range ResArr {
			fmt.Printf("%d ", val)
		}
	}
}

package main

import (
    "fmt"
    "math"
)

func prime(n int) bool {
    if n == 2 {
        return true
    }

    if n%2 == 0 {
        return false
    }

    limit := int(math.Sqrt(float64(n)))
    for i := 3; i <= limit; i++ {
        if n%i == 0 {
            return false
        }
    }
    return true
}

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

    q := make([]int, 0)
    for i := 2; i < n; i++ {
        if !prime(i) {
            continue
        }
        for p := i; p <= n; p *= i {
            q = append(q, p)
        }
    }

    fmt.Println(len(q))
    for _, e := range q {
        fmt.Print(" ", e)
    }
    fmt.Println()
}

package main

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

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

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

	n := nextInt()
	primes := make([]bool, 1005)
	ans := make([]int, 0)
	primes[1] = true

	for i := 2; i < len(primes); i++ {
		if !primes[i] {
			for j := i * i; j < len(primes); j += i {
				primes[j] = true
			}
		}
	}

	// println(primes)

	for i := 1; i <= n; i++ {
		a := 1

		if !primes[i] {
			for a <= n/i {
				a *= i
				ans = append(ans, a)
			}
		}
	}

	println(len(ans))
	for i := range ans {
		print(ans[i], " ")
	}
	println(n)
}

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

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

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

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

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

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

package main

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

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

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

	n := nextInt()
	primes := make([]bool, 1001)
	ans := make([]int, 0)
	primes[1] = true

	// for i := 2; i < len(primes); i++ {
	// 	if !primes[i] {
	// 		for j := i * i; j*j < len(primes); j += i {
	// 			primes[j] = true
	// 		}
	// 	}
	// }

	for i := 1; i <= n; i++ {
		a := 1

		if !primes[i] {
			for a <= n/i {
				a *= i
				ans = append(ans, a)
			}
		}
	}

	println(len(ans))
	for i := range ans {
		print(ans[i], " ")
	}
	println(n)
}

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

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

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

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

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

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

package main

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

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

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

	n := nextInt()
	primes := make([]bool, 1001)
	ans := make([]int, 0)
	primes[1] = true

	// for i := 2; i < len(primes); i++ {
	// 	if !primes[i] {
	// 		for j := i * i; j*j <= len(primes); j += i {
	// 			primes[j] = true
	// 		}
	// 	}
	// }

	// for i := 1; i <= n; i++ {
	// 	a := 1

	// 	if !primes[i] {
	// 		for a <= n/i {
	// 			a *= i
	// 			ans = append(ans, a)
	// 		}
	// 	}
	// }

	println(len(ans))
	for i := range ans {
		print(ans[i], " ")
	}
	println(n)
}

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

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

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

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

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

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


package main

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

func main() {
	n, t := ReadInt(), ReadInt()
	a := ReadInt64Slice(n)

	out <- S(solve(int64(n), int64(t), a))
	close(out)
	outWg.Wait()
}

func solve(n, t int64, a []int64) int64 {

	start := int64(0)
	max := int64(0)
	sum := int64(0)

	for i := int64(0); i < int64(n); i++ {
		sum += a[i]
		if sum > t {
			sum -= a[start]
			start += 1
		}
		if (i-start+1) > max && sum <= t {
			max = i - start + 1
		}
	}
	return max
}

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

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

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(writer *bufio.Writer) {
		defer outWg.Done()
		defer writer.Flush()

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

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, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return i
}

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

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

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

func Max(args ...int64) int64 {
	maxV := int64(math.MinInt64)
	for _, v := range args {
		if v > maxV {
			maxV = v
		}
	}
	return maxV
}

func Min(args ...int64) int64 {
	minV := int64(math.MaxInt64)
	for _, v := range args {
		if v < minV {
			minV = v
		}
	}
	return minV
}

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

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

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

package main

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

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

	a := make([]int, n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; scanner.Scan() && i < n; i++ {
		ai, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		a[i] = ai
	}

	max_books := 0

	start := -1
	time := 0
	books := 0
	for i := 0; i < n; i++ {
		if a[i] > t {
			if books > max_books {
				max_books = books
			}
			start = -1
			time = 0
			books = 0
			continue
		}
		if start < 0 && a[i] <= t {
			start = i
			time += a[i]
			books++
		} else if start >= 0 {
			if time+a[i] <= t {
				time += a[i]
				books++
			} else {
				if books > max_books {
					max_books = books
				}
				for j := start; j < i; j++ {
					time -= a[j]
					books--
					if time+a[i] <= t {
						start = j + 1
						time += a[i]
						books++
						break
					}
				}
			}
		}
	}
	if books > max_books {
		max_books = books
	}

	fmt.Println(max_books)
}

//http://codeforces.com/problemset/problem/279/B

package main

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

func main() {
	reader := NewStdReader(os.Stdin)

	n, t := reader.ReadInt(), reader.ReadInt()
	a := make([]int, n)

	sum := 0
	start := -1
	max := 0
	for i := 0; i < n; i++ {
		a[i] = reader.ReadInt()
		if start < 0 {
			if a[i] <= t {
				start = i
				sum = a[i]
			}
		} else {
			if sum+a[i] <= t {
				sum += a[i]
			} else {
				if i-start > max {
					max = i - start
				}
				if a[i] > t {
					start = -1
				} else {
					for sum+a[i] > t {
						sum -= a[start]
						start++
					}
					sum += a[i]
				}
			}
		}
	}

	if start >= 0 && n-start > max {
		max = n - start
	}

	fmt.Print(max)
}

type StdReader struct {
	buf *bufio.Reader
}

func NewStdReader(reader io.Reader) *StdReader {
	return &StdReader{bufio.NewReaderSize(reader, 10*1024*1024)}
}

func (std *StdReader) ReadInt() int {

	r := 0
	sign := 1
	ok := false

	for {
		b, e := std.buf.ReadByte()

		if e != nil {
			break
		}
		if b >= '0' && b <= '9' {
			r = r*10 + int(b-'0')
			ok = true
		} else {
			if ok {
				break
			} else {
				if b == '-' {
					sign = -sign
				}
			}
		}
	}

	return sign * r
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    var n,t int
    fmt.Scan(&n,&t)
    a := make([]int,n)
    for i := 0; i < n; i++ {
        scanner.Scan()
        a[i], _ = strconv.Atoi(scanner.Text())
    }
    total, in := 0, 0
    for (in < n) && ((total+a[in]) <= t) {
        total += a[in]
        in++
    }
    max := in
    for i := 0; i < n; i++ {
        total -= a[i]
        for (in < n) && ((total+a[in]) <= t) {
            total += a[in]
            in++
        }
        if max < (in-i-1) {
            max = in-i-1
        }
    }
    fmt.Println(max)
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    var n,t int
    fmt.Scan(&n,&t)
    a := make([]int,n)
    for i := 0; i < n; i++ {
        scanner.Scan()
        a[i], _ = strconv.Atoi(scanner.Text())
    }
    max, total, in := 0, 0, 0
    for i := -1; i < n; i++ {
        if i != -1 { total -= a[i] }
        for (in < n) && ((total+a[in]) <= t) {
            total += a[in]
            in++
        }
        if max < (in-i-1) {
            max = in-i-1
        }
    }
    fmt.Println(max)
}

package main

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

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

func init() {
	in.Split(bufio.ScanWords)
	buf := make([]byte, 2500000, 2500000)
	in.Buffer(buf, 0)
}
func exit() {
	out.Flush()
}

// io
func nextInt() int {
	in.Scan()
	ret, _ := strconv.Atoi(in.Text())
	return ret
}
func nextString() string {
	in.Scan()
	return in.Text()
}
func nextBytes() []byte {
	in.Scan()
	return in.Bytes()
}

/*
 */
var num int64
var left int64
var timeSum []int64

func main() {
	defer exit()
	num = int64(nextInt())
	left = int64(nextInt())
	timeSum = make([]int64, num+1, num+1)

	for i := int64(1); i != num+1; i++ {
		timeSum[i] = timeSum[i-1] + int64(nextInt())
	}
	ans := int64(0)

	for i := int64(1); i != num+1; i++ {
		minusBase := timeSum[i-1]
		// test one
		if timeSum[i]-minusBase > left {
			continue
		}
		l := i
		r := num
		for {
			if l == r {
				break
			}
			mid := (l + r + 1) / 2
			midv := left >= (timeSum[mid] - minusBase)
			if midv {
				l = mid
			} else {
				r = mid - 1
			}
		}
		temp := l - i + 1
		if temp > ans {
			ans = temp
		}
	}
	fmt.Fprintf(out, "%d\n", ans)
}

package main

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

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

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

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

    var n, t int
    line, _ := reader.ReadString(' ')
    fmt.Sscanln(line, &n)
    fmt.Sscanln(Read(reader), &t)

    a := make([]int, n)

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

    dp := make([]int, n + 1)
    dp[0] = 0
    dp[1] = a[0]
    for i := 2; i < n + 1; i++ {
        dp[i] = dp[i - 1] + a[i - 1]
    }

    writer := bufio.NewWriter(os.Stdout)
    var r int = 1
    var max int = 0
    for i := 0; i < n + 1; i++ {

        if r == n + 1 {
            break
        }

        var j int = r
        for j = r; j < n + 1; j++ {
            next := dp[j] - dp[i]
            if next > t {
                if max < j - i {
                    max = j - i
                }
                r = j
                break
            }
        }

        if j == n + 1 && max < n - i + 1 {
            max = n - i + 1
            r = n + 1
        }
    }

    Write(writer, max - 1)

    writer.Flush()
}

//http://codeforces.com/problemset/problem/279/B

package main

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

func main() {
	reader := NewStdReader(os.Stdin)

	n, t := reader.ReadInt(), reader.ReadInt()
	a := make([]int, n)

	sum := 0
	start := 0
	max := 0
	for i := 0; i < n; i++ {
		a[i] = reader.ReadInt()
		sum += a[i]
		for sum > t {
			sum -= a[start]
			start++
		}
		if i - start + 1 > max {
			max = i - start + 1
		}
	}

	fmt.Print(max)
}

type StdReader struct {
	buf *bufio.Reader
}

func NewStdReader(reader io.Reader) *StdReader {
	return &StdReader{bufio.NewReaderSize(reader, 10*1024*1024)}
}

func (std *StdReader) ReadInt() int {

	r := 0
	sign := 1
	ok := false

	for {
		b, e := std.buf.ReadByte()

		if e != nil {
			break
		}
		if b >= '0' && b <= '9' {
			r = r*10 + int(b-'0')
			ok = true
		} else {
			if ok {
				break
			} else {
				if b == '-' {
					sign = -sign
				}
			}
		}
	}

	return sign * r
}

package main

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

func solve(n int, t int, arr []int) int {
	left, sum, result := 0, 0, 0

	for right := 0; right < n; right++ {
		sum += arr[right]
		for sum > t {
			sum -= arr[left]
			left++
		}
		result = max(result, right-left+1)
	}

	return result
}

func max(n1 int, n2 int) int {
	if n1 > n2 {
		return n1
	}

	return n2
}

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

	var n, t int

	fmt.Fscanf(r, "%d %d\n", &n, &t)

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	fmt.Fprintf(os.Stdout, "%d\n", solve(n, t, arr))

}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var i, j, n, t, max_books, sum int64
	fmt.Fscanln(reader, &n, &t)
	mins_to_read := make([]int64, n)
	for i = 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &mins_to_read[i])
	}
	for i = 0; i < n; {
		if mins_to_read[i] > t {
			// This books can not be part of any sequence
			i += 1
			j = i
			sum = 0
			continue
		}
		// Form a sequence of books whose reading mins sum up to 't'
		for i < n && sum+mins_to_read[i] <= t {
			sum += mins_to_read[i]
			i += 1
		}
		if i-j > max_books {
			max_books = i - j
		}
		if i == n {
			break
		}
		// make the sum exceed 't'
		sum += mins_to_read[i]
		// remove books that were added earlier
		for j < i && sum > t {
			sum -= mins_to_read[j]
			j += 1
		}
		i += 1
	}
	fmt.Fprintln(writer, max_books)
}

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

func main() {
	var n,t,s,r int
	l:=1
	a:=make([]int,100005)
	fmt.Scan(&n,&t)
	input:= bufio.NewScanner(os.Stdin)
	input.Split(bufio.ScanWords)
	for i:=1;i<=n;i++ {
		input.Scan()
		aa,_:= strconv.Atoi(input.Text())
		a[i]=aa
		s+=a[i]
		for ;s>t; {
			s-=a[l]
			l++
		}
		if r<i-l+1 {
			r=i-l+1
		}
	}
	fmt.Println(r)
}

package main

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

func main() {

	//scanner := bufio.NewScanner(os.Stdin)
	reader := bufio.NewReader(os.Stdin)
	//line := 0

	//var n int64
	var t int64
	var i int64 = 0
	var j int64 = 0
	var tmpMinutes []string
	var minutes []int64
	var listReadBooks []int64

	//scanner.Scan()
	inputLine1, _ := reader.ReadString('\n')
	value := strings.Split(strings.TrimSpace(inputLine1), " ")
	//fmt.Scanf("%d %d", &n, &t)

	//n = (value[0])
	//t = int64(value[1])
	//n, _ = strconv.ParseInt(string(value[0]), 10, 64)
	t, _ = strconv.ParseInt(string(value[1]), 10, 64)
	//fmt.Println(n, t)
	//scanner.Scan()
	//var str string
	inputLine2, _ := reader.ReadString('\n')
	//fmt.Scan(&str)
	//fmt.Println(inputLine2)
	//tm
	//if n == 100000 && t == 23010915 {
	//	//value1 := scanner.Text()
	//	fmt.Println(inputLine2)
	//	tmpMinutes = strings.Split(strings.TrimSpace(inputLine2), " ")
	//	fmt.Println(len(tmpMinutes))
	//	fmt.Println(tmpMinutes)
	//} else {
		tmpMinutes = strings.Split(strings.TrimSpace(inputLine2), " ")
	//}

	minutes = convertStringToInt64(tmpMinutes)

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

	length := int64(len(minutes))

	var readBooks int64 = 0
	var readMinutes int64 = 0
	for i = 0; i < length; i++ {
		//j := i
		//fmt.Println(i, j, readMinutes, minutes[i], readBooks)
		if minutes[i] + readMinutes <= t {
			readMinutes += minutes[i]
			readBooks++
		} else {
			listReadBooks = append(listReadBooks, readBooks)
			readMinutes = readMinutes + minutes[i] - minutes[j]
			//readMinutes -= minutes[j]
			//readBooks--
			j++
		}
		if i == length - 1 {
			listReadBooks = append(listReadBooks, readBooks)
		}

		//for i < length && minutes[i] + readMinutes <= t {
			//fmt.Printf("%v - %v: ", i, j)
			//fmt.Println("minutes[j]: ",  minutes[j])
			//readMinutes += minutes[j]
			//j++
			//readBooks++
			//fmt.Println(readMinutes, readBooks)
		//}
		//break
		//fmt.Println(readBooks)
		//listReadBooks = append(listReadBooks, readBooks)
	}
	//fmt.Println(listReadBooks)

	sort.Slice(listReadBooks, func(i, j int) bool {
		return listReadBooks[i] > listReadBooks[j]
	})

	fmt.Println(listReadBooks[0])
}

func convertStringToInt64(minutes []string) []int64 {
	var result []int64
	for _, string := range minutes {
		if string == "" {
			continue
		}
		value, err := strconv.ParseInt(string, 10, 64)
		if err != nil {
			fmt.Println(err)
		}
		result = append(result, value)
	}
	return result
}

package main

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

func main() {
	n, t := ReadInt(), ReadInt()
	a := ReadInt64Slice(n)

	out <- S(solve(int64(n), int64(t), a))
	close(out)
	outWg.Wait()
}

func solve(n, t int64, a []int64) int64 {

	start := int64(0)
	max := int64(0)
	sum := int64(0)

	for i := int64(0); i < int64(n); i++ {
		sum += a[i]
		if sum > t {
			sum -= a[start]
			start += 1
		}
		if (i-start+1) > max && sum <= t {
			max = i - start + 1
		}
	}
	return max
}
func main1() {
	n, t := ReadInt(), int64(ReadInt())
	a := ReadInt64Slice(n)

	maxBookCount := int64(0)
	for i := 0; i < n; i++ {
		bookCount := int64(0)
		timeLeft := t
		for j := i; timeLeft > 0 && j < n; j++ {
			if a[j] <= timeLeft {
				bookCount++
				timeLeft -= a[j]
			} else {
				break
			}
		}
		maxBookCount = Max(maxBookCount, bookCount)
	}
	out <- S(maxBookCount)

	close(out)
	outWg.Wait()
}

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

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

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(writer *bufio.Writer) {
		defer outWg.Done()
		defer writer.Flush()

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

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, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return i
}

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

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

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

func Max(args ...int64) int64 {
	maxV := int64(math.MinInt64)
	for _, v := range args {
		if v > maxV {
			maxV = v
		}
	}
	return maxV
}

func Min(args ...int64) int64 {
	minV := int64(math.MaxInt64)
	for _, v := range args {
		if v < minV {
			minV = v
		}
	}
	return minV
}

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

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

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

// 279B-mic
package main

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

func main() {
	w := bufio.NewScanner(os.Stdin)
	w.Split(bufio.ScanWords)
	var n, t int
	fmt.Scan(&n, &t)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		w.Scan()
		a[i], _ = strconv.Atoi(w.Text())
	}

	k := 0
	d := 0
	st := 0
	m := 0
	for i := 0; i < n; i++ {
		k = k + a[i]
		if k <= t {
			m = i - st + 1
		} else {
			k = k - a[st]
			st++
		}
		if d < m {
			d = m
		}
	}
	fmt.Println(d)

}

//http://codeforces.com/problemset/problem/279/B

package main

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

func main() {
	reader := NewStdReader(os.Stdin)

	n, t := reader.ReadInt(), reader.ReadInt()
	a := make([]int, n)

	sum := 0
	start := 0
	max := 0
	for i := 0; i < n; i++ {
		a[i] = reader.ReadInt()
		sum += a[i]
		if i - start + 1 > max {
			max = i - start + 1
		}
		for sum+a[i] > t && start <= i {
			sum -= a[start]
			start++
		}
	}

	fmt.Print(max)
}

type StdReader struct {
	buf *bufio.Reader
}

func NewStdReader(reader io.Reader) *StdReader {
	return &StdReader{bufio.NewReaderSize(reader, 10*1024*1024)}
}

func (std *StdReader) ReadInt() int {

	r := 0
	sign := 1
	ok := false

	for {
		b, e := std.buf.ReadByte()

		if e != nil {
			break
		}
		if b >= '0' && b <= '9' {
			r = r*10 + int(b-'0')
			ok = true
		} else {
			if ok {
				break
			} else {
				if b == '-' {
					sign = -sign
				}
			}
		}
	}

	return sign * r
}

//http://codeforces.com/problemset/problem/279/B

package main

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

func main() {
	reader := NewStdReader(os.Stdin)

	n, t := reader.ReadInt(), reader.ReadInt()
	a := make([]int, n)

	sum := 0
	start := 0
	max := 0
	for i := 0; i < n; i++ {
		a[i] = reader.ReadInt()
		sum += a[i]
		for sum+a[i] > t {
			sum -= a[start]
			start++
		}
		if i - start + 1 > max {
			max = i - start + 1
		}
	}

	fmt.Print(max)
}

type StdReader struct {
	buf *bufio.Reader
}

func NewStdReader(reader io.Reader) *StdReader {
	return &StdReader{bufio.NewReaderSize(reader, 10*1024*1024)}
}

func (std *StdReader) ReadInt() int {

	r := 0
	sign := 1
	ok := false

	for {
		b, e := std.buf.ReadByte()

		if e != nil {
			break
		}
		if b >= '0' && b <= '9' {
			r = r*10 + int(b-'0')
			ok = true
		} else {
			if ok {
				break
			} else {
				if b == '-' {
					sign = -sign
				}
			}
		}
	}

	return sign * r
}

package main

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

func main() {

	//scanner := bufio.NewScanner(os.Stdin)
	reader := bufio.NewReader(os.Stdin)
	//line := 0

	//var n int64
	var t int64
	var i int64
	var tmpMinutes []string
	var minutes []int64
	//var listReadBooks []int64

	//scanner.Scan()
	inputLine1, _ := reader.ReadString('\n')
	value := strings.Split(strings.TrimSpace(inputLine1), " ")
	//fmt.Scanf("%d %d", &n, &t)

	//n = (value[0])
	//t = int64(value[1])
	//n, _ = strconv.ParseInt(string(value[0]), 10, 64)
	t, _ = strconv.ParseInt(string(value[1]), 10, 64)
	//fmt.Println(n, t)
	//scanner.Scan()
	//var str string
	inputLine2, _ := reader.ReadString('\n')
	//fmt.Scan(&str)
	//fmt.Println(inputLine2)
	//tm
	//if n == 100000 && t == 23010915 {
	//	//value1 := scanner.Text()
	//	fmt.Println(inputLine2)
	//	tmpMinutes = strings.Split(strings.TrimSpace(inputLine2), " ")
	//	fmt.Println(len(tmpMinutes))
	//	fmt.Println(tmpMinutes)
	//} else {
		tmpMinutes = strings.Split(strings.TrimSpace(inputLine2), " ")
	//}

	minutes = convertStringToInt64(tmpMinutes)

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

	length := int64(len(minutes))

	var readBooks int64 = 0
	for i = 0; i < length; i++ {
		j := i
		var readMinutes int64 = 0

		for j < length && minutes[j] + readMinutes <= t {
			//fmt.Printf("%v - %v: ", i, j)
			//fmt.Println("minutes[j]: ",  minutes[j])
			readMinutes += minutes[j]
			j++
			readBooks++
			//fmt.Println(readMinutes, readBooks)
		}
		break
		//fmt.Println(readBooks)
		//listReadBooks = append(listReadBooks, readBooks)
	}
	fmt.Println(readBooks)

	//sort.Slice(listReadBooks, func(i, j int) bool {
	//	return listReadBooks[i] > listReadBooks[j]
	//})
	//
	//fmt.Println(listReadBooks[0])
}

func convertStringToInt64(minutes []string) []int64 {
	var result []int64
	for _, string := range minutes {
		if string == "" {
			continue
		}
		value, err := strconv.ParseInt(string, 10, 64)
		if err != nil {
			fmt.Println(err)
		}
		result = append(result, value)
	}
	return result
}

package main

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

func main() {

	scanner := bufio.NewScanner(os.Stdin)
	//line := 0

	var n int64
	var t int64
	var i int64
	var tmpMinutes []string
	var minutes []int64
	var listReadBooks []int64

	scanner.Scan()
	value := strings.Split(strings.TrimSpace(scanner.Text()), " ")
	n, _ = strconv.ParseInt(value[0], 10, 64)
	t, _ = strconv.ParseInt(value[1], 10, 64)

	scanner.Scan()
	if (n == 100000 && t == 23010915) || (n == 10 && t ==15) {
		value1 := scanner.Text()
		fmt.Println(value1)
		tmpMinutes = strings.Split(strings.TrimSpace(value1), " ")
		fmt.Println(len(tmpMinutes))
		fmt.Println(tmpMinutes)
	} else {
		tmpMinutes = strings.Split(strings.TrimSpace(scanner.Text()), " ")
	}

	minutes = convertStringToInt64(tmpMinutes)

	length := int64(len(minutes))

	for i = 0; i < length; i++ {
		j := i
		var readMinutes int64 = 0
		var readBooks int64 = 0
		for j < length && minutes[j] + readMinutes <= t {
			//fmt.Printf("%v - %v: ", i, j)
			//fmt.Println("minutes[j]: ",  minutes[j])
			readMinutes += minutes[j]
			j++
			readBooks++
			//fmt.Println(readMinutes, readBooks)
		}
		listReadBooks = append(listReadBooks, readBooks)
	}

	sort.Slice(listReadBooks, func(i, j int) bool {
		return listReadBooks[i] > listReadBooks[j]
	})

	fmt.Println(listReadBooks[0])
}

func convertStringToInt64(minutes []string) []int64 {
	var result []int64
	for _, string := range minutes {
		if string == "" {
			continue
		}
		value, err := strconv.ParseInt(string, 10, 64)
		if err != nil {
			fmt.Println(err)
		}
		result = append(result, value)
	}
	return result
}

package main

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

func main() {

	//scanner := bufio.NewScanner(os.Stdin)
	reader := bufio.NewReader(os.Stdin)
	//line := 0

	//var n int64
	var t int64
	var i int64 = 0
	var j int64 = 0
	var tmpMinutes []string
	var minutes []int64
	var listReadBooks []int64

	//scanner.Scan()
	inputLine1, _ := reader.ReadString('\n')
	value := strings.Split(strings.TrimSpace(inputLine1), " ")
	//fmt.Scanf("%d %d", &n, &t)

	//n = (value[0])
	//t = int64(value[1])
	//n, _ = strconv.ParseInt(string(value[0]), 10, 64)
	t, _ = strconv.ParseInt(string(value[1]), 10, 64)
	//fmt.Println(n, t)
	//scanner.Scan()
	//var str string
	inputLine2, _ := reader.ReadString('\n')
	//fmt.Scan(&str)
	//fmt.Println(inputLine2)
	//tm
	//if n == 100000 && t == 23010915 {
	//	//value1 := scanner.Text()
	//	fmt.Println(inputLine2)
	//	tmpMinutes = strings.Split(strings.TrimSpace(inputLine2), " ")
	//	fmt.Println(len(tmpMinutes))
	//	fmt.Println(tmpMinutes)
	//} else {
		tmpMinutes = strings.Split(strings.TrimSpace(inputLine2), " ")
	//}

	minutes = convertStringToInt64(tmpMinutes)

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

	length := int64(len(minutes))

	var readBooks int64 = 0
	var readMinutes int64 = 0
	for i = 0; i < length; i++ {
		//j := i
		fmt.Println(i, j, readMinutes, minutes[i], readBooks)
		if minutes[i] + readMinutes <= t {
			readMinutes += minutes[i]
			readBooks++
		} else {
			listReadBooks = append(listReadBooks, readBooks)
			readMinutes -= minutes[j]
			readBooks--
			j++
		}
		if i == length - 1 {
			listReadBooks = append(listReadBooks, readBooks)
		}

		//for i < length && minutes[i] + readMinutes <= t {
			//fmt.Printf("%v - %v: ", i, j)
			//fmt.Println("minutes[j]: ",  minutes[j])
			//readMinutes += minutes[j]
			//j++
			//readBooks++
			//fmt.Println(readMinutes, readBooks)
		//}
		//break
		//fmt.Println(readBooks)
		//listReadBooks = append(listReadBooks, readBooks)
	}
	fmt.Println(listReadBooks)

	sort.Slice(listReadBooks, func(i, j int) bool {
		return listReadBooks[i] > listReadBooks[j]
	})

	fmt.Println(listReadBooks[0])
}

func convertStringToInt64(minutes []string) []int64 {
	var result []int64
	for _, string := range minutes {
		if string == "" {
			continue
		}
		value, err := strconv.ParseInt(string, 10, 64)
		if err != nil {
			fmt.Println(err)
		}
		result = append(result, value)
	}
	return result
}

package main

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

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

	a := make([]int, n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; scanner.Scan() && i < n; i++ {
		ai, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		a[i] = ai
	}

	merge_sort(a, 0, n-1)

	books := 0
	time := 0
	for i := 0; i < n; i++ {
		if time+a[i] <= t {
			time += a[i]
			books++
		} else {
			break
		}
	}

	fmt.Println(books)
}

func merge(buffer []int, start, middle, end int) {
	sorted := make([]int, end-start+1)

	i := start
	j := middle + 1
	k := 0
	for i <= middle && j <= end {
		if buffer[i] <= buffer[j] {
			sorted[k] = buffer[i]
			i++
		} else {
			sorted[k] = buffer[j]
			j++
		}
		k++
	}
	for i <= middle {
		sorted[k] = buffer[i]
		k++
		i++
	}
	for j <= end {
		sorted[k] = buffer[j]
		k++
		j++
	}

	i = start
	k = 0
	for i <= end {
		buffer[i] = sorted[k]
		i++
		k++
	}
}

func merge_sort(buffer []int, start, end int) {
	if end > start {
		middle := (end + start) / 2
		merge_sort(buffer, start, middle)
		merge_sort(buffer, middle+1, end)
		merge(buffer, start, middle, end)
	}
}

package main

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

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

	a := make([]int, n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; scanner.Scan() && i < n; i++ {
		ai, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		a[i] = ai
	}

	max_books := 0

	start := -1
	time := 0
	books := 0
	for i := 0; i < n; i++ {
		if a[i] > t {
			if books > max_books {
				max_books = books
			}
			start = -1
			time = 0
			books = 0
			continue
		}
		if start < 0 && a[i] <= t {
			start = i
			time += a[i]
			books++
		} else if start >= 0 {
			if time+a[i] <= t {
				time += a[i]
				books++
			} else {
				if books > max_books {
					max_books = books
				}
				for j := start; j < i; j++ {
					time -= a[j]
					books--
					if time+a[i] <= t {
						start = j + 1
						time += a[i]
						books++
						break
					}
				}
			}
		}
	}
	if books > max_books {
		max_books = books
	}

	fmt.Println(books)
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    var n,t int
    fmt.Scan(&n,&t)
    a := make([]int,n)
    for i := 0; i < n; i++ {
        scanner.Scan()
        a[i], _ = strconv.Atoi(scanner.Text())
    }
    ans := 0
    for i := n-1; i >= 0; i-- {
        if ((i+1) < n) { a[i] = a[i]+a[i+1] }
        if a[i] <= t { ans = n-i }
    }
    fmt.Println(ans)
}

package main

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

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

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

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

    var n, t int
    line, _ := reader.ReadString(' ')
    fmt.Sscanln(line, &n)
    fmt.Sscanln(Read(reader), &t)

    a := make([]int, n)

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

    dp := make([]int, n + 1)
    dp[0] = 0
    dp[1] = a[0]
    for i := 2; i < n + 1; i++ {
        dp[i] = dp[i - 1] + a[i - 1]
    }

    //var l int = 0
    //var e int = 0
    var r int = 1
    var max int = 0
    var last int = 0
    for i := 0; i < n + 1; i++ {
        last = 0
        for j := r; j < n + 1; j++ {
            next := dp[j] - dp[i]
            if next > t {
                if max < last {
                    max = last
                    //l = i
                    //e = j
                }
                r = j
                break
            }
            last = next
        }
    }

    writer := bufio.NewWriter(os.Stdout)
    Write(writer, max - 1)

    writer.Flush()
}

package main

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

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

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

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

    var n, t int
    line, _ := reader.ReadString(' ')
    fmt.Sscanln(line, &n)
    fmt.Sscanln(Read(reader), &t)

    a := make([]int, n)

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

    dp := make([]int, n + 1)
    dp[0] = 0
    dp[1] = a[0]
    for i := 2; i < n + 1; i++ {
        dp[i] = dp[i - 1] + a[i - 1]
    }

    writer := bufio.NewWriter(os.Stdout)
    var l int = 0
    var e int = 0
    var r int = 1
    var max int = 0
    var last int = 0
    for i := 0; i < n + 1; i++ {

        if r == n + 1 {
            break
        }

        last = 0
        for j := r; j < n + 1; j++ {
            next := dp[j] - dp[i]
            if next > t {
                if max < last {
                    max = last
                    l = i
                    e = j
                }
                r = j
                break
            }
            last = next
        }

        if max < last {
            max = last
            l = i
            e = n
        }
    }

    Write(writer, e - l)

    writer.Flush()
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var i, j, n, t, max_books, sum int64
	fmt.Fscanln(reader, &n, &t)
	mins_to_read := make([]int64, n)
	for i = 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &mins_to_read[i])
	}
	for i = 0; i < n; {
		if mins_to_read[i] > t {
			// This books can not be part of any sequence
			i += 1
			j = i
			continue
		}
		// Form a sequence of books whose reading mins sum up to 't'
		for i < n && sum+mins_to_read[i] <= t {
			sum += mins_to_read[i]
			i += 1
		}
		if i-j > max_books {
			max_books = i - j
		}
		if i == n {
			break
		}
		// make the sum exceed 't'
		sum += mins_to_read[i]
		// remove books that were added earlier
		for j < i && sum > t {
			sum -= mins_to_read[j]
			j += 1
		}
		i += 1
	}
	fmt.Fprintln(writer, max_books)
}

package main

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

func main() {
	n, t := ReadInt(), int64(ReadInt())
	a := ReadInt64Slice(n)

	maxBookCount := int64(0)
	for i := 0; i < n; i++ {
		bookCount := int64(0)
		timeLeft := t
		for j := i; timeLeft > 0 && j < n; j++ {
			if a[j] <= timeLeft {
				bookCount++
				timeLeft -= a[j]
			}
		}
		maxBookCount = Max(maxBookCount, bookCount)
	}
	out <- S(maxBookCount)

	close(out)
	outWg.Wait()
}

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

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

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(writer *bufio.Writer) {
		defer outWg.Done()
		defer writer.Flush()

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

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, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return i
}

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

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

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

func Max(args ...int64) int64 {
	maxV := int64(math.MinInt64)
	for _, v := range args {
		if v > maxV {
			maxV = v
		}
	}
	return maxV
}

func Min(args ...int64) int64 {
	minV := int64(math.MaxInt64)
	for _, v := range args {
		if v < minV {
			minV = v
		}
	}
	return minV
}

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

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

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

package main

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

func main() {
	n, t := ReadInt(), int64(ReadInt())
	a := ReadInt64Slice(n)

	max_so_far := int64(0)
	max_ending_here := int64(0)
	l := -1
	//r := 0

	for i := 0; i < n; i++ {
		max_ending_here = max_ending_here + a[i]

		if max_ending_here >= t {
			if max_ending_here+a[l+1] <= t {
				l = l + 1
				//r = i
				if max_ending_here > max_so_far {
					max_so_far = max_ending_here
				}
			}else {
				max_ending_here = 0
			}
		} else if max_so_far < max_ending_here && max_ending_here <= t {
			max_so_far = max_ending_here
		}

	}

	out <- S(max_so_far - 1)
	close(out)
	outWg.Wait()
}

func main1() {
	n, t := ReadInt(), int64(ReadInt())
	a := ReadInt64Slice(n)

	maxBookCount := int64(0)
	for i := 0; i < n; i++ {
		bookCount := int64(0)
		timeLeft := t
		for j := i; timeLeft > 0 && j < n; j++ {
			if a[j] <= timeLeft {
				bookCount++
				timeLeft -= a[j]
			} else {
				break
			}
		}
		maxBookCount = Max(maxBookCount, bookCount)
	}
	out <- S(maxBookCount)

	close(out)
	outWg.Wait()
}

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

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

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(writer *bufio.Writer) {
		defer outWg.Done()
		defer writer.Flush()

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

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, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return i
}

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

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

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

func Max(args ...int64) int64 {
	maxV := int64(math.MinInt64)
	for _, v := range args {
		if v > maxV {
			maxV = v
		}
	}
	return maxV
}

func Min(args ...int64) int64 {
	minV := int64(math.MaxInt64)
	for _, v := range args {
		if v < minV {
			minV = v
		}
	}
	return minV
}

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

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

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

package main

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

func main() {
	n, t := ReadInt(), ReadInt()
	a := ReadInt64Slice(n)

	out <- S(solve(int64(n), int64(t), a))
	close(out)
	outWg.Wait()
}

//L = 1;
//for (; R<=N; )
//{
//if (Sum<=M && Ans<R-L+1)
//Ans = R-L+1;
//
//if (Sum<M)
//{
//R++; Sum+=A[R];
//}
//else
//{
//Sum-=A[L];
//L++;
//}
//}
func solve(n, t int64, a []int64) int64 {

	start := int64(0)
	max := int64(0)
	sum := int64(0)

	for i := int64(0); i < int64(n); i++ {
		if (i-start+1) > max && sum <= t {
			max = i - start + 1
		}

		if sum > t {
			sum -= a[start]
			start += 1
		} else {
			sum += a[i]
		}

	}
	return max
}
func main1() {
	n, t := ReadInt(), int64(ReadInt())
	a := ReadInt64Slice(n)

	maxBookCount := int64(0)
	for i := 0; i < n; i++ {
		bookCount := int64(0)
		timeLeft := t
		for j := i; timeLeft > 0 && j < n; j++ {
			if a[j] <= timeLeft {
				bookCount++
				timeLeft -= a[j]
			} else {
				break
			}
		}
		maxBookCount = Max(maxBookCount, bookCount)
	}
	out <- S(maxBookCount)

	close(out)
	outWg.Wait()
}

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

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

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(writer *bufio.Writer) {
		defer outWg.Done()
		defer writer.Flush()

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

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, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return i
}

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

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

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

func Max(args ...int64) int64 {
	maxV := int64(math.MinInt64)
	for _, v := range args {
		if v > maxV {
			maxV = v
		}
	}
	return maxV
}

func Min(args ...int64) int64 {
	minV := int64(math.MaxInt64)
	for _, v := range args {
		if v < minV {
			minV = v
		}
	}
	return minV
}

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

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

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

//http://codeforces.com/problemset/problem/279/B

package main

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

func main() {
	reader := NewStdReader(os.Stdin)

	n, t := reader.ReadInt(), reader.ReadInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = reader.ReadInt()
	}

	sort.Ints(a)
	sum := 0
	for i := 0; i < n; i++ {
		sum += a[i]
		if sum > t {
			fmt.Print(i)
			return
		}
	}

	fmt.Print(n)
}

type StdReader struct {
	buf *bufio.Reader
}

func NewStdReader(reader io.Reader) *StdReader {
	return &StdReader{bufio.NewReaderSize(reader, 10*1024*1024)}
}

func (std *StdReader) ReadInt() int {

	r := 0
	sign := 1
	ok := false

	for {
		b, e := std.buf.ReadByte()

		if e != nil {
			break
		}
		if b >= '0' && b <= '9' {
			r = r*10 + int(b-'0')
			ok = true
		} else {
			if ok {
				break
			} else {
				if b == '-' {
					sign = -sign
				}
			}
		}
	}

	return sign * r
}