Harryxun/stf_run huggingface dataset:
import numpy as np
N,M = map(int,input().split())
cards = list(map(int,input().split()))
exchange_lists=[]
for i in range (M):
  exchange_lists.append(list(map(int,input().split())))
exchange_lists.sort(key = itemgetter(1))
def exchange_cards(cards,exchange):
  cards.sort()
  count = 0
  for i in range(len(cards)):
    if (exchange[1] > cards[i])and(exchange[0] > count):
      cards[i] = exchange[1]
      count += 1
    else:
      break
  return cards
      
for i in range(M):
  cards = exchange_cards(cards,exchange_lists[i])
print(np.sum(cards))

### FIXED CODE ###

import numpy as np
N,M = map(int,input().split())
cards = list(map(int,input().split()))
exchange_lists=[]
for i in range (M):
  exchange_lists.append(list(map(int,input().split())))
exchange_lists.sort(key = lambda x:x[1],reverse=True)
cards.sort()
count = 0
for i in range(M):
  exchange=exchange_lists[i]
  num = 0
  for j in range(count,N):
    if (exchange[1] > cards[j])and(exchange[0] > num):
      cards[j] = exchange[1]
      count += 1
      num+=1
    else:
      break
  
print(np.sum(cards))
d,n = map(int,input().split())
s = n * (100**d)
s1 = 101 * (100**d)
if n <= 99:
  print(s)
elif n = 100:
  print(s1)

### FIXED CODE ###

d,n = map(int,input().split())
s = n * (100**d)
s1 = 101 * (100**d)
if n <= 99:
  print(s)
else:
  print(s1)
S = input()
if S.count(7):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

S = input()
if S.count('7'):
    print("Yes")
else:
    print("No")
#!/usr/bin/env python3
import sys
from math import factorial



MOD = 1000000007  # type: int


def cmb(n, r, p):
    return (factorial(n) // (factorial(r) * factorial(n - r))%p)

def solve(N: int, K: int):
    c = N-K

    for i in range(K):
        # i+1回の操作でとるために両端を除くセパレータの数はi個
        b = cmb(K-1, i, MOD)
        # 両端を含めたセパレータの数はi+2個
        # セパレータには最低1つ配属するので，配置する赤玉の数はN-K-i個
        # この赤玉をi+2個のセパレータに配属させる
        # i+2 H c-i
        if c-i+1<0:
            print(0)
        else:
            k = cmb(c+1, c-i, MOD)
        print(b*k%MOD)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from math import factorial
MOD = 1000000007  # type: int

def cmb(n, r, p):
    return (factorial(n) // (factorial(r) * factorial(n - r))%p)

def solve(N: int, K: int):
    c = N-K

    for i in range(K):
        # i+1回の操作でとるために両端を除くセパレータの数はi個
        # 両端を含めたセパレータの数はi+2個
        # セパレータには最低1つ配属するので，配置する赤玉の数はN-K-i個
        # この赤玉をi+2個のセパレータに配属させる
        # i+2 H c-i
        if c-i<0:
            print(0)
        else:
            b = cmb(K-1, i, MOD)
            k = cmb(c+1, c-i, MOD)
            print(b*k%MOD)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()
b = int(input())

if b == "A":
	print("T")
elif b == "C":
	print("G")
elif b == "G":
	print("C")
else:
	print("A")


### FIXED CODE ###

b = input()

if b == "A":
	print("T")
elif b == "C":
	print("G")
elif b == "G":
	print("C")
else:
	print("A")
n = int(input())
x = list(map(int,input().split()))
Min,Max = min(x),max(x)
s = [0] * (Max - Min)
k = 0

for i in range(Min,Max):
    for j in x:
        s[k] += (j - i) ** 2
    k += 1
print(min(s)) 

### FIXED CODE ###

n = int(input())
x = list(map(int,input().split()))
Min,Max = min(x),max(x)
if Min == Max:
    print(0)
    exit()
s = [0] * (Max - Min)
k = 0

for i in range(Min,Max):
    for j in x:
        s[k] += (j - i) ** 2
    k += 1
print(min(s))
n=int(input())
absn=abs(n)
sign=[1,-1]

b,cnt=1,0
while b<absn*2:
    b*=2
    cnt+=1
ans=[]
while cnt >= 0:
    sub=n-b*sign[cnt%2]
    if abs(sub)<abs(b) or abs(sub)<=abs(n):
        ans.append("1")
        n=sub
    else:
        ans.append("0")
    b//=2
    cnt-=1
for i in range(3):
    if ans[i]=="1":break
print("".join(ans[i::]))



### FIXED CODE ###

n=int(input())
ans=[]
if n%2==1:
    ans.append("1")
    n-=1
else:ans.append("0")
n//=2
while n!=0:
    ans.append("1") if n%2==1 else ans.append("0")
    n//=-2
print("".join(ans[::-1]))
import sys

N = int(input())
ls = list(map(int, input().split()))
k = len(ls)
p = [ i for i in ls if (i%4) == 0]
j = [ i for i in ls if (i%4) != 0]
r = [ i for i in j if (i%2) == 0]

if(len(p) >= int(k/2)):
    print('Yes')
elif (len(p) >= (len(j) - len(r))):
    print('Yes')
else:
    print('No')
----

### FIXED CODE ###

import sys

N = int(input())
ls = list(map(int, input().split()))
k = len(ls)
p = [ i for i in ls if (i%4) == 0]
j = [ i for i in ls if (i%4) != 0]
r = [ i for i in j if (i%2) == 0]

if(len(p) >= int(k/2)):
    print('Yes')
elif (len(p) >= (len(j) - len(r))):
    print('Yes')
else:
    print('No')
top=0
sum=0
def sort(a,n)
    for i in range(n):
        sum=sum+a[i-1]
        if a[i-1]<a[i] or i==1:
            top=a[n-1]
asp=0
def am(m):
    asp=1-(1/(4*m))
    if top>sum*asp:
        print("No")
    else:
        print("Yes")

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

sort(a,n)
am(m)

### FIXED CODE ###

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

new_a=sorted(a,reverse=True)
sums=sum(a)

if new_a[m-1]>=sums/(m*4):
    print("Yes")
else:
    print("No")
n , m = map(int, input().split(' '))
s = [0,2,5,5,4,5,6,3,7,6]
a = list(map(int, input().split(' ')))
a.sort()
d = [0]
for i in range(n):
    d.append(-1)
#i 本　マッチを使う
for i in range(n+1):
    j = 0
    while j < len(a):
        if d[i-s[a[j]]] >= 0:
            d[i] = d[i-s[a[j]]] +1
            break
        else:
            j+= 1
result = []
a.sort(reverse = True)
while n > 0:
    j = 0
    while j < len(a):
        if d[n-s[a[j]]] +1 == d[n]:
            result.append(a[j])
            n -= s[a[j]]
        else:
            j += 1        
print(''.join(list(map(str, result))))

### FIXED CODE ###

n , m = map(int, input().split(' '))
s = [0,2,5,5,4,5,6,3,7,6]
a = list(map(int, input().split(' ')))
r = []
for i in range(len(a)):
    r.append([s[a[i]],a[i]])
r.sort()
d = [-1]*(n+1)
d[0] = 0
for i in range(1,n+1):
    j = 0
    while j < len(a):
        if i-s[r[j][1]] < 0:
            j += 1
        elif d[i-s[r[j][1]]] >= 0:
            d[i] = d[i-s[r[j][1]]] +1
            break
        else:
            j+= 1
result = []
a.sort(reverse = True)
while n > 0:
    j = 0
    while j < len(a):
        if n < s[a[j]]:
            j += 1
        elif d[n-s[a[j]]] +1 == d[n]:
            result.append(a[j])
            n -= s[a[j]]
            break
        else:
            j += 1
print(''.join(list(map(str, result))))
n, m = map(int, input().split()) 
ab = []
for i in range(n):
  a, b = map(int, input().split()) 
  ab.append([a,b])

cd = []  
for i in range(n):
  c, d = map(int, input().split()) 
  cd.append([c,d])

d = {}
for i in range(len(ab)):
  for j in range(len(cd)):
    d[j+1] = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
  print(min(d, key=d.get))

### FIXED CODE ###

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

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

for a, b in ab:
  distance = [abs(a-c) + abs(b-d) for c,d in cd]
  print(distance.index(min(distance))+1)
a,b=map(int,input().split())
if a==b:print(2*c)
else:print(max(a,b)+max(a-1,b-1))


### FIXED CODE ###

a,b=map(int,input().split())
if a==b:print(2*a)
else:print(max(a,b)+max(a-1,b-1))
S = list(input())
X = []
NX = ""

for i in range(len(S)):
    if S[i] == "x": X.append(i)
    else: NX += S[i]
    
NXr = ""
for i in reversed(range(len(NX))): NXr += NX[i]

if NXr != NX: print(-1)
else:
    mid = S.index(NX[(len(NX) - 1)//2])
    Xleft, Xright = set(), set()
    for x in X:
        if x < mid: Xleft |= {mid-x}
        else: Xright |= {x-mid}
    print(len(Xleft ^ Xright))

### FIXED CODE ###

S = list(input())
X, A = [], []
NX = ""

for i in range(len(S)):
    if S[i] == "x": X.append(i)
    else: 
        NX += S[i]
        A.append(i)
    
for i in range(len(NX)//2):
    if NX[i] != NX[-1-i]:
        print(-1)
        break
else:
    if NX == "": print(0)
    else:
        l, r = 0, len(S)-1
        midl = A[(len(NX)-1)//2]
        midr = (A[(len(NX)-1)//2] if len(NX)%2==1 else A[(len(NX)-1)//2 + 1])
        Add = 0
        while l < midl or r > midr:
            if S[l] == S[r] == "x":
                l += 1
                r -= 1
            elif S[l] == "x":
                l += 1
                Add += 1
            elif S[r] == "x":
                r -= 1
                Add += 1
            else:
                l += 1
                r -= 1
        print(Add)
X,N = map(int, input().split())
p = list(map(int, input().split()))
p = sorted(p)
lista = list(range(101))
for i in p:
    if i in lista:
        lista.remove(i)
def binary_search_find_closest(data, target):
    if len(data) == 0:
        return None
    if len(data) == 1:
        return data[0]
    min_diff = float('inf')
    imin = 0
    imax = len(data) - 1
    closest_num = None
    while imin <= imax:
        imid = imin + (imax - imin) // 2
        #　中心の左右の値と目標との差を計算する。
        if imid + 1 < len(data):
            min_diff_right = abs(data[imid+1] - target)
        if imid > 0:
            min_diff_left = abs(data[imid-1] - target)
        # 最初の差と最も最小に近い値を更新する。
        if min_diff_left < min_diff:
            min_diff = min_diff_left
            closest_num = data[imid-1]
        if min_diff_right < min_diff:
            min_diff = min_diff_right
            closest_num = data[imid+1]
        # 2分探索する。
        if data[imid] < target:
            imin = imid + 1
        elif data[imid] > target:
            imax = imid -1
        else:
            return data[imid]
    return closest_num
binary_search_find_closest(lista,X)

### FIXED CODE ###

import numpy as np
X,N = map(int, input().split())
p = list(map(int, input().split()))
p = sorted(p)
lista = list(range(-100,200))
for i in p:
    if i in lista:
        lista.remove(i)
def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """
    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    print(list[idx])
if N == 0:
    print(X)
else:
    getNearestValue(lista, X)
n=int(input())
d=dict()

for i in range(n):
  a=input()
  d.setdefault(s,0)
  d[s] += 1

mx=0
result=[]
for key,value in d.items:
  if mx < value:
    mx = value
    result=[key]
  elif mx == value:
    result.append(key)

result.sort()

for i in range(len(result)):
  print(i)

### FIXED CODE ###

n=int(input())
d=dict()

for i in range(n):
  a=input()
  d.setdefault(a,0)
  d[a] += 1

mx=0
result=[]
for key,value in d.items():
  if mx < value:
    mx = value
    result=[key]
  elif mx == value:
    result.append(key)

result.sort()

for i in range(len(result)):
  print(result[i])
N = int(input())
D = [int(d) for d in input().split()]

D.sort()
mod = 998244353

if D[0] == 0:
    if N == 1:
        ans = 1
    elif D[1] == 1:
        cnt = 0
        num = 1
        ans = 1
        for i in range(1, N):
            if D[i] == num:
                cnt += 1
            elif num == 1:
                prev = cnt
                cnt = 1
                num += 1
            elif D[i] == num+1:
                ans *= prev**cnt
                ans %= mod
                prev = cnt
                cnt = 1
                num += 1
            else:
                ans = 0
                break
        if cnt > 0:
            ans *= prev**cnt
            ans %= mod
    else:
        ans = 0
else:
    ans = 0
    
print(ans)

### FIXED CODE ###

N = int(input())
D = [int(d) for d in input().split()]

f = 0
if D[0] != 0:
    f = -1
mod = 998244353
L = []

num = 0
cnt = 0
D.sort()
for i in range(N):
    if D[i] == num:
        cnt += 1
    elif D[i] == num+1:
        L.append(cnt)
        cnt = 1
        num += 1
    else:
        f = -1
        break
        
L.append(cnt)
ans = 1
if f == 0:
    if D[0] != 0:
        ans = 0
    if N > 1:
        if D[1] != 1:
            ans = 0
    if ans > 0:
        for i in range(1, len(L)):
            ans *= L[i-1]**L[i]
            ans %= mod
else:
    ans = 0
    
print(ans)
N = int(input())
S = input()
Q = int(input())
K = [int(i) for i in input().split()]

for k in K:
    ans = 0

    d = m = dm = 0
    for i, si in enumerate(S):
        if 0 <= i - K:
            if S[i - K] == "D":
                d -= 1
                dm -= m
            elif S[i - K] == "M":
                m -= 1

        if si == "D":
            d += 1
        elif si == "M":
            m += 1
            dm += d
        elif si == "C":
            ans += dm

    print(ans)

### FIXED CODE ###

N = int(input())
S = input()
Q = int(input())
K = [int(i) for i in input().split()]

for k in K:
    ans = 0

    d = m = dm = 0
    for i, si in enumerate(S):
        if 0 <= i - k:
            if S[i - k] == "D":
                d -= 1
                dm -= m
            elif S[i - k] == "M":
                m -= 1

        if si == "D":
            d += 1
        elif si == "M":
            m += 1
            dm += d
        elif si == "C":
            ans += dm

    print(ans)
a,b = input().split(' ')

if b%a == 0 :
  print(b+a)
else :
  print(b -a)

### FIXED CODE ###

a,b = map(int, input().split(' '))
 
if b%a == 0 :
  print(b+a)
else :
  print(b -a)
n=int(input())
h=[int(x) for x in input().split()]

ans_list=[]

def A(i,n,h,ans_list):
    ans=0
    for j in range(i,n-1):
        if h[j]>=h[j+1]:
            ans+=1
            if j==n-2:
                ans_list.append(ans)
                break
        else:
            ans_list.append(ans)
            A(j+1,n,h,ans_list)
            break
        
if n==1:
    print(0)
else:
    A(0,n,h,ans_list)
    print(max(ans_list))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
n=int(input())
h=[int(x) for x in input().split()]

ans_list=[]

def A(i,n,h,ans_list):
    ans=0
    for j in range(i,n-1):
        if h[j]>=h[j+1]:
            ans+=1
            if j==n-2:
                ans_list.append(ans)
                break
        else:
            ans_list.append(ans)
            A(j+1,n,h,ans_list)
            break
        
if n==1:
    print(0)
else:
    A(0,n,h,ans_list)
    print(max(ans_list))
N = int(input())
A = list(map(int, input().split))
# N = 9
# A = [1, 2, 1, 2, 1, 2, 1, 2, 1]
# N = 7
# A = [1, 2, 3, 2, 1, 999999999, 1000000000]
# N = 6
# A = [1, 2, 3, 2, 2, 1]
# N = 2
# A = [1, 1]
A = A + [A[-1]]

d = 0
i = 0

inc = None
while i < N:
    if inc is None:
        if A[i] < A[i + 1]:
            inc = True
            d += 1
        elif A[i] > A[i + 1]:
            inc = False
            d += 1
        else:
            inc = None
    else:
        if inc:
            if A[i] > A[i + 1]:
                inc = None
        else:
            if A[i] < A[i + 1]:
                inc = None
    i += 1

if inc is None:
    d += 1
print(d)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
# N = 9
# A = [1, 2, 1, 2, 1, 2, 1, 2, 1]
# N = 7
# A = [1, 2, 3, 2, 1, 999999999, 1000000000]
# N = 6
# A = [1, 2, 3, 2, 2, 1]
# N = 2
# A = [1, 1]
A = A + [A[-1]]

d = 0
i = 0

inc = None
while i < N:
    if inc is None:
        if A[i] < A[i + 1]:
            inc = True
            d += 1
        elif A[i] > A[i + 1]:
            inc = False
            d += 1
        else:
            inc = None
    else:
        if inc:
            if A[i] > A[i + 1]:
                inc = None
        else:
            if A[i] < A[i + 1]:
                inc = None
    i += 1

if inc is None:
    d += 1
print(d)
import sys, math
from functools import lru_cache
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

# unionfind
class Uf:
    def __init__(self, N):
        self.p = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def root(self, x):
        if self.p[x] != x:
            self.p[x] = self.root(self.p[x])

        return self.p[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        u = self.root(x)
        v = self.root(y)

        if u == v: return

        if self.rank[u] < self.rank[v]:
            self.p[u] = v
            self.size[v] += self.size[u]
            self.size[u] = 0
        else:
            self.p[v] = u
            self.size[u] += self.size[v]
            self.size[v] = 0

            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1

    def count(self, x):
        return self.size[self.root(x)]

def main():
    N, M = mi()
    A, B = i2(M)
    if M == 0:
        print(1)
        return

    uf = Uf(N)
    for i in range(M):
        uf.unite(A[i]-1, B[i]-1)

    print(max(uf.count(i) for i in range(N)))
    


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys, math
from functools import lru_cache
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

# unionfind
class Uf:
    def __init__(self, N):
        self.p = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def root(self, x):
        if self.p[x] != x:
            self.p[x] = self.root(self.p[x])

        return self.p[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        u = self.root(x)
        v = self.root(y)

        if u == v: return

        if self.rank[u] < self.rank[v]:
            self.p[u] = v
            self.size[v] += self.size[u]
            self.size[u] = 0
        else:
            self.p[v] = u
            self.size[u] += self.size[v]
            self.size[v] = 0

            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1

    def count(self, x):
        return self.size[self.root(x)]

def main():
    N, M = mi()

    if M == 0:
        print(1)
        return
        
    A, B = i2(M)

    uf = Uf(N)
    for i in range(M):
        uf.unite(A[i]-1, B[i]-1)

    print(max(uf.count(i) for i in range(N)))
    


if __name__ == '__main__':
    main()
n = input()
lst = [int(x) for x in input().split()].sort()
alice = 0
bob = 0
while len(lst)>0:
    alice += lst.pop(0)
    bob += lst.pop(0)
print(alice-bob)

### FIXED CODE ###

n = input()
lst = sorted([int(x) for x in input().split()], reverse=True)
alice = 0
bob = 0
for i in range(len(lst)):
    if i%2:
        bob += lst[i]
    else:
        alice += lst[i]
print(alice-bob)
str1 =str(input())
s1 = str1.split(' ')
m = int(s1[0])
n = int(s1[1])
x = (m*(m-1))/2
y = (n*(n-1))/2
print(int((x+y))

### FIXED CODE ###

str1 =str(input())
s1 = str1.split(' ')
m = int(s1[0])
n = int(s1[1])
x = (m*(m-1))/2
y = (n*(n-1))/2
print(int(x+y))
def main():
    import heapq
    import sys
    import numpy as np
    from scipy.sparse import csr_matrix
    from scipy.sparse.csgraph import shortest_path

    input = sys.stdin.readline

    MAX  = 10 ** 15

    N, M, s, t = map(int, input().split())

    edge = np.array([input().split() for _ in range(M)], dtype = np.int64).T
    g1 = csr_matrix((edge[2], (edge[:2] - 1)), (N, N))
    g2 = csr_matrix((edge[3], (edge[:2] - 1)), (N, N))

    d1 = shortest_path(g1, directed = False, indices = s - 1, method = 'auto')
    d2 = shortest_path(g2, directed = False, indices = t - 1, method = 'auto')

    d = d1 + d2

    # print (d1)
    # print (d2)

    # print (g1)
    # print (g2)

    # print (edge)

    tmp = MAX
    ans = [MAX] * N
    for i in range(N - 1, -1, -1):
        tmp = min(tmp, d[i])
        ans[i] -= int(tmp)

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

if __name__ == "__main__":
    main()



### FIXED CODE ###

import heapq
import sys
input = sys.stdin.readline

MAX  = 10 ** 15

N, M, s, t = map(int, input().split())

g1 = [[] for _ in range(N + 1)]
g2 = [[] for _ in range(N + 1)]
for _ in range(M):
    u, v, a, b = map(int, input().split())
    
    g1[u].append((a, v))
    g1[v].append((a, u))
    
    g2[u].append((b, v))
    g2[v].append((b, u))

d1 = [MAX] * (N + 1)
d2 = [MAX] * (N + 1)

d1[s] = 0 #始点の距離を0にする
pque = []
heapq.heappush(pque, [0, s]) #要素を[距離、頂点]として管理　最初の位置を入れる

while len(pque) != 0: #queの中に要素が残っている時
    p = heapq.heappop(pque) #最も距離が短いものを取り出す
    v = p[1] #距離が最も短い頂点
    if d1[v] < p[0]: #取り出した値より既に小さい値がdに入っているときは無視して次へ
        continue
    for i in range(len(g1[v])): #頂点vの隣接リストを走査
        e = g1[v][i]
        if d1[e[1]] > d1[v] + e[0]: #距離が更新できるかを検討
            d1[e[1]] = d1[v] + e[0]
            heapq.heappush(pque, [d1[e[1]], e[1]]) #更新できた場合、その値をpqueに入れる

# print (d1)

d2[t] = 0 #始点の距離を0にする
pque = []
heapq.heappush(pque, [0, t]) #要素を[距離、頂点]として管理　最初の位置を入れる

while len(pque) != 0: #queの中に要素が残っている時
    p = heapq.heappop(pque) #最も距離が短いものを取り出す
    v = p[1] #距離が最も短い頂点
    if d2[v] < p[0]: #取り出した値より既に小さい値がdに入っているときは無視して次へ
        continue
    for i in range(len(g2[v])): #頂点vの隣接リストを走査
        e = g2[v][i]
        if d2[e[1]] > d2[v] + e[0]: #距離が更新できるかを検討
            d2[e[1]] = d2[v] + e[0]
            heapq.heappush(pque, [d2[e[1]], e[1]]) #更新できた場合、その値をpqueに入れる

# print (d2)

tmp = MAX
ans = [MAX] * N
for i in range(N, 0, -1):
    tmp = min(tmp, d1[i] + d2[i])
    ans[i - 1] -= tmp

print (*ans, sep = '\n')
a,b = int(input()).split
print(a*b," "a*2+b*2) 

### FIXED CODE ###

list=input().split()
x=int(list[0])
y=int(list[1])
print (x*y,(x*2)+(y*2))
a=int(input())
if a=25:
  print('Christmas')
elif a=24:
  print('Christmas Eve')
elif a=23:
  print('Christmas Eve Eve')
elif a=22:
  print('Christmas Eve Eve Eve')



### FIXED CODE ###

a=int(input())
if a==25:
  print('Christmas')
elif a==24:
  print('Christmas Eve')
elif a==23:
  print('Christmas Eve Eve')
elif a==22:
  print('Christmas Eve Eve Eve')
# coding: utf-8
import math


N = int(input())
Xi = list(map(int, input().split()))
Xi.sort()
min = Xi[0]
max = Xi[N-1]
tmp = 0
result = math.inf
for i in range(min,max+1):
    for j in range(0,N):
        tmp += (Xi[j] - i)**2
    if tmp <= result:
        result = tmp
    tmp = 0

print(result)

### FIXED CODE ###

# coding: utf-8
import sys

N = int(input())
Xi = list(map(int, input().split()))
Xi.sort()
min = Xi[0]
max = Xi[N-1]
tmp = 0
result = sys.maxsize
for i in range(min,max+1):
    for j in range(0,N):
        tmp += (Xi[j] - i)**2
    if tmp <= result:
        result = tmp
    tmp = 0

print(result)
n=int(input())
a,b=map(int, input().split())
p=list(map(int, input().split())
c=[0,0,0]
for i in p:
       if i <=a:
        c[0] +=1
       elif i>b:
        c[2] +=1
       else:
        c[1]+=1
print(min(c))

### FIXED CODE ###

n = int(input())
a,b = map(int,input().split())
l = list(map(int,input().split()))
c = [0]*3
for i in l:
    if i <= a:
        c[0] += 1
    elif i > b:
        c[2] += 1
    else:
        c[1] += 1
print(min(c))