Harryxun/stf_run huggingface dataset:
#D

def dig(n, count):
    global sc

    if sc[n] == -1:
        sc[n] = 0
    else:
        return
    
    sc[n] = count + c[n]
    
    for i in E[n]:
        dig(i, sc[n])

        


#XXX=[int(x) for x in Input.split()]

n,q = (int(x) for x in input().split())
#n,q = XXX[0:2]

#A = []
#B = []
E = [[] for i in range(n+1)]
for i in range(n-1):
    a,b = (int(x) for x in input().split())
    #a,b = XXX[i*2+2:i*2+4]
    #A.append(a)
    #B.append(b)
    E[a].append(b)
    E[b].append(a)

P = []
X = []
for i in range(q):
    p,x = (int(x) for x in input().split())
    #p,x = XXX[i*2+n*2:i*2+n*2+2]
    P.append(p)
    X.append(x)

c = [0]*(n+1)
for i in range(len(P)):
    c[P[i]]+=X[i]

#print(c)

sc = [-1]*(n+1)

dig(1,0)
result = map(str, sc[1:])
print(" ".join(result))
    

### FIXED CODE ###

#D
       


#XXX=[int(x) for x in Input.split()]

n,q = (int(x) for x in input().split())
#n,q = XXX[0:2]

E = [[] for i in range(n+1)]
for i in range(n-1):
    a,b = (int(x) for x in input().split())
    #a,b = XXX[i*2+2:i*2+4]
    #A.append(a)
    #B.append(b)
    E[a].append(b)
    E[b].append(a)

P = []
X = []
for i in range(q):
    p,x = (int(x) for x in input().split())
    #p,x = XXX[i*2+n*2:i*2+n*2+2]
    P.append(p)
    X.append(x)

c = [0]*(n+1)
for i in range(len(P)):
    c[P[i]]+=X[i]

#sc = [-1]*(n+1)
sc = [0]*(n+1)
checked = [False]*(n+1)
stac = [1]

#dig(1,-1,0)

while stac:
    th = stac.pop()
    sc[th] += c[th]
    checked[th] = True
    
    for i in E[th]:
        if checked[i] == False:
            sc[i] += sc[th]
            stac.append(i)

result = map(str, sc[1:])
print(" ".join(result))
#!/usr/bin/env python
# coding: utf-8

# In[ ]:


A, B, C = map(int, input().split())


# In[ ]:


ans = int(C-(A-B))
if ans < 0:
    print(0)
else:
    print(ans)



### FIXED CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[ ]:


a = int(input())
s = input()


# In[ ]:


if a >= 3200:
    print(s)
else:
    print('red')
n = int(input())
li = [tuple(map(int,input().split())) for _ in range(n)]
li.sort(key=lambda x: x[1])
t = 0
for i in range(n):
    if t + li[i][0] > li[i][1]:
        print("No")
        exit()
    else:
        t += li[i][0]
print("Yes")

### FIXED CODE ###

S = input()
for i in range(len(S)-1):
  if S[i] == S[i+1]:
    print("Bad")
    exit()
print("Good")
S,T=input().split()
A,B=map(int,input().split())
U=input()
dic={S:A,T:B}
dict[U]-1
print(dict[S] dict[T])

### FIXED CODE ###

S,T=input().split()
A,B=map(int,input().split())
U=input()
dic={S:A,T:B}
dic[U]-=1
print(dic[S],dic[T])
#96
h, w = map(int, input().split())
s = [['.']*(w+2)] + [['.']+list(input())+['.'] for _ in range(w)] + [['.']*(w+2)]
a = True
for i in range(1, w+1):
    for j in range(1, w+1):
        if s[i][j] == '#':
           up = s[i-1][j]
           left = s[i][j-1]
           right = s[i][j+1]
           down = s[i+1][j]
           if up == '.' and left == '.' and right == '.' and down == '.':
                a = False
                break
    if not a:
        break
if a ==True:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
 
flag = False
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            if (j-1 >= 0 and s[i][j-1] == '.') and (j+1 < W and s[i][j+1] == '.') and (i-1 >= 0 and s[i-1][j] == '.') and (i+1 < H and s[i+1][j] == '.'):
                print('No')
                flag = True
                break
    if flag:
        break
else:
    print('Yes')
a,b,c = map(int,input())
count = 0
for i in range(a,b+1):
        if c % i == 0:
                count += 1
        print(count)

### FIXED CODE ###

a,b,c = map(int,input().split())
count = 0
for i in range(a,b+1):
        if c % i == 0:
                count += 1
print(count)
A,B,C = map(int(),input().split())

arr = [A, B, C]
fives = 0
sevens = 0

for num in arr:
    if num == 5:
        fives += 1
    if num == 7:
        sevens += 1

if fives == 2 and sevens == 1:
    print("YES")
else:
    print("NO")


### FIXED CODE ###

A, B, C = map(int, input().split())

arr = [A, B, C]
fives = 0
sevens = 0

for num in arr:
    if num == 5:
        fives += 1
    if num == 7:
        sevens += 1

if fives == 2 and sevens == 1:
    print("YES")
else:
    print("NO")
N, X=map(int, input().split())
L=list(map(int, input().split()))

l=0
counter=0
while l<=X:
  l+=L[counter]
  counter+=1

### FIXED CODE ###

import numpy as np

temp=list(map(int, input().split()))

N=temp[0]
X=temp[1]

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

ind=1
while np.sum(L[:ind])<=X and ind<=N:
  ind+=1
  
print(ind)
from operator import itemgetter

def eratosthenes(n):
    table = [True] * (n + 1)
    table[0] = table[1] = True
    for i in range(2, int(round(pow(n, 0.5)))):
        if not table[i]:
            continue
        for j in range(i + i, n, i):
            table[j] = False
    return table

if __name__ == "__main__":
    N = int(input())
    f = itemgetter(*[int(input()) for _ in range(N)])
    print(sum(f(eratosthenes(100000))))

### FIXED CODE ###

from random import randrange


def eratosthenes(size):
    table = [True] * (size + 1)
    table[0] = table[1] = True
    for i in range(2, int(round(pow(size+1, 0.5)))):
        if not table[i]:
            continue
        for j in range(i + i, size+1, i):
            table[j] = False
    return table


def miller_rabin(n, k=20):
    if n == 2:
        return True
    if n == 1 or n % 2 == 0:
        return False
    d = n - 1
    while d & 1 == 0:
        d >>= 1
    for _ in range(k):
        a = randrange(1, n)
        y = pow(a, d, n)
        t = d
        while t != n - 1 and y != 1 and y != n - 1:
            y = pow(y, 2, n)
            t <<= 1
        if y != n - 1 and (t & 1) == 0:
            return False
    return True

if __name__ == "__main__":
    N = int(input())
    print(sum(map(miller_rabin, [int(input()) for _ in range(N)])))
# ABC119B - Digital Gifts
def main():
    _, XU = open(0).read().split()
    ans, RATE = 0, 380000
    for x, u in zip(*[iter(XU)] * 2):
        x = float(x)
        ans += x if u == "JPY" else x * RATE
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC119B - Digital Gifts
n = int(input())
lst = [input().rstrip().split() for _ in range(n)]
total = 0

for i in range(n):
    if lst[i][1] == 'JPY':
        total += int(lst[i][0])
    else:
        total += 380000 * float(lst[i][0])
        
print(total)
i = 0
while 1:
   x = raw_input()
   i += 1
   if x == 0: 
     break
   print "Case %s : %s" % (i,x)

### FIXED CODE ###

i = 0
while 1:
   x = raw_input()
   i += 1
   if x == '0': 
     break
   print "Case %s: %s" % (i,x)
#入力
input = input()

#リスト化
exec('lst = [' + input + ']')

#出力
print(lst[0], lst[1], lst[2], sep=' ')

### FIXED CODE ###

print(input().replace(',', ' '))
K,N = map(int,input().split())

MOD = 998244353

fact = [1]*3000
t = 1
for i in range(1,3000):
    t = (t*i)%MOD
    fact[i] = t

def ncr(n,r):
    return (fact[n] * pow(fact[r],MOD-2,MOD) % MOD) * pow(fact[n-r],MOD-2,MOD) % MOD

for i in range(2,2*K+1):
    t1,t2 = 0,0
    Ans = 0
    # p : 足して i になる整数の組の数
    np = i//2 - max(i-1-K,0)
    # p組からq組, 片方を使用する場合の数を足し合わせる
    # 偶奇で場合分け
    if i%2==0:
        # 偶数の場合 : 1組だけ同じ数の組があるため特別扱いする
        np -= 1
        for nq in range(np+1):
            # 同じ数の組の数字を全く含まない場合
            t1 = ncr(np,nq)*(2**nq)
            t1 %= MOD
            nr = K - np*2 - 1
            t2 = ncr(N+nr-1,N-nq) if N+nr-1>=N-nq else 0
            t2 %= MOD
            Ans += t1*t2
            # 同じ数の組の数字を1つ含む場合
            t2 = ncr(N-1+nr-1,N-1-nq) if N-1+nr-1>=N-1-nq else 0
            t2 %= MOD
            Ans += t1*t2
    else:
        # 奇数の場合 : p組全て互いに異なる数
        for nq in range(np+1):
            t1 = ncr(np,nq)*(2**nq)
            t1 %= MOD
            nr = K - np*2
            t2 = ncr(N+nr-1,N-nq) if N-1+nr-1>=N-1-nq else 0
            t2 %= MOD
            Ans += t1*t2
    print(Ans%MOD)


### FIXED CODE ###

K,N = map(int,input().split())

MOD = 998244353

fact = [1]*4000
t = 1
for i in range(1,4000):
    t = (t*i)%MOD
    fact[i] = t

factinv = [1]*4000
for i in range(1,4000):
    factinv[i] = pow(fact[i], MOD-2, MOD)

def ncr(n,r):
    if n < 0 or r < 0 or n-r < 0:
        return 0
    return (fact[n] * factinv[r] * factinv[n-r]) % MOD

def nhr(n,r):
    if n == 0 and r == 0:
        return 1
    return ncr(n+r-1, r)

for i in range(2,2*K+1):
    t1,t2 = 0,0
    Ans = 0
    # p : 足して i になる整数の組の数
    np = i//2 - max(i-1-K,0)
    # p組からq組, 片方を使用する場合の数を足し合わせる
    # 偶奇で場合分け
    if i%2==0:
        # 偶数の場合 : 1組だけ同じ数の組があるため特別扱いする
        np -= 1
        for nq in range(np+1):
            # 同じ数の組の数字を全く含まない場合
            t1 = ncr(np,nq)*pow(2, nq, MOD)
            t1 %= MOD
            t2 = nhr(K-np*2+nq-1,N-nq)
            t2 %= MOD
            Ans = (Ans + t1*t2) % MOD
            # 同じ数の組の数字を1つ含む場合
            t2 = nhr(K-np*2+nq-1,N-nq-1)
            t2 %= MOD
            Ans = (Ans + t1*t2) % MOD
    else:
        # 奇数の場合 : p組全て互いに異なる数
        for nq in range(np+1):
            t1 = ncr(np,nq)*pow(2, nq, MOD)
            t1 %= MOD
            t2 = nhr(K-np*2+nq,N-nq)
            t2 %= MOD
            Ans = (Ans + t1*t2) % MOD
    print(Ans%MOD)
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [1000000000] * N
dp[0] = 0

for i in range(N - 1):
    for j in range(1, min(K + 1, N-1)):
        dp[i + j] = min(abs(h[i + j] - h[i]) + dp[i])

print(dp[N - 1])


### FIXED CODE ###

import numpy as np

N, K = map(int, input().split())
h = np.array(list(map(int, input().split())), dtype='int')
dp = np.ones(N, dtype='int') * 1000000000
dp[0] = 0

for i in range(1, N):
    dp[i] = min(dp[max(i-K,0):i] + abs(h[max(i-K,0):i] - h[i]))

print(dp[N - 1])
import sys
sys.setrecursionlimit(10000000000)


def process():
    data = []
    for line in get_data():
        line = line.split()
        if len(line) == 2:
            if line[0] == line[1] == '0':
                data = []
                continue
            H = int(line[0])
            W = int(line[1])
        elif len(line) == 0:
            pass
        else:
            data.append(line[0])
            if len(data) == H:
                field = create_field(H, W)
                print(search(H, W, data, field))


def search(H, W, data, field):
    count = 0
    for i in xrange(H):
        for j in xrange(W):
            if field[i][j] == 0:
                continue
            _search(i, j, H, W, data[i][j], data, field)
            count += 1
    return count


def _search(i, j, H, W, cell, data, field):
    field[i][j] = 0
    for a in xrange(i-1, i+2):
        if -1 < a < H:
            pass
        else:
            continue
        for b in xrange(j-1, j+2):
            if -1 < b < W:
                pass
            else:
                continue

            if a != i and b != j:
                continue

            if field[a][b] == 0:
                continue
            if cell == data[a][b]:
                _search(a, b, H, W, cell, data, field)
    return


def create_field(H, W):
    field = []
    for i in xrange(H):
        raw = []
        for j in xrange(W):
            raw.append(1)
        field.append(raw)
    return field


def get_data():
    return [line.strip() for line in input()]

process()

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000000)


def main():
    solve()


def solve():
    for data in get_dataset():
        print search(data)


def search(data):
    count = 0
    H = len(data)
    W = len(data[0])
    for i in xrange(H):
        for j in xrange(W):
            if data[i][j] == '.':
                continue
            _search(i, j, H, W, data[i][j], data)
            count += 1
    return count


def _search(i, j, H, W, cell, data):
    data[i][j] = '.'
    for a in xrange(i-1, i+2):
        if not -1 < a < H:
            continue
        for b in xrange(j-1, j+2):
            if not -1 < b < W:
                continue

            if a != i and b != j:
                continue

            if data[a][b] == '.':
                continue

            if cell == data[a][b]:
                _search(a, b, H, W, cell, data)
    return


def get_dataset():
    dataset = []
    while True:
        line = raw_input().rstrip().split()
        H = int(line[0])
        if H == 0:
            break

        data = []
        for i in xrange(H):
            data.append(list(raw_input().rstrip()))
        dataset.append(data)
    return dataset


if __name__ == '__main__':
    main()
import numpy as np

N=int(input())
A=[]
PRECISION_DIGITS=9
NO_ENTRY = 0
cnt=np.full((PRECISION_DIGITS*2,PRECISION_DIGITS*2),NO_ENTRY,int)
# cnt=np.zeros((PRECISION_DIGITS*2,PRECISION_DIGITS*2),int)

# print(cnt)

for n in range(N):
	tmpA = float(input())
	tmpA = int(tmpA*10**PRECISION_DIGITS)
	#print(tmpA)

	five = 0
	two = 0
	# (10**9) -> (two,five)=(9,9)
	# min = 10**-9, ignore < 10**9 ???
	while (tmpA % 5) == 0 and five < PRECISION_DIGITS*2:
		five += 1
		tmpA //= 5
	while (tmpA % 2) == 0 and two < PRECISION_DIGITS*2:
		two += 1
		tmpA //= 2

	if cnt[two][five] == 0:
		cnt[two][five]=1
	else:
		cnt[two][five]+=1

# print(cnt)
ans = 0

for x1 in range(PRECISION_DIGITS*2):
	for y1 in range(PRECISION_DIGITS*2):
		if cnt[x1][y1] == NO_ENTRY:
			continue

		for x2 in range(PRECISION_DIGITS*2):
			for y2 in range(PRECISION_DIGITS*2):
				if cnt[x2][y2] == NO_ENTRY:
					continue
				# 2**a(a>=0) and 5**b(b>=0) => integer
				if 0 <= x1+x2 - PRECISION_DIGITS*2 and 0 <= y1+y2 -PRECISION_DIGITS*2:
					if x1 == x2 and y1 == y2:
						# same entry
						# Total number of combinations choose 2 items
						# nC2 = n*(n-1)/2
						ans += int((cnt[x1][y1]*(cnt[x2][y2]-1))//2)
					else:
						ans += cnt[x1][y1]*cnt[x2][y2]

		# count up completed entry
		cnt[x1][y1] = NO_ENTRY

print(ans)



### FIXED CODE ###

N=int(input())
A=[]
PRECISION_DIGITS=9
cnt={}


for n in range(N):
	tmpA = float(input())
	tmpA = round(tmpA*(10**PRECISION_DIGITS))
	#print(tmpA)

	two = 0
	five = 0
	while (tmpA % 2) == 0:
		two += 1
		tmpA /= 2
	while (tmpA % 5) == 0:
		five += 1
		tmpA /= 5

	if (two,five) in cnt:
		cnt[(two,five)]+=1
	else:
		cnt[(two,five)]=1

keys=sorted(cnt.keys())
# print(keys)
ans = 0
for t1 in keys:
	for t2 in keys:
		# 2**a(a>=0) and 5**b(b>=0) => integer
		if 18 <= t1[0]+t2[0] and 18 <= t1[1]+t2[1]:
			cnt1 = cnt[(t1[0],t1[1])]
			cnt2 = cnt[(t2[0],t2[1])]
			if t1 < t2:
				ans += int(cnt1*cnt2)
			elif t1 == t2:
				# same entry
				# Total number of combinations choose 2 items
				# nC2 = n*(n-1)/2
				ans += int(cnt1*(cnt1-1)/2)


print(ans)
a=input()
x=2
y=1
for i in range(a-1):
    z=x+y
    x=y
    y=z

print z

### FIXED CODE ###

a=input()
x=2
y=1
z=1
for i in range(a-1):
    z=x+y
    x=y
    y=z

z=str(z)
print z
w, h, x, y = list(map(int, input().split()))

center = 1 if x == w / 2 and y == h / 2 else 0

print((w * h / 2) + ' ' + center)

### FIXED CODE ###

w, h, x, y = list(map(int, input().split()))

center = 1 if x == w / 2 and y == h / 2 else 0

print(str(w * h / 2) + ' ' + str(center))
# dpぽい気がするのでそうする
s = input()
dp = {}


def rec(i, cur_g, cur_p, tmp):
    if i in dp:
        return dp[i]
    if i == len(s):
        ret = 0
        for j in range(len(s)):
            if tmp[j] == "p" and s[j] == "g":
                ret += 1
            elif tmp[j] == "g" and s[j] == "p":
                ret -= 1
        return ret
    if cur_g > cur_p:
        # パーを出せる（出さなくてもいい）
        if s[i] == "g":
            ret = max(
                rec(i + 1, cur_g, cur_p + 1, tmp + "p"),
                rec(i + 1, cur_g + 1, cur_p, tmp + "g"),
            )
            dp[i] = ret
            return ret
        else:
            ret = max(
                rec(i + 1, cur_g, cur_p + 1, tmp + "p"),
                rec(i + 1, cur_g + 1, cur_p, tmp + "g"),
            )
            dp[i] = ret
            return ret

    else:
        # 勝てるかどうかにかかわらずグーを出すしか無い
        ret = rec(i + 1, cur_g + 1, cur_p, tmp + "g")
        dp[i] = ret
        return ret


print(rec(0, 0, 0, ""))


### FIXED CODE ###

# dpぽい気がするのでそうする
# なぜかREなる....
# pythonだとrecursion limitがアレなのを忘れていた...
# なぜかTLEなる....

import sys

sys.setrecursionlimit(10 ** 8)


s = input()
dp = {}


def rec(i, cur_g, cur_p, g, p):
    if i in dp:
        return dp[i]
    if i == len(s):
        ret = p - g
        dp[i] = ret
        return ret
    if cur_g > cur_p:
        # パーを出せる（出さなくてもいい）
        if s[i] == "g":
            ret = max(
                rec(i + 1, cur_g, cur_p + 1, g, p + 1),
                rec(i + 1, cur_g + 1, cur_p, g, p),
            )
            dp[i] = ret
            return ret
        elif s[i] == "p":
            ret = max(
                rec(i + 1, cur_g, cur_p + 1, g, p),
                rec(i + 1, cur_g + 1, cur_p, g + 1, p),
            )
            dp[i] = ret
            return ret
    else:
        # 勝てるかどうかにかかわらずグーを出すしか無い
        if s[i] == "g":
            ret = rec(i + 1, cur_g + 1, cur_p, g, p)
            dp[i] = ret
            return ret
        elif s[i] == "p":
            ret = rec(i + 1, cur_g + 1, cur_p, g + 1, p)
            dp[i] = ret
            return ret


print(rec(0, 0, 0, 0, 0))
a,b,c = map(int,input(),split())
print(a*b//2)


### FIXED CODE ###

a,b,c = map(int,input().split())
print(a*b//2)
S = input()

if S = "SUN":
    print(7)

elif S = "MON":
    print(6)

elif S = "TUE":
    print(5)

elif S = "WED":
    print(4)

elif S = "THU":
    print(3)

elif S = "FRI":
    print(2)

elif S = "SAT":
    print(1)

### FIXED CODE ###

S = input()

if S == "SUN":
    print(7)

elif S == "MON":
    print(6)

elif S == "TUE":
    print(5)

elif S == "WED":
    print(4)

elif S == "THU":
    print(3)

elif S == "FRI":
    print(2)

elif S == "SAT":
    print(1)
a,b,k=map(int,input().split())
l=[]
for i in range(1,a):
  if a%i==0 and b%i==0:
    l.append(i)
print(l[k-1])


### FIXED CODE ###

a,b,k=map(int,input().split())
l=[]
for i in range(1,min(a,b)+1):
  if a%i==0 and b%i==0:
    l.append(i)
print(l[len(l)-k])
s = input()

s[0]s = input()

flg = 0

for i in range(3):
    if s[i] == s[i + 1]:
        flg = 1

if flg == 1:
    print("Bad")
else:
    print("Good")


### FIXED CODE ###

s = input()

flg = 0

for i in range(3):
    if s[i] == s[i + 1]:
        flg = 1

if flg == 1:
    print("Bad")
else:
    print("Good")
N=int(input())
A=[int(i) for i in input().split()]
A.sort()
miss=0
if N%2==0:
    for i in range(int(N/2)):    
        if miss==1:
            break
        for j in range(2):
            if A[0]==2*i+1:
                A.pop(0)
            else:
                miss=1
                break
                
    if miss==1:
        print(0)
    else:
        print(int((2**int(N/2))%(10e9+7)))

else:
    if A[0]!=0:
        miss=1
        A.pop(0)
    else:
        A.pop(0)
    for i in range(int((N-1)/2)):
        if miss==1:
            break
        for j in range(2):
            if A[0]==2*i+2:
                A.pop(0)
            else:
                miss=1
                break
                
    if miss==1:
        print(0)
    else:
        print(int((2**int((N-1)/2))%(10e9+7)))



### FIXED CODE ###

N=int(input())
A=[int(i) for i in input().split()]
A.sort()
miss=0

if N%2==0:
    for i in range(int(N/2)):    
        if miss==1:
            break
        for j in range(2):
            if A[0]==2*i+1:
                A.pop(0)
            else:
                miss=1
                break
                
    if miss==1:
        print(0)
    else:
        print(int((2**int(N/2))%(10**9+7)))

else:
    if A[0]!=0:
        miss=1
        A.pop(0)
    else:
        A.pop(0)
    for i in range(int((N-1)/2)):
        if miss==1:
            break
        for j in range(2):
            if A[0]==2*i+2:
                A.pop(0)
            else:
                miss=1
                break
                
    if miss==1:
        print(0)
    else:
        print(int((2**int((N-1)/2))%(10**9+7)))
a,b,c = map(string,input().split())
print(c+' '+a+' '+b)


### FIXED CODE ###

a,b,c = map(str,input().split())
print(c+' '+a+' '+b)
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
#print(x,y,abs(x)<abs(y))
#exit()
if x+y==0:
    print("infinity")
#elif (x<0 and y<0) or (x>0 and y>0):
#    print(0)
#elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
#    print(1)

#elif x<0 and x+y>0:
#    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>0])
#elif x<0 and x+y<0:
#    print((y//abs(x+y))*2)
#elif x>0 and x+y<0:
#    print((x//abs(x+y))*2+[0,1][x%abs(x+y)>0])
elif x>0 and x+y>0:
    print((abs(y)//(x+y))*2)
else:
    print(hhh)


### FIXED CODE ###

T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
 
P = (A1 - B1) * T1
Q = (A2 - B2) * T2
if P > 0:
	P *= -1
	Q *= -1
 
if P + Q < 0:
	print(0)
elif P + Q == 0:
	print("infinity")
else:
	S = (-P) // (P + Q)
	T = (-P) % (P + Q)
	if T != 0:
		print(S * 2 + 1)
	else:
		print(S * 2)
a,b = map(int,input().split())
print(max(0,a-(2*b))

### FIXED CODE ###

a,b = map(int,input().split())
print(max(0,a-(2*b)))
N, M = map(int, input().split(' '))

def fib(n):
    a, b = 0, 1
    for i in range(0, n):
        a, b = b, a + b
    return a

a_p = int(input())
sum = fib(a_p)
for i in range(M-1):
    a = int(input())
    diff = a - a_p
    if diff == 1:
        print('0')
        exit()
    sum *= fib(diff-1)
    sum %= 1000000007
    a_p = a

sum *= fib(N - a_p)

print(sum % 1000000007)


### FIXED CODE ###

N, M = map(int, input().split(' '))

MOD = 1000000007

def fib(n):
    a, b = 0, 1
    for i in range(0, n):
        a, b = b, a + b
    return a

broken_step = []
p_a = -1
for i in range(M):
    a = int(input())
    if (a - p_a == 1):
        print("0")
        exit()
    else:
        p_a = a
    broken_step.append(a-1)

count_0 = 0
count_1 = 1
next_broken = 0
pre_is_broken = False
for i in range(N):
    if (next_broken >= len(broken_step) or i != broken_step[next_broken]):
        if (pre_is_broken):
            count_0 = 0
            pre_is_broken = False
        else:
            count_0, count_1 = count_1, count_0 + count_1
            count_0 %= MOD
            count_1 %= MOD
    else:
        next_broken+=1
        count_0 = 0
        pre_is_broken = True

print(count_1)
a,b=(int(x) for x in input().split())
print(a)
print(b)

am=int(100/8*a)
al=int(100/8*(a+1))
if (a%4)==0:
       al=al-1

bm=int(10*b)
bl=int(10*(b+1))-1

#print (am,al)
#print (bm,bl)
for ia in range(am,al+1):
       for ib in range(bm,bl+1):
       		if ia==ib:
       			print (ia)
       			exit()
      
print -1

### FIXED CODE ###

a,b=(int(x) for x in input().split())

for i in range(1,1010):
#	print (i)
	ia=int(i*0.08)
	ib=int(i*0.1)
#	print (ia,ib)
	if ia==a and ib==b:
		print (i)
		exit()
else:
	print (-1)
A = int(input())
B = list(map(int, input().split()))  

dai=[0, 0, 0, 0, 0]
for i, l in enumerate(B):
  if i==0:
    continue
  if B[i-1]-B[i]>0:
    dai[i]=B[i-1]-B[i]
    B[i]+=B[i-1]-B[i]

print(sum(dai))
  

### FIXED CODE ###

A = int(input())
B = list(map(int, input().split()))  

dai=[0 for _ in range(A)]

for i, l in enumerate(B):
  if i==0:
    continue
  if B[i-1]-B[i]>0:
    dai[i]=B[i-1]-B[i]
    B[i]+=B[i-1]-B[i]

print(sum(dai))
from fractions import gcd
a,b,c,d = map(int,input().split())
l = (c*d) // gcd(c,d)
 
x = b//c - (a-1)//c
y = b//d - (a-1)//d
z = b//l - (a-1)//l
s = int(x+y-z)
 
print(b-a+1-s)

### FIXED CODE ###

s = ''
for i in input():
    if s == i:
        print("Bad")
        exit()
    s = i
print("Good")