Harryxun/stf_run huggingface dataset:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2000)
INF=float('inf')
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
d=[INF]*n
nbr=[[] for _ in range(n)]
used=[False]*m
for x in l:
    x[0]-=1
    x[1]-=1
#print(l)
for i in range(m):
    nbr[l[i][0]].append(i)
    nbr[l[i][1]].append(i)
#print(nbr)
def sol(i):
    if d[i]==INF:
        d[i]=0
    for x in nbr[i]:
        if used[x]:continue
        used[x]=True
        if l[x][0]==i:
            if d[l[x][1]]==INF:
                d[l[x][1]]=d[i]+l[x][2]
            elif d[l[x][1]]!=d[i]+l[x][2]:
                print('No')
                exit()
            sol(l[x][1])
        else:
            if d[l[x][0]]==INF:
                d[l[x][0]]=d[i]-l[x][2]
            elif d[l[x][0]]!=d[i]-l[x][2]:
                print('No')
                exit()
            sol(l[x][0])
for i in range(n):
    sol(i)
#print(d)
print('Yes')

### FIXED CODE ###

def solve():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    INF=float('inf')
    n,m=map(int,input().split())
    l=[list(map(int,input().split())) for _ in range(m)]
    d=[INF]*n
    nbr=[[] for _ in range(n)]
    used=[False]*m
    for x in l:
        x[0]-=1
        x[1]-=1
    #print(l)
    for i in range(m):
        nbr[l[i][0]].append(i)
        nbr[l[i][1]].append(i)
    #print(nbr)
    def sol(i):
        for x in nbr[i]:
            if used[x]:continue
            used[x]=True
            i1=l[x][0]^l[x][1]^i
            dd=d[i]+l[x][2]*(2*(l[x][0]==i)-1)
            if d[i1]!=dd and d[i1]!=INF:
                print('No')
                exit()
            elif d[i1]==INF:
                d[i1]=dd
                sol(i1)
    for i in range(n):
        if d[i]==INF:
            d[i]=0
            sol(i)
    #print(d)
    print('Yes')
solve()
A = input()
B = input()
AA = f"{A:>101}"
BB = f"{B:>101}"
if AA == BB:
    print("EQUAL")
elif AA>BB:
    print("GREATER")
else:
    print("LESS")

### FIXED CODE ###

A = input()
B = input()
AA = "%101s" % A
BB = "%101s" % B
if AA == BB:
    print("EQUAL")
elif AA>BB:
    print("GREATER")
else:
    print("LESS")
T = input()
X = input()

print("{0:.3f}".format(T/X))

### FIXED CODE ###

T, X = map(float, input().split())
 
print("{0:.4f}".format(T/X))
a,b,c,d,r=map(int,input().split())
a-=r*2
b-=r*2
c-=r
d-=r

if 0<c and 0<d and 0<a and 0<b:
	print("Yes")
elif:
	print("No")

### FIXED CODE ###

a,b,c,d,r=map(int,input().split())

if a>0:
	if c<0:
		print("No")
		exit()

if a<0:
	if c>0:
		print("No")
		exit()		

if b>0:
	if d<0:
		print("No")
		exit()

if b>0:
	if d<0:
		print("No")
		exit()

a=abs(a)
b=abs(b)
c=abs(c)
d=abs(d)

a-=r*2
b-=r*2
c-=r
d-=r

if 0<=c and 0<=d and 0<=a and 0<=b and c<=a and d<=b:
	print("Yes")
else:
	print("No")
import math
def nCr(n,r):
    return math.factorial(n) / math.factorial(r) / math.factorial(n-r)
N,M=list(map(int,input().split(' ')))
print(int(nCr(N,2)+nCr(M,2)))

### FIXED CODE ###

import math
def nCr(n,r):
    return math.factorial(n) / math.factorial(r) / math.factorial(n-r) if n>1 else 0
N,M=list(map(int,input().split(' ')))
print(int(nCr(N,2)+nCr(M,2)))
a, b, c, d = map(int, input().split())

if a==b==c or b==c==d or a==b==c==d:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a = str(input())
 
if a[0]==a[1]==a[2] or a[1]==a[2]==a[3] or a[0]==a[1]==a[2]==a[3]:
  print('Yes')
else:
  print('No')
N=int(input())

if N=1:
    print(1)
elif 2<=N<=3:
    print(2)
elif 4<=N<=7:
    print(4)
elif 8<=N<=15:
    print(8)
elif 16<=N<=31:
    print(16)
elif 32<=N<=63:
    print(32)
elif 64<=N<=100:
    print(64)

### FIXED CODE ###

N=int(input())

if N==1:
    print(1)
elif 2<=N<=3:
    print(2)
elif 4<=N<=7:
    print(4)
elif 8<=N<=15:
    print(8)
elif 16<=N<=31:
    print(16)
elif 32<=N<=63:
    print(32)
elif 64<=N<=100:
    print(64)
N, K = map(int, input().split())
A = list(map(int, input().split()))
teleport = dict()
for i, a in enumerate(A):
    teleport[i+1] = a
# teleport

state = 1
connect = []
looplen= 0
for n in range(K):
    connect.append(state)
    state = teleport[state] 
    if state in connect:
        loop_init = connect.index(state)
        looplen = n-connect.index(state)+1   #0->0なら1
        #print(connect.index(state))
        #print(n)
        break
init
index = (k-init)%looplen
end = connect[index+init]
print(end)

### FIXED CODE ###

looplenn,k = map(int,input().split())
a = [0]+list(map(int,input().split()))

def bin(arr,val):
    left,right = 0,len(arr)-1
    while left<=right:
        mid = (left+right)//2
        if arr[mid]==val: return 1
        elif arr[mid]<val: left = mid + 1
        else: right = mid - 1
    return 0

know = []
now = 1
while not bin(know, now):
    know.append(now)
    now = a[now]

loop_start = a[know[-1]]
for i,num in enumerate(know):
    if num == loop_start:
        loop_init = i
        loop = know[i:]
        break

#print(know,start,loop)

cnt = len(loop)
if k < len(know):
    ans = know[k]
else:
    ans = loop[(k-loop_init)%cnt]
# ans = loop[k%cnt]


print(ans)
N, K = [int(_) for _ in input().split()]

S = input()

xs = []

i = 0

while i < N :
    l = 0
    while i < N and S[i] == '1':
        i += 1
        l += 1
    xs.append(l)
    l = 0
    while i < N and S[i] == '0':
        i += 1
        l += 1
    xs.append(l)

xs += [0] * (K * 2)

#print(xs)

result = 0

l = (K * 2) + 1
result = r = sum(xs[0:l])
#print("*", result, r)

i = 0
while i + l + 1 < N:
    r = r - xs[i] - xs[i+1] + xs[i+l] + xs[i+l+1]
    result = max(result, r)
    #print(result, r)
    i += 2

print(result)


### FIXED CODE ###

N, K = [int(_) for _ in input().split()]

S = input()

xs = []

i = 0

while i < N :
    l = 0
    while i < N and S[i] == '1':
        i += 1
        l += 1
    xs.append(l)
    l = 0
    while i < N and S[i] == '0':
        i += 1
        l += 1
    xs.append(l)

xs += [0] * (K * 2)

#print(xs)

result = 0

l = (K * 2) + 1
result = r = sum(xs[0:l])
#print("*", result, r)

i = 0
while i + l + 1 < len(xs):
    r = r - xs[i] - xs[i+1] + xs[i+l] + xs[i+l+1]
    result = max(result, r)
    #print(result, r)
    i += 2

print(result)
n=int(input())
ans4=0
ans2=0
a=input().split()
for i in range(n):
  if a[i]%4==0:
    ans4+=1
  elif a[i]%2==0:
    ans2+=1
  else:
    pass
if (n-ans2)//2+1<=ans4:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

from math import ceil
n=int(input())
ans4=0
ans2=0
ans0=0
a=list(map(int,input().split()))
for i in range(n):
  if a[i]%4==0:
    ans4+=1
  elif a[i]%2==0:
    ans2+=1
  else:
    ans0+=1
if ans2>0:
  if ans0<=ans4:
    print('Yes')
  else:
    print('No')
else:
  if ceil((ans0+ans4)/2)>=ans0:
    print('Yes')
  else:
    print('No')
import fileinput

for line in fileinput.input():
    vals = line.split()
    print min(vals[0] - vals[1], vals[2])

### FIXED CODE ###

vals = [int(x) for x in input(). split()]
dif = vals[0] - vals[1]
 
if dif >= vals[2]:
  print(0)
else:
  print(vals[2] - dif)
from sys import stdin

A, B = map(int, stdin.readline().split())
if A >= 13:
  print(B):
elif 12 >= A >= 6:
  print(B // 2)
else:
  print(0)

### FIXED CODE ###

from sys import stdin

A, B = map(int, stdin.readline().split())
if A >= 13:
  print(B)
elif 12 >- A and A >= 6:
  print(B // 2)
else:
  print(0)
h, w = [int(n) for n in ipt[:1]]
i,j = [h,w].sort()
area = i*j
if i % 3 == 0 or j % 3:
    print(0)
else:
    p=j//3+1
    a = i*(p)
    b= i//2*(j-p)
    print(abs(a-b))

### FIXED CODE ###

h, w = [int(n) for n in input().split()]
i = min(h, w)
j = max(h, w)
area = i * j
if i % 3 == 0 or j % 3 == 0:
    print(0)
else:
    lst = []
    for r, s in [(i, j), (j, i)]:
        
        p = s // 3 + 1
        q = s // 3 
        a1 = r * p
        a2 = r * q
        b1 = r // 2 * (s - p)
        bb1 = (r // 2 - 1) * (s - p)
        b2 = r // 2 * (s - q)
        bb2 = (r // 2 - 1) * (s - q)
        c1 = (s - p) // 2 * r
        cc1 = ((s - p) // 2- 1) * r
        c2 = (s - q) // 2 * r
        cc2 = ((s - q) // 2 - 1) * r
        tup = [(a1, b1), (a2, b2), (a1, c1), (a2, c2),
               (a1, bb1), (a2, bb2), (a1, cc1), (a2, cc2)]
        lst.extend([abs(max(a, b, area - a - b) - min(a, b, area - a - b))
                    for a, b in tup])
    print(min(lst))
import bisect

n = int(input())
l = sorted(list(map(int, input().split())))

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        ans += bisect.bisect_left(l, l[i]+l[j]) - (j+1)
        #print(l,i,j,bisect.bisect_left(l, l[i]+l[j]))
print(ans)

### FIXED CODE ###

N = int(input())
a = list(input())
count = 1
for i in range(N):
  if i>0:
    if a[i-1]==a[i]:
      pass
    elif a[i-1]!=a[i]:
      count+=1
      
print(count)
a,b,c=map(int,input().split())

if a*b*c==a*a*a and a+b+c==3a:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a,b,c=map(int,input().split())

if a*b*c==a*a*a and a+b+c==3*a:
  print("Yes")
else:
  print("No")
n = int(input())                                                            
  for i in range(n + 1):
      if i != 0 and i % 3 == 0:
          print('',i,end='')
      elif '3' in str(i):
          print('',i,end='')

### FIXED CODE ###

n = int(input())
for i in range(n + 1):
    if i != 0:
        if i % 3 == 0 or '3' in str(i):
            print('',i,end='')                                                  
print()
N = int(input())
L = list(map(int, input().split()))
 
ans = 0
if(N >= 3):
  t = []
  for i in range(N):
    for j in range(i+1, N):
      for k in range(j+1, N):
        if((abs(L[j]-L[k]) < L[i]) & (L[i] < L[j]+L[k])): t.append((L[i], L[j], L[k]))
  ans = len(set(t))

print(ans)

### FIXED CODE ###

S = input()
 
ans = 0
if S == 'RRR': ans = 3
else:
  if ('RR' in S): ans = 2
  else:
    if('R' in S): ans = 1
    else: ans = 0
 
print(ans)
import math
a,b,C = map(float,input().split())
C_rad=math.pi*C/180
print("{0:.8f}".format(math.sin(C_rad)*a*b/2))
print("{0:.8f}".format(a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(C_rad))))
print("{0:.8f}".format(b*math.sin(C_rad)))

### FIXED CODE ###

class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
 
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
 
    def print_top(self): print(self.top)
    def print_right(self): print(self.right)
 
    def get_label(self):
        return [self.top, self.front, self.right, self.left, self.rear, self.bottom]

    def compare(self, label):
        for op in 'EEENEEENEEESEEESEEENEEEN':
            if self.get_label() == label:
                return True
            self.roll(op)
        else:
            return False
  
if __name__=='__main__':
    n = int(input())
    L = []
    for i in range(n):
        label = list(map(int,input().split()))
        for d in L:
            if d.compare(label): break
        else:
            L.append(dice(label))
            continue
        print('No')
        break
    else:
        print('Yes')
N, M=map(int, input().split())
AB= [map(int, input().split()) for _ in range(M)]
A, B = [list(i) for i in zip(*AB)]

G=[0]*(N+1)
sw=1
for i in range(M):
    if G[A[i]]+G[B[i]]==0:
        G[A[i]]=sw
        G[B[i]]=sw
        sw+=1
    if G[A[i]]!=0:
        G[B[i]]=G[A[i]]
    else:
        G[A[i]]=G[B[i]]
G=G[1:]
import collections
c=collections.Counter(G)
print(c.most_common()[0][1])

### FIXED CODE ###

N, M=map(int, input().split())
A=[]
B=[]
for i in range(M):
    a,b=map(int, input().split())
    A.append(a)
    B.append(b)
# AB= [map(int, input().split()) for _ in range(M)]
# A, B = [list(i) for i in zip(*AB)]
def find(x,parent):
    if parent[x]==x:
        return x
    else:
        parent[x]=find(parent[x],parent)
        return(parent[x])
        
def union(x,y,parent,rank):
    xroot=find(x,parent)
    yroot=find(y,parent)
    if rank[xroot]>rank[yroot]:
        parent[yroot]=xroot
    elif rank[yroot]>rank[xroot]:
        parent[xroot]=yroot
    elif rank[yroot]==rank[xroot]:
        parent[yroot]=xroot
        rank[xroot]+=1
    return(parent,rank)

    
parent=[i for i in range(N+1)]
rank=[0]*(N+1)
for i in range(M):
    parent,rank=union(A[i],B[i],parent,rank)
for i in range(N+1):
    find(i,parent)
G=parent[1:]
import collections
c=collections.Counter(G)
print(int(c.most_common()[0][1]))
a,b=map(int,input())
print(max(a+b,a-b,a*b))

### FIXED CODE ###

a,b=map(int,input().split())
print(max(a+b,a-b,a*b))
count = 0

def marge(A,left,mid,right):
    global count
    n1 = mid -left
    n2 = right -mid
    L = []
    R = []
    j=0
    for i in range(left,n1+left):
        L[j]=A[i]
        j += 1
    L[j+1] = float("inf")
    j=0
    for i in range(mid,n2+mid):
        R[j]=A[i]
        j += 1
    R[j+1] = float("inf")



'''
    L.append(float("inf"))
    R.append(float("inf"))
'''
    r_id,l_id = 0,0
    for k in range(left,right):
        count += 1
        if(L[l_id] <= R[r_id]):
            A[k] = L[l_id]
            l_id += 1
        else:
            A[k] = R[r_id]
            r_id += 1

def margeSort(A,left,right):
    if left+1 < right:
        mid = int((left+right)/2)
        margeSort(A,left,mid)
        margeSort(A,mid,right)
        marge(A,left,mid,right)


n = int(input())
s = input()
A = []
A = list(map(int,s.split()))

margeSort(A,0,n)

A_str = map(str,A)
print(" ".join(list(A_str)))
print(count)

### FIXED CODE ###

count = 0

def marge(A,left,mid,right):
    global count
    n1 = mid -left
    n2 = right -mid
    L = []
    R = []
    for i in range(left,n1+left):
        L.append(A[i])
    for i in range(mid,n2+mid):
        R.append(A[i])

    L.append(float("inf"))
    R.append(float("inf"))

    r_id,l_id = 0,0
    for k in range(left,right):
        count += 1
        if(L[l_id] <= R[r_id]):
            A[k] = L[l_id]
            l_id += 1
        else:
            A[k] = R[r_id]
            r_id += 1

def margeSort(A,left,right):
    if left+1 < right:
        mid = int((left+right)/2)
        margeSort(A,left,mid)
        margeSort(A,mid,right)
        marge(A,left,mid,right)


n = int(raw_input())
s = raw_input()
A = []
A = map(int,s.split())

margeSort(A,0,n)

A_str = map(str,A)
print(" ".join(list(A_str)))
print count
n = int(input())

q = deque()
for i in range(n):
    cmd = input().strip()
    if cmd == 'deleteFirst':
        q.popleft()
        continue
    if cmd == 'deleteLast':
        q.pop()
        continue
    cmd, x = cmd.split()
    x = int(x)
    if cmd == 'insert':
        q.appendleft(x)
        continue
    if cmd == 'delete':
        try:
            q.remove(x)
        except:
            pass
        continue

print(' '.join(map(str, q)))

### FIXED CODE ###

import sys
from collections import deque

n = int(sys.stdin.readline())
q = deque()
for i in range(n):
    cmd = sys.stdin.readline()[:-1]
    if cmd[0] == 'i':
        q.appendleft(cmd[7:])
    elif cmd[6] == ' ':
        try:
            q.remove(cmd[7:])
        except:
            pass
    elif cmd[6] == 'F':
        q.popleft()
    else:
        q.pop()

print(' '.join(q))
n,a,b = list(map(int,input().split(" ")))
mod = 10**9 + 7

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result = int(numerator[k]) * result % mod

    return result
  
 def m_power_n_mod(m,n,mod):
    q = 1
    f = m
    while(n > 0):
        c = n % 2
        n = int((n-c)/2)
        q = (q * f**c) % mod
        f = f**2 % mod
    return q
 
print((m_power_n_mod(2,n,mod) - 1 - cmb(n,a)%mod - cmb(n,b)%mod)%mod)

### FIXED CODE ###

n,a,b = list(map(int,input().split(" ")))
mod = 10**9 + 7

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result = int(numerator[k]) * result % mod

    return result

def m_power_n_mod(m,n,mod):
    q = 1
    f = m
    while(n > 0):
        c = n % 2
        n = int((n-c)/2)
        q = (q * f**c) % mod
        f = f**2 % mod
    return q

print((m_power_n_mod(2,n,mod) - 1 - cmb(n,a)%mod - cmb(n,b)%mod)%mod)
from collections import Counter
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0]())
D = list(map(int, inputs[1]().split()))

if (D[0] != 0):
    print(0)
else:
    c = Counter(D)
    if (c[0] > 1):
        print(0)
    else:
        ans = 1
        for i in range(1,max(D)+1):
            ans *= c[i-1]**c[i]
        print(ans % 998244353)

### FIXED CODE ###

from collections import Counter
inputs = open(0).readlines()

n = int(inputs[0])
*D, = map(int, inputs[1].split())
mod = 998244353

nbs = [0] * (max(D)+1)
for k, v in Counter(D).items():
    nbs[k] = v

if D[0] != 0 or nbs[0] != 1:
    print(0)
else:
    ans = 1
    for n0, n1 in zip(nbs, nbs[1:]):
        ans = ans * pow(n0, n1, mod) % mod
    print(ans)
a=int(input)
print(800*a-200*(int(a/15)))

### FIXED CODE ###

a=int(input())
print(800*a-200*(int(a/15)))
import math

N=int(input())
print((math.factorical(N))%(10**9+7))

### FIXED CODE ###

import math
N=int(input())

print(math.factorial(N)%(10**9+7))
while True:
    H,W=[int(x) for x in input().split()]
    if H == 0 and W == 0 : break
    for a in range(H):
        for b in range(W):
        print("#")



### FIXED CODE ###

while True:
    H,W=[int(x) for x in input().split()]
    if H == 0 and W == 0 : break
    for a in range(H):
        for b in range(W):
            print("#",end='')
        print('')
    print('')
import sys
n,q=map(int,input().split())
s=input()
l=[[i for i in l.split()] for l in sys.stdin]
def right_fallen(x):
  stack=x
  for i in range(n):
    if stack==n:
      return True
    if stack==-1:
      return False
    if l[i][0]==x[stack]:
      if l[i][1]=='R':
        stack+=1
      else:
        stack-=1
  return False
def right_fallen(x):
  stack=x
  for i in range(n):
    if stack==n:
      return False
    if stack==-1:
      return True
    if l[i][0]==x[stack]:
      if l[i][1]=='R':
        stack+=1
      else:
        stack-=1
  return False
def binary_search():
  ok=n
  ng=-1
  while(abs(ok-ng)>1):
    mid=(ok+ng)//2
    if right_fallen(mid):
      ok=mid
    else:
      ng=mid
  return ok
def binary_search2():
  ok=-1
  ng=n
  while(abs(ok-ng)>1):
    mid=(ok+ng)//2
    if left_fallen(mid):
      ok=mid
    else:
      ng=mid
  return ok
print(binary_search-binarysearch2-1)

### FIXED CODE ###

import sys
n,q=map(int,input().split())
s=input()
l=[[i for i in l.split()] for l in sys.stdin]
def right_fallen(x):
  stack=x
  for i in range(q):
    if stack==n:
      return True
    if stack==-1:
      return False
    if l[i][0]==s[stack]:
      if l[i][1]=='R':
        stack+=1
      else:
        stack-=1
  if stack==n:
    return True
  return False
def left_fallen(x):
  stack=x
  for i in range(q):
    if stack==n:
      return False
    if stack==-1:
      return True
    if l[i][0]==s[stack]:
      if l[i][1]=='R':
        stack+=1
      else:
        stack-=1
  if stack==-1:
    return True
  return False
def binary_search():
  ok=n
  ng=-1
  while(abs(ok-ng)>1):
    mid=(ok+ng)//2
    if right_fallen(mid):
      ok=mid
    else:
      ng=mid
  return ok
def binary_search2():
  ok=-1
  ng=n
  while(abs(ok-ng)>1):
    mid=(ok+ng)//2
    if left_fallen(mid):
      ok=mid
    else:
      ng=mid
  return ok
print(binary_search()-binary_search2()-1)
# -*- coding: utf-8 -*-
      
      
   ddd

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Nov  3 09:19:07 2018

@author: sk
"""

     
      
b, c = map(int, input().split())
     
s=0.5*(b+c)
     
d = int(s)
    
if s-d > 0:
    v=int(d+1)
else :
    v=int(d)
print(v)
N, X = map(int, input().split())
L = list(map(int, input().split()))

count = 1
position = 0

while position <= X:
    position += L.pop(0)
    if position <= X:
        count += 1

print(count)

### FIXED CODE ###

N, X = map(int, input().split())
L = list(map(int, input().split()))

count = 1
position = 0

while L and position <= X:
    position += L.pop(0)
    if position <= X:
        count += 1

print(count)
def dfs(s):
    global K, cnt, ans, S
    if cnt == K:
        ans = s
        return
    for c in alpha:
        if S.count(s + c) > 0:
            cnt += 1
            dfs(s + c)


S = input()
K = int(input())
cnt = 0
alpha = [chr(ord('a') + i) for i in range(26)]
ans = ''
dfs('')
print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)


def dfs(s, pos):
    global N, K
    ns = {}
    if len(A) > K:
        return
    for i in pos:
        ni = i + 1
        if ni < N:
            x = s + S[ni]
            if x in ns:
                ns[x].append(ni)
            else:
                ns[x] = [ni]
    candidate = []
    for x in list(ns.keys()):
        candidate.append((x, ns[x]))
    candidate.sort()
    for c, idx in candidate:
        A.add(c)
        dfs(c, idx)


S = list(input())
N = len(S)
K = int(input())
alpha = [chr(ord('a') + i) for i in range(26)]

A = set()
for c in alpha:
    if len(A) < K:
        pos = []
        for i, s in enumerate(S):
            if c == s:
                A.add(c)
                pos.append(i)
        dfs(c, pos)

A = list(A)
A.sort()
print(A[K - 1])
import copy
N = int(input())
A = list(map(int, input().split()))

a_types = set(A)

count_dict = [0] * N
for each in a_types:
    count_dict[each] = A.count(each)

all_types = 0
for value in count_dict:
    all_types += value * (value - 1) // 2

# result_dict = {}
# for each in a_types:
#     result_dict[each] = all_types - count_dict[each] + 1

for a in A:
    print(all_types - count_dict[a] + 1)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))

c = [0]*n

for i in range(n):
    c[a[i]-1] = c[a[i]-1] + 1
    
total = 0
for x in c:
    total = total + x*(x-1)//2

for i in range(n):
    print(total - c[a[i]-1] + 1)
s=input()
k=int(input())
count=0
for one in s:
  if one=="1":
    count+=1
  else:
    break
print(int(s.replace("1","")[0]) if k>=count else 1)

### FIXED CODE ###

s=input()
k=int(input())
count=0
for one in s:
  if one=="1":
    count+=1
  else:
    break
print(int(s.replace("1","")[0]) if k>count else 1)
n,m = map(int,input().split())
res ={}
for _ in range(m):
    x,y = map(int,input().split())
    res[x] = res.get(x,[]) + [y]
memo = {} #nodeを始点としたパスの最長長さ
def dfs(node):
    if node in memo:
        return memo[node]
    a = 0
    for n in res.get(node,[]):
        a = max(a,dfs(n)+1)
    memo[node] = a
    return memo[node]

ans = 0
for i in range(1,n+1):
    ans = max(ans,dfs(i))
print(ans)

### FIXED CODE ###

from collections import deque
 
N, M = map(int, input().split())
adjL = [[] for v in range(N)]
indegs = [0] * N
for _ in range(M):
    x, y = map(int, input().split())
    adjL[x-1].append(y-1)
    indegs[y-1] += 1
 
dp = [0] * N
Q = deque([v for v in range(N) if indegs[v] == 0])
while Q:
    vNow = Q.popleft()
    for v2 in adjL[vNow]:
        dp[v2] = max(dp[v2], dp[vNow] + 1)
        indegs[v2] -= 1
        if indegs[v2] == 0:
            Q.append(v2)
 
print(max(dp))