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

from itertools import combinations
import numpy as np
n, k = map(int, input().split())
hs = []
for i in range(n):
    hs.append(int(input()))
def get_diff(x):
    return max(x) - min(x)
print(min(np.array(list(map(get_diff, list((combinations(hs, k))))))))

### FIXED CODE ###

import numpy as np
n, k = map(int, input().split())
hs = []
for i in range(n):
    hs.append(int(input()))

if list(np.diff(hs)) == list(np.zeros(n-1, dtype=int)):
    print('0')
else:
    sorted_hs = np.sort(hs)
    try:
        print(min([min(np.diff(sorted_hs[i::k-1])) for i in range(k) if not len(sorted_hs[i::k-1]) == 1]))
    except:
        print('0')
### BUGGY CODE ###

FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

def f(x):
    ans = 0
    while x:
        x = x% bin(x).count('1')
        ans+=1
    return ans

N = rri()
num = int('0b'+rr(),2)
for i in range(N):
    cur_num = num ^ (1<<(N-i-1))
    print(f(cur_num))

### FIXED CODE ###

FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]
N = rri()

num = list(rr())
count = num.count('1')
pwrTwo_plus = [0] * N 
pwrTwo_plus[0] = 1 % (count+1)
if count>1:
    pwrTwo_minus = [0] * N 
    pwrTwo_minus[0] = 1 % (count-1)  
for i in range(1, N):  
    pwrTwo_plus[i] = pwrTwo_plus[i - 1] * (2 % count)  
    pwrTwo_plus[i] %= count+1
    if count>1:
        pwrTwo_minus[i] = pwrTwo_minus[i - 1] * (2 % count)  
        pwrTwo_minus[i] %= count-1

def getMod(_str, n, k, plus) :  
    
    # To store the result  
    res = 0
    i = 0
    j = n - 1
    while (i < n) :  
  
        # If current bit is 1  
        if (_str[j] == '1') :  
  
            # Add the current power of 2  
            if plus:
                res += (pwrTwo_plus[i] )  
                res %= k  
            else:
                res += (pwrTwo_minus[i] )  
                res %= k  
              
        i += 1
        j -= 1
  
    return res  
dic = {}
def f(x):
    if x in dic:
        return dic[x]
    if x== 0:
        return 0
    tmp = x% bin(x).count('1')
    dic[x] = f(tmp)+1
    return dic[x]
    

ans_1 = getMod(num, N, count+1, True)
if count>1:
    ans_2 = getMod(num, N, count-1, False)
for i in range(N):
    if num[i] =='0':
        cur_count = count+1
    else:
        cur_count =count-1
    if cur_count ==0:
        print(0)
    else:
        if num[i] =='0':
            cur_num = ans_1
            cur_num += pwrTwo_plus[N-1-i]
            cur_num %= cur_count
            print(f(cur_num)+1)
        else:
            cur_num = ans_2
            cur_num -=pwrTwo_minus[N-1-i] 
            cur_num %= cur_count
            print(f(cur_num)+1)
### BUGGY CODE ###

from queue import Queue

H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]
blackQ = Queue()

for i, wField in enumerate(field):
    for j, w in enumerate(wField):
        if w == "#":
            blackQ.put((i, j))

ans = 0
while(True):
    for _ in range(blackQ.qsize()):
        i, j = blackQ.get()
        if i - 1 >= 0 and field[i-1][j] != "#":
            field[i-1][j] = "#"
            blackQ.put((i - 1, j))
        if i + 1 <= H - 1 and field[i+1][j] != "#":
            field[i+1][j] = "#"
            blackQ.put((i + 1, j))
        if j - 1 >= 0 and field[i][j-1] != "#":
            field[i][j-1] = "#"
            blackQ.put((i, j - 1))
        if j + 1 <= W - 1 and field[i][j + 1] != "#":
            field[i][j+1] = "#"
            blackQ.put((i, j + 1))

    if blackQ.empty():
        break

    ans += 1

print(ans)


### FIXED CODE ###

H, W = map(int, input().split())
func = (lambda x: 1 if x == "#" else 0)
field = [[func(i) for i in input()] for _ in range(H)]
blackQ = []

for i, wField in enumerate(field):
    for j, w in enumerate(wField):
        if w == 1:
            blackQ.append((i, j))

ans = 0
while(True):
    bQ = []
    for _ in range(len(blackQ)):
        i, j = blackQ.pop()
        if i - 1 >= 0 and field[i-1][j] != 1:
            field[i-1][j] = 1
            bQ.append((i - 1, j))
        if i + 1 <= H - 1 and field[i+1][j] != 1:
            field[i+1][j] = 1
            bQ.append((i + 1, j))
        if j - 1 >= 0 and field[i][j-1] != 1:
            field[i][j-1] = 1
            bQ.append((i, j - 1))
        if j + 1 <= W - 1 and field[i][j + 1] != 1:
            field[i][j+1] = 1
            bQ.append((i, j + 1))

    if len(bQ) == 0:
        break

    ans += 1
    blackQ = bQ

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

#拡張ユークリッド互除法
#ax+by=1の1つの解(gcd(a,b)=1)
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2] != 1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def modinv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m #負の値を返さないように

X,Y = map(int,input().split())

X,Y = min(X,Y),max(X,Y)

if (X+Y)%3 != 0 or X*2-Y < 0:
    ans = 0
else:
    a = (2*X-Y)//3
    b = (2*Y-X)//3
    m = 10**9+7
    ans = 1
    for i in range(b+1,a+b+1):
        ans = ans*i%m
    for i in range(1,a+1):
        ans = ans*modinv(i,m)%m
print(ans)


### FIXED CODE ###

X,Y = map(int,input().split())
P = 10**9 + 7
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

if (X+Y)%3 != 0:
    ans = 0
elif min(X,Y)*2 < max(X,Y):
    ans = 0
else:
    A = (min(X,Y)-abs(X-Y))//3+abs(X-Y)
    B = (min(X,Y)-abs(X-Y))//3
    ans = 1
    for i in range(A):
        ans = ans*(A+B-i)%P
    for i in range(1,A+1):
        ans = ans*mod_inv(i,P)%P
print(ans)
### BUGGY CODE ###

# Q3

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

def changeDirection(S, L, N):
    Sb = S[:L-1].count('W')
    Sa = S[L:].count('E')
    return Sb + Sa

cnt = N
for i in range(1, N + 1):
    tmp = changeDirection(S, i, N)
    if tmp < cnt:
        cnt = tmp
        
print(cnt)

### FIXED CODE ###

def EW(x, char):
    re = 0
    if x == char:
        re = 1
    return re
        
def main(num, string):
    e = list(map(lambda x:EW(x, 'E'), string))
    w = list(map(lambda x:EW(x, 'W'), string))
    
    for i in range(1, num):
        w[i] = w[i-1] + w[i]
        e[num - i -1] = e[num - i  - 1] + e[num - i]
    
    w.insert(0, 0)
    w.insert(num+1,0)
    e.insert(0, 0)
    e.insert(num+1, 0)
    cnt = num
    for i in range(1, num + 1):
        tmp = w[i-1] + e[ i + 1]
        if tmp < cnt:
            cnt = tmp
    return cnt

num = int(input())
string = input()
 
print(main(num, string))
### BUGGY CODE ###

N = int(input())

A = []
for i in range(N):
    a = int(input())
    if a not in A:
        A.append(a)
    else:
        A.remove(a)
        
print(len(A))

### FIXED CODE ###

from collections import Counter
n = int(input())
A = Counter([int(input()) for i in range(n)]).most_common()
B = []

for i in range(len(A)):
    if A[i][1] % 2 == 1:
        B.append(A[i][1])
        
print(len(B))
### BUGGY CODE ###

n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)

cnt = 0

for i in range(n - 2):
    for j in range(i + 1, n - 1):
        base = l[i] - l[j]
        for k in range(j + 1, n):
            if l[k] > base:
                cnt += 1
            else:
                break
print(cnt)

### FIXED CODE ###

import bisect
n = int(input())
l = list(map(int, input().split()))
l.sort()

cnt = 0

for i in range(n - 1, 0, -1):
    for j in range(i - 1, -1, -1):
        base = l[i] - l[j]
        idx = bisect.bisect_right(l, base)
        cnt += max(j - idx, 0)
print(cnt)
### BUGGY CODE ###

n = int(input())
M = 10**9+7
sum = 1
for i in range(1,n+1):
  sum *= i%M
print(sum%M)

### FIXED CODE ###

n = int(input())
d = 1
for i in range(1,n+1):
  d = (d*i)%(10**9+7)
print(d)
### BUGGY CODE ###

from collections import Counter,defaultdict,deque
from bisect import bisect_left
import sys,math,itertools,pprint,fractions,time
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

st = time.time()
n = inp()
a = []
for i in range(n):
    b = inpl()
    a.append(deque(b))
zan = n*(n-1)//2
res = 0
while True:
    res += 1
    now = zan
    s = set()
    for i in range(n):
        if i in s or a[i] == deque([]): continue
        end = True
        chk = a[i][0] - 1
        if not chk in s and a[chk][0] == i+1:
            zan -= 1
            if not zan: 
                print(res); quit()
            a[i].popleft(); a[chk].popleft()
            s.add(i); s.add(chk)
        # print(res,i,chk,a)
    if now == zan or st - time.time() > 1.8:
        print(-1)
        quit()

            


### FIXED CODE ###

from collections import Counter,defaultdict,deque
from bisect import bisect_left
import sys,math,itertools,pprint,fractions,time
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

st = time.time()
n = inp()
a = []
for i in range(n):
    b = inpl()
    a.append(deque(b))
zan = n*(n-1)//2
res = 0
while True:
    res += 1
    now = zan
    s = set()
    for i in range(n):
        if i in s or a[i] == deque([]): continue
        end = True
        chk = a[i][0] - 1
        if not chk in s and a[chk][0] == i+1:
            zan -= 1
            if not zan: 
                print(res); quit()
            a[i].popleft(); a[chk].popleft()
            s.add(i); s.add(chk)
        # print(res,i,chk,a)
        nnn = time.time()
    if now == zan:
        print(-1)
        quit()
    if nnn - st > 1.7:
        print(n*(n-1)//2)
        quit()
### BUGGY CODE ###

N,K = map(int, input().split())
answer = list(map(lambda x: sum(range(1,x+1))/x, list(map(int, input().split()))))
total = 0
for i in range(0,N-K+1):
    total = max(total, sum(answer[i:i+K]))
print(total)

### FIXED CODE ###

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

S = [0]*(N+1)
for i in range(N):
  S[i+1] = S[i] + (1+p[i])/2

ans = 0
for i in range(N-K+1):
  diff = S[i+K] - S[i]
  ans = max(ans, diff)
print(ans)
### BUGGY CODE ###

def solve():
    N, W = map(int, input().split())
    weight = [0 for i in range(N)]
    value = [0 for i in range(N)]
    for i in range(N):
        weight[i], value[i] = map(int, input().split())
    dp = [0 for w in range(W + 1)]

    for i in range(N):
        # wi = weight[i]
        # vi = value[i]
        for w in range(W, -1, -1):
            _w = w + weight[i]
            # _v = dp[w] + value[i]
            if _w > W: continue
            # if _v <= dp[_w]: continue
            dp[_w] = max(dp[_w], dp[w] + value[i])
    return dp[-1]

print(solve())


### FIXED CODE ###

def solve():
    N, W = map(int, input().split())
    weight = [0 for i in range(N)]
    value = [0 for i in range(N)]
    for i in range(N):
        weight[i], value[i] = map(int, input().split())
    dp = [0 for w in range(W + 1)]

    for i in range(N):
        wi = weight[i]
        vi = value[i]
        for w in range(W, -1, -1):
            _w = w + wi
            _v = dp[w] + vi
            if _w > W: continue
            if _v <= dp[_w]: continue
            dp[_w] = _v
    return dp[-1]

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

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,k=LI()
  l=LI()

  dp=[inf]*n
  dp[0]=0
  for i in range(1,n):
    for j in range(max(0,i-k),i):
      dp[i] = min(dp[i], dp[j] + abs(l[i]-l[j]))

  return dp[n-1]

print(main())


### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,k=LI()
  l=LI()

  dp=[inf]*100010
  dp[0]=0
  for i in range(n):
    for j in range(1,k+1):
      if i+j<n:
        dp[i+j]=min(dp[i+j],dp[i]+abs(l[i+j]-l[i]))

  return dp[n-1]

print(main())
### BUGGY CODE ###

MOD = 10**9+7
n, c = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sig = [[0 for _ in range(max(b)+1)] for _ in range(c+1)]
for i in range(c+1):
	for j in range(1, max(b)+1):
		sig[i][j] = sig[i][j-1] + pow(j, i, MOD)
		sig[i][j] %= MOD

def sigma(C, A, B):
	return (sig[C][B] - sig[C][A-1]) % MOD

dp = [[0 for _ in range(c+1)] for _ in range(n)]
for j in range(c+1):
	dp[0][j] = sigma(j, a[0], b[0])

for i in range(1, n):
	for j in range(c+1):
		for k in range(j+1):
			dp[i][j] += dp[i-1][k] * sigma(j-k, a[i], b[i])
			dp[i][j] %= MOD

print(dp[n-1][c])

### FIXED CODE ###

MOD = 10**9+7
n, c = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sig = [[0 for _ in range(max(b)+1)] for _ in range(c+1)]
for i in range(c+1):
	for j in range(1, max(b)+1):
		sig[i][j] = sig[i][j-1] + pow(j, i, MOD)
		sig[i][j] %= MOD

def sigma(C, A, B):
	return (sig[C][B] - sig[C][A-1]) % MOD

dp = [[0 for _ in range(c+1)] for _ in range(n)]
for j in range(c+1):
	dp[0][j] = sigma(j, a[0], b[0])

for i in range(1, n):
	for j in range(c+1):
		for k in range(j+1):
			dp[i][j] += dp[i-1][k] * sigma(j-k, a[i], b[i])
			dp[i][j] %= MOD

print(dp[n-1][c])
### BUGGY CODE ###

# https://atcoder.jp/contests/abc084/tasks/abc084_d

Nmax = 10**6 + 1

def prime_test(n):
    if n == 1:
        return False
    i = 2
    while i*i<=n:
        if n%i:
            i += 1
        else:
            return False
    return True

cum = [0]*Nmax

for n in range(1,Nmax,2):
    if prime_test(n) and prime_test((n + 1)/2):
        cum[n] = cum[n-2] + 1
    else:
        cum[n] = cum[n - 2]

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(cum[r] - cum[l-2])


### FIXED CODE ###

# https://atcoder.jp/contests/abc084/tasks/abc084_d

Nmax = 10**5 + 1

def prime_test(n):
    if n == 1:
        return False
    i = 2
    while i*i<=n:
        if n%i:
            i += 1
        else:
            return False
    return True

cum = [0]*Nmax

for n in range(1,Nmax,2):
    cum[n] = cum[n-2] + (prime_test(n) and prime_test((n + 1)/2))

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(cum[r] - cum[l-2])
### BUGGY CODE ###

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

now = 1
cnt = 0
x = []

for i in range(n):
    if sss[i] == str(now):
        cnt += 1
    else:
        x.append(cnt)
        now = 1 - now
        cnt = 1
if cnt != 0:
    x.append(cnt)
if len(x) % 2 == 0:
    x.append(0)

Add = 2 * k + 1
ans = 0

for i in range(len(x))[::2]:
    tmp = 0
    left = i
    right = min(i + Add, len(x))
    for j in range(left, right):
        tmp += x[j]
    ans = max(tmp, ans)

print(ans)

### FIXED CODE ###

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

cnt = 0
state = sss[0]
x = []
if sss[0] == "0":
    x.append(0)
for s in sss:
    if s == state:
        cnt += 1
    else:
        state = s
        x.append(cnt)
        cnt = 1
x.append(cnt)
if sss[-1] == "0":
    x.append(0)
#11101010110011
#1:3 1 1 2 2
#0: 1 1 1 2

#1
#1

y = [0]
for i in range(len(x)):
    y.append(y[i] + x[i])
#:0,1,2,3,4,5,6 7, 8 ,9
#:0,3,4,5,6,7,8,10,12,14

#0,1

z = []
for i in range(k*2+1,len(y))[::2]:
    z.append(y[i] - y[i - (k*2+1)])
#print(x)
#print(y)
#print(z)
if len(x) <= k*2-1:
    print(sum(x))
else:
    print(max(z))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

MOD = 10 ** 9 + 7
s = input().strip()
n = len(s)
if s[-1] == "?":
    tmp = [1 for i in range(10)] + [0 for i in range(3+13*(n-1))]

else:
    tmp = [0 for i in range(13*n)]
    # print("-------------------")
    # print(s[-1])
    # print(int(s[-1]))
    tmp[int(s[-1])] = 1
# print(len(tmp))
keta = 1
for kt, c in enumerate(s[::-1][1:]):
    keta = (keta * 10) % 13
    nw = [0 for i in range(13)]
    if c != "?":
        seni = int(c) * keta
        for j in range(13):
            tmp[(j + seni) % 13 + (kt + 1) * 13] += tmp[kt * 13 + j] % MOD
    else:
        for isure in range(10):
            seni = isure * keta
            for j in range(13):
                tmp[(j + seni) % 13 + (kt + 1) * 13] += tmp[kt * 13 + j] % MOD
                # print(nw)

    # print(tmp[(13*kt):13*(kt+1)])
    # tmp = [num % MOD for num in nw]
    # tmp = nw
print(tmp[-8] % MOD)




### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)
 
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
 
MOD = 10 ** 9 + 7
s = input().strip()
n = len(s)
if s[-1] == "?":
    tmp = [1 for i in range(10)] + [0 for i in range(3+13*(n-1))]
 
else:
    tmp = [0 for i in range(13*n)]
    # print("-------------------")
    # print(s[-1])
    # print(int(s[-1]))
    tmp[int(s[-1])] = 1
# print(len(tmp))
keta = 1
for kt, c in enumerate(s[::-1][1:]):
    keta = (keta * 10) % 13
    
    if c != "?":
        seni = int(c) * keta
        for j in range(13):
            tmp[(j + seni) % 13 + (kt + 1) * 13] += tmp[kt * 13 + j] % MOD
    else:
        for isure in range(10):
            seni = isure * keta
            for j in range(13):
                tmp[(j + seni) % 13 + (kt + 1) * 13] += tmp[kt * 13 + j] % MOD
                # print(nw)
 
    # print(tmp[(13*kt):13*(kt+1)])
    # tmp = [num % MOD for num in nw]
    # tmp = nw
print(tmp[-8] % MOD)
### BUGGY CODE ###

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

c = collections.Counter(a)
keys, values = zip(*c.most_common())
ans = 0
for i in values:
  if i != 1:
  	ans += (i*(i-1)//2)

for i in a:
    ct = 0
    for j in keys:
      if i == j:
        co = values[ct]
        break
      ct += 1
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

      

### FIXED CODE ###

import collections
n = int(input())
a = list(map(str,input().split()))
ls = [i for i in range(2*10**5)]
c = collections.Counter(a)
comon = c.most_common()
ans = 0

for i in comon:
    if i != 1:
      ls[int(i[0])] = i[1]
      ans += (i[1]*(i[1]-1)//2)

for i in a:
    co = ls[int(i)]
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))
### BUGGY CODE ###

import bisect
import numpy as np
N,M,Q = map(int,input().split())
lr = [0]*M
for i in range(M):
    l,r = map(int,input().split())
    lr[i] = [l,r]
lr = sorted(lr,key=lambda x:x[0])
lr_t = list(np.array(lr).transpose())
for i in range(Q):
    p,q = map(int,input().split())
    I = bisect.bisect_left(lr_t[0],p)
    r = sorted(lr_t[1][I:])
    I = bisect.bisect(r,q)
    print(I)

### FIXED CODE ###

import numpy as np
N,M,Q = map(int,input().split())
c = [[0]*(N+1) for i in range(N+1)]
for i in range(M):
    l,r = map(int,input().split())
    c[l][r] += 1
c = np.cumsum(np.cumsum(c,axis=0),axis=1)
for i in range(Q):
    p,q = map(int,input().split())
    print(c[q][q]-c[q][p-1]-c[p-1][q]+c[p-1][p-1])
### BUGGY CODE ###

n,m=map(int, input().split(" "))
tower=list(map(int, input().split(" ")))
road=[list(map(int, input().split(" "))) for i in range(m)]
ans=0
for i in range(1, n + 1):
  for j in range(m):
    if road[j][0] == i:
      if tower[road[j][1]-1] >= tower[i-1]:
        break
    elif road[j][1] == i:
      if tower[road[j][0]-1] >= tower[i-1]:
        break
  else:
    ans += 1
print(ans)

### FIXED CODE ###

n,m=map(int, input().split(" "))
tower=list(map(int, input().split(" ")))
road=[list(map(int, input().split(" "))) for i in range(m)]
kosuu = [0 for i in range(n)]
temp = [0 for i in range(n)]
ans=0
for i in range(m):
  kosuu[road[i][0] - 1] += 1
  kosuu[road[i][1] - 1] += 1
for i in range(m):
  if tower[road[i][0] - 1] > tower[road[i][1] - 1]:
    temp[road[i][0] - 1] += 1
  elif tower[road[i][0] - 1] < tower[road[i][1] - 1]:
    temp[road[i][1] - 1] += 1
count = 0
for i in range(n):
  #print(n)
  if kosuu[i] == temp[i]:
    count += 1
print(count)
### BUGGY CODE ###

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

a = [0] + list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0
cnta = 0
ans = 0


for i in range(n + 1):
    cnta += a[i]
    cnt = cnta
    if cnt > k:
        ans = max(ans, i - 1)
        break
    for j in range(m):
        cnt += b[j]
        if cnt > k:
            ans = max(ans, i + j)
            break
    else:
        ans = max(ans, i + j + 1)
print(ans)

### FIXED CODE ###

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

A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0

a = [0]
b = [0]

for i in range(n):
    a.append(a[i] + A[i])

for i in range(m):
    b.append(b[i] + B[i])

j = m

for i in range(n + 1):
    if a[i] > k:
        break
    while a[i] + b[j] > k:
        j -= 1
    else:
        ans = max(ans, i + j)
print(ans)
### BUGGY CODE ###

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

LR = [list(map(int, input().split())) for i in range(M)]
pq = [list(map(int, input().split())) for i in range(Q)]

res = [[0]*N for i in range(N)]

def lsadd(L,R):
    L-=1
    R-=1
    for i in range(0,L+1):
        for j in range(R,N):    
            res[i][j] += 1

for l,r in LR:
    lsadd(l,r)

for p,q in pq:
    print(res[p-1][q-1])


### FIXED CODE ###

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

LR = [list(map(int, input().split())) for i in range(M)]
pq = [list(map(int, input().split())) for i in range(Q)]

res = [[0]*N for i in range(N)]

def lsadd(L,R):
    L-=1
    R-=1
    for i in range(0,L+1):  
        res[i][R] += 1

for l,r in LR:
    lsadd(l,r)

for p,q in pq:
    print(sum(res[p-1][:q]))
### BUGGY CODE ###

from itertools import combinations_with_replacement

K = int(input())
k_range = list(range(1, K+1))

result = 0
for comb in combinations_with_replacement(k_range, 3):
    min_abc = min(comb)
    for i in range(min_abc, 0, -1):
        if (comb[0]%i == 0 and comb[1]%i == 0) and comb[2]%i == 0:
            if comb[0]==comb[1] and comb[1]==comb[2]:
                coef = 1
            elif (comb[0]!=comb[1] and comb[1]!=comb[2]) and comb[2]!=comb[0]:
                coef = 6
            else:
                coef = 3
            result += i * coef
            break
print(result)

### FIXED CODE ###

from itertools import combinations_with_replacement

K = int(input())
k_range = list(range(1, K+1))

result = 0
for comb in combinations_with_replacement(k_range, 3):
    min_abc = min(comb)
    for i in range(min_abc, 0, -1):
        if (comb[0]%i == 0 and comb[1]%i == 0) and comb[2]%i == 0:
            if comb[0]==comb[1] and comb[1]==comb[2]:
                coef = 1
            elif (comb[0]!=comb[1] and comb[1]!=comb[2]) and comb[2]!=comb[0]:
                coef = 6
            else:
                coef = 3
            result += i * coef
            break
print(result)