Harryxun/stf_run huggingface dataset:
import math
a,b = list(map(int, input().split()))

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))

### FIXED CODE ###

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

def gcd( x, y ):
    while y != 0:
        x, y = y, x%y
    return x

def lcm(x, y):
    return (x * y) // gcd(x, y)

print(lcm(a, b))
from sys import stdin
from scipy import special
N,M = list(map(int, (stdin.readline().strip().split())))
count=0
count+=special.comb(N,2, True)
count+=special.comb(M,2, True)
print(count)

### FIXED CODE ###

from sys import stdin
import itertools
N,M = list(map(int, (stdin.readline().strip().split())))
count=0
count+=len(list(itertools.combinations(range(N), 2)))
count+=len(list(itertools.combinations(range(M), 2)))
print(count)
import sys

N_MAX = 100010

sys.setrecursionlimit(100000)

dp = [-1]*N_MAX
vec = [0]*N_MAX

def frog(n):
  if dp[n] != -1:
    return dp[n]
  else:
    dp[n] = min(frog(n-1) + abs(vec[n] - vec[n-1]) , frog(n-2) + abs(vec[n] - vec[n-2]))
    return dp[n]
  
N = int(input())
ln = list(map(int, input().split()))

for i in range(N):
  vec[i] = ln[i]

dp[0] = 0
dp[1] = abs(vec[0] - vec[1])

print(frog(N-1))


  

### FIXED CODE ###

import sys

N_MAX = 100010

sys.setrecursionlimit(500000)

dp = [-1]*N_MAX
vec = [0]*N_MAX

def frog(n):
  if dp[n] != -1:
    return dp[n]
  else:
    dp[n] = min(frog(n-1) + abs(vec[n] - vec[n-1]) , frog(n-2) + abs(vec[n] - vec[n-2]))
    return dp[n]
  
N = int(input())
ln = list(map(int, input().split()))

for i in range(N):
  vec[i] = ln[i]

dp[0] = 0
dp[1] = abs(vec[0] - vec[1])

print(frog(N-1))
A=input()
B=input()
C=input()
s="a"
while true:
  print(str(len(A))+str(len(B))+str(len(C)))
  if s=="a":
    s=A[0]
    A=A[1:]
    if len(A)==0:
        print("A")
        break
  elif s=="b":
    s=B[0]
    B=B[1:]
    if len(B)==0:
        print("B")
        break
  else:
    s=C[0]
    C=C[1:]
    if len(C)==0:
        print("C")
        break


### FIXED CODE ###

A=input()
B=input()
C=input()
s="a"
while (len(A)!=0 or s!="a") and (len(B)!=0 or s!="b") and (len(C)!=0 or s!="c"):
  if s=="a":
    s=A[0]
    A=A[1:]
  elif s=="b":
    s=B[0]
    B=B[1:]
  else:
    s=C[0]
    C=C[1:]
if len(A)==0 and s=="a":
    print("A")
elif len(B)==0 and s=="b":
    print("B")
else:
    print("C")
n, m = int(input())
print((n-1)*(m-1))

### FIXED CODE ###

n, m = map(int, input().split())
print((n-1)*(m-1))
li=input().split()[0]
child_li=[1]*len(li)
for i in range(len(li)):
    new_child_li=[0]*len(li)
    for j in range(len(li)):
# jでそれぞれのますをみる
        if li[j]=='R':
            new_child_li[j+1]+=child_li[j]
        else:
            new_child_li[j-1]+=child_li[j]
    child_li=new_child_li


rl_list=[(i,i+1) for i in range(len(li)-1) if li[i]=='R' and li[i+1]=='L']

        
if len(li)%2:
    for i in rl_list:
        new_child_li[i], new_child_li[i+1]=new_child_li[i+1], new_child_li[i]
print(*new_child_li, sep=' ')

### FIXED CODE ###

li=input()
n=len(li)
child_li=[0]*n


ruiseki=0
for i in range(n-1):
    if li[i]=='R':
        ruiseki+=1
        if li[i+1]=='L':
            child_li[i+1]=ruiseki//2
            child_li[i]=(ruiseki+1)//2
    else:
        ruiseki=0

        
ruiseki=0
for i in range(n-1, 0, -1):
    if li[i]=='L':
        ruiseki+=1
        if li[i-1]=='R':
            child_li[i-1]+=ruiseki//2
            child_li[i]+=(ruiseki+1)//2
    else:
        ruiseki=0
        
print(*child_li)
import sys

N=int(input())
A = list(map(int,input().split()))
 
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

if gcd_list(A) > 1:
    print("not coprime")
    sys.exit()

D = [i for i in range(max(A)+1)] #iを割り切る最小の素数を格納
p = 2
 
while(p*p<=max(A)):
    if D[p]==p:
        for i in range(2*p,max(A)+1,p):
            if D[i]==i:
                D[i]=p
 
    p+=1
    
prime = set()
for a in A:
    tmp=D[a]
    L=set()
    while(a>1):
        a=a//tmp
        L.add(tmp)
        tmp=D[a]

    for l in L:
        if l in prime:
            print("setwise coprime")
            sys.exit()
        else:
            prime.add(l)

print("pairwise coprime")

### FIXED CODE ###

D,T,S=map(int,input().split())

if D <= T*S:
    print('Yes')
else:
    print('No')
# D - Even Relation

import sys
sys.setrecursionlimit = 10**6

n = int(input())

# adjacency list
alist = [[] for _ in range(n)]

for _ in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    alist[u].append((v, w))
    alist[v].append((u, w))

#print(alist)

dlist = [-1] * n

def dfs(node, par, dist):
    dlist[node] = dist%2
    for i, j in alist[node]:
        if i==par:
            continue
        else:
            dfs(i, node, dist+j)

dfs(0,0,0)

for i in range(n):
    print(dlist[i])    


### FIXED CODE ###

# D - Even Relation

from collections import deque

n = int(input())

# adjacency list
alist = [[] for _ in range(n)]

for _ in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    alist[u].append((v, w%2))
    alist[v].append((u, w%2))

#print(alist)

dlist = [-1] * n
dlist[0] = 0

q = deque()
q.append(0)

while len(q)>0:
    node = q.popleft()
    for i, j in alist[node]:
        if dlist[i]<0:
            q.append(i)
            dlist[i] = (dlist[node] + j)%2
        else:
            continue

'''
def dfs(node, par, dist):
    dlist[node] = dist%2
    for i, j in alist[node]:
        if i==par:
            continue
        else:
            dfs(i, node, dist+j)
dfs(0,0,0)
'''

for i in range(n):
    print(dlist[i])
def get_cost(arr, n):
  if n == 1:
    return abs(arr[1] - arr[0])
  elif n == 0:
    return 0
  else:
    return min(
      abs(arr[n] - arr[n-1]) + get_cost(arr, n-1),
      abs(arr[n] - arr[n-2]) + get_cost(arr, n-2)
    )


N = int(input())
arr = [int(num) for num in input().split()]
print(get_cost(arr, N-1))


### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)

def get_cost(arr, n, dp):
  if dp[n] != float('inf'):
    return dp[n]
  if n == 1:
    dp[1] = abs(arr[1] - arr[0])
    return dp[1]
  elif n == 0:
    dp[0] = 0
    return dp[0]
  else:
    dp[n] = min(
      abs(arr[n] - arr[n-1]) + get_cost(arr, n-1, dp),
      abs(arr[n] - arr[n-2]) + get_cost(arr, n-2, dp)
    )
    return dp[n]


N = int(input())
arr = [int(num) for num in input().split()]
dp_arr = [float('inf')]*N
print(get_cost(arr, N-1, dp_arr))
from sys import setrecursionlimit
setrecursionlimit(100000)

S = input().split(" ")
N = int(S[0])
Q = int(S[1])

arr = []
prr = []
for i in range(N-1):
    S = input().split(" ")
    ar = [int(S[0]),int(S[1])]
    arr.append(ar)

for i in range(Q):
    S = input().split(" ")
    pr = [int(S[0]), int(S[1])]
    prr.append(pr)



def prepare(n, q, arr, prr):
    links = [[] for _ in range(n)]
    values = [0 for _ in range(n)]
    lineStates = [-1 for _ in range(n)]
    finalValues = [0 for _ in range(n)]
    for ar in arr:
        start = ar[0] - 1
        end = ar[1] - 1
        links[start].append(end)
        links[end].append(start)

    for pr in prr:
        i = pr[0] - 1
        x = pr[1]
        values[i] += x

    return links, values, lineStates, finalValues


links, values, lineStates, finalValues = prepare(N, Q, arr, prr)


def dfs(currentNode, arr, parrentAccumulate):
    childNodes = links[currentNode]
    parrentAccumulate += values[currentNode]
    finalValues[currentNode] = parrentAccumulate
    lineStates[currentNode] = 1
    for ch in childNodes:
        if lineStates[ch] == -1:
            dfs(ch, arr, parrentAccumulate)


dfs(0, links, 0)
print(*finalValues)

### FIXED CODE ###

from sys import setrecursionlimit
setrecursionlimit(100000)
from collections import deque

S = input().split(" ")
N = int(S[0])
Q = int(S[1])

arr = []
prr = []
for i in range(N-1):
    S = input().split(" ")
    ar = [int(S[0]),int(S[1])]
    arr.append(ar)

for i in range(Q):
    S = input().split(" ")
    pr = [int(S[0]), int(S[1])]
    prr.append(pr)



def prepare(n, q, arr, prr):
    links = [[] for _ in range(n)]
    values = [0 for _ in range(n)]
    finalValues = [0 for _ in range(n)]
    for ar in arr:
        start = ar[0] - 1
        end = ar[1] - 1
        links[start].append(end)
        links[end].append(start)

    for pr in prr:
        i = pr[0] - 1
        x = pr[1]
        values[i] += x

    return links, values, finalValues


links, values, finalValues = prepare(N, Q, arr, prr)


def bfs():
    q = deque()

    q.append((0,-1,0))

    while len(q) > 0:
        currentNode,parentNode,parentAccumulate = q.popleft()
        parentAccumulate += values[currentNode]
        finalValues[currentNode] += parentAccumulate
        childNodes = links[currentNode]
        for ch in childNodes:
            if ch == parentNode:
                continue
            q.append((ch,currentNode,finalValues[currentNode]))

bfs()
print(*finalValues)
import sys

n = raw_input()
text = sys.stdin.readlines()
tmp = "zzz"
for i in text:
    i = i.strip('\n')
    for j in range(len(i)):
        if i[j] > tmp[j]:
            break
        elif i[j] == tmp[j]:
            continue
        else:
            tmp = i
print tmp

### FIXED CODE ###

import sys

n = int(raw_input())
text = sys.stdin.readlines()
tmp = "{"
for i in text:
    i = i.strip('\n')
    if i < tmp:
        tmp = i
print tmp
import sys

input = sys.stdin.readline().strip
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0] * n
dp[0] = 0
dp[1] = abs(h[0] - h[1])

for i in range(2, n):
    dp[i] = min(abs(h[i] - h[j]) + dp[j] for j in range(max(0, i - k), i))
print(dp[n - 1])


### FIXED CODE ###

import sys


def input():
    return sys.stdin.readline().strip()


def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [0] * n
    dp[0] = 0
    dp[1] = abs(h[0] - h[1])

    for i in range(2, n):
        dp[i] = min(abs(h[i] - h[j]) + dp[j] for j in range(max(0, i - k), i))
    print(dp[n - 1])


if __name__ == "__main__":
    main()
k = int(input())
li = []
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      n = (a,b,c)
      li.append(reduce(gcd,n))

print(sum(li))

### FIXED CODE ###

from math import gcd
from functools import reduce

def func(a,b,c):
  if a == b and b == c:
    return a
  elif a == b and b !=c:
    return gcd(a,c)
  elif a != b and b ==c:
    return gcd(a,b)
  else:
    return reduce(gcd,(a,b,c))

k = int(input())
li = []
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      li.append(func(a,b,c))

print(sum(li))
import math

N = int(input())

for i in range(1, math.floor(math.sqrt(N))):
    if N % i == 0:
        factor = N / i

factor = int(factor)
print(len(str(factor)))


### FIXED CODE ###

import math

N = int(input())

for i in range(1, math.ceil(math.sqrt(N)) + 1):
    if N % i == 0:
        factor1 = N / i
        factor2 = i

factor1 = int(factor1)

if factor1 < factor2:
    print(len(str(factor2)))
else:
    print(len(str(factor1)))
N,M = list(map(int,input().split()))
S = []
C = []
ans = [0 for i in range(N)]
fr = 0
for i in range(M):
    s = 0
    c = 0
    s,c = list(map(int,input().split()))
    S.append(s)
    C.append(c)

for i in range(M):
    if C[i] != ans[S[i]-1] and ans[S[i]-1] != 0:
        fr = 1
    else:
        ans[S[i]-1] = C[i]

if fr != 0:
    print(-1)
elif (ans[0]*100 + ans[1]*10 + ans[2]) > 10**(N-1):
    print(ans[0]*100 + ans[1]*10 + ans[2])
else:
    print(-1)

### FIXED CODE ###

N,M = list(map(int,input().split()))
S = []
C = []
ans = [11 for i in range(N)]
fr = 0
for i in range(M):
    s = 0
    c = 0
    s,c = list(map(int,input().split()))
    S.append(s)
    C.append(c)

for i in range(M):
    if C[i] != ans[S[i]-1] and ans[S[i]-1] != 11:
        fr = 1
    elif C[i] == 0 and S[i] == 1 and N > 1:
        fr = 1
    else:
        ans[S[i]-1] = C[i]

for i in range(N):
    if ans[i] == 11:
        ans[i] = 0

if ans[0] == 0 and N > 1:
    ans[0] = 1

if fr != 0:
    print(-1)
else:
    if N == 3:
        print(ans[0]*100 + ans[1]*10 + ans[2])
    elif N == 2:
        print(ans[0]*10 + ans[1])
    else:
        print(ans[0])
s=input()
score=0
for i in range(0,len(s)/2+1):
  if s[i]!=s[len(s)-i]:
    score+=1
    
print(score)

### FIXED CODE ###

s=input()
score=0

for i in range(0,int(len(s)/2)):
    if s[i]!=s[len(s)-1-i]:
        score+=1

print(score)
import sys


def g(a,b):
    return g(abs(a-b),a) if a%abs(a-b)!=0 else abs(a-b)
sets = sys.stdin.readlines()
for line in sets:
    a, b = map(int, line.split())
    c = g(a, b)
    print(c, a*b//c)

### FIXED CODE ###

import sys
 
def gcd(inta, intb):
    large = max(inta, intb)
    small = min(inta,intb)
    mod = large % small
    if mod ==0:
        return small
    else:
        return gcd(small, mod) 
     
def lcm(inta, intb, intgcd):
    return (inta * intb // intgcd)
 
sets = sys.stdin.readlines()
for line in sets:
    a, b = map(int, line.split())
    c = gcd(a, b)
    print(c, lcm(a, b, c))
import sys
readline = sys.stdin.readline().strip


def solve():
    N = int(input())
    brackets_generator = (readline() for _ in range(N))

    grads_positive = list()
    grads_negative = list()

    total = 0
    for brackets in brackets_generator:

        elevation, bottom = 0, 0

        for bk in brackets:

            elevation += 1 if bk == '(' else -1
            bottom = min(bottom, elevation)

        if elevation >= 0:
            grads_positive.append((bottom, elevation))
        elif elevation < 0:
            grads_negative.append((bottom - elevation, -elevation))

        total += elevation

    if total != 0:
        return False

    grads_positive.sort(reverse=True)
    grads_negative.sort(reverse=True)

    def is_good(grads):
        elevation, bottom = 0, 0
        for grad in grads:
            bottom = elevation + grad[0]
            if bottom < 0:
                return False
            elevation += grad[1]

        return True

    if is_good(grads_positive) and is_good(grads_negative):
        return True
    else:
        return False


def main():
    ok = solve()
    if ok:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()


### FIXED CODE ###

# import sys
# input = sys.stdin.readline


def solve():
    N = int(input())
    brackets_gen = (input() for _ in range(N))

    grads_positive = list()
    grads_negative = list()

    total = 0
    for brackets in brackets_gen:

        elevation, bottom = 0, 0

        for bk in brackets:

            elevation += 1 if bk == '(' else -1
            bottom = min(bottom, elevation)

        if elevation >= 0:
            grads_positive.append((bottom, elevation))
        elif elevation < 0:
            grads_negative.append((bottom - elevation, -elevation))

        total += elevation

    if total != 0:
        return False

    grads_positive.sort(reverse=True)
    grads_negative.sort(reverse=True)

    def is_good(grads):
        elevation, bottom = 0, 0
        for grad in grads:
            bottom = elevation + grad[0]
            if bottom < 0:
                return False
            elevation += grad[1]

        return True

    if is_good(grads_positive) and is_good(grads_negative):
        return True
    else:
        return False


def main():
    ok = solve()
    if ok:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()
a = input()
i = 1
while i <= a :  
    i *= 2
print(i/2)

### FIXED CODE ###

a = int(input())
i = 1
while(i<=a):
	i *= 2
print(int(i/2))
n = int(input())

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

ans = sum(b)
for i in range(len(a)-1):
    if a[i]+1 == a[i+1]:
        ans += c[a[i]-1]


print(ans)
~

### FIXED CODE ###

n = int(input())

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

ans = sum(b)
for i in range(len(a)-1):
    if a[i]+1 == a[i+1]:
        ans += c[a[i]-1]


print(ans)
import numpy as np 

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

A_array = np.array(list(map(int, input().split())))

if K > 1000:
  K = 1000

for k in range(K):

    B_list = list()

    inf_array = np.array(range(N)) + 0.5 - A_array
    sup_array = np.array(range(N)) + 1.5 + A_array
        
    B_list = [((inf_array <= m+1) & (m+1<=sup_array)).sum() for m in range(N)]

    A_array = np.array(B_list)
    
print(' '.join(map(str, A_array)))    

### FIXED CODE ###

S = input()
nick = str()
for n in range(3):
  nick = nick + S[n]    

print(nick)
import string

w = input()
w.upper()

cnt = 0

while True:
    S = input().split()
    for s in S:
        s.upper()

        i = 0
        while i < len(s):
            if s not in string.digits:
                s.erase(i)
                i -= 1
            i += 1

        if (s == w):
            cnt += 1
    if S[-1] == 'END_OF_TEXT':
        break

print(cnt)

### FIXED CODE ###

W = input().lower()

cnt = 0
while True:
    T = input().split()
    
    if T[0] == "END_OF_TEXT":
        break
        
    for string in T:
        string = string.rstrip(".").lower()
        #print(string)
        if W == string:
           cnt = cnt + 1
        
print(cnt)
S,T = input().split()
A,B = input().split()
U = input()

if U = S:
  print(A-1)
else:
  print(B-1)


### FIXED CODE ###

S,T = input().split()
A,B = input().split()
U = input()

if U == S:
  print(int(A)-1, B)
else:
  print(A, int(B)-1)
s = input()
a = s.index('a')
sr = s[::-1]
z = sr.index('z')
print(len(s) - a - z)


### FIXED CODE ###

s = input()
a = s.index('A')
sr = s[::-1]
z = sr.index('Z')
print(len(s) - a - z)
import math
#import fractions
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

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

a=A[0]
for b in A:
    a=lcm(a,b)
    #a = a /fractions.gcd(a, b)*b

count=0
for i in A:
    count+=a/i
    #if count>(10**9)+7:
    #    count=count%((10**9)+7)
print(math.floor(count%((10**9)+7)))

### FIXED CODE ###

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

a=A[0]
for b in A:
    a = (a * b) // fractions.gcd(a, b)

count=0
for i in A:
    count+=a//i

print((count%((10**9)+7)))
s=input()
a=int(input())
r=[]
for i in range(len(s)):
  for j in range(i+1,min(k+i,len(s))+1):
    r.append(s[i:j])
r=list(set(r))
r.sort()
print(r[a-1])

### FIXED CODE ###

s=input()
a=int(input())
r=[]
for i in range(len(s)):
  for j in range(i+1,min(a+i,len(s))+1):
    r.append(s[i:j])
r=list(set(r))
r.sort()
print(r[a-1])
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    h, w = list(map(int, input().rstrip('\n').split()))
    a = [["."] * w for _ in range(h)]
    ql = []
    ql = collections.deque(ql)
    fq = collections.defaultdict(list)
    for i in range(h):
        s = str(readline().rstrip().decode('utf-8'))
        for j in range(w):
            if s[i][j] == "#":
                a[i][j] = "#"
                ql.append([0, i, j])
                fq[i, j]

    mt = 0
    while True:
        if len(ql) != 0:
            cost, x, y = ql.popleft()
            mt = max(mt, cost)
            for xv, yv in [[x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]]:
                if 0 <= xv < h and 0 <= yv < w:
                    if (xv, yv) not in fq and a[xv][yv] == ".":
                        ql.append([cost + 1, xv, yv])
                        fq[xv, yv]
        else:
            break
    print(mt)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    h, w = list(map(int, readline().split()))
    a = [[True] * w for _ in range(h)]
    ql = collections.deque()
    for i in range(h):
        s = list(str(readline().rstrip().decode('utf-8')))
        for j in range(w):
            if s[j] == "#":
                ql.append([0, i, j])
                a[i][j] = False
    while ql:
        cost, x, y = ql.popleft()
        for xv, yv in ((x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)):
            if 0 <= xv < h and 0 <= yv < w:
                if a[xv][yv]:
                    ql.append([cost + 1, xv, yv])
                    a[xv][yv] = False
    print(cost)


if __name__ == '__main__':
    solve()
n=int(input())
a=sorted(map(int,input().split()))[::-1]
j=i=0
while n:i+=a[i]>i;j+=a[j]>=i,n-=1
print('SFeicrosntd'[(a[i-1]^i|j^i)&1::2])


### FIXED CODE ###

n=int(input())
a=sorted(map(int,input().split()))[::-1]
i=0
while i<n and a[i]>i:i+=1
j=i
while j<n and a[j]>=i:j+=1
print('SFeicrosntd'[(a[i-1]-i)&1 or (j-i)&1::2])
import math
import sys
sys.setrecursionlimit(30000)
N=int(input())
edges=[[] for i in range(N+1)]
d=[-1 for i in range(N+1)]
for i in range(1,N):
	u,v,w=[int(i) for i in input().split()]
	edges[u].append([v,w])
	edges[v].append([u,w])
def kyori(u):
	for v,w in edges[u]:
		if d[v]==-1:
			d[v]=d[u]+w
			kyori(v)
d[1]=0
kyori(1)
for i in d[1:]:
	if i%2==0:
		print(1)
	else:
		print(0)

### FIXED CODE ###

import math
import sys
sys.setrecursionlimit(30000)
N=int(input())
edges=[[] for i in range(N+1)]
d=[-1 for i in range(N+1)]
for i in range(1,N):
	u,v,w=[int(i) for i in input().split()]
	edges[u].append([v,w])
	edges[v].append([u,w])
def kyori(u):
	for v,w in edges[u]:
		if d[v]==-1:
			d[v]=d[u]+w
			kyori(v)
d[1]=0
kyori(1)
for i in d[1:]:
	if i%2==0:
		print(1)
	else:
		print(0)
import copy,sys
def amida(A,x):
  for e in A:
    if e[x]==1:x+=1
    elif e[x-1]==1:x-=1
  return x
def f():
  for i in range(d):
    for j in range(1,n+1):
      if A[i][j]==0:
        B=copy.deepcopy(A)
        B[i][j]=1
        if amida(B,m)==p:
          print i+1,j
          return
  print 1
  return

n=input()
m=input()
p=input()
d=input()
A=[]
for s in sys.stdin:
  if s=="0\n":break
  A+=[[0]+map(int,list(s[:-1]))+[0]]
if amida(A,m)==p: print 0
else:f()

### FIXED CODE ###

import sys
def amida(A,x):
  for e in A:
    if e[x]=="1":x+=1
    elif e[x-1]=="1":x-=1
  return x
def f():
  for i in D:
    for j in range(1,n):
      if A[i][j-1:j+2]=="000":
        B=[e[:] for e in A]
        B[i]=B[i][:j]+"1"+B[i][j+1:]
        if amida(B,m)==p:
          print i+1,j
          return
  print 1
  return

while 1:
  n=input()
  if n==0:break
  m=input()
  p=input()
  D=range(input())
  A=["0"+raw_input()+"0" for i in D]
  if amida(A,m)==p:print 0
  else:f()
n = int(input())
x = list(map(int,input().split()))
mod=1e9+7
a = [-1]*(n+1)
def step(i):
    if i>=n-1:
        a[i]=0
        return x[-1]
    if(a[i]!=-1):return x[i]
    a[i] = min(abs(step(i+1)-x[i])+a[i+1],abs(step(i+2)-x[i])+a[i+2])%mod;
    return x[i]
step(0)
print(int(a[0]%mod))


### FIXED CODE ###

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

dp = [0, abs(h[1]-h[0])]
if n >2:
    for i in range(2,n):
        dp.append(min(abs(h[i]-h[i-2])+dp[-2], abs(h[i]-h[i-1])+dp[-1]))
else:
    print(dp[-1])
    exit()

print(dp[-1])
a,b=map(int, input().split()) 
if i in range(a):
    if((a-i)*2 + (i)*4 == b):
        print('Yes')
    else:
        print('No')
            

### FIXED CODE ###

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

for i in range(a+1):
    if (a-i)*2+(i)*4 == b:
        print('Yes')
        break
    if i==a:
        print('No')
n = int(input())
a = [int(input()) for i in range(n)]

m = max(a)

for i in range(n):
  if a[i]!=m:
    print(m)
  else:
    print(max([j for j in a if index(j)==i ]))

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]

b = sorted(a, reverse=True)

for i in range(n):
    if a[i] == b[0]:
        print(b[1])
    else:
        print(b[0])
n,k = map(int,input().split())
p = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = -float("INF")
for i in range(n):
    pi = p[i]
    x = c[pi-1]
    a = x
    for j in range(k-1):
        pi = p[pi-1]
        a = max(a,x+c[pi-1])
        x += c[pi-1]
    ans = max(ans,a)
print(ans)


### FIXED CODE ###

s = input()
ans = 0
a = 0
for si in s:
    if si == "R":
        a += 1
    else:
        ans = max(ans,a)
        a = 0
print(max(ans,a))