Problem:
The Smallest Window I For a given array $a_1, a_2, a_3, ... , a_N$ of $N$ elements and an integer $S$, find the smallest sub-array size (smallest window length) where the sum of the sub-array is greater than or equal to $S$. If there is not such sub-array, report 0. Constraints  $1 \leq N \leq 10^5$  $1 \leq S \leq 10^9$  $1 \leq a_i \leq 10^4$  Input The input is given in the following format. $N$ $S$ $a_1$ $a_2$ ... $a_N$  Output Print the smallest sub-array size in a line. Sample Input 1 6 4
1 2 1 2 3 2 Sample Output 1 2 Sample Input 2 6 6
1 2 1 2 3 2 Sample Output 2 3 Sample Input 3 3 7
1 2 3 Sample Output 3 0

Solution (Python):
import sys
INF = (sys.maxint)/3

def SmallestWindow(S, a_list):
	i = 0
	j = 0
	tmpS = 0
	res = INF
	while 1 :
		while tmpS < S and i <len(a_list):
			tmpS += a_list[i]
			i = i+1
		if (tmpS <S):
			break
		res = min (res, i-j)
		tmpS -=a_list[j]
		j += 1
	if res == INF:
		res = 0
	return res
		

def main():
	N, S = map(int, raw_input().split())
	a_list = map(int, raw_input().split())
	print SmallestWindow(S, a_list)

if __name__ == '__main__':
	main()

Solution (Python):
from queue import deque

n, s = map(int, input().split())
q = deque()
t = 0
ans = 1e6
for a in map(int, input().split()):
    t += a
    q.append(a)
    if t < s:
        continue
    while t >= s:
        t -= q.popleft()
    ans = min(ans, len(q) + 1)
print(ans if ans < 1e6 else 0)

Solution (Python):
N,S = map(int,input().split(" "))
a = list(map(int,input().split(" ")))

ans = float('inf')
l = 0
r = 0
sumv = 0
while True:
	while r < N and sumv < S:
		sumv += a[r]
		r += 1

	if sumv < S:
		break

	ans = min(ans,r-l)
	sumv -= a[l]
	l += 1

if ans == float('inf'):
	ans = 0
print(ans)

Solution (Python):
N,S = map(int, input().split())
As = list(map(int, input().split()))
i = 0
j = 0
sum = 0
m_l = float('inf')

while True:
	while j < N and sum < S:
		sum += As[j]
		j += 1
	
	if sum < S:
		break
	m_l = min(j-i, m_l)
	sum -= As[i]
	i += 1
	
"""
while j < N:
	sum += As[j]
	j += 1
	while i < j and sum :
		sum -= As[i]
		i += 1
		if sum >= S:
			continue
		m_l = min(j-i+1, m_l)
		break
"""
print(m_l if m_l != float('inf') else 0)

Solution (Python):
n,s = map(int, input().split())
a = list(map(int, input().split()))
ans = float("inf")
ma = 0
mi = 0
v = 0
for i in range(n):
    v += a[i]
    if v >= s:
        ma = i
        while v >= s:
            v -= a[mi]
            mi += 1
        ans = min(ans, ma-mi+2)
ans = ans if ans != float("inf") else 0
print(ans)

Solution (Python):
INF = 10**18

N, S = map(int, input().split())
A = list(map(int, input().split()))

res = INF

rt = 0
s = 0

for lt in range(N):
    while rt < N and s < S:
        s += A[rt]
        rt += 1
    if s >= S:
        res = min(res, rt - lt)
    s -= A[lt]

print(res if res != INF else 0)

Solution (Python):
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


N,S = map(int,input().split())
table = list(map(int,input().split()))

ans = BIG_NUM

left = 0
right = 0
tmp_sum = table[0]

while left < len(table):
    while True:
        if tmp_sum >= S:
            ans = min(ans,right-left+1)
            break
        if right == len(table)-1:
            break
        right += 1
        tmp_sum += table[right]

    if tmp_sum < S:
        break

    while True:
        if left > right:
            break
        tmp_sum -= table[left]
        left += 1
        if tmp_sum >= S:
            ans = min(ans,right-left+1)
        else:
            break
    right = max(right,left)


if ans == BIG_NUM:
    print("0")
else:
    print("%d"%(ans))

Solution (Python):






from sys import stdin,setrecursionlimit
from bisect import bisect_left





setrecursionlimit(10**6)
input=stdin.readline

n,s=map(int,input().split())
a=[int(i) for i in input().split()]
nows=0
ans=2<<20
left=0
for right in range(n):
    nows+=a[right]
    while left<=right and right<n:
        if nows>=s:
            ans=min(ans,right-left+1)
            nows-=a[left]
            left+=1
        else: break
        
print(ans%(2<<20))

Solution (Python):
N, S = map(int, input().split())
a = list(map(int, input().split()))

ans = float('INF')
total = 0
l = r = 0

while r < N:
    total += a[r]
    r += 1

    if total >= S:
        while total >= S:
            total -= a[l]
            l += 1
        ans = min(ans, r-l+1)

if ans == float('INF'): ans = 0
print(ans)

Solution (Python):
import sys


if __name__ == "__main__":
    N, S = map(lambda x: int(x), input().split())
    a = list(map(lambda x: int(x), input().split()))

    ans = sys.maxsize
    s = 0
    e = 0
    value = 0
    for idx in range(N):
        value += a[idx]
        if (S <= value):
            e = idx
            while (S <= value):
                value -= a[s]
                s += 1
            ans = min(ans, e - s + 2)
    ans = ans if ans != sys.maxsize else 0
    print(ans)

Solution (Python):
n,s=map(int,input().split( ))
a=list(map(int,input().split( )))
a.append(0)
min=10000000000
sum_temp=0

i_first=0
i_next=0
while i_next<n:
    while sum_temp<s and i_next<=n:
        sum_temp+=a[i_next]
        i_next+=1
    while sum_temp-a[i_first]>=s:
        sum_temp-=a[i_first]
        i_first+=1
    if i_next-i_first<min and sum_temp>=s:
        min=i_next-i_first
    sum_temp-=a[i_first]
    i_first+=1
    if i_first>=n:
        break
if min<10000000000:
    print(min)
else:
    print(0)

Solution (Python):

"""
Sliding Window - The Smallest Window I
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_3_A&lang=jp

"""
N, S = map(int, input().split())
A = [int(a) for a in input().split()]

total, l, r = 0, 0, 0
ans = float('inf')
while True:
    while r < N and total < S:
        total += A[r]
        r += 1
    if total < S:
        break
    ans = min(ans, r-l)
    total -= A[l]
    l += 1
print(ans if ans != float('inf') else 0)

Solution (Python):
from queue import deque

INF = 2**31-1
n, s = map(int, input().split())
A = list(map(int, input().split()))
q = deque()
t = 0
ans = INF
for a in A:
    t += a
    q.append(a)
    if t < s:
        continue
    while t >=s:
        t -=q.popleft()
    ans = min(ans,len(q)+1)
print(ans if ans < INF else 0)

Solution (Python):
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def LIR(n): return [LI() for i in range(n)]
def MI(): return map(int, input().split())


"""
n,q = map(int, input().split(" "))
group = [[i] for i in range(n)]
key = [i for i in range(n)]
for i in range(q):
    com, x, y = map(int, input().split(" "))
    if com == 0:
        if key[x] != key[y]:
            v = key[y]
            group[key[x]] = group[key[x]] + group[key[y]]
            for j in group[v]:
                key[j] = key[x]
            group[v] = []
    if com == 1:
        if key[x] == key[y]:
            print(1)
        else:
            print(0)
"""

"""
def root(x,n):
    if par[x][0] == x:
        return [x,n+par[x][1]]
    return root(par[x][0],par[x][1])
def unite(x,y):
    rx = root(x)
    ry = root(y)
    if rx[0] == ry[0]:
        return
    par[rx][0] = ry[0]
    par[rx][1] += ry[1]
n,q = map(int, input().split(" "))
par = [[i,0] for i in range(n)]
for i in range(q):
    q = list(map(int, input().split(" ")))
    if q[0] == 0:

        if root(q[1],0) != root(q[])
"""


"""
n,q = map(int, input().split(" "))
k = 2**31-1
a = [float("inf") for i in range(n)]
for i in range(q):
    com, x, y = map(int, input().split(" "))
    if com == 0:
        a[x] = y
    else:
        mi = k
        for j in range(x, y+1):
            if a[j] == float("inf"):
                mi = min(mi, k)
            else:
                mi = min(mi,a[j])
        print(mi)
"""



















n,s = MI()
a = LI()
for i in range(1,n):
    a[i] += a[i-1]
a.insert(0,0)
l = 0
r = 0
ans = float("inf")
if a[1] >= s:
    print(1)
    quit()
while r < n:
    r += 1
    if a[r]-a[l] >= s:
        while a[r]-a[l] >= s and l < r:
            l += 1
        ans = min(ans, r-l+1)
if ans == float("inf"):
    print(0)
    quit()
print(ans)





"""
n,t = map(int, input().split(" "))
num = [0 for i in range(t)]
for i in range(n):
    l,r = map(int, input().split(" "))
    num[l] += 1
    if r < t:
        num[r] -= 1
for i in range(1,t):
    num[i] += num[i-1]
print(max(num))
"""


"""
n = int(input())
lec = [[0 for i in range(1001)] for j in range(1001)]
max_x = 0
max_y = 0
for i in range(n):
    x,y,s,t = map(int, input().split(" "))
    lec[y][x] += 1
    lec[y][s] -= 1
    lec[t][x] -= 1
    lec[t][s] += 1
    max_x = max(max_x, s)
    max_y = max(max_y, t)

for i in range(max_y+1):
    for j in range(1, max_x+1):
        lec[i][j] += lec[i][j-1]

for i in range(1, max_y+1):
    for j in range(max_x+1):
        lec[i][j] += lec[i-1][j]

ans = 0
for i in range(max_y+1):
    for j in range(max_x+1):
        ans = max(ans, lec[i][j])

print(ans)
"""

Solution (Python):
N, S = map(int, input().split())
*A, = map(int, input().split())

ans = N+1

v = t = 0
for s in range(N):
    while t < N and v < S:
        v += A[t]
        t += 1
    if S <= v:
        ans = min(ans, t-s)
    v -= A[s]
print(ans if ans < N+1 else 0)

Solution (Python):





def find(xs, size, s):
    sum_ = sum(xs[:size])
    if s <= sum_:
        return True
    for i in range(len(xs)-size):
        sum_ -= xs[i]
        sum_ += xs[i+size]
        if s <= sum_:
            return True
    return False


def run():
    n, s = [int(i) for i in input().split()]
    li = [int(i) for i in input().split()]

    if s > sum(li):
        print(0)
        return
    elif s < max(li):
        print(1)
        return

    i, j = 0, n
    while i+1 < j:
        
        
        mid = (i + j) // 2
        
        if find(li, mid, s):
            j = mid
        else:
            i = mid

    print(j)


if __name__ == '__main__':
    run()