Harryxun/stf_run huggingface dataset:
import bisect

N, K = input().split()
dList = [int(x) for x in input().split()]
useList = [0,1,2,3,4,5,6,7,8,9]
for d in dList:
    useList.remove(d)
result = ''
if int(N[0]) > max(useList):
    # 桁上げが必要
    if useList[0] != 0:
        result += str(useList[0])
    else:
        result += str(useList[1])
    result += str(useList[0])*(len(N)-1)
else:
    for i in range(len(N)):
        a = int(N[i])
        if a in useList:
            result += N[i]
            continue
        else:
            count = 0
            if a > max(useList):
                while not max(useList) > int(result[-1]):
                    count += 1
                    result = result[:-1]
                count += 1
                sect = int(result[-1])
                result = result[:-1]
                result += str(useList[bisect.bisect_right(useList, sect)])
                result += str(useList[0])*(len(N)-len(result))
            else:
                result += str(useList[bisect.bisect_right(useList, a)])
                result += str(useList[0])*(len(N)-i-1)
            break
print(result)

### FIXED CODE ###

import bisect

N, K = input().split()
dList = [int(x) for x in input().split()]
useList = [0,1,2,3,4,5,6,7,8,9]
for d in dList:
    useList.remove(d)
result = ''
if int(N[0]) > max(useList):
    # 桁上げが必要
    if useList[0] != 0:
        result += str(useList[0])
    else:
        result += str(useList[1])
    result += str(useList[0])*(len(N))
else:
    for i in range(len(N)):
        a = int(N[i])
        if a in useList:
            result += N[i]
            continue
        else:
            count = 0
            if a > max(useList):
                while not max(useList) > int(result[-1]):
                    count += 1
                    result = result[:-1]
                    if result == '':
                        break
                if result == '':
                    if useList[0] != 0:
                        result += str(useList[0])
                    else:
                        result += str(useList[1])
                    result += str(useList[0])*(len(N))
                    break
                count += 1
                sect = int(result[-1])
                result = result[:-1]
                result += str(useList[bisect.bisect_right(useList, sect)])
                result += str(useList[0])*(len(N)-len(result))
            else:
                result += str(useList[bisect.bisect_right(useList, a)])
                result += str(useList[0])*(len(N)-i-1)
            break
print(result)
S = input()
W = ['Sunny', 'Cloudy', 'Rainy']
for i, w in enumerate(W):
  if S = w:
    print(W[(i+1)%3])
    break

### FIXED CODE ###

S = input()
W = ['Sunny', 'Cloudy', 'Rainy']
for i, w in enumerate(W):
  if S == w:
    print(W[(i+1)%3])
    break
N = int(input())
ls = list(map(int,input().split()))

boxes = [[] for i in range(N)]
impossible = False
for idx,num in enumerate(ls):
    if num>=N:
        impossible=True
        break
    boxes[num].append(idx)

check_start=-1
ans = 1

if impossible:
    ans = 0
elif boxes[0][0]!=0:
    ans = 0
elif len(boxes[0])>=2:
    ans = 0
else:
    for i in range(N-1):
        a = len(boxes[i])
        b = len(boxes[i+1])
        if a == 0:
            check_start = i
            rest_ls = boxes[i:]
            if rest_ls.count([])!=len(rest_ls):
                ans = 0
            break
        ans*=a**b
baisu = ans//998244353
print(ans-(998244353*baisu))

### FIXED CODE ###

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

boxes = [[] for i in range(N)]
impossible = False
for idx,num in enumerate(ls):
    if num>=N:
        impossible=True
        break
    boxes[num].append(idx)

check_start=-1
ans = 1

if impossible:
    ans = 0
elif len(boxes[0])==0:
    ans = 0
elif boxes[0][0]!=0:
    ans = 0
elif len(boxes[0])>=2:
    ans = 0
else:
    for i in range(N-1):
        a = len(boxes[i])
        b = len(boxes[i+1])
        if a == 0:
            check_start = i
            rest_ls = boxes[i:]
            if rest_ls.count([])!=len(rest_ls):
                ans = 0
            break
        ans*=a**b
baisu = ans//998244353
print(ans-(998244353*baisu))
import pandas as pd
import math

N = int(input())
print("No")

### FIXED CODE ###

import math
from itertools import groupby

N = int(input())
S = ["".join(sorted(input())) for i in range(N)]
sizes = [len(list(v)) for k, v in groupby(sorted(S))]


def combinations_count(n, r):
    if n == 1:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


ans = sum([combinations_count(size, 2) for size in sizes])
print(ans)
a = input()
if a < 1200:
 print("ABC")
elif a < 2800:
 print("ARC")
else:
 print("AGC")

### FIXED CODE ###

a = int(input())
if a < 1200:
 print("ABC")
elif a < 2800:
 print("ARC")
else:
 print("AGC")
a,b,x = map(int,input().split())

if(a* 1000000000 + b * len(str(1000000000)) <= x):
    print(1000000000)
    exit()

n = int(x/a)

while(True):

    if(n == 0):
        print(0)
        exit()

    if(a * n + b * len(str(n)) <= x):
        print(n)
        exit()
    else:
     n -= 1

### FIXED CODE ###

day = str(input())

days = ["SAT","FRI","THU","WED","TUE","MON","SUN"]

for d in days:
    if(day == d):
        print(days.index(d) + 1)
tomorrow = {
  'Sunny': 'Cloudy',
  'Cloudy': 'Rainy',
  'Rainy': 'Sunny'
}
print(tomorrow[int(input())])


### FIXED CODE ###

tomorrow = {
  'Sunny': 'Cloudy',
  'Cloudy': 'Rainy',
  'Rainy': 'Sunny'
}
print(tomorrow[input()])
number = input(N)
word = list(input((S))
judge = 'Yes'
            
if N%2 == 1:
    print('No')
elif for i in range(N/2):
    if word[i] != word[2i]:
        judge = 'No'

print(judge)            	
            		


### FIXED CODE ###

number = int(input())
word = list(input())
judge = 'Yes'
            
if number%2 == 1:
	judge = 'No'
    
else:
	for i in range(int(number/2)):
		if word[i] != word[int(number/2 + i)]:
			judge = 'No'

print(judge)
x=int(input())
print(pow(x,3)

### FIXED CODE ###

x=int(input())
print(x**3)
n=int(input())
s=[]
ansl=[]
for i in range(n):
    s.append(input())
counter = Counter(s)
max=counter.most_common(1)[0][1]
for w in counter.most_common():
    if w[1]==max:
        ansl.append(w[0])
ansl.sort()
for i in range(len(ansl)):
    print(ansl[i])

### FIXED CODE ###

from collections import Counter
n=int(input())
s=[]
ansl=[]
for i in range(n):
    s.append(input())
counter = Counter(s)
max=counter.most_common(1)[0][1]
for w in counter.most_common():
    if w[1]==max:
        ansl.append(w[0])
ansl.sort()
for i in range(len(ansl)):
    print(ansl[i])
if __name__ == "__main__":
    n = int(input())
    l_a = list(map(int, input().split()))
    s_a = list(set(l_a))

    s_a.sort()

    dub_a = [0]*max(s_a)

    for i in l_a:
        dub_a[i-1] += 1

    dp = [1]*max(s_a)

    for i in s_a:
        if 2*i > len(dp)+1:
            pass
        elif dp[2*i-1] == 0:
            pass
        else:
            for j in range(2*i-1, len(dp), i):
                dp[j] = 0


    count = 0
    for i in l_a:
        if dp[i-1]==1 and dub_a[i-1]==1:
            count += 1
    print(count)

### FIXED CODE ###

if __name__ == "__main__":
    n = int(input())
    l_a = list(map(int, input().split()))
    s_a = list(set(l_a))

    #s_a.sort()

    dub_a = [0]*(max(s_a)+1)

    for i in l_a:
        dub_a[i] += 1

    dp = [1]*(max(s_a)+1)

    for i in s_a:
        for j in range(2*i, len(dp), i):
            dp[j] = 0


    count = 0
    for i in s_a:
        if dp[i]==1 and dub_a[i]==1:
            count += 1
    print(count)
A, B, C, D, E, F = map(int, input().split())
W = set()
S = set()
wtr = 100*A
sgr = 0

i = 1
j = 0
while(wtr <= F):
  while(wtr <= F):
    W.add(wtr)
    wtr = i*A*100 + j*B*100
    j +=1
  i +=1
  j = 0
  wtr = i*A*100 + j*B*100
  
i = 0
j = 0
while(sgr <= F):
  while(sgr <= F):
    S.add(sgr)
    sgr = i*C + j*D
    j +=1
  i +=1
  j = 0
  sgr = i*C + j*D
answtr = 100*A
anssgr = 0
  
for wtr in W:
  for sgr in S:
    if (sgr*(answtr+anssgr) > anssgr*(wtr+sgr)) and (sgr*(100+E)<=E*(wtr+sgr) and (wtr+sgr<=F)):
      answtr = wtr
      anssgr = sgr
      if (anssgr*(100+E)==E*(answtr+anssgr):
          print("{} {}".format(answtr+anssgr, anssgr))
          exit()
print("{} {}".format(answtr+anssgr, anssgr))

### FIXED CODE ###

A, B, C, D, E, F = map(int, input().split())
W = set()
S = set()
wtr = 100*A
sgr = 0

i = 1
j = 0
while(wtr <= F):
  while(wtr <= F):
    W.add(wtr)
    wtr = i*A*100 + j*B*100
    j +=1
  i +=1
  j = 0
  wtr = i*A*100 + j*B*100
  
i = 0
j = 0
while(sgr <= F):
  while(sgr <= F):
    S.add(sgr)
    sgr = i*C + j*D
    j +=1
  i +=1
  j = 0
  sgr = i*C + j*D
answtr = 100*A
anssgr = 0
  
for wtr in W:
  for sgr in S:
    if (sgr*(answtr+anssgr) > anssgr*(wtr+sgr)) and (sgr*(100+E)<=E*(wtr+sgr) and (wtr+sgr<=F)):
      answtr = wtr
      anssgr = sgr
print("{} {}".format(answtr+anssgr, anssgr))
X,N = int(input().split())
list = [int(x) for x in input().split()]

min_num = 150

for a in range(-10,110):
    counter = 0
    A = abs(X - a)
    for b in list:
        if a == b:
            counter = 1
        else:
            continue
    if counter == 1:
        continue
    else:
        if A == abs(X - a):
            min_num = (a, min_num)
        elif A > abs(X - a):
            min_num = a
        else:
            continue

print(min_num)

### FIXED CODE ###

X,N = input().split()
list = [int(x) for x in input().split()]

min_num = [300, abs(int(X) - 300)]

for a in range(0,102):
    A = abs(int(X) - a)
    
    if a in list:
        continue
        
    else:
        if A > min_num[1]:
            continue
            
        elif A == min_num[1]:
            min_num[0] = min(a,min_num[0])
            min_num[1] = abs(int(X) - min_num[0])
            
        elif A < min_num[1]:
            min_num[0] = a
            min_num[1] = abs(int(X) - min_num[0])
            
print(min_num[0])
d,n=map(int,input().spilit())
if d==0:
  print('5')
else:
  a=100**d
  print(a*n)

### FIXED CODE ###

d,n=map(int,input().split())
if n < 100:
  print(n*(100**d))
else:
  print((n+1)*100**d)
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()
way = [[] for _ in range(n+1)]
for i in range(m):
    a,b = inpm()
    way[a].append(b)
    way[b].append(a)

ans = [0 for i in range(n+1)]
q = queue.Queue()
q.put((1,0))
while not q.empty():
    room,sign = q.get()
    if ans[room] != 0:
        continue
    ans[room] = sign

    for i in way[room]:
        q.put((i,room))

print('Yes')
for i in range(2,n+1):
    print(ans[i])

### FIXED CODE ###

import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()
way = [[] for _ in range(n+1)]
for i in range(m):
    a,b = inpm()
    way[a].append(b)
    way[b].append(a)

ans = [0 for i in range(n+1)]
q = queue.Queue()
q.put((1,0))
while not q.empty():
    room,sign = q.get()
    if ans[room] != 0:
        continue
    ans[room] = sign

    for i in way[room]:
        q.put((i,room))

print('Yes')
for i in range(2,n+1):
    print(ans[i])
LI=lambda:list(map(int,input().split()))
MI=lambda:map(int,input().split())
I=lambda:input()
k=int(I())
x,y=MI()
if abs(x+y)%2==1 and k%2==0:print(-1);exit()
ans=[]
xx=yy=0
if x<0:vx=-1
elif x>0:vx=1
if y<0:vy=-1
elif y>0:vy=1

while (abs(xx-x)+abs(yy-y))>k*3:
  if abs(xx-x)>=k:xx+=k*vx;ans.append([xx,yy])
  elif abs(yy-y)>=k:yy+=k*vy;ans.append([xx,yy])
  else:break
c=abs(xx-x)+abs(yy-y)
d=k*(0--c//k)
e=d-c
xx=x+e
yy=y+(k-e)*vy
ans.append([xx,yy])
while abs(yy-y)>=k:yy+=k*vy;ans.append([xx,yy])
print(len(ans)+1)
for i in ans:print(*i)
print(x,y)

### FIXED CODE ###

k=int(input())
x,y=map(int,input().split())
if x<0:fx=-1
else:fx=1
if y<0:fy=-1
else:fy=1
ax,ay=abs(x),abs(y)
if ax<ay:
  x,y=y,x
  ax,ay=ay,ax
  fx,fy=fy,fx
  flag=1
else:flag=0
r=ax+ay
if k%2==0 and r%2==1:print(-1);exit()
if r==k:
  print(1)
  if flag:x,y=y,x
  print(x,y)
  exit()
if r%2==1 and r<k:
  print(3)
  anss=[]
  anss.append(((ax+(k-ay))//2,(k-(ax+(k-ay))//2)))
  anss.append((ax+(k-ay),0))
  anss.append((ax,ay))
  for i,j in anss:
    ii,jj=i*fx,j*fy
    if flag:ii,jj=jj,ii
    print(ii,jj)
  exit()
if r%2==0 and r<k:
  rm=(2*k-ax-ay)//2
else:
  rn=(k-(r%k))%k
  if rn%2==1:rn+=k
  rm=rn//2
ans=(r+rm*2)//k
anss=[]*ans
print(ans)
first=[0,-rm]
second=[ax,-rm]
third=[ax,ay]
xx=yy=0
while yy>first[1]:
  if yy-k<=first[1]:
    xx+=k-(yy-first[1])
    yy=first[1]
  else:
    yy-=k
  anss.append((xx*fx,yy*fy))
while xx<second[0]:
  if xx+k>=second[0]:
    yy+=k-(second[0]-xx)
    xx=second[0]
  else:
    xx+=k
  anss.append((xx*fx,yy*fy))
while yy!=third[1]:
  yy+=k
  anss.append((xx*fx,yy*fy))
for i,j in anss:
  ii,jj=i,j
  if flag:ii,jj=jj,ii
  print(ii,jj)
a = 'CODEFESTIVAL2016'
b = input()
lista = list(a)
listb = list(b)
count = 0
for i in range(len(lista)):
  if lista[i]!=listb[i]:
    count++
print(count)

### FIXED CODE ###

a = 'CODEFESTIVAL2016'
b = input()
lista = list(a)
listb = list(b)
count = 0
for i in range(len(lista)):
  if lista[i]!=listb[i]:
    count+=1
print(count)
n, d = map(int, input().split())
a = n // (2d + 1) + 1
print(a)

### FIXED CODE ###

import math
n, d = map(int, input().split())
se = d * 2 + 1
print(math.ceil(n/se))
N, D = [int(_) for _ in input().split()]
X = []
for i in range(D):
    X.append([int(_) for _ in input().split()])

import math

ans = 0
for i in range(5):
    for j in range(i):
        # print(i,j)
        d = X[i] - X[j]
        if math.sqrt(d.dot(d)).is_integer():
            ans += 1
print(ans)

### FIXED CODE ###

N, D = [int(_) for _ in input().split()]
X = []
for i in range(N):
    X.append([int(_) for _ in input().split()])

# N, D = [3, 4]
# X = [
# [-3, 7, 8, 2],
# [-12, 1, 10, 2],
# [-2, 8, 9, 3]
# ]

from math import sqrt

ans = 0
for i in range(N):
    for j in range(i):
        d = 0
        for k in range(D):
            d += (X[i][k] - X[j][k]) ** 2
        if sqrt(d) % 1 == 0:
            ans += 1
print(ans)
s1 = raw_input()
s2 = raw_input()

a = [[0 for i in range(len(s1) + 1)]for i in range(len(s2) + 1)]
for i in range(len(s1) + 1):
    a[0][i] = i
for i in range(len(s2) + 1):
    a[i][0] = i
for i in range(len(s2)):
    for j in range(len(s1)):
        if s1[i] == s2[j]:
            a[j+1][i+1] = a[j][i]
        else:
            a[j+1][i+1] = min([a[j][i+1], a[j+1][i]) + 1
print a[len(s2)][len(s1)]

### FIXED CODE ###

s1 = raw_input()
s2 = raw_input()

a = [[0 for i in range(len(s2) + 1)]for i in range(len(s1) + 1)]
for i in range(len(s2) + 1):
    a[0][i] = i
for i in range(len(s1) + 1):
    a[i][0] = i
for i in range(len(s1)):
    for j in range(len(s2)):
        if s1[i] == s2[j]:
            a[i+1][j+1] = a[i][j]
        else:
            a[i+1][j+1] = min([a[i][j+1], a[i+1][j], a[i][j]]) + 1
print a[len(s1)][len(s2)]
def balance:
	slen = len(S)
	s = S + '##'

	for i in range(slen):
  		if s[i] == s[i+1]:
    		return '{} {}'.format(i + 1, i + 2)

  		if s[i] == [i+2]:
    		return '{} {}'.format(i + 1, i + 3)
    
	return '-1 -1'

    
S = input().strip()
print(balance(S))

### FIXED CODE ###

def d_unbalanced(S):
    S_length = len(S)
    s = S + '##'  # 統一的に扱うため、アルファベットでない文字を番兵とする
    for i in range(S_length):
        # どちらかを満たす文字列をアンバランスなものとして出せばいい
        # 全部調べても成り立たなければ、アンバランスな文字列はない
        if s[i] == s[i + 1]:  # XXと文字が並んでいる
            return '{} {}'.format(i + 1, i + 2)
        elif s[i] == s[i + 2]:  # XYXと文字が並んでいる
            return '{} {}'.format(i + 1, i + 3)
    # アンバランスな文字列はなかった
    return '-1 -1'
 
S = input().strip()
print(d_unbalanced(S))
s = input()
if s[0] == s[1] and s[1] == s[2]:
    print 'no'
    else: print 'yes'

### FIXED CODE ###

s = input()
if s[0] == s[1] and s[1] == s[2]:
    print ('No')
else: 
    print ('Yes')
a,b = map(int,input().sep())

men = a*b
hen = (a+b)*2

print(int(men),int(hen))

### FIXED CODE ###

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

men = a*b
hen = 2*(a+b)

print(men,hen,sep=" ")
def is_palindrome(num):
  return str(num) == str(num)[-1::-1].lstrip("0")

(left, right) = (int(tok) for tok in input().split())
print(len(filter(is_palindrome, range(left, right + 1))))

### FIXED CODE ###

def is_palindrome(num):
    return str(num) == str(num)[-1::-1].lstrip("0")

(left, right) = (int(tok) for tok in input().split())
print(len([i for i in range(left, right + 1) if is_palindrome(i)]))
N=int(input())
ABC=["A","B","C","D","E","F","G","H","I",,"J"]
def dfs(n,s):
  if len(s)==N:
    print(s)
    return
  
  for i in range(n+1):
    _s=s+ABC[i]
    dfs(max(n,i+1),_s)
    
dfs(0,"")

### FIXED CODE ###

N=int(input())
ABC=["a","b","c","d","e","f","g","h","i","j"]
def dfs(n,s):
  if len(s)==N:
    print(s)
    return
  
  for i in range(n+1):
    _s=s+ABC[i]
    dfs(max(n,i+1),_s)
    
dfs(0,"")
k = int(input())
a,b = map(int, input())
print('OK') if b-a+1 >= k else print('NG')

### FIXED CODE ###

k = int(input())
a,b = map(int, input().split())
print('OK') if (a%k ==0 or (b//k)-(a//k) >= 1) else print('NG')
input = list(map(int, input().split(' '))
a = input[0]
b = input[1]
x = a * b
y = (a + b) * 2
print("{} {}".format(a, b))

### FIXED CODE ###

input = list(map(lambda n: int(n), input().split(' ')))
print("{} {}".format(input[0] * input[1], (input[0] + input[1]) * 2))
N = int(input())
S = input()
K = int(input())

key = S[K]
result = 'a'

for i in range(N):
    if S[i] == key:
        result += S[i]
    elif S[i] != key:
        result += '*'
        

print(result[1:])

### FIXED CODE ###

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

key = S[K - 1]
result = 'a'

for i in range(N):
    if S[i] == key:
        result += S[i]
    elif S[i] != key:
        result += '*'
        

print(result[1:])
n = set(list(input()))
n.sort()
if 'abc' == ''.join(n):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = list(set(list(input())))
n.sort()
if 'abc' == ''.join(n):
  print("Yes")
else:
  print("No")
def main():

    N,M = map(int,input().split())
    A = [i for i in map(int,input().split())]
    A.sort()
    tmpB = []
    tmpC = 0
    targetList = []

    for i in range(M):

        element = list(map(int,input().split()))
        targetList.append(element)

    targetList.sort(key=lambda x:x[1],reverse=True)
    for i in range(M):
        for j in range(targetList[i][0]):
            if A[tmpC] < targetList[i][1] and N > tmpC:
                A[tmpC] = targetList[i][1]
                tmpC +=1


    print(sum(A))






if __name__== "__main__":
    main() 


### FIXED CODE ###


def main():

    N,M = map(int,input().split())
    A = [i for i in map(int,input().split())]
    A.sort()
    tmpC = 0
    targetList = []

    for i in range(M):

        element = list(map(int,input().split()))
        targetList.append(element)

    targetList.sort(key=lambda x:x[1],reverse=True)
    
    flag = False
    ans = 0
    for b,c in targetList:
        for j in range(b):
            if N > tmpC and A[tmpC] < c:
                ans += c
                tmpC +=1
            else:
                flag = True
                break
        if flag:
            break
    
    if tmpC < N:

        ans += sum(A[tmpC:])


    print(ans)






if __name__== "__main__":
    main()
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
i = 0
x = 0
y = 0
while i < n:
    if x == 0:
        if a[i] == a[i+1]:
            x = a[i]
            i += 1
    elif y == 0:
        if a[i] == a[i+1]:
            y = a[i]
            i += 1
    i += 1
print(x*y)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
i = 0
x = 0
y = 0
while i < n-1:
    if x == 0:
        if a[i] == a[i+1]:
            x = a[i]
            i += 1
    elif y == 0:
        if a[i] == a[i+1]:
            y = a[i]
            i += 1
    i += 1
print(x*y)
def solve():
    seq1 = raw_input()
    seq2 = raw_input()
 
    x, y = len(seq1), len(seq2)
    a1 = [0 for i in range(y+1)]
    for i in range(x):
        e1 = seq1[i]
        a2 = a1+[]
        for j in range(y):
            if e1 == seq2[j]:
                a1[j+1] = a2[j] + 1
            elif a1[j+1] < a1[j]:
                a1[j+1] = a1[j]
    return a1[-1]
 
n = imput()
for i2 in range(n):
    print solve()

### FIXED CODE ###

def solve():
    seq1 = raw_input()
    seq2 = raw_input()
 
    x, y = len(seq1), len(seq2)
    a1 = [0 for i in range(y+1)]
    for i in range(x):
        e1 = seq1[i]
        a2 = a1+[]
        for j in range(y):
            if e1 == seq2[j]:
                a1[j+1] = a2[j] + 1
            elif a1[j+1] < a1[j]:
                a1[j+1] = a1[j]
    return a1[-1]
 
n = input()
for i2 in range(n):
    print solve()
n,m = input().split()

int(n)
int(m)


print(m*n)

### FIXED CODE ###

n,m = input().split()

n = int(n)
m = int(m)


print((m-1)*(n-1))
n = int(input())
dat = list(map(int,input().split()))

cnt = dict()

for d in dat:
    if cnt.__contains__(d):
        cnt[d]+=1
    else:
        cnt[d]=1

if n%2:
    if cnt[0] != 1:
        print(0)
        exit(0)
    for i in range(2,n,2):
        if cnt[i] != 2:
            print(0)
            exit(0)
else:
    for i in range(1,n,2):
        if cnt[i] != 2:
            print(0)
            exit(0)
print(2**(n//2))


### FIXED CODE ###

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

cnt = dict()

for i in range(n):
    cnt[i] = 0
for d in dat:
    cnt[d]+=1

if n%2:
    if cnt[0] != 1:
        print(0)
        exit(0)
    for i in range(2,n,2):
        if cnt[i] != 2:
            print(0)
            exit(0)
else:
    for i in range(1,n,2):
        if cnt[i] != 2:
            print(0)
            exit(0)
print((2**(n//2))%1000000007)
def dfs(G,s,x):
    Counter[s]+=x
    for nv in G[s]:
        dfs(G,nv,x)
    
N,Q=map(int,input().split())
Counter=[0]*N
G=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(lambda x:int(x)-1,input().split())
    G[a].append(b)
for i in range(Q):
    p,x=map(int,input().split())
    dfs(G,p-1,x)
print(*Counter)

### FIXED CODE ###

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)
def dfs(G,s,p):
    for nv in G[s]:
        if(nv==p):
            continue
        Count[nv]+=Count[s]
        dfs(G,nv,s)
    
N,Q=map(int,input().split())
Count=[0]*N
G=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(lambda x:int(x)-1,input().split())
    G[a].append(b)
    G[b].append(a)
for i in range(Q):
    p,x=map(int,input().split())
    Count[p-1]+=x
dfs(G,0,-1)
print(*Count)
S = ''

if S == 'ABC':
    print('ARC')
else S == 'ARC':
    print('ABC')


### FIXED CODE ###

s = input()
a = ["ABC", "ARC"]
print(a[(a.index(s)+1)%len(a)])
import sys
a = sys.stdin.readlines()

if a[0] == 1:
    print('Hello World')
else:
    print(sum(a[1:]))

### FIXED CODE ###

N = int(input())

if N == 1:
    print('Hello World')
else:
    A = int(input())
    B = int(input())
    print(A+B)
s, t = input().split
print(t + s)

### FIXED CODE ###

s, t = input().split()
print(t + s)