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

#!/usr/bin/env python3
s = input()
t = input()
dp = [[0]*(1+len(t)) for _ in range(1+len(s))]
def match(s_,t_,i,j):
    if s_[i] == t_[j]:
        return 1
    else: return 0
#　配列アラインメントの感じでマッチしたら+1 そうでなかったら+0を返す
# traceback関数を作って戻る必要がある
# 漸化式 dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j],dp[i][j]+match())
# traceback[i+1][j+1] = 0 だったら上、1なら左、2なら斜め
traceback =[[-1]*(1+len(t)) for _ in range(1+len(s))]
for i in range(len(s)):
    for j in range(len(t)):
        if match(s,t,i,j) == 1:
            dp[i+1][j+1] = dp[i][j]+match(s,t,i,j)
            traceback[i+1][j+1] = 3
        elif dp[i][j+1] >= dp[i+1][j] and dp[i][j+1] >= dp[i][j]+match(s,t,i,j):
            dp[i+1][j+1] = dp[i][j+1]
            traceback[i+1][j+1] = 1
        else:
            dp[i+1][j+1] = dp[i+1][j]
            traceback[i+1][j+1] = 2
        
# traceback時の初期値がx = len(s),y = len(t)
# tracebackの挙動を見ながらx,y を更新する
#　終了条件はx,y == 0,0 になったとき
# traceback[x][y] % 2 == 1 の時、s[x-1]を出力する。
x,y = len(s),len(t)
"""for i in range(1+len(s)):
    #print(dp[i])
    print(traceback[i])
"""
output = []
while True:
    if traceback[x][y] == 3:
        output.append(s[x-1])
        #print()
    x -= traceback[x][y] % 2 
    y -= traceback[x][y] // 2
    #print(x,y)
    if x == 1 and y == 1:
        if traceback[x][y] == 3:
            output.append(s[x-1])
        break
    if x == 0 or y == 0:
        break
for i in range(len(output)-1,-1,-1):
    print(output[i],end="")
print()

    

### FIXED CODE ###

#!/usr/bin/env python3
s = input()
t = input()
dp = [[0]*(1+len(t)) for _ in range(1+len(s))]
def match(s_,t_,i,j):
    if s_[i] == t_[j]:
        return 1
    else: return 0
#　配列アラインメントの感じでマッチしたら+1 そうでなかったら+0を返す
# traceback関数を作って戻る必要がある
# 漸化式 dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j],dp[i][j]+match())
# traceback[i+1][j+1] = 0 だったら上、1なら左、2なら斜め
traceback =[[-1]*(1+len(t)) for _ in range(1+len(s))]
for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j]+1
            traceback[i+1][j+1] = 3
        elif dp[i][j+1] >= dp[i+1][j]:
            dp[i+1][j+1] = dp[i][j+1]
            traceback[i+1][j+1] = 1
        else:
            dp[i+1][j+1] = dp[i+1][j]
            traceback[i+1][j+1] = 2
        
# traceback時の初期値がx = len(s),y = len(t)
# tracebackの挙動を見ながらx,y を更新する
#　終了条件はx,y == 0,0 になったとき
# traceback[x][y] % 2 == 1 の時、s[x-1]を出力する。
x,y = len(s),len(t)
"""for i in range(1+len(s)):
    #print(dp[i])
    print(traceback[i])
"""
output = []
while True:
    if traceback[x][y] == 3:
        output.append(s[x-1])
        #print()
    x_ = x
    y_ = y
    x -= traceback[x_][y_] % 2 
    y -= traceback[x_][y_] // 2
    #print(x,y)
    if x == 1 and y == 1:
        if traceback[x][y] == 3:
            output.append(s[x-1])
        break
    if x == 0 or y == 0:
        break
for i in range(len(output)-1,-1,-1):
    print(output[i],end="")
print()
### BUGGY CODE ###

N,M = [int(it) for it in input().split()]
pli=[int(it)-1 for it in input().split()]
sli=[ (lambda a,b:[min(a,b),max(a,b)])(*[int(it)-1 for it in input().split()]) for i in range(M)]
ue = [-1]*N
dw = [[] for i in range(N)]

for a,b in sli:
  if ( b == ue[a] or a == ue[b] ):
    continue
  else:
    _a = ue[a] if ue[a]!=-1 else a 
    _b = ue[b] if ue[b]!=-1 else b
    if (_a == _b and _a != -1):
      continue
      
    if len(dw[_b])>0:
      dw[_a].extend(dw[_b])
      for _p in dw[_b]:
        ue[_p]=_a
      dw[_b]=[]
    dw[_a].append(_b)
    ue[_b]=_a

s = 0
for i in range(N):
  if ue[i]==-1:
    ue[i]=i 
for i in range(N):
  if (ue[i]==ue[pli[i]]):
    s+=1
print (s)


### FIXED CODE ###

N,M = [int(it) for it in input().split()]
pli=[int(it)-1 for it in input().split()]
sli=[ [int(it)-1 for it in input().split()] for i in range(M)]
ue = [-1]*N
dw = [[] for i in range(N)]

for a,b in sli:
  if ( b == ue[a] or a == ue[b] ):
    continue
  else:
    _a = ue[a] if ue[a]!=-1 else a 
    _b = ue[b] if ue[b]!=-1 else b
    if (_a == _b and _a != -1):
      continue
    if (len(dw[_a]) < len(dw[_b])):
      _a,_b=_b,_a
    if len(dw[_b])>0:
      dw[_a].extend(dw[_b])
      for _p in dw[_b]:
        ue[_p]=_a
      dw[_b]=[]
    dw[_a].append(_b)
    ue[_b]=_a

s = 0
for i in range(N):
  if ue[i]==-1:
    ue[i]=i 
for i in range(N):
  if (ue[i]==ue[pli[i]]):
    s+=1
print (s)
### BUGGY CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [0]*n
count = 0

for i in range(k):
  for j in range(n):
    for k in range(n):
      if a[k] >= abs(k-j):
        b[j] += 1
  a = b  
  b = [0]*n
  if a[0] == n:
    count += 1
  if count ==2 :
    break

print(*a)


### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*n
c=[0]*n
cnt=0
while cnt<min(k,101):
  cnt+=1
  for i in range(n):
    b[max(0,i-a[i])]+=1
    if i+a[i]<n-1:
      b[i+a[i]+1]-=1
    c[0]=b[0]
  for j in range(n-1):
    c[j+1]=c[j]+b[j+1]
  a=c
  b=[0]*n
  c=[0]*n
print(*a)
### BUGGY CODE ###

H, W = map(int, input().split())
dist_matrix = [[-1] * W for i in range(H)]
queue = []
for i in range(H):
  line_list = list(input())
  for j in range(W):
    if line_list[j] == "#":  
      dist_matrix[i][j] = 0
      queue.append([i,j])

#cnt = 0
#print(queue)
max_value = 0
while(True):
  #print(len(queue))
  if len(queue) == 0:
    break
  
  i,j = queue.pop(0)
  max_value = dist_matrix[i][j]
  #cnt += 1
  if i > 0 and dist_matrix[i-1][j] == -1:
    dist_matrix[i-1][j] = dist_matrix[i][j] + 1
    queue.append([i-1,j])
  if i < H-1 and dist_matrix[i+1][j] == -1:
    dist_matrix[i+1][j] = dist_matrix[i][j] + 1
    queue.append([i+1,j])
  if j > 0 and dist_matrix[i][j-1] == -1:
    dist_matrix[i][j-1] = dist_matrix[i][j] + 1
    queue.append([i,j-1])
  if j < W-1 and dist_matrix[i][j+1] == -1:
    dist_matrix[i][j+1] = dist_matrix[i][j] + 1
    queue.append([i,j+1])

#print(cnt)
#print(dist_matrix)
print(max_value)

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline
 
H, W = map(int, input().split())
mark_matrix = [[True]*(W+2)]
#mark_matrix.extend([[True]+[False]*(W)+[True] for _ in range(H)])
mark_matrix.extend([[True]+[x!='.' for x in input()] for _ in range(H)])
mark_matrix[H].append(True)
mark_matrix.append([True]*(W+2))
#queue = []
queue = deque()
for i in range(1,H+1):
  for j in range(1,W+1):
    if mark_matrix[i][j]:
      queue.append((i,j))
#  line = input()
#  for j,ch in enumerate(line):
#    if ch == "#":
#      mark_matrix[i+1][j+1] = True
#      queue.append((i+1,j+1))
#for i in range(1,H+1):
#  mark_matrix[i][0] = True
#  mark_matrix[i][W+1] = True
#for j in range(W+2):
#  mark_matrix[0][j] = True
#  mark_matrix[H+1][j] = True
#print(mark_matrix)
 
#cnt = 0
#print(queue)
max_value = 0
while(True):
  #print(len(queue))
  if len(queue) == 0:
    break
  
  new_queue = deque()
  for i,j in queue:
  
    if not mark_matrix[i-1][j]:
      mark_matrix[i-1][j] = True
      #queue.append((i-1,j))
      new_queue.append((i-1,j))
    if not mark_matrix[i+1][j]:
      mark_matrix[i+1][j] = True
      #queue.append((i+1,j))
      new_queue.append((i+1,j))
    if not mark_matrix[i][j-1]:
      mark_matrix[i][j-1] = True
      #queue.append((i,j-1))
      new_queue.append((i,j-1))
    if not mark_matrix[i][j+1]:
      mark_matrix[i][j+1] = True
      #queue.append((i,j+1))
      new_queue.append((i,j+1))
 
  if len(new_queue) == 0:
    break
  else:
    queue = new_queue
    max_value += 1
  
#print(cnt)
#print(dist_matrix)
print(max_value)
### BUGGY CODE ###

import math
N, K = map(int, input().split())
lightPow = list(map(int, input().split()))
 
for i in range(K):
  newLightPow = [0]*(N+1)
  #print(lightPow)
  for pos in range(1, N+1):
    count = 0
    low = math.ceil(pos-(lightPow[pos-1]+0.5))
    high = math.floor(pos+(lightPow[pos-1]+0.5))
    low = min(max(1, low), N)
    high = min(max(1, high), N)
    newLightPow[low-1] += 1
    newLightPow[high] -= 1
    #print("pos:"+str(pos))
    #print("low"+str(low)+" high"+str(high))
    #print(newLightPow)
  check = True
  #print(newLightPow)
  for i in range(1, N):
    newLightPow[i] += newLightPow[i-1]
    if (newLightPow[i] < (N-1)):
      check = False
  lightPow = newLightPow
  if (check):
    break

print(*lightPow[:-1])

### FIXED CODE ###

import math
N, K = map(int, input().split())
lightPow = list(map(int, input().split()))

for i in range(K):
  newLightPow = [0]*(N+1)
  #print(lightPow)
  for pos in range(1, N+1):
    low = pos - lightPow[pos-1]
    high = pos + lightPow[pos-1]
    low = min(max(1, low), N)
    high = min(max(1, high), N)
    newLightPow[low-1] += 1
    newLightPow[high] -= 1
    #print("pos:"+str(pos))
    #print("low"+str(low)+" high"+str(high))
    #print(newLightPow)
    
  check = True
  for i in range(0, N):
    if (i > 0):
      newLightPow[i] += newLightPow[i-1]
    if (newLightPow[i] < N):
      check = False
  lightPow = newLightPow
  if (check):
    break

print(*lightPow[:-1])
### BUGGY CODE ###

import sys

read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)

N, *a = map(int, read().split())

memo = [[0] * N for _ in range(N)]
r = N % 2


def f(i, j):
    n = j - i + 1
    if i == j:
        if n % 2 == r:
            s = a[i]
            memo[i][j] = s
            return s
        else:
            s = -a[i]
            memo[i][j] = s
            return s
    if n % 2 == r:
        s = max(f(i, j - 1) + a[j], f(i + 1, j) + a[i])
    else:
        s = min(f(i, j - 1) - a[j], f(i + 1, j) - a[i])
    memo[i][j] = s
    return s


f(0, N - 1)
print(memo[0][N - 1])


### FIXED CODE ###

import sys

read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)


def solve():
    n, *a = map(int, read().split())
    a = tuple(a)
    dp = [[0] * n for _ in range(n)]
    for i in range(n):
        dp[i][i] = a[i]
    for i in range(n - 2, -1, -1):
        for j in range(i + 1, n):
            L = a[i] - dp[i + 1][j]
            R = a[j] - dp[i][j - 1]
            if L > R:
                dp[i][j] = L
            else:
                dp[i][j] = R
    return dp[0][n - 1]


print(solve())
### BUGGY CODE ###

def main():
    import collections
    import math
    n=int(input())
    a=list(map(int, input().split()))
    c=collections.Counter(a)
    cnt=list(c.items())
    ans=0
    comb=[]
    for i in range(len(cnt)): #各出現数字のAi_C_2を計算
        buf=(cnt[i][1]**2-cnt[i][1])//2
        comb.append(buf)
        ans+=buf
    for ai in a:
        for i in range(len(cnt)):
            if cnt[i][0]==ai:
                print(ans-cnt[i][1]+1)

if __name__=='__main__':
    main()

### FIXED CODE ###

def main():
    import collections
    import math
    n=int(input())
    a=list(map(int, input().split()))
    c=collections.Counter(a)
    cnt=list(c.items())
    ans=0
    comb=[]
    for i in range(len(cnt)): #各出現数字のAi_C_2を計算
        buf=(cnt[i][1]**2-cnt[i][1])//2
        comb.append(buf)
        ans+=buf
    for ai in a:
        print(ans-c[ai]+1)

if __name__=='__main__':
    main()
### BUGGY CODE ###

import sys,math,collections,itertools
input = sys.stdin.readline

N,K=list(map(int,input().split()))
A =[0]+list(map(int,input().split()))
town = 1
town_list = [1]
count = 0
while True:
    town = A[town]
    count +=1
    if count == K:
        print(town)
        exit()
    if town not in town_list:
        town_list.append(town)
    else:
        roop_town_num = town
        break
    
l_ini_index = town_list.index(roop_town_num)
len_roop = len(town_list)-l_ini_index 

if K <= l_ini_index:
    print(town_list[K])
else:
    print(town_list[((K-l_ini_index)%len_roop+l_ini_index)])
    


### FIXED CODE ###

import sys,math,collections,itertools
input = sys.stdin.readline

N,K=list(map(int,input().split()))
A =[0]+list(map(int,input().split()))
town = 1
town_list = [1]
towntown = [0]*(N+1)
towntown[1]=1
count = 0
while True:
    town = A[town]
    count +=1
    if count == K:
        print(town)
        exit()
    if towntown[town] == 0:
        town_list.append(town)
        towntown[town] =1
    else:
        roop_town_num = town
        break
    
l_ini_index = town_list.index(roop_town_num)
len_roop = len(town_list)-l_ini_index 

if K <= l_ini_index:
    print(town_list[K])
else:
    print(town_list[((K-l_ini_index)%len_roop+l_ini_index)])
### BUGGY CODE ###

a = int(input())
b = 1
c = []
for i in range(a):
    c.append(b)
    b += 1

D = 0
for I in range(a):
    if c[I]%5 == 0:
        c.remove(c[I])
        c.insert(I,'a')
    
    elif c[I]%3 == 0:
        c.remove(c[I])
        c.insert(I,'a')
        
    else:
        D = D + c[I]
print(D)

### FIXED CODE ###

a = int(input())
d = 1
D = 0
for I in range(a):
    if d%3 == 0:
        d += 1
    
    elif d%5 == 0:
        d += 1
        
    else:
        D = D + d
        d += 1
print(D)
### BUGGY CODE ###

import numpy as np

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

num_max = max(nums)
next_max = num_max

for idx, el in enumerate(nums):
	del nums[idx]
	if num_max == el:
		if next_max == num_max:
			next_max = max(nums)
			print(next_max)
		else:
			print(next_max)
		
	else:
		print(num_max)
	nums.insert(idx, el)



### FIXED CODE ###

import numpy as np

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

num_max = np.max(nums)
next_max = sorted(nums)[-2]


for idx, el in enumerate(nums):
	if num_max == el:
		print(next_max)		
	else:
		print(num_max)
### BUGGY CODE ###

R, G, B, N = map(int, input().split())

ans = 0

for r in range(N // R + 1):
    for g in range(N // G + 1):
        if (N - r * R - g * G) % B == 0 and r * R + g * G <= N:
            ans += 1

print(ans)



### FIXED CODE ###

R, G, B, N = map(int, input().split())

ans = 0

for r in range(N // R + 1):
    for g in range(N // G + 1):
        if (N - r * R - g * G) % B == 0 and r * R + g * G <= N:
            ans += 1

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

import copy
import heapq

def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y)

def cal(array):
  while(len(array) > 1):
    a = array.pop(0)
    b = array.pop(0)
    array.insert(0, gcd(a, b))
  return array[0]

def bSort(a):
  for i in range(len(a)):
    for j in range(len(a)-1, i, -1):
      if a[j] < a[j-1]:
        a[j], a[j-1] = a[j-1], a[j]

  return a

n = int(input())
a = list(map(lambda x: int(x), input().split()))
a = bSort(a)
answer_list = []

for i in range(int(n)):
  copy_a = copy.copy(a)
  copy_pop_a = copy_a.pop(i)
  heapq.heappush(answer_list, -(cal(copy_a)))

answer = -heapq.heappop(answer_list)
print(answer)


### FIXED CODE ###

import copy
import heapq
import fractions

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

gcd_l = [0]
gcd_r = [0]

for i in range(N):
  gcd_l.append(fractions.gcd(gcd_l[i], A[i]))
  gcd_r.append(fractions.gcd(gcd_r[i], A[-(i+1)]))

gcd_r = gcd_r[::-1]
ans = []

for i in range(N):
  ans.append(fractions.gcd(gcd_l[i], gcd_r[i+1]))

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

import bisect

n,m = map(int, input().split())
a = list(map(int,input().split()))
a.sort()
for i in range(m):
    b,c = map(int,input().split())
    in_ind = bisect.bisect_left(a,c)
    if in_ind <= b:
        a = [c for i in range(in_ind)] + a[in_ind:]
    else:
        a = a[b:in_ind] + [c for i in range(b)] + a[in_ind:]
print(sum(a))

### FIXED CODE ###

from collections import deque

n,m = map(int,input().split())
a = deque(sorted(list(map(int,input().split()))))
bc = [list(map(int,input().split()))[::-1] for i in range(m)]
bc.sort(reverse=True)
def hoge(n,m,a,bc):
    cur_sum = sum(a)
    for x in bc:
        c = x[0]
        for i in range(x[1]):
            prv_sum = cur_sum
            cur_sum -= a.popleft()
            cur_sum += c
            a.append(c)
            if prv_sum >= cur_sum:
                print(prv_sum)
                return
    print(cur_sum)
    return
hoge(n,m,a,bc)
### BUGGY CODE ###

from scipy.sparse import*
i=lambda:tuple(map(int,input().split()))
f=csgraph.johnson
n,m,l=i()
d=eval('[0]*-~n,'*-~n)
while m:a,b,c=i();d[a][b]=c;m-=1
d=f(f(d,0)<=l)
d[d>n]=0
for _ in'_'*i()[0]:print(int(d[i()])-1)

### FIXED CODE ###

from scipy.sparse import*
s=csgraph.floyd_warshall
n,m,l,*t=map(int,open(0).read().split())
d=eval('[9e9]*-~n,'*-~n)
for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=d[b][a]=c
d=s(d)
d[d>l]=9e9
d[d<=l]=1
d=s(d)
d[d>9e9]=9e9
for s,t in zip(*[iter(t[m*3+1:])]*2):print(int(d[s,t]%9e9-1))
### BUGGY CODE ###

import sys

input = sys.stdin.readline
sys.setrecursionlimit(200010)
n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

v = 100000
graph = [[] for i in range(v*2)]
for i in range(n):
    x = info[i][0] - 1
    y = (info[i][1] - 1) + v
    graph[x].append(y)
    graph[y].append(x)

def dfs(pos):
    if visited[pos]:
        return
    visited[pos] = True
    if 0 <= pos < v:
        cnt[0] += 1
    else:
        cnt[1] += 1
    for i in graph[pos]:
        dfs(i)
    return

visited = [False] * (v*2)
cnt = [0]*2
ans = 0
for i in range(v*2):
    cnt[0] = 0
    cnt[1] = 0
    dfs(i)
    ans += cnt[0]*cnt[1]
print(ans - n)

### FIXED CODE ###

import sys

input = sys.stdin.readline
sys.setrecursionlimit(200010)
n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

v = 100000
graph = [[] for i in range(v*2)]
for i in range(n):
    x = info[i][0] - 1
    y = (info[i][1] - 1) + v
    graph[x].append(y)
    graph[y].append(x)

def dfs(pos):
    if visited[pos]:
        return
    visited[pos] = True
    cnt[pos//v] += 1
    for i in graph[pos]:
        dfs(i)
    return

visited = [False] * (v*2)
cnt = [0]*2
ans = 0
for i in range(v*2):
    cnt[0] = 0
    cnt[1] = 0
    dfs(i)
    ans += cnt[0]*cnt[1]
print(ans - n)
### BUGGY CODE ###

R, G, B ,N = map(int, input().split())

cnt = 0
NR = N//R
NG = N//G
for r in range(NR + 1):
  for g in range(NG + 1):
    NrRgG = N - (r*R + g*G)
    if NrRgG >= 0 and NrRgG % B == 0:
      cnt += 1
print(cnt)

### FIXED CODE ###

R, G, B ,N = map(int, input().split())

if R==1 and G==1 and B==1:
  print(int((N+2)*(N+1)*(1/2)))
else:
  RGB = [R, G, B]
  RGB.sort(reverse=True)

  R = RGB[0]
  G = RGB[1]
  B = RGB[2]

  cnt = 0
  NR = N//R
  NG = N//G
  for r in range(NR + 1):
    for g in range(NG + 1):
      NrRgG = N - (r*R + g*G)
      if NrRgG < 0:
        break
      elif NrRgG >= 0:
        if NrRgG % B == 0:
          cnt += 1
  print(cnt)
### BUGGY CODE ###

n = input()

ans = 0
while n:
    t = n[0]
    pre_t = n[:2]
    keta = len(n)-1
    #print(t, pre_t)
    if t < '5' or (t == '5' and pre_t <= '54'):  # 555 の時とか1000円だすと14枚で行けてしまう。。
        ans += int(t)
        n = n[1:]
        #print(n[0],'払った,残り', n, ans)
    else:
        ans += 1
        n = str((10 ** (keta + 1)) - int(n))  # どちらがお金を払うかが入れ替わる
        #print((10 ** (keta + 1)),'払った,お釣り', n, ans)
print(ans)

### FIXED CODE ###

n = input()
lenn = len(n)

dp = [0, 10000]
for d in reversed(n):
    d = int(d)
    dp = [min(d + dp[0], d + 1 + dp[1]), min(10 - d + dp[0], 9 - d + dp[1])]

print(min(dp[0], 1 + dp[1]))
### BUGGY CODE ###

from collections import Counter
N = int(input())
src = list(map(int,input().split()))

ctr1 = Counter()
ctr2 = Counter()

ans = []
for i in range(N):
    ctr1.update([src[i]])
    ctr2.update([src[-i-1]])
    if ctr1 == ctr2:
        ans.append(i+1)
        ctr1 = Counter()
        ctr2 = Counter()

print(*ans)



### FIXED CODE ###

# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
from bisect import bisect_left, insort

N = int(input())
src = list(map(int,input().split()))
ans = []
A, B = [], []

for i in range(N):
    a, b = src[i], src[-i-1]
    addA = False
    addB = False

    if a != b:
        j = bisect_left(B, a)
        if j != len(B) and B[j] == a:
            del B[j]
        else:
            addA = True

        j = bisect_left(A, b)
        if j != len(A) and A[j] == b:
            del A[j]
        else:
            insort(B, b)

        if addA:
            insort(A, a)

    if len(A) == len(B) == 0:
        ans.append(i+1)

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

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = list(list(map(int,input().split())) for i in range(m))

a.sort()
bc.sort(reverse=True,key=lambda x:x[1])
t = 0
for i in range(m):
    for j in range(bc[i][0]):
        if t != n:
            if a[t] < bc[i][1]:
                a[t] = bc[i][1]
                t+=1
            else:
                break
    else:
        continue
    break

print(sum(a))


### FIXED CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = list(list(map(int,input().split())) for i in range(m))

a.sort()
bc.sort(reverse=True,key=lambda x:x[1])
t = 0
for i in range(m):
    for j in range(bc[i][0]):
        if t != n:
            if a[t] < bc[i][1]:
                a[t] = bc[i][1]
                t+=1
            else:
                break
        else:
            break
    else:
        continue
    break

print(sum(a))
### BUGGY CODE ###

R,G,B,N=map(int,input().split())
r,g,b,count=0,0,0,0
while(B*b<=N):
	g=0
	while(G*g<=N-B*b):
		r=(-G*g-B*b+N)/R
		if (float(r).is_integer())&(r>=0):
			count+=1
		g+=1
	b+=1
print(count)

### FIXED CODE ###

R,G,B,N=map(int,input().split())
r,g,b,count=0,0,0,0
for b in range(N+1):
	for g in range(N+1):
		r=-G*g-B*b+N
		if r<0:break
		if (r%R==0): count+=1
print(count)
### BUGGY CODE ###

s = input()

p = len(s)
cnt = 0
temp = 0

while True:
    s = s.replace("01","")
    s = s.replace("10","")
    
    cnt = len(s)
    
    if temp == cnt:
        break
    temp = cnt
    
print(p - cnt)

### FIXED CODE ###

s = input()

c0 = s.count("0")
c1 = s.count("1")

print(min(c0,c1)*2)
### BUGGY CODE ###

XY = input().split()
X,Y = int(XY[0]), int(XY[1])
i = 0
n = 0
if(X == Y):
    print(-1)
else:
    while(n % Y == 0):
        n = i * X
        i+=1
    print(n)

### FIXED CODE ###

XY = input().split()
X,Y = int(XY[0]), int(XY[1])
if(X % Y != 0):
    print(X)
else:
    print(-1)
### BUGGY CODE ###

def resolve():
    n = int(input())

    count = {}
    for _ in range(n):
        name = input()
        if name not in count.keys():
            count[name] = 1

        else:
            count[name] += 1

    max_polls = max(count.values())

    names = []
    for k, v in count.items():
        if v == max_polls:
            names.append(k)

    names.sort()
    for name in names:
        print(name)
        
resolve()

### FIXED CODE ###

from collections import OrderedDict
import sys
input = sys.stdin.readline

def resolve():
    n = int(input())

    count = OrderedDict()
    for _ in range(n):
        name = input()
        if name not in count.keys():
            count[name] = 1

        else:
            count[name] += 1

    count = OrderedDict(
        sorted(count.items(), key=lambda x: x[0])
    )
    max_polls = max(count.values())

    for k, v in count.items():
        if v == max_polls:
            print(k)
            
resolve()
### BUGGY CODE ###

S = list(map(int,input().split()))
H = S[0]
W = S[1]
K = S[2]

def f(h,w,k):
    fib = [1,2,3,5,8,13,21,34,55,1]
    if h == 0 and k == 1:
        return 1
    elif h == 0 and not k == 1:
        return 0
    else:
        if not(k == 1 or k == w):
            return (fib[w-k-1]*fib[k-3]*f(h-1,w,k-1) + fib[k-1]*fib[w-k-1]*f(h-1,w,k) + fib[k-1]*fib[w-k-2]*f(h-1,w,k))
        elif k==1:
            return (fib[w-2]*f(h-1,w,k) + fib[w-3]*f(h-1,w,k+1))
        elif k == w:
            return (fib[w-3]*f(h-1,w,k-1) + fib[w-2]*f(h-1,w,k))

if W == 1:
    answer = 1
else:
    answer = f(H,W,K) % 1000000007
print(answer)

### FIXED CODE ###

S = list(map(int,input().split()))
H = S[0]
W = S[1]
K = S[2]
fib = [1,2,3,5,8,13,21,0,1]
List = [1]
for x in range(0,W):
    List.append(0)

for x in range(0,H):
    X = tuple(List)
    for y in range(0,W):
        List[y] = fib[y-2]*fib[W-y-2]*X[y-1] + fib[y-1]*fib[W-y-2]*X[y] + fib[y-1]*fib[W-y-3]*X[y+1] 

ans = List[K-1] % 1000000007
print(ans)