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

from statistics import median
N = int(input())
X = list(map(int, input().split()))
for i in range(N): 
    Y = X[:i] + X[i+1:]
    print(median(Y))

### FIXED CODE ###

N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)
a = Y[N//2 - 1]
b = Y[N//2]
for i in range(N): 
    if X[i] <= a:
        print(b)
    else:
        print(a)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**5)
def GCD(a, b):
  a, b = max(a,b), min(a, b)
  if a%b == 0:
    return b
  else:
    return GCD(b, a%b)
N = int(input())
A = list(map(int, input().split()))
L = 1
for a in A:
  g = GCD(a, L)
  L = a*L//g
ans = 0
for a in A:
  ans += L//a
print(ans%(7+10**9))

### FIXED CODE ###

import fractions
N = int(input())
A = list(map(int, input().split()))
L = 1
for i in range(N):
  g = fractions.gcd(A[i], L)
  L = A[i]*L//g
ans = 0
for i in range(N):
  ans += L//A[i]
print(ans%(7+10**9))
### BUGGY CODE ###

# -*- coding: utf-8 -*-


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 sorted(divisors, reverse=True)


if __name__ == '__main__':
    n, k = map(int, input().split(' '))
    A = list(map(int, input().split(' ')))
    divisors = make_divisors(sum(A))
    for divisor in divisors:
        remainders = sorted(map(lambda x: x % divisor, A))
        for i in range(1, n):
            ope_num = max(sum(remainders[0:i]), sum(map(lambda x: divisor - x, remainders[i:n])))
            if ope_num <= k:
                print(divisor)
                exit()

### FIXED CODE ###

# -*- coding: utf-8 -*-


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 sorted(divisors, reverse=True)


if __name__ == '__main__':
    n, k = map(int, input().split(' '))
    A = list(map(int, input().split(' ')))
    divisors = make_divisors(sum(A))
    for divisor in divisors:
        remainders = sorted(map(lambda x: x % divisor, A))
        idx = n - sum(remainders) // divisor
        ope_num = sum(remainders[:idx])
        if ope_num <= k:
            print(divisor)
            break
### BUGGY CODE ###

from collections import deque

def main():
  h,w=map(int,input().split())
  mp=[input() for _ in range(h)]
  dist=[-1]*(h*w)
  q=deque()
  
  for i in range(h):
    for j in range(w):
      if mp[i][j]=="#":
        q.append(i*w+j)
        dist[i*w+j]=0
      else:
        dist[i*w+j]=-1
  #print(q)
 
  while q:
    c=q.popleft()
    #print(c,q)
    x=c//w
    y=c%w
    for i,j in ((1,0),(0,1),(-1,0),(0,-1)):
      xx,yy=x+i,y+j
      if (0<=xx<h and 0<=yy<w and dist[xx*w+yy]==-1):
        dist[xx*w+yy]=dist[x*w+y]+1
        q.append(xx*w+yy)
      
  print(max(dist))
  return

main()


### FIXED CODE ###

#copipe
#1次元で格納

def main():
    h,w = map(int,input().split())
    a = []
    for i in range(h):
        a.append(input())

    used = [True]*(h*w)

    p = []
    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                p.append(i*w+j)
                used[i*w+j] = False


    
    res = 0
    while p:
        tank = []
        for e in p:
            if e>w-1 and used[e-w]:
                tank.append(e-w)
                used[e-w] = False
            if e%w > 0 and used[e-1]:
                tank.append(e-1)
                used[e-1] = False
            if e<(h-1)*w and used[e+w]:
                tank.append(e+w)
                used[e+w] = False
            if e%w<w-1 and used[e+1]:
                tank.append(e+1)
                used[e+1] =  False
        p = tank
        res += 1
    print(res-1)

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

import numpy as np
N, K = map(int, input().split())
A = list(map(int, input().split()))
sumlist = [sum(A[j:j+N-i]) for i in range(N) for j in range(i+1)]
sumlist.sort(reverse=True)
sumlist = np.array(sumlist)
ans = sumlist[0]
for i in range(40, -1, -1):
    tmp = (ans & (2 ** i)) // (2 ** i)
    if tmp:
        start = i
        break
f = lambda x: (x & onehot) // onehot
ans_list = [0]
for i in range(start, -1, -1):
    onehot = 2 ** i
    tmp = list(map(f, sumlist))
    if sum(tmp) >= K:
        and_result = np.array(tmp).astype(np.bool)
        sumlist = sumlist[and_result]
        ans = sumlist[0]
        for j in range(1, K):
            ans = ans & sumlist[j]
        ans_list.append(ans)
print(max(ans_list))


### FIXED CODE ###

from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))
cusum = [A[0]]
for i in range(1, N):
    cusum += [cusum[-1]+A[i]]
B = []
for i in range(N):
    B += [cusum[i]]
    for j in range(i+1, N):
        B += [cusum[j] - cusum[i]]
max_bit = 43
ans = 0
while max_bit > 0:
    counter = Counter()
    for b in B:
        for i in range(44):
            if b & 1 == 1:
                counter[i] += 1
            b = b >> 1
    for i in range(max_bit, -1, -1):
        if counter[i] >= K:
            filter_bit = 2 ** i
            B = [b for b in B if b & filter_bit == filter_bit]
            max_bit = i-1
            ans += filter_bit
            break
        max_bit = i
print(ans)
### BUGGY CODE ###

import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())


from collections import deque

def main():
    N = II()
    a_mat = []
    for i in range(N):
        a_mat.append(deque(LI()))

    cnt = 0
    first_list = [a_list.popleft() for a_list in a_mat]
    nend = 0
    while True:
        # この日に試合できる可能性リスト
        # 試合する人リスト
        match_list = []
        for i, a in enumerate(first_list):
            ind = i+1
            # 試合をするペアの要素を入れていく
            if first_list[a-1] == ind:
                match_list.append(i)

        if len(match_list) == 0:
            print(-1)
            return

        # 試合をしたことを反映
        for i in match_list:
            if len(a_mat[i]) == 0:
                first_list[i] = 0
                nend += 1 # 終わった人
            else:
                first_list[i] = a_mat[i].popleft()

        # 一日経過
        cnt += 1

        # 終了判定
        if nend == N:
            break
        # if sum(first_list) == 0:
        #     break

    print(cnt)


main()

### FIXED CODE ###

import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())


from collections import deque

from copy import copy
#debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)
def main():
    N = II()
    a_mat = []
    for i in range(N):
        a_mat.append(deque(LI()))

    cnt = 0
    first_list = [a_list.popleft() for a_list in a_mat]
    nend = 0
    previous_match_list = list(range(N))
    while True:
        # この日に試合できる可能性リスト
        # 試合する人リスト
        match_list = []
        for i in previous_match_list:
            a_no = first_list[i]
            a = a_no-1
            no = i+1
            # 試合をするペアの要素を入れていく
            if first_list[a] == no:
                match_list.append(i)

        dprint(first_list, match_list)

        if len(match_list) == 0:
            print(-1)
            return

        previous_match_list = copy(match_list)

        # 試合をしたことを反映
        for i in match_list:
            if len(a_mat[i]) == 0:
                first_list[i] = 0
                nend += 1 # 終わった人
            else:
                next_no = a_mat[i].popleft()
                next = next_no - 1
                first_list[i] = next_no
                previous_match_list.append(next)

        previous_match_list = list(set(previous_match_list))

        dprint(match_list, previous_match_list)
        dprint("")
        # 一日経過
        cnt += 1

        # 終了判定
        if nend == N:
            break


    print(cnt)


main()
### BUGGY CODE ###

import math

N = int(input())

min_length = -1
for i in range(int(math.sqrt(N))):
    for j in range(i + 1):
        A = j + 1
        if N % A == 0:
            B = int(N / A)
            len_a = len(str(A))
            len_b = len(str(B))
            length = len_a if len_a >= len_b else len_b
            if min_length == -1 or length < min_length:
                # print("len:{}, A:{}, B:{}".format(length, A, B))
                min_length = length
print(min_length)


### FIXED CODE ###

import math

N = int(input())

min_length = -1
for A in range(1, int(math.sqrt(N)) + 1, 1):
    if N % A == 0:
        B = int(N / A)
        len_a = len(str(A))
        len_b = len(str(B))
        length = len_a if len_a >= len_b else len_b
        if min_length == -1 or length < min_length:
            # print("len:{}, A:{}, B:{}".format(length, A, B))
            min_length = length
print(min_length)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
INF = 10**18
sys.setrecursionlimit(10**6)
import itertools as it
import collections as cl
from collections import deque
import math
from functools import reduce
from collections import defaultdict
MOD = 998244353


def li():
    return [int(x) for x in input().split()]

N, K = li()

s = set()
for _ in range(K):
    a, b = li()
    for i in range(a, b+1):
        s.add(i)

# dp[i]: マスiに到達する方法の個数
dp = [0] * (N+1)
dp[0] = 1
for i in range(N):
    for j in range(1,N-i):
        if j in s:
            dp[i+j] += dp[i]
            dp[i+j] %= MOD
print(dp[N-1])



### FIXED CODE ###

import sys
input = sys.stdin.readline
INF = 10**18
sys.setrecursionlimit(10**6)
import itertools as it
import collections as cl
from collections import deque
import math
from functools import reduce
from collections import defaultdict
MOD = 998244353


def li():
    return [int(x) for x in input().split()]

N, K = li()

L, R = [], []
for _ in range(K):
    l, r = li()
    L.append(l)
    R.append(r)

# dp[i]: i番目のマスにいく場合の数
dp = [0] * (N+1)
dp[1] = 1
# 区間 [left, right)の和はdpsum[right] - dpsum[left]
# 区間 [left, right]の和はdpsum[right+1] - dpsum[left]
# マス a~bは区間だと[a-1,b-1]に対応。よってマスliからriの和はdpsum[right] - dpsum[left - 1]
dpsum = [0] * (N+1)
dpsum[1] = 1
for i in range(2, N+1):
    for j in range(K):
        li = max(i - R[j], 1)
        ri = i - L[j]
        if ri >= 0:
            dp[i] += dpsum[ri] - dpsum[li-1]
            dp[i] %= MOD
    dpsum[i] = dpsum[i-1] + dp[i]
    dpsum[i] %= MOD

print(dp[N])
### BUGGY CODE ###

N = int(input())
Alist = list(map(int,input().split()))
ans=[]
for i in range(N):
    if int(i+1) in Alist:
        a=i+1
        #ans.append(str(Alist.count(a))+"\n")
        ans.append(str(Alist.count(a)))
        #print(Alist.count(a))
    else:
        #print(0)
        #ans.append(str(0)+"\n")
        ans.append(str(0))

print(*ans,sep="\n")

### FIXED CODE ###


N = int(input())
Alist = list(map(int,input().split()))#iの上司

result = [0]*N

for i in range(N-1):#最後の社員に部下いない
    result[Alist[i]-1] +=1#上司の順番の要素に+1

for i in range(N):
    print(result[i])
### BUGGY CODE ###

n=int(input())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return len(lower_divisors + upper_divisors[::-1])
sumi=0
for i in range(1,n+1):
    sumi+=i*make_divisors(i)
print(sumi)

### FIXED CODE ###

n=int(input())
ans=0
for i in range(1,n+1):
  y=n//i
  ans+=y*(y+1)*i//2
print(ans)
### BUGGY CODE ###

a=int(input())
b=list(map(int,input().split()))
d=[]
d.append(0)
for i in range(a):
	d.append(b[i])
for i in range(1,a+1):
	sumx=0
	if(i==a):
		e=d[:i]
	else:
		e=d[:i]+d[i+1:]
	for j in range(1,len(e)):
		sumx+=abs(e[j]-e[j-1])
	sumx+=abs(e[-1]-0)
	print(sumx)

### FIXED CODE ###

a=int(input())
b=list(map(int,input().split()))
d=[]
d.append(0)
d=d+b
sumx=0
for i in range(1,a+1):
	sumx+=abs(d[i]-d[i-1])
for i in range(1,a):
	sumx1=sumx-abs(d[i]-d[i-1])-abs(d[i+1]-d[i])+abs(d[i+1]-d[i-1])
	sumx1+=abs(d[-1]-0)
	print(sumx1)
sumx1=sumx-abs(d[-1]-d[-2])+abs(d[-2]-0)
print(sumx1)
### BUGGY CODE ###

from collections import deque

N, M = map(int, input().split(" "))
A = list(map(int, input().split(" ")))
A_que = deque(A)

for i in range(M):
    B, C = map(int, input().split(" "))

    for j in range(B):
        A_que.append(C)

A = list(A_que)
A.sort(reverse=True)
print(sum(A[0:N]))

### FIXED CODE ###

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

A.sort()

D = []
for i in range(M):
    B, C = map(int, input().split(" "))
    D.append((C, B))

#D = list(D_dict)
D.sort(reverse=True)

D_index = 0
D_index_max = len(D)

ans = 0

ct_D_i = 0
ct_D_i_max = D[0][1]

ct_D_total = 0

for i in range(N):
    a = A[i]
    d = D[D_index][0]
    if a > d:
        break

    A[i] = d


    ct_D_i += 1
    if ct_D_i >= ct_D_i_max:
        D_index += 1
        if D_index >= D_index_max:
            break

        ct_D_i = 0
        ct_D_i_max = D[D_index][1]




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

n,p=map(int,input().split())
if n==1:
    print(p)
elif n>p:
    print(1)
else:
    d=int(p**(1/n))
    i=1
    k=1
    c=1
    while i<=d+2:
        if p%(i**n)==0:
            k=i
            c=i
            i+=c
        else:
            i+=c
    else:
        print(k)

### FIXED CODE ###

n,p=map(int,input().split())
if n==1:
    print(p)
else:
    def r(n,p):
        d=int(p**(1/n))
        k=1
        for i in range(1,d+1):
            if p%(i**n)==0:
                k=i
        return k
    c=1
    while r(n,p)!=1:
        s=r(n,p)
        c*=s
        p=p/(s**n)
    print(c)
### BUGGY CODE ###

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

dic = {}
for i in range(1, n+1):
    dic[i] = A[i-1]

L = [1]
tmp = 1
ct = 0
check = 0
while True:
    x = dic[tmp]
    ct += 1
    if x in L:
        check = x
        break
    else:
        L.append(x)
        tmp = x
p = L.index(check)
l = len(L)
roop = l - p
if k < p:
    print(L[k])
else:
    k -= p
    k %= roop
    print(L[p + k])

### FIXED CODE ###

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

visit = [-1] * n   #到達しているかどうかを管理

D = [1]  # 循環するもののindexを格納

tmp = A[0]  #初期位置
ct = 1

while visit[tmp - 1] == -1:
    D.append(tmp)
    visit[tmp - 1] = ct  #到達済に変更
    if k == ct:
        print(tmp)
        exit()
    ct += 1
    tmp = A[tmp - 1]

#循環している場合の残りの処理
k -= visit[tmp - 1]
k %= (ct - visit[tmp - 1])
print(D[visit[tmp - 1] + k])
### BUGGY CODE ###

n = int(input())
list_A = list(map(int, input().split()))
ans = []
for i in range(n):
    if i % 2 == 0:
        ans.append(list_A[i])
    else:
        ans.insert(0, list_A[i])

if n % 2 == 1:
    ans.reverse()
print(*ans)

### FIXED CODE ###

from collections import deque
n = int(input())
list_A = list(map(int, input().split()))
ans = deque([])
for i in range(n):
    if i % 2 == 0:
        ans.append(list_A[i])
    else:
        ans.appendleft(list_A[i])

if n % 2 == 1:
    ans.reverse()
print(*ans)
### BUGGY CODE ###

def main():
    n = int(input())
    
    queue = [i for i in range(1,10)]
    while True:
        if n == 1:
            print(queue.pop(0))
            break
        tmp = queue.pop(0)
        n -= 1
        if tmp%10 != 0:
            queue.append(tmp*10 + tmp%10 - 1)
        queue.append(tmp*10 + tmp%10)
        if tmp%10 != 9:
            queue.append(tmp*10 + tmp%10 + 1)
            
main()

### FIXED CODE ###

"""1, 2, 3, 4, 5, 6, 7, 8, 9, 
10, 11, 12, 21, 22, 23, 32, 33, 34, 43, 44, 45, 54, 55, 56, 65, 66, 67, 76, 77, 78, 87, 88, 89, 98, 99, 
100, 101, 110, 111, 112, 121, 122, 123, 210, 211, 212, 221, 222, 223, 232, 233, 234, 321, 322, 323, 33

1 -> 10,11,12 -> 100,101 ,110,111,112, 121,122,123

2 -> 21,22,23 -> 210,211,212, 221,222,223, 232,233,234"""
def main():
    n = int(input())
    
    queue = [i for i in range(1,10)]
    if n < 10:
        print(queue[n-1])
        return
    n -= 9
    while True:
        if n <= 0:
            print(queue[n-1])
            return
        tmp = queue.pop(0)
        if tmp%10 == 0:
            queue += [tmp*10 + tmp%10, tmp*10 + tmp%10 + 1]
            n -= 2
        elif tmp%10 == 9:
            queue += [tmp*10 + tmp%10 - 1, tmp*10 + tmp%10]
            n -= 2
        else:
            queue += [tmp*10 + tmp%10 - 1, tmp*10 + tmp%10, tmp*10 + tmp%10 + 1]
            n -= 3

main()
### BUGGY CODE ###

from bisect import bisect_right

N,K=list(map(int, input().split()))
A=list(map(int, input().split()))
A.sort()
S=set(A)
S=list(S)
B=[]

def bisectsearch_right(L, a):
    i = bisect_right(L, a)
    return(i)

for _ in S:
  a=A[0]
  j = bisect_right(A,a)
  B+=[j]
  del A[:j]
B.sort()
# print(B)
C=B[:len(S)-K]
print(sum(C))

### FIXED CODE ###

from collections import Counter

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

dic = dict(Counter(A))
ls = list(dic.items())
ls.sort(key=lambda x: x[1])

i=0
ans=0
res=len(ls)
while 1:
  if res <= K or i >= N:
    break
  ans += ls[i][1]
  i+=1
  res-=1
print(ans)
### BUGGY CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
for i in range(N):
    tmp = A.copy()
    tmp.pop(i)
    tmp.sort()
    print(tmp[-1])


### FIXED CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
As = sorted(A)
for i in range(N):
    if A[i] == As[-1]:
        print(As[-2])
    else:
        print(As[-1])
### BUGGY CODE ###

#https://atcoder.jp/contests/abc139/tasks/abc139_b

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

x = 0
i = 0
while True:
    x = a + (a-1)*i
    if x<b:
        i+=1

print(i)

### FIXED CODE ###

#https://atcoder.jp/contests/abc139/tasks/abc139_b

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

c = a-1
cnt=0
'''
cnt = b // c
if b%c>1:
    cnt+=1
print(cnt)
'''
'''
b-=a
cnt = 1
if b>0:
    while True:
        if b>0:
            b-=c
            cnt+=1
        else:
            break
'''
while True:
    if b>1:
        b-=c
        cnt+=1
    else:
        break
print(cnt)
### BUGGY CODE ###

n = int(input())
A = [int(s) for s in input().split()]
i = 0
flag = 0
count = 0
while i < len(A):
  
  
  if A[i] %2 == 0:
    flag = 0
    A[i] = A[i] /2
    count += 1
    i = 0
    
    continue
  else:
    flag += 1
    if flag == len(A):
      print(count)
      exit()
    i += 1
  

  
  
  
    


### FIXED CODE ###

import math
n = int(input())
A = [int(s) for s in input().split()]
i = 0
flag = 0
count = 0
sum = 0


def bynum(x):
  count = 0
  while True:
    if x % 2 == 0:
      x = x / 2
      count += 1
    else:
      return count

for a in A:
  sum += bynum(a)

print(sum)


    



"""
while i < len(A):
  if A[i] %2 == 0:
    flag = 0
    A[i] = A[i] /2
    count += 1
    i = 0
    
    continue
  else:
    flag += 1
    if flag == len(A):
      print(count)
      exit()
    i += 1
  """
### BUGGY CODE ###

import numpy as np
import math

global csA
MAXINT = 2 ** 63 - 1

def getsumanddiff(i, j, k):
    p = csA[j+1] - csA[i]
    q = csA[k+1] - csA[j+1]
    return p, q, abs(p - q)

def getfinaldiff(p, q, r, s):
    return max(p, q, r, s) - min(p, q, r, s)

# N = int(input())
# A = np.array(list(map(int, input().split())))
N = 100000000
A = np.arange(N, dtype=int)
csA = np.concatenate([[0], np.cumsum(A)]) # Cumulative sum

# init
mid0 = 0
mid2 = 2

p, q, r, s = [0]*4
diff = MAXINT

for mid1 in range(1, N - 2):
    diff0 = MAXINT
    diff2 = MAXINT

    # mid0 search
    for i in range(mid0, mid1):
        tmpp, tmpq, tmpdiff0 = getsumanddiff(0, i, mid1)
        if diff0 > tmpdiff0:
            mid0 = i
            diff0 = tmpdiff0
            p = tmpp
            q = tmpq
        else:
            break

    # mid2 search
    start = mid1 if mid2 < mid1 else mid2
    for i in range(start, N - 1):
        if mid1 >= i:
            continue
        tmpr, tmps, tmpdiff2 = getsumanddiff(mid1+1, i, N - 1)
        if diff2 > tmpdiff2:
            mid2 = i
            diff2 = tmpdiff2
            r = tmpr
            s = tmps
        else:
            break

    tmpdiff = getfinaldiff(p, q, r, s)
    if diff > tmpdiff:
        diff = tmpdiff

print(diff)


### FIXED CODE ###

import numpy as np
import math

global csA
MAXINT = 2 ** 63 - 1

def getsumanddiff(i, j, k):
    tmp = csA[j+1]
    p = tmp - csA[i]
    q = csA[k+1] - tmp
    return p, q, abs(p - q)

N = int(input())
# A = np.array(list(map(int, input().split())))
# csA = np.cumsum(A)

csA = [0] * (N+1)
for i, v in enumerate(input().split()):
    csA[i+1] = csA[i] + int(v)

# init
mid0 = 0
mid2 = 2

p, q, r, s = [0]*4
diff = MAXINT

csAN = csA[N]
for mid1 in range(1, N - 2):
    diff0 = MAXINT
    diff2 = MAXINT
    csAmid1 = csA[mid1+1]

    # mid0 search
    for i in range(mid0, mid1):
        # tmpp, tmpq, tmpdiff0 = getsumanddiff(0, i, mid1)
        tmpp = csA[i+1]
        tmpq = csAmid1 - tmpp
        tmpdiff0 = abs(tmpp - tmpq)
        if diff0 > tmpdiff0:
            mid0 = i
            diff0 = tmpdiff0
            p = tmpp
            q = tmpq
        else:
            break

    # mid2 search
    start = mid1 if mid2 < mid1 else mid2
    for i in range(start, N - 1):
        # tmpr, tmps, tmpdiff2 = getsumanddiff(mid1+1, i, N - 1)
        csAi = csA[i+1]
        tmpr = csAi - csAmid1
        tmps = csAN - csAi
        tmpdiff2 = abs(tmpr - tmps)
        if diff2 > tmpdiff2:
            mid2 = i
            diff2 = tmpdiff2
            r = tmpr
            s = tmps
        else:
            break

    tmpdiff = max(p, q, r, s) - min(p, q, r, s)
    if diff > tmpdiff:
        diff = tmpdiff

print(diff)
### BUGGY CODE ###

r,g,b,n = map(int,input().split())
count = 0
rr = n // r
gg = n // g
bb = n // b
for i in range(rr+1):
  for j in range(gg+1):
    if n >= i*r + j*g and (n - (i*r + j*g)) %  b == 0:
        count += 1
print(count)


### FIXED CODE ###

r,g,b,n = map(int,input().split())
count = 0
rr = n // r
for i in range(rr+1):
  for j in range((n-i*r)//g+1):
    tmp = n - (i*r + j*g)
    if tmp >= 0 and tmp %  b == 0:
        count += 1
print(count)
### BUGGY CODE ###

def reads(offset = 0):
	return [int(i) - offset for i in input().split(' ')]
(N, M) = reads()
Q = int(input())
A = reads(1)
pos = [-1] * M
pat = []
freq = [0] * (M+1)
freq[0] = N
counter = 0
for i in A[::-1]:
	if (i not in pat):
		pat.append(i)
		pos[i] = counter
		counter += 1
		if(counter == M):
			break
for i in range(M):
	if (pos[i] == -1):
		pat.append(i)	
for i in A[::-1]:
	temp = pos[i]
	if (freq[temp] > 0):
		freq[temp] -= 1
		freq[temp+1] += 1
for i in range(M):
	if (freq[i] != 0):
		start = i
		break
p = pat[start:]
p.sort()
if(p == pat[start:]):
	print("Yes")
else:
	print("No")

### FIXED CODE ###

def reads(offset = 0):
	return [int(i) - offset for i in input().split(' ')]
def Judge(vector):
	length = len(vector)-1
	for i in range(length):
		if(vector[i] > vector[i+1]):		
			return 0
	return 1
(N, M) = reads()
Q = int(input())
A = reads(1)
pos = [-1] * M
pat = []
freq = [0] * (M+1)
freq[0] = N
found = set()
counter = 0
for i in A[::-1]:
	if (i not in found):
		pat.append(i)
		found.add(i)
		pos[i] = counter
		counter += 1
		if(counter == M):
			break
for i in range(M):
	if (pos[i] == -1):
		pat.append(i)	
for i in A[::-1]:
	temp = pos[i]
	if (freq[temp] > 0):
		freq[temp] -= 1
		freq[temp+1] += 1
start = M
for i in range(M):
	if (freq[i] != 0):
		start = i
		break
print("Yes") if Judge(pat[start:]) else print("No")
### BUGGY CODE ###

N=int(input())

c=list(input())

def split(c,i):
    left=c[:i]
    right=c[i:]
    return left,right

minimum=len(c)

for i in range(0,len(c)+1):
    left,right=split(c,i)
    W=left.count('W')
    R=right.count('R')
    min_i=max(W,R)
    if min_i < minimum:
        minimum=min_i

print(minimum)

### FIXED CODE ###

N=int(input())

c=list(input())

minimum=len(c)
W=0
R=c.count('R')

for i in range(0,len(c)):
    if c[i]=='W':
        W += 1
    else :
        R -= 1
    min_i=max(W,R)
    if min_i < minimum:
        minimum=min_i

if c.count('R')==0:
    minimum=0

print(minimum)