Harryxun/stf_run huggingface dataset:
H,W = map(int,input().split())
L = []
for i in range(H) :
    L.append(list(input()))
flag = 0
for i in range(H) :
    for j in range(W) :
        if L[i][j] == "#" :
            if j == 0 :
                if i == 0 :
                    if (L[i+1][j] != "#") and (L[i][j+1] != "#") :
                        flag = 1
                elif i == (W-1) :
                    if (L[i-1][j] != "#") and (L[i][j+1] != "#") :
                        flag = 1
                else :
                    if (L[i-1][j] != "#") and (L[i][j+1] != "#") and (L[i+1][j] != "#") :
                        flag = 1
            elif j == (H-1) :
                if i == 0 :
                    if (L[i+1][j] != "#") and (L[i][j-1] != "#") :
                        flag = 1
                elif i == (W-1) :
                    if (L[i-1][j] != "#") and (L[i][j-1] != "#") :
                        flag = 1
                else :
                    if (L[i-1][j] != "#") and (L[i][j-1] != "#") and (L[i+1][j] != "#") :
                        flag = 1
            else :
                if i == 0 :
                    if (L[i+1][j] != "#") and (L[i][j+1] != "#") and (L[i][j-1] != "#") :
                        flag = 1
                elif i == (W-1) :
                    if (L[i-1][j] != "#") and (L[i][j+1] != "#") and (L[i][j-1] != "#") :
                        flag = 1
                else :
                    if (L[i-1][j] != "#") and (L[i][j+1] != "#") and (L[i+1][j] != "#") and (L[i-1][j] != "#") :
                        flag = 1
        if flag == 1 :
            break
    if flag == 1 :
        break
if flag == 0 :
    print("Yes")
else :
    print("No")



### FIXED CODE ###

H,W = map(int,input().split())
L = [input() for i in range(H)]
dxy = [[1,0],[-1,0],[0,1],[0,-1]]
flag = 1

for y in range(H) :
    for x in range(W) :
        if L[y][x] == "#" and flag == 1 :
            for dx,dy in dxy :
                nx = x+dx
                ny = y+dy
                if (0 <= nx <= W-1) and (0 <= ny <= H-1) :
                    if L[ny][nx] == "#" :
                        flag = 1
                        break
                    else :
                        flag = 0
if flag == 1 :
    print("Yes")
else :
    print("No")
i,j=map(int,input().split())
listA=[]
for i in range(i):
    listA.append(list(map(int,input().split())))
    listA[n].append(sum(listA[n]))
listA.append([])
for n in range(j+1):
    number =0
    for m in range(i):
        number+=listA[m][n]
    listA[i].append(number)
for n in range(i+1):
    print(''.join(map(str,listA[n])))
   


### FIXED CODE ###

i,j=map(int,input().split())
listA=[]
for n in range(i):
    listA.append(list(map(int,input().split())))
    listA[n].append(sum(listA[n]))
listA.append([])
for n in range(j+1):
    number=0
    for m in range(i):
        number+=listA[m][n]
    listA[i].append(number)
for n in range(i+1):
    print(' '.join(map(str,listA[n])))
import math
from scipy import optimize

def f1(sita,b,x):
    return b**2/8*math.sin(sita)*(3-math.cos(sita))-x


def resolve():
    a,b,x=map(int,input().split())
    xx=x/a
    
    if x==b*a**2:
        print(0)
    elif xx<a*b/2:
        ts=b**2/(xx)/2
        print(math.degrees(ans[0]))
        
    elif xx==a*b/2:
        print(45)
    else:
        ts=a**2/(a*b-xx)/2
        print(90-math.degrees(math.atan(ts)))
        
if __name__ == "__main__":
    resolve()

### FIXED CODE ###

import math

def resolve():
    a,b,x=map(int,input().split())
    xx=x/a
    
    if x==b*a**2:
        print(0)
    elif xx<a*b/2:
        ts=b**2/(xx)/2
        print(math.degrees(math.atan(ts)))
        
    elif xx==a*b/2:
        print(45)
    else:
        ts=a**2/(a*b-xx)/2
        print(90-math.degrees(math.atan(ts)))
if __name__ == "__main__":
    resolve()
A,B = map(int, input(),split())
print(A*B/2)

### FIXED CODE ###

A,B,C = map(int, input().split())
print(A*B//2)
n, q = list(map(int, input().split()))
s = input()

def f(i):
    cnt = 0
    for j in range(i-1):
        #print(s[j:j+2])
        if s[j:j+2] == 'AC':
            cnt += 1
    return cnt

for _ in range(q):
    l, r = list(map(int, input().split()))
    #print(s[l-1:r])
    print(f(r) - f(l))


### FIXED CODE ###

n, q = list(map(int, input().split()))
s = input()

#def f(i):
#    cnt = 0
#    for j in range(i-1):
#        #print(s[j:j+2])
#        if s[j:j+2] == 'AC':
#            cnt += 1
#    return cnt

ftab = [0]*(n+1)
cnt = 0

for i in range(n-1):
    if s[i:i+2] == 'AC':
        cnt += 1
    ftab[i+2] = cnt

for _ in range(q):
    l, r = list(map(int, input().split()))
    #print(s[l-1:r])
    print(ftab[r] - ftab[l])
N=input()
S=input()
R=[]
G=[]
B=[]
for i in range(len(S)):
    if S[i]=='R':
        R.append(i)
    if S[i]=='G':
        G.append(i)
    if S[i]=='B':
        B.append(i)

count=0
for i in range(len(R)):
    for j in range(len(G)):

        if max(R[i],G[j])+abs(R[i]-G[j]) in B:
            count+=1

        if min(R[i],G[j])-abs(R[i]-G[j]) in B:
            count+=1

        if (R[i]+G[j])/2 in B:
            count+=1


print(str((len(R)*len(G)*len(B))-count))


### FIXED CODE ###

N=input()
if "7" in N:
  print('Yes')
else:
  print('No')
DEBUG = False
if DEBUG:
    N = int(input())

def check(n):
    print("? " + str(n), flush = True)
    if DEBUG:
        rtn = 'Y' if (n <= N) == (str(n) <= str(N)) else 'N'
        print(rtn)
        return rtn
    else:
        return input()

if check(10000000000) == 'Y':
    for i in range(11, 0, -1):
        n = 1
        tmp = 10**i - 1
        if check(tmp) == 'N':
            n = tmp + 1
            break
else:
    for i in range(1, 10):
        tmp = 10**i
        if check(tmp) == 'N':
            l = tmp // 10
            r = tmp - 1
            break
    while l + 1 < r:
        m = (l + r) // 2
        if check(10 * m) == 'Y':
            r = m
        else:
            l = m
    n = r

print("! "+ str(n), flush = True)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
s = [0]
ans = 1e18
for ai in a:
    s.append(s[-1] + ai)
for i in range(1, n):
    ans = min(ans, abs(s[i] - (s[-1] - s[i])))
print(ans)
#%%
import numpy as np
n,nige,oni = map(int,input().split())
aa = np.zeros((n,n),dtype=bool)
for i in range(n-1):
    a,b = map(int,input().split())
    aa[a-1][b-1] = 1
    aa[b-1][a-1] = 1
nigel = np.zeros(n,dtype=bool)
nigel[nige-1] = 1
onil = np.zeros(n,dtype=bool)
onil[oni-1] = 1
ans = 0
for i in range(n-1):
    nigel = np.any(aa[nigel] == True,axis = 0)
    if np.logical_and(onil,nigel).sum() == nigel.sum():
        print(ans)
        exit()
    ans += 1
    onil = np.any(aa[onil] == True,axis = 0)
    nigel = np.logical_and(nigel,~onil)
    if nigel.sum() == 0:
        print(ans)
        exit()

### FIXED CODE ###

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,u,v = mi()
data = [[] for _ in range(n)]
for i in range(n-1):
    a,b = mi()
    a -= 1
    b -= 1
    data[a].append(b)
    data[b].append(a)
inf = -1
oni = [inf]*n
ko = [inf]*n

from collections import deque

def start(hazime,alis):
    d = deque()
    d.append((hazime-1,0))
    alis[hazime-1] = 0
    while d:
        ima,num = d.popleft()
        num += 1
        for i in data[ima]:
            if alis[i] != inf:
                continue
            alis[i] = num 
            d.append((i,num))
start(u,ko)
start(v,oni)

if len(data[u]) == 1 and data[u] == v:
    print(0) 
    exit()
ans = -1
for i in range(n):
    if ko[i] <= oni[i]:
        ans = max(ans,oni[i]-1)
print(ans)
n = int(input())
alst = list(map(int, input().split()))
edges = [[] for _ in range(n)]
rev_edges = [[] for _ in range(n)]
for i in range(n):
  edges[i].append((i + alst[i]) % n)
  rev_edges[(i + alst[i]) % n].append(i)

def dfs(x, ret, edges, visited):
  visited[x] = True
  for e in edges[x]:
    if not visited[e]:
      dfs(e, ret, edges, visited)
  ret.append(x)

def dfs_rev(x, cycles, rev_edges, visited):
  visited[x] = True
  flag = False
  for e in rev_edges[x]:
    if not visited[e]:
      cycles.add(e)
      dfs_rev(e, cycles, rev_edges, visited)
      flag = True
    elif x == e:
      flag = True
  if flag:
    cycles.add(x)

order = []
visited = [False] * n
for i in range(n):
  if not visited[i]:
    dfs(i, order, edges, visited)

order.reverse()

visited = [False] * n
cycles = set()
for i in order:
  if not visited[i]:
    dfs_rev(i, cycles, rev_edges, visited)
print(len(cycles))


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

def dfs(x, order, edges, visited):
  visited[x] = True
  for e in edges[x]:
    if not visited[e]:
      dfs(e, order, edges, visited)
  order.append(x)

def dfs_rev(x, rev_edges, visited):
  visited[x] = True
  ret = 0
  for e in rev_edges[x]:
    if not visited[e]:
      ret += 1
      ret += dfs_rev(e, rev_edges, visited)
  return ret


n = int(input())
alst = list(map(int, input().split()))
edges = [[] for _ in range(n)]
rev_edges = [[] for _ in range(n)]
for i in range(n):
  edges[i].append((i + alst[i]) % n)
  rev_edges[(i + alst[i]) % n].append(i)

order = []
visited = [False] * n
for i in range(n):
  if not visited[i]:
    dfs(i, order, edges, visited)
order.reverse()

visited = [False] * n
cycles = 0
for i in order:
  if not visited[i]:
    a = dfs_rev(i, rev_edges, visited)
    if a > 0 or i in rev_edges[i]:
      a += 1
    cycles += a
print(cycles)
N=int(input())
A=list(map(int,input().split()))
ans=1
for i in range(N):
  ans*=A[i]
if ans<=10**18:
  print(ans)
else:
  print(-1)

### FIXED CODE ###

a,b=map(int,input().split())
print(a*b)
N,A,B=map(int,input().split())
ball=('b'*A+'a'*B)*10000
print(ball[0:N].count('b'))

### FIXED CODE ###

N,A,B=map(int,input().split())
if N == (N//(A+B))*(A+B):
    print(N-(N//(A+B))*(B))
elif (N//(A+B))*(A+B)<N <= (N//(A+B))*(A+B)+A:
    print(N-(N//(A+B))*(B))
else:
    print((N//(A+B)+1)*(A))
import math

N,K = map(int,input().split())
A = [int(x) for x in input().split()]
lower = 0
upper = 10**10

while upper - lower > 0.1:
    cuts = 0
    trial = (lower + upper) / 2
    for i in A:
        cuts += math.ceil(i/trial)-1
    if cuts <= K:
        upper = trial
    else:
        lower = trial
ans = math.ceil(lower)
cuts = 0
for i in A:
    cuts += math.ceil(i / ans) - 1
if cuts <= K: print(ans)
else: print(ans + 1)

### FIXED CODE ###

import math, sys

N,K = map(int,input().split())
A = [int(x) for x in input().split()]
lower = 0
upper = 10**10

while upper - lower > 0.1:
    cuts = 0
    trial = (lower + upper) / 2
    for i in A:
        cuts += math.ceil(i/trial)-1
    if cuts <= K:
        upper = trial
    else:
        lower = trial
ans = math.ceil(lower)
if ans == 0:
    print(1)
    sys.exit()
cuts = 0
for i in A:
    cuts += math.ceil(i / ans) - 1
if cuts <= K: print(ans)
else: print(ans + 1)
a = list(map(int,input().split()))
b = list(map(int,input().split()))

su = 0
c = [0]
for  i in range(len(b)-2):
	c.append(0)

for i in range(a[0] - 1):
	c[i] = b[i+1] - b[i]

for i in range(len(c)):
	if a[2] <= c[i]*a[1]:
		su += a[2]
	else:
		su += c[i]*a[1]

print(su

### FIXED CODE ###

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

su = 0
c = [0]
for  i in range(len(b)-2):
	c.append(0)

for i in range(a[0] - 1):
	c[i] = b[i+1] - b[i]

for i in range(len(c)):
	if a[2] <= c[i]*a[1]:
		su += a[2]
	else:
		su += c[i]*a[1]

print(su)
N,M = map(int,input().split(' '))
l = [int(input()) for i in range(M)]
 
pre = 0
last = -1
ans_l = []
flag = False
l.append(N+1)
 
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]
 
for i in l:
    if i==1:
        last = 1
        continue
    if i-last==1:
        flag =True
        break
    n = i - last - 3
    r = 0
    tmp = 1
    dif = 1
    while dif>0:
        r += 1
        if n<=0 or n<r:
            break
        tmp += cmb(n, r)
        dif = n-r
        n -= 1
    ans_l.append(tmp)
    # print(i,ans_l)
    last = i
if flag:
    print(0)
else:
    ans = 1
    for i in ans_l:
        ans*=i
    print(ans%1000000007)

### FIXED CODE ###

N,M = map(int,input().split(' '))
l = set([int(input()) for i in range(M)])

mod = 10**9+7
dp = {}
for i in range(N+1):
    dp[i] = 1
dp[1] = 0 if 1 in l else 1

for i in range(2,N+1):
    if i in l:
        dp[i] = 0
        continue
    else:
        dp[i] = dp[i-1]%mod + dp[i-2]%mod
        dp[i] = dp[i]%mod

print(dp[N]%mod)
N,u,v=map(int,input().split())

du,dv=[0]*-~N,[0]*-~N
T=[list() for i in range(-~N)]

def dsf(p,t,v,d):
  d[v]=t
  for i in T[v]:
    if i!=p:
      dsf(v,t+1,i,d)

for i in range(N-1):
  a,b=map(int,input().split())
  T[a].append(b)
  T[b].append(a)

dsf(0,0,u,du)
dsf(0,0,v,dv)

if du[v]==1 and len(T[v])==1:
  print(0)
else:
  m=0
  for i in range(1,~-N):
    if du[i] < dv[i]:
      if m<du[i]:
        v,m=i,du[i]

  if m!=0:
    print(du[v]+m-1)
  else:
    m=N+1
    for i in range(1,~-N):
      if du[i]==dv[i]:
        m=min(m,du[i])
    print(m)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)
N,u,v=map(int,input().split())

du,dv=[0]*-~N,[0]*-~N
T=[list() for i in range(-~N)]

def dfs(p,t,v,d):
  d[v]=t
  for i in T[v]:
    if i!=p:
      dfs(v,t+1,i,d)

for i in range(N-1):
  a,b=map(int,input().split())
  T[a].append(b)
  T[b].append(a)

dfs(0,0,u,du)
dfs(0,0,v,dv)

c=0
for i in range(1,-~N):
  if len(T[i])==1 and i!=v:
    if du[i]<dv[i]:
      c=max(c,~-dv[i])

print(c)
n, k = map(int, input().split())
A = list(map(int, input().split()))

MOD = 10 ** 9 + 7

AA = sorted(A, key=lambda x: -abs(x))

ans = []
mns = []
pls = []
itr = 0
while itr < k:
  ans.append(AA[itr])
  if AA[itr] < 0:
    mns.append(AA[itr])
  else:
    pls.append(AA[itr])
  itr += 1

mflg = False
pflg = False
zflg = False
if all(a < 0 for a in A) and k % 2 == 1:
  AA = sorted(A, key=lambda x: abs(x))
  mns = []
  for itr in range(k):
    mns.append(AA[itr])

elif len(mns) % 2 != 0:
  mm = mns[-1]
  pp = pls[-1]
  for i in range(itr, n):
    nn = AA[i]
    if nn > 0 and not pflg:
      pp *= nn
      pflg = True
      pv = nn
    elif nn < 0 and not mflg:
      mm *= nn
      mflg = True
      mv = nn
    elif nn == 0:
      zflg = True
  if mflg and not pflg:
    if pls:
      del pls[-1]
      mns.append(mv)
      
  elif pflg and not mflg:
    del mns[-1]
    pls.append(pv)

a = 1
for m in mns:
  a = (a * m) % MOD
for p in pls:
  a = (a * p) % MOD

print(a)

### FIXED CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))

MOD = 10 ** 9 + 7

AA = sorted(A, key=lambda x: -abs(x))

nega1 = []
posi1 = []
for a in AA[:k]:
  if a < 0:
    nega1.append(a)
  else:
    posi1.append(a)

nega2 = []
posi2 = []
for a in AA[k:]:
  if a < 0:
    nega2.append(a)
  else:
    posi2.append(a)

if all(a < 0 for a in A) and k % 2 == 1:
  AA = sorted(A, key=lambda x: abs(x))
  nega1 = []
  posi1 = []
  for a in AA[:k]:
    nega1.append(a)

elif n == k:
  pass

elif len(nega1) % 2 != 0:
  if posi1 and nega2 and posi2:
    if abs(nega1[-1] * nega2[0]) < abs(posi1[-1] * posi2[0]):
      del nega1[-1]
      nega1.append(posi2[0])
    else:
      del posi1[-1]
      posi1.append(nega2[0])
  elif not posi1 or not nega2:
    del nega1[-1]
    nega1.append(posi2[0])
  elif not posi2:
    del posi1[-1]
    posi1.append(nega2[0])
  
a = 1
for m in posi1:
  a = (a * m) % MOD
for p in nega1:
  a = (a * p) % MOD
 
print(a)
N,X= map(int, input().split())
L=list(map(int, input().split()))
D, ans=0, 0
for i in range(N+1):
    if D<=X:
        D+=L[i]
        ans+=1
    else:
        break
print(ans)

### FIXED CODE ###

N,X= map(int, input().split())
L=list(map(int, input().split()))
D, ans=0, 0
for i in range(N):
    if D<=X:
        ans+=1
        D+=L[i]
    else:
        break
if D<=X:
    ans+=1
print(ans)
def main(N,A):
    B=[0]
    count = 0
    for i in range(N):
        T = A[i] + B[i]
        print(B)
        if T in B:

            print('count:',count)
            count += B.count(T)


    # B = [A[i] +B[i] for i in range(N)]
    #
    # count = [ count + 1 for m in range(len(B)) if B[i] - B[i-m] == 0]

        # for m in range(len(B)):
        #     if T - B[m] == 0:
        #         # print(i, m)
        #         # print(B[i],B[i-m])
        #         # print(T)
        #         # print("kore",B[i],B[i-m])
        #         count += 1
        B.append(T)


    #print(count)
    print(B)
    return print(count)

if __name__ == "__main__":
    N=int(input())
    A=list(map(int,input().split()))

    main(N,A)

### FIXED CODE ###

import collections

def main(N,A):
    B=[0]
    count = 0
    for i in range(N):
        T = A[i] + B[i]

        B.append(T)
    c = collections.Counter(B)

    for i in range(len(c)):
        k, v = c.popitem()
        for z in range(v):
            count += z

    return print(count)

if __name__ == "__main__":
    N=int(input())
    A=list(map(int,input().split()))

    main(N,A)
suits = {"S":0, "H":1, "C":2, "D":3}
cards = [[0 for i2 in range(13)] for i1 in ("S", "H", "C", "D")]
n = int(input())

for i in range(n):
    (suit, rank) = input().split(" ")
    cards[suits[suit]][int(rank)] = 1

for suit in ("S", "H", "C", "D"):
    for number in range(13):
        if cards[suits[suit]][number + 1] != 1:
            print(suit, number + 1)

### FIXED CODE ###

suits = {"S":0, "H":1, "C":2, "D":3}
cards = [[0 for i2 in range(13)] for i1 in ("S", "H", "C", "D")]
n = int(input())

for i in range(n):
    (suit, rank) = input().split(" ")
    cards[suits[suit]][int(rank) - 1] = 1

for suit in ("S", "H", "C", "D"):
    for number in range(13):
        if cards[suits[suit]][number] != 1:
            print(suit, number + 1)
N = int(input())

p = [int(x) for x in input().split(' ')]
sorted_p = sorted(p)
count = 0
for i in range(N):
    if p[i] != sorted_p[i]:
        count += 1
if count == 0 or count == 2:
    print("YES")
else:
    print("NO")


### FIXED CODE ###

A, B = map(int, input().split(' '))
ans = (A + B) / 2
print(int(ans)) if ans == int(ans) else print('IMPOSSIBLE ')
n = int(input())
s = str(input())

ans = 0
max = 0
for i in range(n):
    if s[i]=="I":
        ans+=1
        max = max(ans, max)
    else:
        ans-=1
        max = max(ans, max)
print(max)

### FIXED CODE ###

n = int(input())
s = input()

ans = 0
x = 0
for i in range(n):
    if s[i]=="I":
        ans+=1
        x = max(ans, x)
    else:
        ans-=1
        x = max(ans, x)
print(x)
from scipy.special import comb

n, k = map(int, input().split(' '))

def f(x,y):
    return comb(x-1, y-1)

for i in range(1,k+1):
    S = f(n-k, i-1) + 2 * f(n-k, i) + f(n-k, i+1)
    print(int(f(k, i) * S))
    

### FIXED CODE ###

from math import factorial

n, k = map(int, input().split(' '))

def binom_fac(n,k):
    return factorial(n) // (factorial(n-k) * factorial(k))

def f(n,k):
    if n < k:
        return 0
    if n == 0 & k == 0:
        return 1
    if k < 1:
        return 0
    
    return binom_fac(n-1, k-1)

for i in range(1,k+1):
    S = f(n-k, i-1) + 2 * f(n-k, i) + f(n-k, i+1)
    out = int(f(k, i) * S)
    
    print(out % (10**9 + 7))
n = input()
  n_max = -(10**9)
  n_min = input()

  for i in range(0, n-1):
   R = input()
   if n_max < R - n_min:
    n_max = R - n_min
   if R < n_min:
    n_min = R

  print n_max

### FIXED CODE ###

n = int(raw_input())
minv = int(raw_input())
maxv = -1*10**9
  
for j in range(n-1):
  nums = int(raw_input())  
  diff = nums - minv
  if maxv < diff:
    maxv = diff
  if nums < minv:
    minv = nums
  
print maxv
import sys
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
  print(res)
  sys.exit()
res = 1
for i in range(n):
  res = res * a[i]
  if(res > pow(10,18)):
    res = -1
print(res)

### FIXED CODE ###

import sys
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
  res = 0
  print(res)
  sys.exit()
  
res = 1
for i in range(n):
  if(res > pow(10,18)):
    break
  else:
    res = res * a[i]
if(res > pow(10,18)):
   res = -1
print(res)
t1,t2 = map(int,input().split())

a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
c1 = b1-a1
c2 = b2-a2

s = t1*c1
t = s + t2*c2
print(c1,c2,s,t)
ans = -1
if s * t > 0:
    ans = 0
elif t == 0:
    ans="infinity"
else:
    if s > t:
        tt = abs(t)
        ans = -((-s / tt)//1)*2 - 1
        if s / tt - s//tt < 10**-25:
            ans += 1
    else:
        ss = abs(s)
        ans = -((-ss / t)//1)*2 - 1
        if ss / t -ss//t < 10**-25:
            ans += 1
print(int(ans))

### FIXED CODE ###

t1,t2 = map(int,input().split())

a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
c1 = b1-a1
c2 = b2-a2

s = t1*c1
t = s + t2*c2
# print(c1,c2,s,t)
ans = -1
if s * t > 0:
    ans = 0
elif t == 0:
    ans=-10
else:
    if s > t:
        tt = abs(t)
        ans = -((-s / tt)//1)*2 - 1
        if s / tt - s//tt < 10**-25:
            ans += 1
    else:
        ss = abs(s)
        ans = -((-ss / t)//1)*2 - 1
        if ss / t -ss//t < 10**-25:
            ans += 1
if ans == -10:
    print("infinity")
else:
    print(int(ans))
n, x = map(int, input().split())
llist = list(map(int, input().split()))

d = 0
ans = 1
i = 0
while d <= x:
  d += llist[i]
  i += 1
  ans += 1
print(ans - 1)

### FIXED CODE ###

n, x = map(int, input().split())
llist = [0] + list(map(int, input().split())) + [1e9]
for i in range(1, n+2):
  llist[i] += llist[i-1]

for i in range(n+2):
  if llist[i] > x:
    break
print(i)
#!/usr/bin/env python3
import sys
import math
sys.setrecursionlimit(10000)
INF = 1<<32


def solve(a: int, b: int, x: int):
    y = float(x)/float(a)
    ans = .0
    if y >= a*b//2:
        bd = 2.0*(a*b-y)/a
        ans = 90.0-math.degrees(math.atan(a/bd))
    else:
        ad = 2.0*y/b
        ans = 90.0-math.degrees(math.atan(ad/b))

    print(ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    solve(a, b, x)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import math
sys.setrecursionlimit(10000)
INF = 1<<32


def solve(a: int, b: int, x: int):
    y = float(x)/float(a)
    ans = .0
    if (a**2 * b - x) == 0:
        ans = 0.0
    elif y >= a*b/2:
        bd = 2.0*(a*b-y)/a
        ans = 90.0-math.degrees(math.atan(a/bd))
    else:
        ad = 2.0*y/b
        ans = 90.0-math.degrees(math.atan(ad/b))

    print(ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    solve(a, b, x)

if __name__ == '__main__':
    main()
import re

s = input()
li = s.splite("/")
month = int(li[1])

if month > 4:
  print('TBD')
else:
  print("Heisei")

return 0

### FIXED CODE ###

import re

s = input()
li = s.split("/")
month = int(li[1])

if month > 4:
  print('TBD')
else:
  print("Heisei")
n, w = map(int, input().split())

nap = [list(map(int, input().split())) for _ in range(n)]

INF = float('inf')
num = 10**5 + 10
dp = [[INF]*num for _ in range(110)]

dp[0][0] = 0
for i in range(n):
    for v in range(num):
        if v + nap[i][1] <= num:
            dp[i+1][v+nap[i][1]] = min(dp[i+1][v+nap[i][1]], dp[i][v] + nap[i][0])
        dp[i+1][v] = min(dp[i+1][v], dp[i][v])

for v in reversed(range(num)):
    if dp[n][v] <= w:
        print(v)
        exit()


### FIXED CODE ###

n, w = map(int, input().split())

nap = [list(map(int, input().split())) for _ in range(n)]

INF = float('inf')
num = 10**5 + 10
dp = [[INF]*(10**5+10) for _ in range(110)]

dp[0][0] = 0
for i in range(n):
    for v in range(10**5+1):
        if v + nap[i][1] <= 10**5+1:
            dp[i+1][v+nap[i][1]] = min(dp[i+1][v+nap[i][1]], dp[i][v] + nap[i][0])
        dp[i+1][v] = min(dp[i+1][v], dp[i][v])

for v in reversed(range(10**5+1)):
    if dp[n][v] <= w:
        print(v)
        exit()