Harryxun/stf_run huggingface dataset:
import numpy as np
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
s=1
c=0
l=0
r=-1
while True:
    if k-c>=2:
        if a[r]*a[r-1]>=a[l]*a[l+1]:
            s*=a[r]*a[r-1]
            r-=2
            c+=2
        else:
            s*=a[l]*a[l+1]
            l+=2
            c+=2
    else:
        if a[r]<0:
            s=1
            a=np.abs(a)
            a=list(a)
            a.sort()
            while True:
                s*=a[c1]
                c1+=1
                s%=10**9+7
                if c1==k:
                    s=-s
                    print(s%10**9+7)
                    exit()
        else:s*=a[r]
        c+=1
    s%=10**9+7
    if k==c:break
print(s)

### FIXED CODE ###

import numpy as np
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
s=1
c=0
l=0
r=-1
c1=0
while True:
    if k-c>=2:
        if a[r]*a[r-1]>a[l]*a[l+1]:
            s*=a[r]*a[r-1]
            r-=2
            c+=2
        else:
            s*=a[l]*a[l+1]
            l+=2
            c+=2
    else:
        if a[r]<0:
            s=1
            a=np.absolute(a)
            a=list(a)
            a.sort()
            while True:
                s*=a[c1]
                c1+=1
                s%=10**9+7
                if c1==k:
                    s=-s
                    print(s%10**9+7)
                    exit()
        else:s*=a[r]
        c+=1
    s%=10**9+7
    if k==c:break
print(s)
N = int(input())
K = int(input())
h = list(map(int, input().split()))
 
num =0
for i in range(N):
    if h[i]>K or h[i] == K:
        num =num+ 1
print(num)

### FIXED CODE ###

N,K = map(int, input().split())
h = list(map(int, input().split()))
 
num =0
for i in range(N):
    if h[i]>K or h[i] == K:
        num =num+ 1
print(num)
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
from bisect import bisect_left
from collections import deque
#======================================================#
def main():
    N = II()
    cc = list(IS())
    cc_rev = cc[::-1]
    cnt = 0
    indexs = []
    for i, c in enumerate(cc):
        if c == 'W':
            indexs.append(i)
    indexs = deque(indexs)
    if cc.count('W') == 0:
        print(0)
        return 0
    for i, c in enumerate(cc_rev):
        if c == 'R':
            idx = indexs.popleft()
            if i >= idx:
                cc[idx] = 'R'
                cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
from bisect import bisect_left
from collections import deque
#======================================================#
def main():
    n = II()
    cc = list(IS())
    cc_rev = cc[::-1]
    cnt = 0
    indexs = []
    for i, c in enumerate(cc):
        if c == 'W':
            indexs.append(i)
    indexs = deque(indexs)
    if cc.count('W') == 0:
        print(0)
        return 0
    # print(indexs)
    for i, c in enumerate(cc_rev):
        if c == 'R':
            if indexs:
                idx = indexs.popleft()
                if idx < (n-i-1):
                    cc[idx] = 'R'
                    cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()
sd=list(input())
t=list(input())

sd=list(sts)
t=list(ts)

for i in range(len(sd)-len(t)+1):
    ii=len(sd)-len(t)-i
    yn=""
    for j in range(len(t)):
        if sd[ii+j]!=t[j] and sd[ii+j]!="?":
            yn="NG"
            break
    if yn=="NG":
        continue
    else:
        yn="yes"
        break
    
if yn=="NG": 
    print("UNRESTORABLE")
#elif yn=="": 
#    print("UNRESTORABLE")
#elif yn=="yes":
else:
    s=sd.copy()
    for j in range(len(t)):
        s[ii+j]=t[j]
    for j in range(len(s)):
        if s[j]=="?":
           s[j]="a"
    strt="".join(s)
    print(strt)

### FIXED CODE ###

sd=list(input())
t=list(input())

yn=""
for i in range(len(sd)-len(t)+1):
    ii=len(sd)-len(t)-i
    yn=""
    for j in range(len(t)):
        if sd[ii+j]!=t[j] and sd[ii+j]!="?":
            yn="NG"
            break
    if yn=="NG":
        continue
    else:
        yn="yes"
        break
    
if yn=="NG" or yn=="": 
    print("UNRESTORABLE")
else:
    for j in range(len(t)):
        sd[ii+j]=t[j]
    for j in range(len(sd)):
        if sd[j]=="?":
           sd[j]="a"
    strt="".join(sd)
    print(strt)
import sys
from heapq import *

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))

countA = [0] * (N + 1)
countB = [0] * (N + 1)
for x in A:
    countA[x] += 1
for x in B:
    countB[x] += 1

q = []
only_A = []
only_B = []
for i in range(N + 1):
    if countA[i] and countB[i]:
        q.append((-countA[i] - countB[i], i))
        continue
    if countA[i]:
        for _ in range(countA[i]):
            only_A.append(i)
    elif countB[i]:
        for _ in range(countB[i]):
            only_B.append(i)
heapify(q)

if q and -q[0][0] > N:
    print('No')
    exit()
print('Yes')

ans = []
while q:
    _, x = heappop(q)
    if q:
        _, y = heappop(q)
        flag = True
    else:
        y = only_B.pop()
        flag = False
    countA[x] -= 1
    countB[y] -= 1
    ans.append((x, y))
    if countA[x]:
        heappush(q, (-countA[x] - countB[x], x))
    else:
        for _ in range(countB[x]):
            only_B.append(x)
    if countB[y]:
        heappush(q, (-countA[y] - countB[y], y))
    if flag and not countB[y]:
        for _ in range(countA[y]):
            only_A.append(y)
while only_A:
    x, y = only_A.pop(), only_B.pop()
    ans.append((x, y))

X, Y = zip(*ans)
print(*Y)

### FIXED CODE ###

import sys
from heapq import *

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))

countA = [0] * (N + 1)
countB = [0] * (N + 1)
for x in A:
    countA[x] += 1
for x in B:
    countB[x] += 1

q = []
only_A = []
only_B = []
for i in range(N + 1):
    if countA[i] and countB[i]:
        q.append((-countA[i] - countB[i], i))
        continue
    for _ in range(countA[i]):
        only_A.append(i)
    for _ in range(countB[i]):
        only_B.append(i)
heapify(q)

if q and -q[0][0] > N:
    print('No')
    exit()
print('Yes')

ans = []
while q:
    _, x = heappop(q)
    if q:
        _, y = heappop(q)
        flag = True
    else:
        y = only_B.pop()
        flag = False
    countA[x] -= 1
    countB[y] -= 1
    ans.append((x, y))
    if countA[x]:
        heappush(q, (-countA[x] - countB[x], x))
    else:
        for _ in range(countB[x]):
            only_B.append(x)
    if flag and countB[y]:
        heappush(q, (-countA[y] - countB[y], y))
    if flag and not countB[y]:
        for _ in range(countA[y]):
            only_A.append(y)
while only_A:
    x, y = only_A.pop(), only_B.pop()
    assert countA[x] > 0
    assert countB[y] > 0
    countA[x] -= 1
    countB[y] -= 1
    ans.append((x, y))

ans.sort()
X, Y = zip(*ans)
print(*Y)
a=int(input("Enter the height a in meters="))
b=int(input("Enter the height b in meters="))
c=int(input("Enter the height c in meters="))
if(1<=a and 1<=b and 1<=c and a<=100 and b<=100 and c<=100):
    if(b-a==c-b):
        print("Yes")
    elif(c-b==b-a):
        print("Yes")
    else:
        print("NO")

### FIXED CODE ###

a,b,c=input().split()

a=int(a)
b=int(b)
c=int(c)

if b-a==c-b:
    print("YES")
else:
    print("NO")
from math import gcd

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

if N == 1:
    print(1)
    exit()

def saisho_ko_baisu(A,B):
    return A*B // gcd(A,B)
#     # A < B
#     x = A*B
#     r = B%A
#     while r!=0:
#         B = A
#         A = r
#         r = B%A
#     return x//A

A.sort(reverse = True)
tmp = saisho_ko_baisu(A[0], A[1])
res = tmp//A[0] + tmp//A[1]
for i in range(2,N):
    if tmp % A[i] != 0:
        new = saisho_ko_baisu(A[i], tmp)
        res *= new//tmp
        tmp = new
    res += tmp // A[i]

print(res % (10**9 + 7))


### FIXED CODE ###

from fractions import gcd

def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

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

div = 10**9 + 7
lcm_num = lcm(a)
ans = [lcm_num//ai for ai in a]

print(sum(ans)%div)
#!/usr/bin/env python3
from collections import Counter

from scipy.special import comb

_, *a = map(int, open(0).read().split())
c = Counter(a)
s = sum(comb(i, 2, exact=True) for i in c.values())
for i in a:
    print(s - c[i] + 1)


### FIXED CODE ###

#!/usr/bin/env python3
from collections import Counter

from scipy.special import comb

_, *a = map(int, open(0).read().split())
c = Counter(a)
s = sum(comb(i, 2, exact=True) for i in c.values())
for i in a:
    print(s - c[i] + 1)
mo=10**9+7
n,m=map(int,input().split())
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]
X,Y=0,0
for i in range(n):
    X+=x[i]*(n-2*i-1)
    X%=mo
for i in range(n):
    Y+=y[i]*(n-2*i-1)
    Y%=mo
print(X*Y%mo)

### FIXED CODE ###

mo=10**9+7
n,m=map(int,input().split())
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]
X,Y=0,0
for i in range(n):
    X+=x[i]*(n-2*i-1)
    X%=mo
for i in range(m):
    Y+=y[i]*(m-2*i-1)
    Y%=mo
print(X*Y%mo)
# -*- Coding: utf-8 -*-
N, X = map(int, input().split())
L = list(map(int,input().split()))

index = 0
Sum = 0
while Sum <= X:
    Sum += L[index]
    index += 1

print(index) 



### FIXED CODE ###

N,X = map(int,input().split())
L = list(map(int,input().split()))

ans = 1 #位置0も1にカウントするから
p = 0 #今のポジション
for i in range(N):
    p += L[i]
    if p <= X:
         ans += 1
    else:
        break

print(ans)
a,_,b=input()
print('H' if a==H & b==H or a==D & b==D else 'D')


### FIXED CODE ###

a,_,b=input()
print('H' if a==b else 'D')
n, k = map(int, input().split())
s = input()

print(s[:k-1] + lower(s[k-1]) + s[k:])

### FIXED CODE ###

n, k = map(int, input().split())
s = input()
print(s[:k-1] + s[k-1].lower() + s[k:])
def gcd(x, y):
    if x == y:
        return x
    if x < y and y % x:
        return x
    if x > y and x % y:
        return y

    r = 1
    for i in range(1, int(min(x, y) / 2) + 1):
        if x % i == 0 and y % i == 0:
            r = i
    return r
 
x, y = map(int, re.split(' ', raw_input()))
print(gcd(x, y))

### FIXED CODE ###

import re

def gcd(x, y):
    if x == y:
        return x
    if x < y and y % x == 0:
        return x
    if x > y and x % y == 0:
        return y
    if x <= y:
        m = y % x
        return gcd(x, m)
    if x >= y:
        m = x % y
        return gcd(y, m)

    l = list(range(1, int(min(x, y) / 2) + 1))
    l.reverse()
    r = 1
    for i in l:
        if x % i == 0 and y % i == 0:
            return i
    return 1
 
x, y = map(int, re.split(' ', raw_input()))
print(gcd(x, y))
import itertools

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


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p


p = 998244353
N = n   # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans = 0

l2 = m*(m-1)**(n-k-2)
for _k in range(k, -1, -1):
    # print(_k)

    l2 %= p
    l2 *= (m - 1)
    l2 %= p

    ncr = cmb(n - 1, _k, p)
    ans += ncr * l2
    ans %= p


print(ans)


### FIXED CODE ###

import itertools

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


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p


p = 998244353
N = n   # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans = 0

l2 = m*(m-1)**(n-k-1)
for _k in range(k, -1, -1):
    # print(_k)

    ncr = cmb(n - 1, _k, p)
    ans += ncr * l2
    ans %= p
    l2 %= p
    l2 *= (m - 1)


print(ans)
#!/usr/bin/env python
x, y, z, k = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
D = []
E = []
for b in B:
    for c in C:
        D.append(b+c)
D.sort(reverse=True)[:k]
n = 0
for a in A:
    for d in D:
       E.append(a+d)
E.sort(reverse=True)
for e in E[:k]:
    print(e)

### FIXED CODE ###

#!/usr/bin/env python
import numpy as np
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
D = []
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
for i in range(min(K,X)):
    for j in range(min((K//(i+1),Y))):
        for k in range(min(((K//(i+1)+1)//(j+1)),Z)):
            D.append(A[i]+B[j]+C[k])
D.sort(reverse=True)
for i in range(K):
    print(int(D[i]))
a, b, k = map(int, input().split())
da = []
db = []
dc = []
for i in range(1,a+1):
    if a%i == 0:
    	da.append(i)

for j in range(1, b+1):
    if b%j == 0:
    	db.append(j)

for k in da:
    if k in db:
    	dc.append(k)

if dc:
    dc.sort(reverse = True)
    print(dc[k-1])

### FIXED CODE ###

a, b, k = map(int, input().split())
da = []
db = []
dc = []
for i in range(1,a+1):
    if a%i == 0:
    	da.append(i)

for j in range(1, b+1):
    if b%j == 0:
    	db.append(j)

for l in da:
    if l in db:
    	dc.append(l)

dc.sort(reverse = True)
print(dc[k-1])
# -*- coding: utf-8 -*-
import sys
stack=[]
for i in sys.stdin:
    a=int(i.split('\n')[0])
    if a >0 :
        stack.append(a)
    else :
        print stack.pop()

### FIXED CODE ###

import sys
stack=[]
for i in sys.stdin:
    try:
        a=int(i)
        if a >0 :
            stack.append(a)
        else :
            print stack.pop()
    except:
        pass
import re
import numpy as np
 
N, K = [int(i) for i in re.split(" ", input())]
A = [int(i) for i in re.split(" ", input())]
count = 0
 
for i in range(N):
  tmp = 0
  for j, a in enumerate(A[i:]):
    tmp += a
    if tmp <= K:
      count += N - j
      break

print(count)

### FIXED CODE ###

import re
X, A = [int(i) for i in re.split(" ", input())]
if X < A:
  print(0)
else:
  print(10)
N = int(input())
outputs = []
for i in range(1, int(N**0.5)):
  if N%i == 0:
    outputs.append(i+N//i-2)
print(min(outputs))

### FIXED CODE ###

N = int(input())
minstep = 9999999999999999999999999999999
for i in range(1, int(N**0.5+1)):
  if N%i == 0:
    minstep = min(minstep, i+N//i-2)
print(minstep)
n=int(input())
lists=list(map(int,input().split()))
anslists=[0]*(n)

for i in range(n-1,-1,-1):
 # i= n-1, n-2......1,0
 #左からi+1番目に着いて調べる
    number=n//(i+1)
    if number==1:
          anslists[i]=lists[i]
    else:
　　    
        for some in range(number):
               check+=anslists[(i+1)*(some+1)]
        nums=check-lists[i]
        if nums%2==0:
           anslists[i]=lists[i]
        elif nums%2!=0:
           if lists[i]==0:
               anslists[i]=1
           if lists[i]==1:
               anslists[i]=0
Anscnt=0
Anslist=[]
for j in range(n):
    if anslists[j]==1:
        Anslist.append(j+1)
        Anscnt+=1
print(Anscnt)
print(*Anslist)


        
           
           
  

           
       
        
   
          
          


### FIXED CODE ###

n=int(input())
lists=list(map(int,input().split()))
lists.insert(0,0)
anslists=[0]*(n+1)
for j in range(n,0,-1):
# j=n,n-1,.......,2,1という感じ
    numbers=n//j
    if numbers==1:
        anslists[j]=lists[j]
    else:
        check=0
        for i in range(2,numbers+1):
            check+=anslists[i*j]
            
        if check%2==0:
            anslists[j]=lists[j]
            
        else:
            
            if lists[j]==1:
                anslists[j]=0
                
            if lists[j]==0:
                anslists[j]=1
                

printA=0

del anslists[0]


Anslist=[]
for k in range(n):
    if anslists[k]==1:
        printA+=1
        Anslist.append(k+1)
print(printA)
print(*Anslist)
import sys
sys.setrecursionlimit(10000)

class UnionFindTree:
	def __init__(self,size):
		"""
		size個の集合を作成
		負の値は、ルートで集合の個数
		正の値は、次の要素
		"""
		self.table=[-1 for _ in range(size)]

	def find(self,x):
		"""
		グループ番号を取得
		"""
		# 本質的には、木を上に辿るだけ
		# ただし、通常、UnionFindでは経路圧縮を行うのが普通らしい
		if self.table[x] < 0:
			# 一個上がルートならば、それを返して終わり
			return x
		else:
			# そうでなければ、ルートまで辿るついでに経路圧縮
			self.table[x] = self.find(self.table[x])
			return self.table[x]
		return x

	# 併合
	def union(self,x,y):
		# s1,s2は正
		# table[s1],table[s2]は負
		s1=self.find(x)
		s2=self.find(y)
		if s1!=s2:
			# 個数が小さい方をルートにくっつける
			# ルートサイズは負なので、ルートが大きい方が個数が小さい?
			if self.table[s2]<=self.table[s1]:
				# s1が小さい
				self.table[s1]+=self.table[s2]
				self.table[s2]=s1
			else:
				# s2が小さい
				self.table[s2]+=self.table[s1]
				self.table[s1]=s2
			return True
		return False

	def groupCount(self):
		ret=0
		for i in range(len(self.table)):
			if self.table[i] < 0:
				ret+=1
		return ret

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

UF=UnionFindTree(N)

for n in range(M):
	A,B=map(int,input().split())
	UF.union(A,B)


print(UF.groupCount()-1)



### FIXED CODE ###


import sys
sys.setrecursionlimit(10000)

class UnionFindTree:
	def __init__(self,size):
		"""
		size個の集合を作成
		負の値は、ルートで集合の個数
		正の値は、次の要素
		"""
		self.table=[-1 for _ in range(size)]

	def find(self,x):
		"""
		グループ番号を取得
		"""
		# 本質的には、木を上に辿るだけ
		# ただし、通常、UnionFindでは経路圧縮を行うのが普通らしい
		if self.table[x] < 0:
			# 一個上がルートならば、それを返して終わり
			return x
		else:
			# そうでなければ、ルートまで辿るついでに経路圧縮
			self.table[x] = self.find(self.table[x])
			return self.table[x]
		return x

	# 併合
	def union(self,x,y):
		# s1,s2は正
		# table[s1],table[s2]は負
		s1=self.find(x)
		s2=self.find(y)
		if s1!=s2:
			# 個数が小さい方をルートにくっつける
			# ルートサイズは負なので、ルートが大きい方が個数が小さい?
			if self.table[s2]<=self.table[s1]:
				# s1が小さい
				self.table[s1]+=self.table[s2]
				self.table[s2]=s1
			else:
				# s2が小さい
				self.table[s2]+=self.table[s1]
				self.table[s1]=s2
			return True
		return False

	def groupCount(self):
		ret=0
		for i in range(len(self.table)):
			if self.table[i] < 0:
				ret+=1
		return ret

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

UF=UnionFindTree(N)

for _ in range(M):
	A,B=map(int,input().split())
	UF.union(A-1,B-1)


print(UF.groupCount()-1)
N,K = list(map(int,input().split()))
Ha = list(map(int,input().split()))
Hb = sorted(Ha,reverse=True)
del Hb[:K]
print(sum(Hb))

### FIXED CODE ###

H = int(input())
ans = 0
num = 1
A = [1]
for i in range(100):
  if H / 2 < 1:
    ans += 1
    break
  else:
    H = H / 2
    ans += 1
for j in range(ans-1):
  A.append(num*2)
  num = num*2
print(sum(A))
arr = list(map(str, input().split()))

i = 0

operand = []

while i < len(arr):
    if arr[i] == '+':
        a = operand.pop(-1)
        b = operand.pop(-1)
        operand.append(b + a)
    elif arr[i] == '-':
        a = operand.pop(-1)
        b = operand.pop(-1)
        operand.append(b - a)
    elif arr[i] == '*':
        a = operand.pop(-1)
        b = operand.pop(-1)
        operand.append(b * a) 
   else:
        operand.append(int(arr[i]))
    i += 1

print(operand[0])



### FIXED CODE ###

arr = list(map(str, input().split()))

i = 0

operand = []

while i < len(arr):
    if arr[i] == '+':
        a = operand.pop(-1)
        b = operand.pop(-1)
        operand.append(b + a)
    elif arr[i] == '-':
        a = operand.pop(-1)
        b = operand.pop(-1)
        operand.append(b - a)
    elif arr[i] == '*':
        a = operand.pop(-1)
        b = operand.pop(-1)
        operand.append(b * a)
    else:
        operand.append(int(arr[i]))
    i += 1

print(operand[0])
n, k = (int(each) for each in input().split())
if n > k:
    a = n%k
    print(min(abs(a-k), a))
else:
    k = k%n+n+n
    b = min(abs(n-k), k-abs(n-k))
    if b == 0:
        print(n)
    else:
        print(b)

### FIXED CODE ###

def calc(n, k):
    if n == 0:
        return 0
    if n > k:
        a = n%k
        return min(abs(a-k), a)
    # kのほうがnより大きいとき
    if n*2 < k:
        return n
    else:
        # k = k%n+n+n
        return min(abs(n-k), k-abs(n-k))

n, k = (int(each) for each in input().split())
print(calc(n, k))
from typing import List


class Solution:
    def solve(self, N: int, P: List[int]) -> int:

        max_p = N
        answer = 0

        for pn in P:
            if pn <= max_p:
                answer += 1
                max_p = pn

        return answer


if __name__ == '__main__':

    # standard input
    N = int(input())

    P = list(map(int, input().split()))

    # solve
    solution = Solution()
    print(solution.solve(N, P))


### FIXED CODE ###

class Solution:
#    def solve(self, N: int, P: List[int]) -> int:
    def solve(self, N, P) :
        max_p = N
        answer = 0

        for pn in P:
            if pn <= max_p:
                answer += 1
                max_p = pn

        return answer


if __name__ == '__main__':

    # standard input
    N = int(input())

    P = list(map(int, input().split()))

    # solve
    solution = Solution()
    print(solution.solve(N, P))
a,b,q = map(int,input().split())

jinjya = []
otera = []

for i in range(a):
    jinjya.append(int(input()))
for i in range(b):
    otera.append(int(input()))

def find(arr,tar,start,end):
    if start == end:
        return start
    bar = (start+end)//2
    if arr[bar]<tar:
        return find(arr,tar,bar+1,end)
    elif arr[bar]>tar:
        return find(arr,tar,start,bar-1)
    else:
        return bar
for i in range(q):
    jinjyaEast = 0
    jinjyaWest = 0
    oteraEast = 0
    oteraWest = 0
    pos = int(input())
    idx = find(jinjya,pos,0,len(jinjya)-1)
    if(jinjya[idx] < pos):
        jinjyaWest = jinjya[idx]
        if idx<len(jinjya)-1:
            jinjyaEast = jinjya[idx+1]
    else:
        jinjyaEast = jinjya[idx]
        if idx>0:
            jinjyaWest = jinjya[idx-1]
    idx = find(otera,pos,0,len(otera)-1)
    if(otera[idx] < pos):
        oteraWest = otera[idx]
        if idx<len(otera)-1:
            oteraEast = otera[idx+1]
    else:
        oteraEast = otera[idx]
        if idx>0:
            oteraWest = otera[idx-1]
    res = []
    j = []
    o = []
    if jinjyaWest != 0:
        j.append(jinjyaWest)
    if jinjyaEast != 0:
        j.append(jinjyaEast)
    if oteraWest != 0:
        o.append(oteraWest)
    if oteraEast != 0:
        o.append(oteraEast)
    for a in j:
        for b in o:
            res.append(min(abs(pos-a)+abs(b-a),abs(pos-b)+abs(a-b)))
    print(min(res))


### FIXED CODE ###

import bisect
a,b,q = map(int,input().split())

jinjya = []
otera = []

for i in range(a):
    jinjya.append(int(input()))
for i in range(b):
    otera.append(int(input()))

INF = 10**18
jinjya = [-INF] + jinjya + [INF]
otera = [-INF] + otera + [INF]


for i in range(q):
    res = INF
    pos = int(input())
    j,o = bisect.bisect_right(jinjya,pos),bisect.bisect_right(otera,pos)
    for a in [jinjya[j-1],jinjya[j]]:
        for b in [otera[o-1],otera[o]]:
            res = min(res,abs(pos-a)+abs(a-b),abs(pos-b)+abs(a-b))
    print(res)
n = int(input())
s, t = map(str,input().split())
ans = ""
for i, j in zip(s,t):
  ans += i
  ans += j
print(ans)

### FIXED CODE ###

s = input()
c = 0
if len(s)%2==0:
  for a,b in zip(s[len(s)//2:],reversed(s[:len(s)//2])):
    if a != b:
      c+=1
else:
  for a,b in zip(s[len(s)//2+1:],reversed(s[:len(s)//2])):
    if a != b:
      c += 1
print(c)