You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: 1185C2.go
    path of file: ./repos/codeforces-go/main/1100-1199
    
    the code of the file until where you have to start completion: package main

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

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

	cnt := [101]int{}
	var n, m, t, sum int
	for Fscan(in, &n, &m); n > 0; n-- {
		Fscan(in, &t)
		s, c := sum+t-m, 0
		for i := 100; s > 0 && i > 0; i-- { // 漏写了 s > 0 WA 了一次
			if
    
func CF1185C2(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	cnt := [101]int{}
	var n, m, t, sum int
	for Fscan(in, &n, &m); n > 0; n-- {
		Fscan(in, &t)
		s, c := sum+t-m, 0
		for i := 100; s > 0 && i > 0; i-- { // 漏写了 s > 0 WA 了一次
			if s <= cnt[i]*i {
				c += (s + i - 1) / i
				break
			}
			c += cnt[i]
			s -= cnt[i] * i
		}
		Fprint(out, c, " ")
		sum += t
		cnt[t]++
	}
}