Harryxun/stf_run huggingface dataset:
N, Q = map(int, input().split())
s = '#' + input() + '#'
T = []
D = []
for t, d in [input().split() for _ in range(Q)]:
  T.append(t)
  D.append(-1 if d=='L' else 1)

#そのゴーレムがどちらかの端にたどり着けるかの関数
def canReachEnd(iL, dir):
  nowL = iL
  nowt = s[iL]
  for t, d in zip(T, D):
    if t == nowt:
      nowL += {nowt = snowL]
  if dir == 1 and nowL == N+1:
    return True
  elif dir == -1 and nowL == 0:
    return True
  else:
    return False

#1. iは左にたどりつくがi+1はたどりつかないiを探す
left = 0
right = N+1
while right > left+1:
  check = (left+right)//2
  if canReachEnd(check, -1):
    left = check
  else:
    right = check
leftborder = left

#2. jは右にたどりつくがj-1はたどりつかない jを探す
left = leftborder
right = N+1
while right > left+1:
  check = (left+right)//2
  if canReachEnd(check, 1):
    right = check
  else:
    left = check
rightborder = right

dropcnt = 0
dropcnt += leftborder
dropcnt += (N-(rightborder-1))
print(N-dropcnt)

### FIXED CODE ###

N, Q = map(int, input().split())
s = '#' + input() + '#'
#room[0], [1~N], [N+1]と考える
#文字を取り出すとき:[1~N]
T = [] #Title[0～Q-1]
D = [] #Direction[0～Q-1] R:1, L:-1で表現
for t, d in [input().split() for _ in range(Q)]:
  T.append(t)
  D.append(-1 if d=='L' else 1)

#そのゴーレムがどちらかの端にたどり着けるかの関数
#True, Falseを返す
def canReachEnd(iL, dir):
  #iLは初期マス(1~N), dirは方向(L:-1, R:1)
  
  #nowL:今いるマスの位置
  nowL = iL
  #nowt:今いるマスに書いてある文字
  nowt = s[iL]
  for t, d in zip(T, D):
    if t == nowt:
      #左に動いても右に動いてもdを足せばok
      #端に落ちたら文字が'#'なので気にしない
      nowL += d
      nowt = s[nowL]
      
  if dir == 1 and nowL == N+1:
    return True
  elif dir == -1 and nowL == 0:
    return True
  else: return False
#たどり着けるかの関数終わり

#ここから二分探索で2つの「境目」を探す

#(1)「iは左に辿り着くがi+1は辿り着かない」iを探す
#何も辿り着かない場合はi=0とする？
#全部辿り着く場合はi=Nとする？
#leftとrightが隣接したときのleftを答えとする？
##すると、ありえるleftの範囲は0~N
left = 0
right = N+1
while right > left+1:
  check = (left+right)//2
  
  if canReachEnd(check, -1):left = check
  else: right = check
#答えを代入
leftborder = left


#(2)「jは右に辿り着くがj-1は辿り着かない」jを探す
#何も辿り着かない場合はj=N+1とする？
#全部辿り着く場合はj=1とする？
#leftとrightが隣接したときのrightを答えとする？
##すると、ありえるrightの範囲はleftborder+1~N+1
left = leftborder #(1)で左に辿り着くと分かった部分は省く
right = N+1
while right > left+1:
  check = (left+right)//2
  
  if canReachEnd(check, 1):right = check
  else: left = check
#答えを代入
rightborder = right

#二分探索終わり

#lbには左に辿り着く限界,rbには右に辿り着く限界が格納
#1~lbまでは全部左端に落ちる lb==0なら0
#rb~Nまでは全部右端に落ちる rb==N+1なら0

dropcnt = 0
dropcnt += leftborder
dropcnt += (N-(rightborder-1))
print(N-dropcnt)
a,b=map(int,input().split()
list=[4,6,9,11]
if a==2 or b==2:
  print('No')
elif a in list and b in list:
  print('Yes')
elif a not in list and b not in list:
  print('Yes')
else:
  print('No')


### FIXED CODE ###

a,b=map(int,input().split())
list=[4,6,9,11]
if a==2 or b==2:
  print('No')
elif a in list and b in list:
  print('Yes')
elif a not in list and b not in list:
  print('Yes')
else:
  print('No')
import collections

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

m = 0
for i in range(N):
    m = max(set(S[:i]) & set(S[i:]), m)

print(m)

### FIXED CODE ###

import collections

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

m = 0
index = 0
for i in range(N):
    a = set(S[:i])
    b = set(S[i:])
    d = 0
    for c in a:
        if c in b:
            d += 1
    if d > m:
        m = d
        index = i
print(m)
import sys

stdin = sys.stdin

mod = 1000000007
inf = 1 << 60

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()
w = na()

ans = inf
d = [0] * (n + 1)
b = [0] * (n + 1)
for i in range(1, n + 1):
	d[i] = w[i - 1] + d[i - 1]
	b[i] = w[n - i] + b[i - 1]
b.reverse()
for i in range(1, n):
	ans = min(ans, abs(d[i] - b[i]))

print(ans

### FIXED CODE ###

import sys

stdin = sys.stdin

mod = 1000000007
inf = 1 << 60

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()
w = na()

ans = inf
d = [0] * (n + 1)
b = [0] * (n + 1)
for i in range(1, n + 1):
	d[i] = w[i - 1] + d[i - 1]
	b[i] = w[n - i] + b[i - 1]
b.reverse()
for i in range(1, n):
	ans = min(ans, abs(d[i] - b[i]))

print(ans)
import math
N,X=map(int,input().split())
x=[int(i) for i in input().split()]
A=[]
for t in x:
    A.append(abs(t-X))
ans=A[0]
for s in A:
    ans=math.gcd(ans,s)
print(ans)

### FIXED CODE ###

import fractions
N,X=map(int,input().split())
x=[int(i) for i in input().split()]
A=[]
for t in x:
    A.append(abs(t-X))
ans=A[0]
for s in A:
    ans=fractions.gcd(ans,s)
print(ans)
n=int(input())
v=sorted(list(map(int, input().split())))
s=v[0]/(2**(n-1))
for i in  range(1,n):
  s+=v[n]/(2**(n-i))
print(s)

### FIXED CODE ###

n=int(input())
v=sorted(list(map(int, input().split())))
s=v[0]/(2**(n-1))
for i in  range(1,n):
  s+=v[i]/(2**(n-i))
print(s)
from collections import Counter
import sys

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ca = Counter(A)
cb = Counter(B)
maxA = 0
maxB = 0
for item in ca.values():
    maxA = max(maxA, item)
for item in cb.values():
    maxB = max(maxB, item)
if maxA + maxB > N:
    print('No')
    sys.exit()

KEYS = sorted(cb.keys(), key=lambda x: cb[x])
KEYS.reverse()
index = 0

ans = []
for i in range(N):
    tmp = index
    while A[i] == KEYS[tmp] or cb[KEYS[tmp]] == 0:
        tmp += 1
    ans.append(KEYS[tmp])
    cb[KEYS[tmp]] -= 1
    if cb[KEYS[index]] == 0:
        index += 1

print('Yes')
print(*ans)

### FIXED CODE ###

from collections import Counter
import sys
import random
 
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ca = Counter(A)
cb = Counter(B)
for i in range(N+1):
    if ca[i] + cb[i] > N:
        print('No')
        sys.exit()

C = [0] * (N+1)
D = [0] * (N+1)

for i in range(N):
    C[i+1] += C[i] + ca[i+1]
    D[i+1] += D[i] + cb[i+1]

x = 0

for i in range(N):
    x = max(x, C[i+1] - D[i])

ans = [B[(i-x)%N] for i in range(N)]

print('Yes')
print(*ans)
n,k=map(int, input().split(" "))
X=list(map(int, input().split(" ")))
import bisect
maxvalue=100000000000000000000000
place=bisect.bisect_left(X,0)

if k<place:
    X=X[place-k:]
elif k<n-place:
    X=X[:place-n]

#print(place)
for i in range(n-k+1):
    low=X[i]
    high=X[i+k-1]
    if high*low<0:
        low=abs(low)
        high=abs(high)
        value=min(low,high)*2+max(low,high)
    else:
        low=abs(low)
        high=abs(high)
        value=low+high
    #print(value)
    if value<maxvalue:
        maxvalue=value
print(maxvalue)


### FIXED CODE ###

n,k=map(int, input().split(" "))
X=list(map(int, input().split(" ")))
#import bisect
maxvalue=100000000000000000000000
#place=bisect.bisect_left(X,0)

#if k<place:
#    X=X[place-k:]
#if k<n-place:
#    X=X[:-(n-place-k)]

#print(X)
#print(place)
for i in range(n-k+1):
    low=X[i]
    high=X[i+k-1]
    if high*low<0:
        low=abs(low)
        high=abs(high)
        value=min(low,high)*2+max(low,high)
    else:
        low=abs(low)
        high=abs(high)
        value=max(low,high)
    #print(value)
    if value<maxvalue:
        maxvalue=value
print(maxvalue)
import math
from fractions import gcd
def get_primenumber(number):
    prime_list = []
    search_list = list(range(2,number+1))
    while True:
        if search_list[0] > math.sqrt(number):
            prime_list.extend(search_list)
            break
        else:
            head_num = search_list[0]
            prime_list.append(head_num)
            search_list.pop(0)
            search_list = [num for num in search_list if num % head_num != 0]
    return prime_list

A, B = map(int, input().split())
g = gcd(A, B)
if g==1:
    print(1)
else:
    pn = get_primenumber(int(math.sqrt(g)))
    print(len(pn))

### FIXED CODE ###

def gcd(a, b):
    return gcd(b, a%b) if b!=0 else a

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def isprime(n):
    sup = int(n**0.5)
    for i in range(2, sup+1):
        if n%i==0:
            return False
    return True

A, B = map(int, input().split())
g = gcd(A, B)
divs = make_divisors(g)
ans = 0
for d in divs:
    ans += 1 if isprime(d) else 0
print(ans)
n=input()
l=[map(int,input().strip().split())]
ans=0
for i in range(1,len(l)-2):
  gc=0;
  lc=0;
  if(l[i] >l[i-1] or l[i]>l[i+1]):
    gc=1
  if(l[i] <l[i-1] or l[i]<l[i+1]):
    lc=1
   ans+=gc & lc

### FIXED CODE ###

n=input()
l=list(map(int,input().strip().split()))
ans=0
for i in range(1,len(l)-1):
  gc=0;
  lc=0;
  if(l[i] >l[i-1] or l[i]>l[i+1]):
    gc=1
  if(l[i] <l[i-1] or l[i]<l[i+1]):
    lc=1
  ans+=(gc & lc)
  #print(gc,lc,l[i])
print(ans)
import sys
import math
import numpy as np
import copy

def main():
    s = input()
    print "ARC" if s == "ABC" else "ABC"
    return 0

if __name__ == '__main__':
    sys.exit(main())

### FIXED CODE ###

import sys
import math
import numpy as np
import copy

def main():
    s = input()
    print("ARC" if s == "ABC" else "ABC")
    return 0

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

class union_find:
    def __init__(self,N):
        self.r = np.ones(N)*-1
    
    def root(self,x):
        if self.r[x]<0:
            return int(x)
        else:
            self.r[x] = self.root(int(self.r[x]))
            return int(self.r[x])
        
    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        else:
            self.r[x] += self.r[y]
            self.r[y] = int(x)
            return True
        
    def size(self,x):
        return -self.r[self.root(x)]


N,M = [int(i) for i in input().split()]

Union = union_find(N)
for i in range(M):
    x,y = [int(i) for i in input().split()]
    Union.unite(x,y)

Y = 0
for i in range(N):
    Y = max(Y,Union.size(i))
print(int(Y))

### FIXED CODE ###

import numpy as np

class union_find:
    def __init__(self,N):
        self.r = np.ones(N)*-1
    
    def root(self,x):
        if self.r[x]<0:
            return int(x)
        else:
            self.r[x] = self.root(int(self.r[x]))
            return int(self.r[x])
        
    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        else:
            self.r[x] += self.r[y]
            self.r[y] = int(x)
            return True
        
    def size(self,x):
        return -self.r[self.root(x)]


N,M = [int(i) for i in input().split()]

Union = union_find(N)
for i in range(M):
    x,y = [int(i) for i in input().split()]
    Union.unite(x-1,y-1)

Y = - min(Union.r)
print(int(Y))
#C問題
N,M = map(int,input().split())
ab=[list(map(int,input().split())) for i in range(M)]
reach=[-1]*(N)
reach[0]=0
ans=0
def cdfs(n):
    global ans
    global reach
    if sum(reach)==0:
        ans+=1
        reach=[-1]*(N)
        reach[0]=0
        return
    else:
        for j in range(N):
            if reach[j] == -1 and ([n+1,j+1] in ab or [j+1,n+1] in ab):
                reach[j] = 0
                cdfs(j)
                reach[j] = -1
            else:
                pass
        return
reach[0]=0
cdfs(0)
print(ans)
    

### FIXED CODE ###

#C
import itertools
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]

path = [(i+1) for i in range(N)]
p_list = list(itertools.permutations(path,N))

ans = 0
for pl in p_list:
    if pl[0] == 1:
        flag = 0
        for i in range(N-1):
            ab1 = [pl[i],pl[i+1]]
            ab2 = [pl[i+1],pl[i]]
            if ab1 in AB or ab2 in AB:
                pass
            else:
                flag = 1
                break
        if flag == 0:
            ans+=1
            
print(ans)
H,W=map(int,input().split())
s=[input() for _  in range(H)]
G=[["#"]*(W+2) for _ in range(H+2)]

for i in range(H):
    for j in range(W):
        G[i+1][j+1]=s[i][j]

def search(y,x):
    q=[(y,x)]
    d=[[-1]*(W+2) for _ in range(H+2)]
    d[y][x]=0
    while q:
        y1,x1=q.pop()
        for y2,x2 in ((y1+1,x1),(y1,x1+1),(y1-1,x1),(y1,x1-1)):
            if G[y2][x2]=="." and d[y2][x2]==-1:
                d[y2][x2]=d[y1][x1]+1
                q.append((y2,x2))
    return max(max(_) for _ in d)


for i in range(H):
    for j in range(W):
        if G[i+1][j+1]==".":
            ans=max(search(i+1,j+1),ans)

print(ans)

### FIXED CODE ###

H,W=map(int,input().split())
f=H*W
d=[[0]*f for _ in range(f)]


s=[input() for _  in range(H)]
    
for i in range(H):
    for j in range(W-1): 
        cnt=W*i+j
        d[cnt+1][cnt]=s[i][j]==s[i][j+1]=="."
        d[cnt][cnt+1]=s[i][j]==s[i][j+1]=="."
       
for i in range(H-1):
    for j in range(W): 
        cnt=W*i+j
        d[cnt][cnt+W]=s[i][j]==s[i+1][j]=="."
        d[cnt+W][cnt]=s[i][j]==s[i+1][j]=="."
        
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
csr=np.array(d)


ans=-1
k=shortest_path(csr)
for i in range(f):   
    for q in range(f):
            if k[i][q]>=f+1:k[i][q]=-1

    ans=max(ans,max(k[i]))

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

check = False
for i in range(n):

	if b[0]in a[i]:
		index=a[i].index(b[0])
		check=True
		for k in range(m):
			if i+k>n:
				check=False
				break

			if not b[k]in a[i+k] or a[i+k].index(b[k])!=index:
				check=False
				break

	if check:
		break

print("Yes" if check else "No")

### FIXED CODE ###

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

for i in a:
    for j in b:
        if j not in i:
            print("No")
            quit()
print("Yes")
N = int(input())
a = [ ]
for i in range(1:10):
    for j in range(i:10):
        b = i*j
        a.append(b)
if a.count(N) == 0:
    print('No')
else:
    print('Yes')


### FIXED CODE ###

N = int(input())
a = [ ]
for i in range(1,10):
    for j in range(i,10):
        b = i*j
        a.append(b)
if a.count(N) == 0:
    print('No')
else:
    print('Yes')
n , k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10**9 + 7
a.sort(reverse=True)
ans = 1
plus = []
minus = []
zero = 0
for i in range(n):
    if a[i] > 0:
        plus.append(a[i])
    elif a[i] < 0:
        minus.append(a[i])
    elif a[i] == 0:
        zero += 1
if len(plus) + len(minus) < k:
    print(0)
elif len(minus) == 0:
    for i in range(k):
        ans *= plus[i]
        ans %= mod
    print(ans)
elif len(plus) == 0:
    if k % 2 == 0:
        for i in range(k):
            ans *= minus[n-1-i]
            ans %= mod
        print(ans)
    elif k % 2 == 1:
        if zero >= 1:
            print(0)
        elif zero == 0:
            for i in range(k):
                ans *= minus[i]
                ans %= mod
            print(ans)
elif len(plus) + len(minus) == k:
    if len(minus) % 2 == 1 and zero >= 1:
        print(0)
    else:
        for i in plus:
            ans *= i
            ans %= mod
        for i in minus:
            ans *= i
            ans %= mod
        print(ans)
else:
    if k % 2 == 1:
        ans = plus[0]
        del plus[0]
        k -= 1
    re = []
    for i in range(k//2):
        if 2*i + 1 >= len(plus):
            break
        re.append(plus[2*i]*plus[2*i+1])
    minus.sort()
    for i in range(k//2):
        if 2*i + 1 >= len(plus):
            break
        re.append(minus[2*i]*minus[2*i+1])
    re.sort(reverse=True)
    for i in range(k//2):
        ans *= re[i]
        ans %= mod
    print(ans)
    

### FIXED CODE ###

from collections import deque
n , k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10**9 + 7
ans = 1
plus = []
minus = []

if n == k:
    for i in range(n):
        ans *= a[i]
        ans %= mod
    print(ans)
    exit()
    
for i in range(n):
    if a[i] >= 0:
        plus.append(a[i])
    elif a[i] < 0:
        minus.append(a[i])

if not plus and k % 2 == 1:
    minus.sort(reverse=True)
    for i in range(k):
        ans *= minus[i]
        ans %= mod
    print(ans)
    exit()

plus.sort(reverse=True)
minus.sort()
plus = deque(plus)
minus = deque(minus)

cou = []
while True:
    if len(cou) == k:
        break
    elif len(cou) == k-1:
        cou.append(plus.popleft())
        break
    else:
        if len(plus)>=2 and len(minus)>=2:
            p1 = plus.popleft()
            p2 = plus.popleft()
            m1 = minus.popleft()
            m2 = minus.popleft()
            if p1*p2 > m1*m2:
                cou.append(p1)
                plus.appendleft(p2)
                minus.appendleft(m2)
                minus.appendleft(m1)
            else:
                cou.append(m1)
                cou.append(m2)
                plus.appendleft(p2)
                plus.appendleft(p1)
        elif len(plus) < 2:
            m1 = minus.popleft()
            m2 = minus.popleft()
            cou.append(m1)
            cou.append(m2)
        elif len(minus) < 2:
            p1 = plus.popleft()
            cou.append(p1)

        
for i in cou:
    ans *= i
    ans %= mod
print(ans)
def main():
    """"ここに今までのコード"""
    import sys
    input = sys.stdin.readline
    n,m=map(int,input().split())
    A=list(map(int,input().split()))
    #A.sort()
    if n==1:
        ans=(m//(A[0]//2)+1)//2
        print(int(ans))
        exit()
    from fractions import gcd
    kou=A[0]*A[1]//gcd(A[0],A[1])
    from bisect import bisect_right as br
    c=br(A,A[-1]//2)
    for a in A:
        kou=a*kou//gcd(a,kou)
    for a in range(min(c+1,n))
        if (kou//A[a])%2==0:
            print(0)
            exit()
    kou//=2
    #print(kou)
    ans=(m//kou+1)//2
    print(int(ans))
if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    """"ここに今までのコード"""
    import sys
    input = sys.stdin.readline
    n,m=map(int,input().split())
    A=list(map(int,input().split()))
    #A.sort()
    if n==1:
        ans=(m//(A[0]//2)+1)//2
        print(int(ans))
        exit()
    from fractions import gcd
    kou=A[0]*A[1]//gcd(A[0],A[1])
    for a in A:
        kou=a*kou//gcd(a,kou)
        if (kou//a)%2==0:
            print(0)
            exit()
    kou//=2
    #print(kou)
    ans=(m//kou+1)//2
    print(int(ans))
if __name__ == '__main__':
    main()
a, b, c = map(int, input().split())
if c - (a - b) <= 0:
    print(0)
else:
    print(c - (a-b))


### FIXED CODE ###

n = int(input())
ans = 0
for i in range(1, n + 1):
    if len(str(i)) % 2 == 1:
        ans += 1
print(ans)
n,x=map(int,input().split())
l=list(map(int,input().split()))
ns=1
dis=0
i=0
while dis<=x:
  
  dis+=l[i]
  i+=1
  if dis>x:
    break
  ns+=1
print(ns)


### FIXED CODE ###

n,x=map(int,input().split())
l=list(map(int,input().split()))
ns=1
dis=0
i=0
while dis<=x:
  
  dis+=l[i]
  i+=1
  if dis>x:
    break
  elif i==n:
    ns+=1
    break
  ns+=1
print(ns)
d=[i:=0]*8**7
for j in[*open(0)][1].split():d[int(j)]+=1
while i<1e6:
 i+=1;j=i
 while j<1e6:j+=i;d[j]*=d[i]<1
print(d.count(1))

### FIXED CODE ###

d = [0] * (10**6 + 1)
n = int(input())
for a in map(int, input().split()):
    d[a] += 1
ans = 0
for i in range(1, 10**6 + 1):
    if d[i] == 1:
        ans += 1
    if d[i] > 0:
        for j in range(i, 10**6 + 1, i):
            d[j] = 0
print(ans)
s=input()
#s="RRLLLLRLRRLL"
a = [0] * len(s)
l_first = 0
r_first = 0

for i in range(len(s)):
    ii =len(s)-i-1
    if s[ii] == "R":
        if r_first==0:
            d = len(s)-ii-1
            r_first=ii
            a[ii+1]+=int(d/2)+d%2
            a[ii]+=int(d/2)
        else:
            d = -ii+r_first-1
            r_first=ii
            a[ii+1]+=int(d/2)+d%2
            a[ii]+=int(d/2)    
for i in range(len(s)):
    if s[i] == "L":
        if l_first==0:
            d = i-l_first
            l_first=i
            a[i-1]+=int(d/2)+d%2
            a[i]+=int(d/2)
        else:
            d = i-l_first-1
            l_first=i
            a[i-1]+=int(d/2)+d%2
            a[i]+=int(d/2)
print(" ".join(a))

### FIXED CODE ###

s=input()
#s="RRLLLLRLRRLL"
a = [0] * len(s)
l_first = 0
r_first = 0

for i in range(len(s)):
    ii =len(s)-i-1
    if s[ii] == "R":
        if r_first==0:
            d = len(s)-ii-1
            r_first=ii
            a[ii+1]+=int(d/2)+d%2
            a[ii]+=int(d/2)
        else:
            d = -ii+r_first-1
            r_first=ii
            a[ii+1]+=int(d/2)+d%2
            a[ii]+=int(d/2)    
for i in range(len(s)):
    if s[i] == "L":
        if l_first==0:
            d = i-l_first
            l_first=i
            a[i-1]+=int(d/2)+d%2
            a[i]+=int(d/2)
        else:
            d = i-l_first-1
            l_first=i
            a[i-1]+=int(d/2)+d%2
            a[i]+=int(d/2)
print(" ".join(list(map(str,a))))
a,b = map(int,input().split())
c = 2*b
d = a-c
if d > 0:
print('d')
elif d <= 0:
print('0')

### FIXED CODE ###

a,b = map(int,input().split())
c = 2*b
d = a-c
if d > 0:
 print(d)
elif d <= 0:
 print(0)
a, b = map(int, input().split())
if (a <= b):
    print(a)
else:
    print(a-1

### FIXED CODE ###

a, b = map(int, input().split())
if (a <= b):
    print(a)
else:
    print(a-1)
l=list(map(int,input().split()))
    l.sort()
    print(int(0.5*l[0]*l[1]))

### FIXED CODE ###

l=list(map(int,input().split()))
l.sort()
print(int(0.5*l[0]*l[1]))
li = [int(input().split()) for i in range(3)]
if li[0]<li[1] and li[1]<li[2]:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

a,b,c = map(int,input().split())
if a<b and b<c:
    print('Yes')
else:
    print('No')
import re
s = input()
x = s[8:-8]
print('{}''{}''{}'.format('A', *re.findall('[A-Z]', x), 'C'))


### FIXED CODE ###

s = input()
print('A'+s[8]+'C')
if x < a:
	print(0)
if x >= a:
	print(10)

### FIXED CODE ###

x,a = map(int,input().split())
if x < a:
	print("0")
if x >= a:
	print("10")
a,b=map(int,input().split())

print(-(-((a+b)//2))

### FIXED CODE ###

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

print(-(-(a+b)//2))
n, m = list(map(int, input().split()))
tmps = [[0 for i in range(1)] for j in range(m)]
pys = []
for i in range(0, m):
    p, y = list(map(int, input().split()))
    tmps[p].append(y)
    pys.append([p, y])
    
for i in range(m):
    tmps[i].sort()
 
for py in pys:
    p, y = py
    yindex = tmps[p].index(y)
    print('{:06}'.format(p) + '{:06}'.format(yindex))

### FIXED CODE ###

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

for i in range(m):
    p, y = list(map(int, input().split()))
    pyxs.append([p, y, i])

pyxs.sort(key = lambda x: x[1])

num = [0] * (n+1)
ans = [None]*m

for p, y, x in pyxs:
    ans[x] = '{:06}'.format(p) + '{:06}'.format(num[p]+1)
    num[p] += 1

for s in ans:
    print(s)
N, A, B = map(int, input().rstrip().split())
if A + B == 0:
    ret = 0
else:
    ret = int(N / (A + B)) * A + ('b'*A + 'r'*B)[:(N % (A + B))].count('b')
print(ret)


### FIXED CODE ###

N, A, B = map(int, input().rstrip().split())
if A == 0:
    ret = 0
elif A + B == 0:
    ret = 0
else:
    tmp1 = int(N / (A + B)) * A
    tmp2 = 0
    if A > N % (A + B):
        tmp2 = N % (A + B)
    else:
        tmp2 = A
    ret = tmp1 + tmp2
print(ret)
from fractions import *
n,*a=map(int,open(0).read().split())
b=1
for i in a:b*=i//gcd(b,i)
print(sum(b//i for i in a)%(10**9+7)) 


### FIXED CODE ###

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

if n==m: print("Yes")
else: print("No")
while 1:
  N,A,B,C,X = map(int,raw_input().split())
  if N == A == B == C == X == 0:break
  sum = 0
  Z = 0
  Y = [int(x) for x in raw_input().split()]
  if (X in Y) == True:
      Y.remove(X)
  while Z == 0:
      if sum == 10000:
          sum = -2
          Z = 1
      sum += 1
      X = (A*X+B)%C
      if X == Y[0]:
          Y.pop(0)
          if len(Y) == 0:
              Z = 1
  print sum

### FIXED CODE ###

while True:
  N,A,B,C,X = map(int,raw_input().split())
  if N == A == B == C == X == 0:break
  sum = 0
  Z = 0
  Y = [int(x) for x in raw_input().split()]
  if X == Y[0]:
      Y.pop(0)
      if len(Y) == 0:
          Z = 1
  while Z == 0:
      if sum == 10000:
          sum = -2
          Z = 1
      sum += 1
      X = (A*X+B)%C
      if X == Y[0]:
          Y.pop(0)
          if len(Y) == 0:
              Z = 1
  print sum