Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

S = input()
T = input()

d = [[] for _ in range(27)]
alpha2num = lambda c: ord(c) - ord("a") + 1
ans = 0

for i, s in enumerate(S):
    d[alpha2num(s)].append(i)

idx = -1
for t in T:
    dl = d[alpha2num(t)]
    if not(dl):
        ans = -1
        break
    for i in dl:
        if i > idx:
            ans += i - idx
            idx = i
            break
    else:
        ans += (len(S) - idx + dl[0])
        idx = dl[0]

print(ans)

### FIXED CODE ###

import bisect

S = input()
T = input()

d = [[] for _ in range(27)]
alpha2num = lambda c: ord(c) - ord("a") + 1

for i, s in enumerate(S):
    d[alpha2num(s)].append(i)

idx = -1
l = 0
ans = 0
for t in T:
    dl = d[alpha2num(t)]
    if not dl:
        ans = -1
        break
    insert_idx = bisect.bisect_right(dl, idx)
    if insert_idx == len(dl):
        l += 1
        idx = dl[0]
    else:
        idx = dl[insert_idx]
    ans = l * len(S) + idx + 1

print(ans)
### BUGGY CODE ###

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

dp = [0 for i in range(b+1)]

for i in range(a):
	w,h = map(int,input().split())
	for j in range(b,w-1,-1):
		dp[j] = max(dp[j],dp[j-w] + h)

print(max(dp))

### FIXED CODE ###

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

dp = [0 for i in range(b+1)]

for i in range(a):
	w,h = map(int,input().split())
	for j in range(b,w-1,-1):
		dp[j] = max(dp[j],dp[j-w] + h)

print(max(dp))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N, K = map(int, input().split())
P = [[] for i in range(N)]

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


dic = {}


def Perm(n, k):
    if (n, k) in dic:
        return dic[(n, k)]
    ans = 1
    for i in range(n - k + 1, n + 1):
        ans *= i % MOD
    dic[(n, k)] = ans % MOD
    return ans % MOD


def dfs(g, p):
    ans = Perm(K - 2, len(P[p]) - 1) % MOD
    for c in P[p]:
        if not c == g:
            ans *= dfs(p, c) % MOD
    return ans % MOD


ans = Perm(K, len(P[0]) + 1)
for c in P[0]:
    ans *= dfs(0, c) % MOD

print(ans % MOD)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N, K = map(int, input().split())
P = [[] for i in range(N)]

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


dic = {}


def Perm(n, k):
    if (n, k) in dic:
        return dic[(n, k)]
    ans = 1
    for i in range(n - k + 1, n + 1):
        ans *= i
        ans %= MOD
    dic[(n, k)] = ans
    return ans


def dfs(g, p):
    ans = Perm(K - 2, len(P[p]) - 1)
    for c in P[p]:
        if not c == g:
            ans *= dfs(p, c)
            ans %= MOD
    return ans


ans = Perm(K, len(P[0]) + 1)
for c in P[0]:
    ans *= dfs(0, c)
    ans %= MOD

print(ans)
### BUGGY CODE ###

h,w,n=map(int,input().split())
ab=[list(map(int,input().split())) for _ in [0]*n]
ab_d=dict()
for a,b in ab:
    if a not in ab_d.keys():
        ab_d[a]={b}
    else:
        ab_d[a].add(b)

ans=[set() for _ in range(9)]
for a,b in ab:
    temp=[[2 for _ in [0]*5] for _ in [0]*5]
    for i in range(5):
        if 0<a+i-2<=h:
            if a+i-2 in ab_d.keys():
                temp_d=ab_d[a+i-2]
            else:
                temp_d=set()
            for j in range(5):
                if 0<b+j-2<=w:
                    if b+j-2 in temp_d:
                        temp[i][j]=1
                    else:
                        temp[i][j]=0
    for i in range(3):
        for j in range(3):
            cnt=[temp[i+k][j+l] for k in range(3) for l in range(3)]
            if 2 not in cnt:
                ans[sum(cnt)-1].add((a+i-2,b+j-2))
                
for i in range(9):
    ans[i]=len(ans[i])

print((h-2)*(w-2)-sum(ans))
for i in ans:
    print(i)

### FIXED CODE ###

h,w,n=map(int,input().split())
ab=[list(map(int,input().split())) for _ in [0]*n]
ab_d={a*(10**9)+b-1 for a,b in ab}

ans=[set() for _ in range(9)]
for a,b in ab:
    temp=[None for _ in [0]*25]
    for i in range(5):
        for j in range(5):
            if 0<a+i-2<=h and 0<b+j-2<=w:
                if (a+i-2)*(10**9)+b+j-3 in ab_d:
                    temp[i*5+j]=1
                else:
                    temp[i*5+j]=0
    for i in range(3):
        for j in range(3):
            cnt=[temp[(i+k)*5+j+l] for k in range(3) for l in range(3)]
            if None not in cnt:
                ans[sum(cnt)-1].add((a+i-2)*(10**9)+b+j-3)
                
for i in range(9):
    ans[i]=len(ans[i])

print((h-2)*(w-2)-sum(ans))
for i in ans:
    print(i)
### BUGGY CODE ###

#!/usr/bin/env python3
import numpy as np


DEBUG = True
dprint = print if DEBUG else lambda *x : x

H, N = [int(str) for str in input().strip().split()]
AB = [[int(str) for str in input().strip().split()] for _ in range(N)]

dp = [0]
for h in range(1, H + 1):
    dp.append(min([i[1] + dp[max(0, h - i[0])] for i in AB]))
    
print(dp[-1])

### FIXED CODE ###

H, N = [int(str) for str in input().strip().split()]
AB = [[int(str) for str in input().strip().split()] for _ in range(N)]

dp = [0]
for h in range(1, H + 1):
    a, b = min(AB, key=lambda i: i[1] + dp[max(0, h - i[0])])
    dp.append(b + dp[max(0, h - a)])    
print(dp[-1])
### BUGGY CODE ###

S = list(input())
Q = int(input())
query = [list(input().split()) for _ in range(Q)]
revflag = 0

for i in query:
    if i[0] == '1':
        revflag = 1 - revflag
    else:
        if (revflag == 0 and i[1] == '1') or (revflag == 1 and i[1] == '2'):
            S.insert(0, i[2])
        else:
            S.append(i[2])

if revflag == 0:
    print(''.join(S))
else:
    print(''.join(S[::-1]))

### FIXED CODE ###

S = input()
Q = int(input())
query = [list(input().split()) for _ in range(Q)]
revflag = 0
before = ""
after = ""

for i in query:
    if i[0] == '1':
        revflag = 1 - revflag
    else:
        if (revflag == 0 and i[1] == '1') or (revflag == 1 and i[1] == '2'):
            before += i[2]
        else:
            after += i[2]

if revflag == 0:
    print(before[::-1]+S+after)
else:
    print(after[::-1]+S[::-1]+before)
### BUGGY CODE ###

N = int(input())
S = str(input())

import itertools as it
import numpy as np
x = list(it.combinations(list(S), 3))
y = ["".join(i) for i in x]
z = len(np.unique(y))
print(z)

### FIXED CODE ###

N = int(input())
S = str(input())

a = []
for i in range(10):
    for j in range(10):
        for z in range(10):
            a.append([i,j,z])

s = list(S)
s = [int(i) for i in s]
ans = 0
for n in a:
    flag = 0
    for i,name in enumerate(s):
        if name == n[0]:
            n = n[1:]
            flag += 1
        if flag == 3:
            ans += 1
            break

print(ans)
### BUGGY CODE ###

import bisect

n = int(input())
ans_head=[-1]

a_list=[]
for i in range(n):
  a_list.append(int(input()))

for i in range(n):
  a=a_list[i]
  if ans_head[0]>=a:
    ans_head=[a]+ans_head
  else:
    insert_index = bisect.bisect_left(ans_head,a)
    ans_head[insert_index-1]=a

  #print(ans_head)
print(len(ans_head))


### FIXED CODE ###

import bisect
n=int(input())
A=[]
for i in range(n):
  A.append(int(input()))
Ans=[A[-1]]
for i in reversed(range(n-1)):
  a=A[i]
  if a>=Ans[-1]:
    Ans.append(a)
  else:

    Ans[bisect.bisect_right(Ans,a)]=a

print(len(Ans))
### BUGGY CODE ###

import sys

n = int(input())
a = []
for _ in range(n):
	a.append(tuple(map(int,input().split())))
a = tuple(a)

play = [0 for _ in range(n)]
flag = [True for _ in range(n)]
count = 0
ans = 0
while True:
	break_flag = True
	for i in range(n):
		if flag[i]:
			num = a[i][play[i]]-1
			if flag[num] and a[num][play[num]]-1 == i:
				play[num] += 1
				play[i] += 1
				flag[num] = False
				flag[i] = False
				break_flag = False
				count += 1
	if break_flag:
		print(-1)
		sys.exit()
		break
	ans += 1
	if count == n*(n-1)//2:
		break
	for i in range(n):
		if play[i] < n-1:
			flag[i] = True
		else:
			flag[i] = False

if ans == 0:
	print(-1)
else:
	print(ans)


### FIXED CODE ###

import sys
readline = sys.stdin.readline
def main():
	limit = 10 ** 4
	n = int(input())
	a = []
	for _ in range(n):
		a.append(tuple(map(int,input().split())))
	a = tuple(a)

	play = [0 for _ in range(n)]
	flag = [True for _ in range(n)]
	count = 0
	ans = 0
	while True:
		break_flag = True
		for i in range(n):
			if flag[i]:
				num = a[i][play[i]]-1
				if flag[num] and a[num][play[num]]-1 == i:
					play[num] += 1
					play[i] += 1
					flag[num] = False
					flag[i] = False
					break_flag = False
					count += 1
		if break_flag:
			print(-1)
			sys.exit()
		ans += 1

		if count == n*(n-1)//2:
			break
		if ans > limit:
			print(n*(n-1)//2)
			sys.exit()
		for i in range(n):
			if play[i] < n-1:
				flag[i] = True
			else:
				flag[i] = False

	if ans == 0:
		print(-1)
	else:
		print(ans)
if __name__ == '__main__':
	main()
### BUGGY CODE ###

import bisect

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [0] * Q
C = [0] * Q
for i in range(Q):
    B[i], C[i] = map(int, input().split())

A.sort()
Sum = sum(A)

for i in range(Q):
    L = bisect.bisect_left(A, B[i])
    R = bisect.bisect_right(A, B[i])
    num = R - L
    Sum += num * (C[i] - B[i])

    for j in range(L, R):
        A[j] = C[i]

    A.sort()
    print(Sum)


### FIXED CODE ###

import bisect

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [0] * Q
C = [0] * Q
for i in range(Q):
    B[i], C[i] = map(int, input().split())

DP = [0]*(10**5+1)

for i in range(len(A)):
    DP[A[i]] += 1

Sum = sum(A)

for i in range(Q):
    Sum += (C[i]-B[i])*DP[B[i]]
    DP[C[i]] += DP[B[i]]
    DP[B[i]] = 0
    print(Sum)
### BUGGY CODE ###

import sys

N, K = map(int, input().split())
H = list(map(int, input().split()))
DP = [0] * N  # N番目までに使用する最小エネルギ-
for n in range(1, N):
    if n == 1:
        DP[1] = abs(H[1] - H[0])
    else:
        min_value = sys.maxsize
        for j in range(1, K + 1 if K < n else n+1):
            tmp_dpn = abs(H[n] - H[n - j]) + DP[n - j]
            if tmp_dpn < min_value:
                min_value = tmp_dpn
        DP[n] = min_value
print(DP[-1])


### FIXED CODE ###

import sys

N, K = map(int, input().split())
H = list(map(int, input().split()))
DP = [0] * N  # N番目までに使用する最小エネルギ-
for n in range(1, N):
    if n == 1:
        DP[1] = abs(H[1] - H[0])
    else:
        min_value = sys.maxsize
        for j in range(1, K + 1 if K < n else n+1):
            tmp_dpn = abs(H[n] - H[n - j]) + DP[n - j]
            if tmp_dpn < min_value:
                min_value = tmp_dpn
        DP[n] = min_value
print(DP[-1])
### BUGGY CODE ###

s = str(input())
q = int(input())
flip = -1
strs = '/'
 
for i in range(q):
    query = list(map(str, input().split()))
    if query[0] == '1':
        flip = flip * -1
    elif query[0] == '2':
        if query[1] == '1':
            if flip == -1:
                strs = query[2] + strs
            else:
                strs = strs + query[2]
        else:
            if flip == -1:
                strs = strs + query[2]
            else:
                strs = query[2] + strs
 
if flip == -1:
    ans = strs.replace('/', s)
else:
    ans = strs[::-1].replace('/', s[::-1])
 
print(ans)

### FIXED CODE ###

from collections import deque

s = str(input())
q = int(input())
flip = -1
strf = deque()
strb = deque()

for i in range(q):
    query = list(map(str, input().split()))
    if query[0] == '1':
        flip = flip * -1
    elif query[0] == '2':
        if query[1] == '1':
            if flip == -1:
                strf.appendleft(query[2])
            else:
                strb.append(query[2])
        elif query[1] == '2':
            if flip == -1:
                strb.append(query[2])
            else:
                strf.appendleft(query[2])

# print(strf)
# print(strb)
ans = ''.join(strf) + s + ''.join(strb)
if flip == 1:
    ans = ans[::-1]
print(ans)

# s = str(input())
# q = int(input())
# flip = -1
# strs = '/'
 
# for i in range(q):
#     query = list(map(str, input().split()))
#     if query[0] == '1':
#         flip = flip * -1
#     elif query[0] == '2':
#         if query[1] == '1':
#             if flip == -1:
#                 strs = query[2] + strs
#             else:
#                 strs = strs + query[2]
#         else:
#             if flip == -1:
#                 strs = strs + query[2]
#             else:
#                 strs = query[2] + strs
 
# if flip == -1:
#     ans = strs.replace('/', s)
# else:
#     ans = strs[::-1].replace('/', s[::-1])
 
# print(ans)
### BUGGY CODE ###

def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

N = int(input())
for i in range(1, N+1):
    if i < 6:
        print(0)
        continue
    cnt = 0
    for x in range(1, 30):
        for y in range(1, 30):
             D = (((x+y)**2 - 4*(x**2+y**2+x*y-i)) ** (1/2))
             if ((x+y)**2 - 4*(x**2+y**2+x*y-i)) > 0 :
                 Z = (-(x+y) + D) / 2
                 if is_integer(Z) and Z>0:
                     cnt += 1
    print(cnt)

### FIXED CODE ###

N = int(input())
lis = [0]*N
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            ans = x**2 + y**2 + z**2 + x*y + y*z + z*x -1
            if ans >= N:
                pass
            else:
                lis[ans] += 1
for i in range(N):
    print(lis[i])
### BUGGY CODE ###

N,K,Q=map(int,input().split())
a=[]
A=[]

for _ in range(Q):
    a.append(int(input()))

for _ in range(N):
    A.append(int(K))

for n in range(Q):
    A[a[n]-1]+=1

for _ in range(Q):
    for m in range(N):
        A[m]-=1
    
for s in range(N):
    if A[s]<1:
        print("No")
    else:
        print("Yes")

### FIXED CODE ###

N,K,Q=map(int,input().split())
a=[]
A=[]

for _ in range(Q):
    a.append(int(input()))

for _ in range(N):
    A.append(int(K))

for n in range(Q):
    A[a[n]-1]+=1
    
for s in range(N):
    if A[s]-Q<1:
        print("No")
    else:
        print("Yes")
### BUGGY CODE ###

from sys import stdin
R,G,B,N=[int(x) for x in stdin.readline().rstrip().split()]
ans=0
for r in range(0,N//R+1):
    for g in range(0,(N-(R*r))//G+1):
        for b in range(0,(N-(R*r)-(G*g))//B+1):
            ball = R*r + G*g + B*b
            if ball == N:
                ans+=1
print(ans)

### FIXED CODE ###

from sys import stdin
R,G,B,N=[int(x) for x in stdin.readline().rstrip().split()]
ans=0
for r in range(0,N//R+1):
    for g in range(0,(N-(R*r))//G+1):
        if (N - R*r - G*g) % B == 0:
            ans+=1
print(ans)
### BUGGY CODE ###

N,M=map(int,input().split())
X=[[] for x in range(N)]
city=[]
for i in range(M):
    P,Y=map(int,input().split())
    P-=1
    city.append((P,Y))
    X[P].append(Y)
X=[sorted(i) for i in X]
for p,y in city:
    num=X[p].index(y)+1
    p+=1
    print("%06d"%p+"%06d"%num)

### FIXED CODE ###

# ABC113 D 

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

P=[[] for _ in [0]*(N+1)]

for i in range(M):
    p,y=map(int,input().split())
    P[p].append((y,i))
    
from bisect import bisect_left as bl

res=[]
for p in range(N+1):
    Y=P[p][:]
    if not Y:
        continue
    
    sortY=sorted(list(set(Y)))
        
    zatY=[]
    for t_y in Y:
        zatY.append(bl(sortY,t_y))
    
    for index in zatY:
        y,i=sortY[index]
        num=10**12+p*10**6+index+1
        res.append((str(num)[1:],i))

res=[y for y,i in sorted(res,key=lambda x:x[1])]
print(*res,sep='\n')
### BUGGY CODE ###

N = int(input())
num = list(map(int, input().split()))

tot = 0

for i in range(len(num)):
  num2 = sum(num[i+1:])
  #print(num2)  

  tot += (num[i] % (10**9+7)) * (num2 % (10**9+7))
  if tot >= (10**9+7): tot = tot % (10**9+7)

print(tot)

### FIXED CODE ###

N = int(input())
num = list(map(int, input().split()))

tot = 0
num2 = [0]*(N-1)
numtot = sum(num)

for i in range(len(num)-1):
  numtot -= num[i]
  num2[i] = numtot % (10**9+7)
  
  num1 = num[i] % (10**9+7)
  
  tot += num1 * num2[i]
  
  if tot >= (10**9+7): tot = tot % (10**9+7)

print(tot)
### BUGGY CODE ###

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

for i in range(len(h)-1):
  if h[i] > h[i+1]:
    h[i] = h[i] - 1
  elif h[i] == h[i+1]:
    if h[i] == min(h[i:])+1:
      h[i] = h[i] - 1
if h == sorted(h):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

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

for i in reversed(range(1,n)):
  if h[i-1] - h[i] == 1:
    h[i-1] -= 1
  elif h[i-1] - h[i] > 1:
    print('No')
    exit()
print('Yes')
### BUGGY CODE ###

S = input()
N = len(S)
K = int(input())
StringList = []
for TSt in range(0,N):
    for TEd in range(TSt+1,N+1):
        StringList.append(S[TSt:TEd])
SetString = sorted(set(StringList))
print(SetString[K-1])

### FIXED CODE ###

S = input()
N = len(S)
K = int(input())
StringList = []
for TSt in range(0,N):
    for TEd in range(TSt+1,TSt+K+1):
        StringList.append(S[TSt:TEd])
SetString = sorted(set(StringList))
print(SetString[K-1])
### BUGGY CODE ###

#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

#input = sys.stdin.readline

########################################
def valid(a,b):
	#print(a,b)
	if 0<=a<=h-1 and 0<=b<=w-1 and arr[a][b] == ".":
		return True
	else:
		return False


h , w = map(int , input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch-=1
cw-=1
dh-=1
dw-=1
arr = [list(input()) for i in range(h)]
#print(arr)
can_vis = []
dist = [[float("inf")]*w for i in range(h)]
q = deque()
ans = float("inf")
q.append((ch,cw))
dist[ch][cw] = 0
#print(dh,dw,ch,cw)
while q:
	#print(q.popleft())
	#print(q)
	curx , cury = q.popleft()
	#can_vis.append((curx,cury))
	for dx,dy in [[1,0],[0,1],[-1,0],[0,-1]]:
		if valid(curx+dx, cury+dy) and dist[curx+dx][cury+dy] > dist[curx][cury]:
			dist[curx+dx][cury+dy] = dist[curx][cury]
			q.append((curx+dx, cury+dy))
	for dx in range(-2,3):
		for dy in range(-2,3):
			if valid(curx+dx, cury+dy) and dist[curx+dx][cury+dy] > dist[curx][cury]:
				dist[curx+dx][cury+dy] = dist[curx][cury] + 1 
				q.append((curx+dx, cury+dy))


if dist[dh][dw] == float("inf"):
	print(-1)
else:
	print(dist[dh][dw])



### FIXED CODE ###

#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################
def valid(a,b):
	#print(a,b)
	if 0<=a<=h-1 and 0<=b<=w-1 and arr[a][b] == ".":
		return True
	else:
		return False


h , w = map(int , input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch-=1
cw-=1
dh-=1
dw-=1
arr = [input() for i in range(h)]
#print(arr)
can_vis = []
dist = [[10**10]*w for i in range(h)]
q = deque()
ans = float("inf")
q.append((ch,cw))
dist[ch][cw] = 0
#print(dh,dw,ch,cw)
while q:
	#print(q.popleft())
	#print(q)
	curx , cury = q.popleft()
	#can_vis.append((curx,cury))
	for dx,dy in [[1,0],[0,1],[-1,0],[0,-1]]:
		if valid(curx+dx, cury+dy) and dist[curx+dx][cury+dy] > dist[curx][cury]:
			dist[curx+dx][cury+dy] = dist[curx][cury]
			q.appendleft((curx+dx, cury+dy))
	for dx in range(-2,3):
		for dy in range(-2,3):
			if valid(curx+dx, cury+dy) and dist[curx+dx][cury+dy] > dist[curx][cury] + 1:
				dist[curx+dx][cury+dy] = dist[curx][cury] + 1 
				q.append((curx+dx, cury+dy))


if dist[dh][dw] == 10**10:
	print(-1)
else:
	print(dist[dh][dw])
### BUGGY CODE ###

import numpy as np
n,m = map(int,input().split())

p = [0] * (n+1)
a = [0] * m
b = [0] * m


for i in range(m):
    a[i],b[i] = map(int,input().split())

s=list()
t=list()
t.append(1)

while(1):
    for j in t:
        for k in range(m):

            if a[k]==j and p[b[k]] == 0:
                p[b[k]]=a[k]
                s.append(b[k])

            if b[k]==j and p[a[k]]==0:
                p[a[k]]=b[k]
                s.append(a[k])

    if len(s)==0:
        break
    else:
        t = s
        s = []
    
if 0 in p[2:]:
    print('No')
else:
    print('Yes')
    for q in p[2:]:
        print(q)


### FIXED CODE ###

import numpy as np
n,m = map(int,input().split())

p = [0 for i in range(n+1)]
q = list()
q2 = list()

g=[[] for i in range(n+1)]

for i in range(m):
    a,b = map(int,input().split())
    g[a].append(b)
    g[b].append(a)


q2.append(1)

while 1:
    q=q2
    q2=[]

    while len(q):
        v = q.pop()
        
        for nv in g[v]:
            if p[nv] == 0:
                p[nv]=v
                g[nv].remove(v)
                q2.append(nv)
    if len(q2)==0:
        break

if 0 in p[2:]:
    print('No')
else:
    print('Yes')
    for q in p[2:]:
        print(q)
### BUGGY CODE ###

N, A, B = map(int, input().split())
capacity = N
is_a = True
cnt = 0

while capacity > 0:
    if is_a:
        ball = A
        cnt += min(capacity, ball)
    else:
        ball = B

    is_a = not is_a
    capacity -= min(capacity, ball)

print(cnt)


### FIXED CODE ###

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

combo = A + B
num_of_combo = N // combo
remaining = N - combo * num_of_combo

print(num_of_combo * A + min(remaining, A))
### BUGGY CODE ###

N, M = map(int, input().split())
prices = list(map(int, input().split()))

for i in range(M):
    max_idx = prices.index(max(prices))
    prices[max_idx] = prices[max_idx] // 2

print(sum(prices))


### FIXED CODE ###

import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: x * (-1), A))
heapq.heapify(A)

for _ in range(M):
    tmp = heapq.heappop(A) * (-1)
    tmp //= 2
    heapq.heappush(A, tmp * (-1))

print(-sum(A))
### BUGGY CODE ###

n = int(input())
line = list(map(int,input().split()))
box = {}
for i in range(1,n+1):
  box[i] = 0
  for j in range(n-1):
    if  i == line[j]:
      box[i] += 1
for k in range(1,n+1):
  print(box[k])

### FIXED CODE ###

import collections
n = int(input())
line = list(map(int,input().split()))
c = collections.Counter(line)
for k in range(1,n):
  print(c[k])
print(0)
### BUGGY CODE ###

n,m = (int(x) for x in input().split())
ans = []
i = 1

while(m//i >= n):
  if(m%i == 0):
    ans.append(i)
  i += 1
  
print(ans[-1])

### FIXED CODE ###

import heapq
n,m = (int(x) for x in input().split())
a1 = []
a2 = []
for i in range(1, int(m**0.5)+1):
  if(m%i == 0):
    a1.append(i)
    a2.append(m//i)
    
a1.extend(a2[::-1])
i = 0

while(i <= len(a1)):
  if(a1[i] >= n):
    print(m//a1[i])
    break
  i += 1
### BUGGY CODE ###

import sys
from collections import deque
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
n,q=map(int,input().split())
ki=[[] for _ in range(n)]
ans=[0]*n

def dfs(numQ,parent):
    for child in ki[numQ]:
        if child==parent:
            continue
        ans[child]+=ans[numQ]
        dfs(child,numQ)

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

for i in range(q):
    p,x=map(int,input().split())
    ans[p-1]+=x

dfs(0,-1)
print(*ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
n,q=map(int,input().split())
ki=[[] for _ in range(n)]
ans=[0]*n

def dfs(numQ,parent):
    for child in ki[numQ]:
        if child==parent:
            continue
        ans[child]+=ans[numQ]
        dfs(child,numQ)

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

for i in range(q):
    p,x=map(int,input().split())
    ans[p-1]+=x

dfs(0,-1)
print(*ans)
### BUGGY CODE ###

N,K,Q = list(map(int,input().split()))
A = []
[A.append(int(input())) for i in range(Q)]

B = [K]*N

for a in A:
    B = list(map(lambda x:x-1,B))
    B[a-1] += 1
for b in B:
    if b>0:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

N,K,Q = list(map(int,input().split()))
A = []
[A.append(int(input())) for i in range(Q)]

B = [K]*N

for a in A:
    B[a-1] += 1
B = list(map(lambda x:x-Q,B))
for b in B:
    if b>0:
        print("Yes")
    else:
        print("No")