Harryxun/stf_run huggingface dataset:
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
L = [[int(v) - 1 for v in input().split()] for _ in range(M)]

class UnionFind:
    def __init__(self, n):
        self.data = [0] * N
        for i in range(N):
            self.data[i] = i
            
    def get_root(self, x):
        r = self.data[x]
        if r == x:
            return r
        p = self.get_root(r)
        self.data[x] = p
        return p
    
    def unite(self, x, y):
        rx = self.get_root(x)
        ry = self.get_root(y)
        
        if rx != ry:
            self.data[rx] = ry
            
    def same(self, x, y):
        return self.get_root(x) == self.get_root(y)
    
u = UnionFind(N)
for a, b, _ in L:
    u.unite(a, b)
    
s = set()
for i in range(N):
    s.add(u.get_root(i))

print(len(s))

### FIXED CODE ###

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

N, M = map(int, input().split())
L = [[int(v) - 1 for v in input().split()] for _ in range(M)]

class UnionFind:
    def __init__(self, n):
        self.data = [0] * N
        for i in range(N):
            self.data[i] = i
            
    def get_root(self, x):
        r = self.data[x]
        if r == x:
            return r
        p = self.get_root(r)
        self.data[x] = p
        return p
    
    def unite(self, x, y):
        rx = self.get_root(x)
        ry = self.get_root(y)
        
        if rx != ry:
            self.data[rx] = ry
            
    def same(self, x, y):
        return self.get_root(x) == self.get_root(y)
    
u = UnionFind(N)
for a, b, _ in L:
    u.unite(a, b)
    
s = set()
for i in range(N):
    s.add(u.get_root(i))

print(len(s))
n = int(input())
r = int(n**0.5)
revList = [i for i in range(r)]
revList = revList[1:]
revList.reverse()

for i in revList:
  if n % i == 0:
    res = int(n/i) + i - 2
    break
print(res)


### FIXED CODE ###

n = int(input())
r = int(n**0.5)
revList = [i for i in range(r+1)]
revList = revList[1:]
revList.reverse()

for i in revList:
  if n % i == 0:
    res = int(n/i) + i - 2
    break
print(res)
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n = ni()
color = nl()
g = [list() for _ in range(n)]
for _ in range(n-1):
    a, b = nm()
    g[a-1].append(b-1)
    g[b-1].append(a-1)

size = [1]*n
par = [-1]*n
h = [list() for _ in range(n+1)]
idx = [0]*n
def dfs(v, p):
    h[color[v]].append(v)
    for x in g[v]:
        if x == p: continue
        par[x] = v
        size[v] += dfs(x, v)
        h[color[v]].append(v)
    h[color[v]].append(v)
    return size[v]
dfs(0, -1)
# print(size)
for v in range(n):
    if g[v][idx[v]] == par[v]:
        idx[v] += 1
acc = [0]*(n+10)
ans = [n*(n+1)//2]*(n+1)
for col in range(1, n+1):
    # print(h[col])
    acc[-1] = 0
    p = [-1]
    for v in h[col]:
        if p[-1] == v:
            p.pop()
            if idx[v] >= len(g[v]):
                acc[p[-1]] += size[v]
                continue
            q = size[g[v][idx[v]]] - acc[v]
            idx[v] += 1
            if idx[v] < len(g[v]) and g[v][idx[v]] == par[v]:
              idx[v] += 1
            ans[col] -= q*(q+1)//2
            acc[v] = 0
            # print(v, q)
            p.append(v)
        else:
            p.append(v)
    q = n - acc[-1]
    # print(-1, q)
    ans[col] -= q*(q+1)//2
print(*ans[1:], sep='\n')

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n = ni()
color = nl()
g = [list() for _ in range(n)]
for _ in range(n-1):
    a, b = nm()
    g[a-1].append(b-1)
    g[b-1].append(a-1)

size = [1]*n
par = [-1]*n
h = [list() for _ in range(n+1)]
idx = [0]*n
def dfs(v, p):
    h[color[v]].append(v)
    for x in g[v]:
        if x == p: continue
        par[x] = v
        size[v] += dfs(x, v)
        h[color[v]].append(v)
    h[color[v]].append(v)
    return size[v]
dfs(0, -1)
# print(size)
for v in range(n):
    if idx[v] < len(g[v]) and g[v][idx[v]] == par[v]:
        idx[v] += 1
acc = [0]*(n+10)
ans = [n*(n+1)//2]*(n+1)
for col in range(1, n+1):
    # print(h[col])
    acc[-1] = 0
    p = [-1]
    for v in h[col]:
        if p[-1] == v:
            p.pop()
            if idx[v] >= len(g[v]):
                acc[p[-1]] += size[v]
                continue
            q = size[g[v][idx[v]]] - acc[v]
            idx[v] += 1
            if idx[v] < len(g[v]) and g[v][idx[v]] == par[v]:
              idx[v] += 1
            ans[col] -= q*(q+1)//2
            acc[v] = 0
            # print(v, q)
            p.append(v)
        else:
            p.append(v)
    q = n - acc[-1]
    # print(-1, q)
    ans[col] -= q*(q+1)//2
print(*ans[1:], sep='\n')
import sys
sys.setrecursionlimit(2000)

n = int(input())

h = [int(i) for i in input().split()]

def dp(cost, p):
  if p == n-1:
    return cost
  if p < n-2:
    return min(dp(cost+abs(h[p]-h[p+1]), p+1), dp(cost+abs(h[p]-h[p+2]), p+2))
  if p == n-2:
    return dp(cost+abs(h[p]-h[p+1]), p+1)

print(dp(0, 0))

### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)
 
n = int(input())
 
h = [int(i) for i in input().split()]
 
d = {}
 
def dp(p):
  if p in d:
    return d[p]
  if p == n-1:
    return 0
  if p < n-2:
    m = min(dp(p+1)+abs(h[p]-h[p+1]), dp(p+2)+abs(h[p]-h[p+2]))
    d[p] = m
    return m
  if p == n-2:
    return dp(p+1)+abs(h[p]-h[p+1])

print(dp(0))
N = int(input())
D_list = list(map(int, input().split()))
M = int(input())
T_list = list(map(int, input().split()))

dic_T = {}
for i in T_list:
    dic_T[i] = T_list.count(i)

dic_D = {}
for i in D_list:
    dic_D[i] = D_list.count(i)

ans = 'YES'
for k in dic_T:
    if dic_T[k] > dic_D[k]:
        ans = 'NO'
        print(ans)
        break

if ans == 'YES':
    print(ans)


### FIXED CODE ###

N = int(input())
D_list = list(map(int, input().split()))
M = int(input())
T_list = list(map(int, input().split()))

dic_T = {}
for i in T_list:
    if i in dic_T:
        dic_T[i] += 1
    else:
        dic_T[i] = 1

dic_D = {}
for i in D_list:
    if i in dic_D:
        dic_D[i] += 1
    else:
        dic_D[i] = 1

for i in dic_T:
    if i in dic_D:
        if not dic_T[i] <= dic_D[i]:
            print('NO')
            exit()
    else:
        print('NO')
        exit()

print('YES')
N = input()

N1 = N[]
print(N1)
if N[0]=='7' or N[1]=='7' or N[2]=='7':
    print('Yes')
else:
    print('No')



### FIXED CODE ###




N = input()

if N[0]=='7' or N[1]=='7' or N[2]=='7':
    print('Yes')
else:
    print('No')
N = int(input())
A = list(map(list, input().split()))
for i in range(N):
    A[i].append(i + 1)  # 出席番号をそれぞれ追加している
A = sorted(A)  # 人数でソート
ans = []
for ai in range(N):
    ans.append(A[ai][1])  # 人数順に出席番号で出力
print(" ".join(map(str, ans)))


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = []
for i in range(N):
    B.append([A[i]])
    B[i].append(i + 1)  # 出席番号をそれぞれ追加している
B = sorted(B)  # 人数でソート
ans = []
for ai in range(N):
    ans.append(B[ai][1])  # 人数順に出席番号で出力
print(" ".join(map(str, ans)))
a,b=map(int,input.split())
if a<=b:
  print('unsafe')
else:
  print('safe')

### FIXED CODE ###

a,b=map(int,input().split())
if a<=b:
  print('unsafe')
else:
  print('safe')
from math import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

n = int(input())

print(gcd_list([int(i) for i in input().split()]))



### FIXED CODE ###

from fractions import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

n = int(input())
print(gcd_list([int(i) for i in input().split()]))
N, M = map(int, input().split())

# AB = [list(map(int, input().split)) for _ in range(M)]

nei_L = [[] for _ in range(M)]
for i in range(M):
    a, b = map(int, input().split())
    nei_L[a - 1].append(b - 1)
    nei_L[b - 1].append(a - 1)

ans = [-1] * N
visited = [0] * N
cost = [0] * N

from collections import deque
queue = deque()

def bfs():
    queue.append(0)

    while len(queue) > 0:

        if all(visited):
            break
        now = queue.popleft()

        for c in nei_L[now]:
            if not visited[c]:
                ans[c] = now
                queue.append(c)
                cost[c] = cost[now] + 1
                visited[c] = 1

bfs()

if -1 in visited[1:]:
    print("No")
else:
    for i in range(N):
        if i == 0:
            print("Yes")
        else:
            print(ans[i] + 1)

### FIXED CODE ###

from collections import deque

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

nei_L = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    nei_L[a - 1].append(b - 1)
    nei_L[b - 1].append(a - 1)

ans = [-1] * N
queue = deque()


def bfs():
    queue.append(0)
    while queue:
        now = queue.popleft()

        for c in nei_L[now]:
            if ans[c] == -1:
                ans[c] = now
                queue.append(c)


bfs()

if -1 in ans[1:]:
    print("No")
else:
    print("Yes")
    for i in range(1, N):
        print(ans[i] + 1)
n = int(input())
m = 0
for i in range(n):
  a, b = input().split(' ')
  a = int(a)
  if b == 'BTC':
    a = 380000*a
    m = m + a
  else:
    m = m + a
print(m)

### FIXED CODE ###

n = int(input().rstrip())
m = 0
for i in range(n):
  a, b = input().rstrip().split(' ')
  a = float(a)
  if b == 'BTC':
    a = 380000*a
  m += a
print(m)
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict

d=defaultdict(int)
m=10**6
sieve=[-1]*10**6
n=IN()
a=LI()
for i in range(n):
    d[a[i]]+=1
    for j in range(2*a[i],m,a[i]):
        sieve[j]=1
ans=0
for i in a:
    if sieve[i]==-1 and d[i]==1:
        ans+=1
print(ans)

### FIXED CODE ###

from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict

d=defaultdict(int)
m=10**6+1
sieve=[-1]*m
n=IN()
a=sorted(LI())
for i in a:
    if d[i]==0:
        d[i]+=1
        for j in range(2*i,m,i):
            sieve[j]=1
    else:
        sieve[i]=1
ans=0
for i in a:
    if sieve[i]==-1:
        ans+=1
print(ans)
A = int(input())
B = int(input())
if A > B:
  print("GREATER")
eiif A == B:
  print("EQUAL")
else:
  print("LESS")

### FIXED CODE ###

A = int(input())
B = int(input())
if A > B:
    print("GREATER")
elif A == B:
    print("EQUAL")
else:
    print("LESS")
import fractions
T = int(input())

L = []
for i in range(0,T):
    L = list(map(int, input().split()))
    A = L[0]
    B = L[1]
    C = L[2]
    D = L[3]

    ans = "Yes"
    if A < B: #前提条件
        ans = "No"
    elif D < B: #前提条件
        ans = "No"
    elif B - C <= 1: #BとCの差が1より小さければ何が来てもOK
        ans = "Yes"
    elif C < B-fractions.gcd(B,D)+(A%fractions.gcd(B,D)):
        ans = "No"


    print(ans)
    L = []



### FIXED CODE ###

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

for i in range(0,N-1):
    if L[i] == L[i+1]:
        L[i+1] = 101
        count += 1

print(count)
a=[]
while True:
 n=input()
 if int(n)==0:break
 a.append(n)
for s in a:
 x,y=s.split()
 if x>y:print(f'{y} < {x}')
 else:print(s)

### FIXED CODE ###

import sys
for s in sys.stdin:
 if'0 0\n'==s:break
 print(*sorted(map(int,s.split())))
n,m = map(int,input().split())
s=set([int(input()) for i in range(m)])
l=[1]+[0]*(n)
INF=1000000007
if n ==1:
    print(1)
    exit()
if len(s)!=0 and s[0]== 1:l[1]=0
else:l[1]=1

for i in range(2,n+1):
    if i in s:l[i]=0
    else:l[i] = (l[i-2]+l[i-1])%INF
print(l[-1])

### FIXED CODE ###

n,m = map(int,input().split())
s=set([int(input()) for i in range(m)])
l=[1]+[0]*n
INF=1000000007
if n ==1:
    print(1)
    exit()
if len(s)!=0 and 1 in s:l[1]=0
else:l[1]=1
for i in range(2,n+1):
    if i in s: l[i]=0
    else:l[i] = (l[i-2]+l[i-1])%INF
print(l[-1])
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(1,N):
  sub = A[i-1] - A[i]
  if sub > 0:
    ans+=sub
print(sub)

### FIXED CODE ###

def main():
  N = int(input())
  A = list(map(int,input().split()))
  ans = 0
  for i in range(1,N):
    sub = A[i-1] - A[i]
    if sub > 0:
      A[i]+=sub
      ans+=sub
  print(ans)
  return
main()
date=str(input())
data.replace("2017","2018")
print(data)

### FIXED CODE ###

date=str(input())
print(date.replace("2017","2018",1))
a = map(int, input().split())
a.sort()
a[0:]

### FIXED CODE ###

a = list(map(int, input().split()))
a.sort()
print(str(a[0]) + " " + str(a[1]) + " " + str(a[2]))
import bisect
n=int(input())
L=[]*n
L=list(map(int,input().split()))
L.sort()
cnt=0
for i in range(n-2):
    for j in range(i+1,n-1):
        ab=L[i]+L[j]
        num=bisect.bisect_left(L[j+1:],ab)
        cnt+=num
print(cnt)

### FIXED CODE ###

A,B = map(int,input().split(" "))
print(max(A-B*2,0))
n = int(input())
a = [int(input()) for _ in range(n)]
a1 = a.sorted()
st = a1[-1]
nd = a1[-2]
for i in a:
  if i = st:
    print(nd)
  else: print(st)

### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
a1 = sorted(a)
st = a1[-1]
nd = a1[-2]
for i in a:
  if i == st:
    print(nd)
  else: print(st)
X, Y = map(int, input())
ans = X
while X <=10**18:
  if ans % Y != 0:
    print(ans)
    break
  else:
    ans += X
print(-1)

### FIXED CODE ###

X, Y = map(int, input().split())
if X % Y == 0:
  print(-1)
else:
  print(X)
a =input()
a =int(a)

if a == 7 or a == 5 or a == 3:
  print(YES)
else:
  print(NO)

### FIXED CODE ###

a =input()
a =int(a)

if a == 7 or a == 5 or a == 3:
  print('YES')
else:
  print('NO')
import numpy as np
A,B,C,D = map(int, input().split())
ndcage = np.arange(A,B+1)

cmlist = np.nonzero(ndcage % C)[0]
dmlist = np.nonzero(ndcage % D)[0]

count=0
for i in cmlist:
    if i in dmlist:
        count+=1
print(count)

### FIXED CODE ###

A,B,C,D = map(int, input().split())

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

lcm=C*D//gcd(C,D)
con1=B//C - (A-1)//C
con2=B//D - (A-1)//D
con3=B//lcm - (A-1)//lcm

print(B-(A-1)-(con1+con2-con3))
n = int(input())
for i in range(n,1000):
  if i[0]==i[1]==i[2]:
    return i
print(i)
  

### FIXED CODE ###

n = int(input())
for i in range(n,1000):
  I = str(i)
  if I[0]==I[1]==I[2]:
    print(i)
    break
N = int(input())
ld = [0] * N
for i in range(N):
    d = int(input())
    ld[i] = d

upper = N + 2
bucket = [0] * upper
for j in range(N):
    bucket[ld[j]] += 1

tower = 0

for k in range(1, N+1):
    if bucket[k] > 0:
        tower += 1

print(tower)

### FIXED CODE ###

N = int(input())
ld = [0] * N
for i in range(N):
    d = int(input())
    ld[i] = d

t = set(ld)

print(len(t))
n,k = map(int,input().split())
a = [0]*3
for _ in range(k):
    kind = int(input())
    for i in list(map(int,input().split())):
        a[i-1] += 1
print(a.count(0))
    

### FIXED CODE ###

n,k = map(int,input().split())
a = [0]*n
for _ in range(k):
    kind = int(input())
    for i in list(map(int,input().split())):
        a[i-1] += 1
print(a.count(0) if 0 in a else 0)
def edit_distance():
 s = raw_input()
 t = raw_input()
 a = len(s)
 b = len(t)
 x = [0 for i in range(b+1)]
 for i in range(a):
   q = s[i]
   x2 = x1+[]
   for j in range(b):
    if (q ==t[j]):
     x[j+1] =x2[j]+1
    elif (x[j+1]<x2[j]+1):
      x[j+1] =x2[j]
 return x1[-1]
n = input()
for i2 in range(n):
 print edit_distance()

     

### FIXED CODE ###

def edit_distance():
 s = raw_input()
 t = raw_input()
 a = len(s)
 b = len(t)
 x = [0 for i in range(b+1)]
 for i in range(a):
   q = s[i]
   x2 = x+[]
   for j in range(b):
    if (q ==t[j]):
     x[j+1] =x2[j]+1
    elif (x[j+1]<x[j]):
     x[j+1] =x[j]
 return x[-1]

n = input()
for i2 in range(n):
 print edit_distance()
a, b, k = map(int, input().split())
num_list = list(range(a,b+1))
smaller = num_list[:k]
larger = num_list[-k:]
ans = smaller + larger
for i in range(k*2) :
    print(ans[i])


### FIXED CODE ###

a, b, k = map(int, input().split())
if (b-a+1) <= 2 * k :
    count = a
    while count <= b :
        print(count)
        count += 1
else :
    for i in range(k) :
        print(a+i)
    for i in range(k) :
        print(b-((k-1)-i))
w = list(input())
for i in w:
  if count.w(i) %2 == 1:
    print("No")
    break
print("Yes")
  

### FIXED CODE ###

import sys
w = list(input())
for i in w:
  if w.count(i) %2 == 1:
    print("No")
    sys.exit()
print("Yes")
a = input()
print(a+a*a+a*a*a)

### FIXED CODE ###

a = int(input())
print(a+a*a+a*a*a)
word = input().lower()
texts = []
while TRUE:
  str = input()
  if str == 'END_OF_TEXT':
    break
  texts.extend([s.lower() for s in str.split()] )
    

ans = texts.count(word)

print(ans)

### FIXED CODE ###

word = input().lower()
texts = []
while True:
  str = input()
  if str == 'END_OF_TEXT':
    break
  texts.extend([s.lower() for s in str.split()] )
    

ans = texts.count(word)

print(ans)
import sys
N=input()
for i in range(1,N+1):
  for j in range(1,N+1):
    if i<j:
      if i*j==N:
        print("Yes")
        sys.exit()
print("No")



### FIXED CODE ###

import sys
N=int(input())
for i in range(1,10):
  for j in range(1,10):
    if i<=j:
      if i*j==N:
        print("Yes")
        sys.exit()
print("No")
#ABC124_C
S=input()
 
S_rev=list(S)[::-1]
 
s=0
st0=0
st1=0
 
def bit_count(x):
    x=bin(x)[2:]
    ans=0
    for i in range(len(x)):
        if int(x[i])==1:
            ans+=1
    return ans
            
 
for i in range(len(S)):
    if i%2==0:
        st0+=2**i
    else:
        st1+=2**i
    if int(S_rev[i])==1:
        s+=2**i
 
cand0=st0^s
cand1=st1^s
 
    
bc0=bit_count(cand0)
bc1=bit_count(cand1)
if bc0>bc1:
    print(bc1)
else:
    print(bc0
    

### FIXED CODE ###

#124_C

S=input()

a=''
b=''

lenS=len(S)

for i in range(lenS):
    if i%2==0:
        a+='1'
        b+='0'
    else:
        a+='0'
        b+='1'
        
ca=0
cb=0
for i in range(lenS):
    if a[i]!=S[i]:
        ca+=1
    if b[i]!=S[i]:
        cb+=1
print(min(ca,cb))
import math
a,b,c,d = map(int,input().split())
AdivC = (a-1)//c
BdivC = b//c
AdivD = (a-1)//d
BdivD = b//d
gc = math.gcd(c,d)
div = (c*d)//gc
AdivCandD = (a-1)//div
BdivCandD = b//div

divC = BdivC - AdivC
divD = BdivD - AdivD
divCandD = BdivCandD - AdivCandD
ans = b-a+1
ans = ans -(divC+divD-divCandD)
print(ans)

### FIXED CODE ###

import fractions
a,b,c,d = map(int,input().split())
AdivC = (a-1)//c
BdivC = b//c
AdivD = (a-1)//d
BdivD = b//d
gc = fractions.gcd(c,d)
div = (c*d)//gc
AdivCandD = (a-1)//div
BdivCandD = b//div

divC = BdivC - AdivC
divD = BdivD - AdivD
divCandD = BdivCandD - AdivCandD
ans = b-a+1
ans = ans -(divC+divD-divCandD)
print(ans)
A,B=map(int,input().split())
count=0
for i in range(A,B+1):
    for j in i:
        array_j=list(map(int,str(j)))
        if array_j==reversed(array_j):
            count+=1
print(count)

### FIXED CODE ###

A,B=map(int,input().split())
count=0
for i in range(A,B+1):
        if str(i)==str(i)[::-1]:
            count+=1
print(count)
x,n=map(int,input().split())
try:
    p=list(map(int,input().split()))
    p.sort()
    min=abs(p[n-1])
    for i in range(p[0]-2*x,p[n-1]):
        if i not in p:
            if min>abs(i-x):
                min=abs(i-x)
                ans=i
except:
    ans=x

print(ans)

### FIXED CODE ###

x, n = map(int, input().split())
a = [int(x) for x in input().split()]
b = [i for i in range(0,102) if i not in a] 
b_tmp = list(map(lambda s:abs(s-x), b)) 
address = b_tmp.index(min(b_tmp))
print(b[address])
n, k, s = map(int, input().split())
if k == 0:
  print(' '.join([s + 1]*n))
else:
  first = [s]*k
  second = [s + 1]*(n - k)
  print(' '.join(first + second))

### FIXED CODE ###

n, k, s = map(int, input().split())
if k == 0:
    if s == 10**9:
        print(' '.join([str(s - 1)]*n))
    else:
        print(' '.join([str(s + 1)]*n))
else:
  first = [str(s)]*k
  if s == 1:
    second = [str(2)]*(n - k)
  else:
    second = [str(max(1, s - 1))]*(n - k)
  print(' '.join(first + second))
N, K = map(int, input().split())
h = input().split()
cnt = 0

for i in range(N):
  if h[i] >= K:
    cnt += 1
    
print(cnt)

### FIXED CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
cnt = 0
 
for i in range(N):
  if h[i] >= K:
    cnt += 1
    
print(cnt)
s=input()
if(s[-1:]=='s'):
  print(s[-1:].replace("s","es"))
else:
  s1=s+"s"
print(s1)

### FIXED CODE ###

s=input()
if(s[-1:]=='s'):
  s1=s+"es"
  print(s1)
else:
  s2=s+"s"
  print(s2)
N = int(input())
A = list(map (int, input().split()))
if 0 in A:
  print(0)
  return
 
re = 1
for i in range(N):
    re *= A[i]
    if re >= pow(10,18):
        print(-1)
        return
else:
    print(re)
    return

### FIXED CODE ###

a = int(input())
ar = list(map(int,input().split(" ")))
if 0 in ar:
    print(0)
    exit()
b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        exit()
print(b)
S, W = list(map(int, input().split()))
if S < W :
    print(unsafe)
if S > W :
    print(safe)

### FIXED CODE ###

S, W = list(map(int, input().split()))
if S <= W :
    print("unsafe")
if S > W :
    print("safe")
n, x = map(int, input().split())
l = list(map(int, input().split()))

cd = 0
for i in range(n):
    cd += l[i]
    if cd > x:
        ans = i + 1
        break

print(ans)

### FIXED CODE ###

n, x = map(int, input().split())
l = list(map(int, input().split()))

cd = 0
ans = n + 1 # xに到達しない場合

for i in range(n):
    cd += l[i]
    if cd > x:
        ans = i + 1
        break

print(ans)
x = int(input())
a = list(map(int,input().split()))
count = 0
flag = True
while flag:
    count += 1
    for i in range(x):
        if a[i]%2 == 0:
            a[i] = a[i]/2
        
        else:
            flag = False
            break
print(count-1)

### FIXED CODE ###

S = list(input())

print(S.count('1'))
T,X = map(int, input().split(" "))
print({T/X:.5f})

### FIXED CODE ###

T,X = map(int, input().split())
print(T/X)
s = input()
a = s/1000 
b = s/100 -(s/1000)*10 
c = s/10 -(s/100)*10 
d = s - (s/10)*10

if a*b > c*d:
    print a*b
elif c*d > a*b:
    print c*d
else:
    print a*b

### FIXED CODE ###

s = raw_input().split()
p= int(s[0]) 
q= int(s[1])
r= int(s[2])
s= int(s[3])
def area(a,b,c, d):
    if a*b > c*d:
        print a*b
    elif c*d > a*b:
        print c*d
    else:
        print a*b
x = area(p,q,r,s)
def II(): return int(input())
def LI(): return [int(i) for i in input().split()]

N, K = map(int, input().split())
H = map(int, input().split())

cost = [0] * N
cost[0] = 0
for n in range(1, N):
  cost[n] = min([ cost[n-k]+abs(H[n-k]-H[n]) for k in range(1, min(n+1, K+1)) ])

print(cost[-1])

#def main():
#    n, k = map(int, input().split())
#    h = list(map(int, input().split()))
#    a = [0] * n
#    a[0] = 0
#    for i in range(1, n):
#        a[i] = min([a[j] + abs(h[i] - h[j]) for j in range(max(0, i - k), i)])
#    print(a[-1])
 
#if __name__ == '__main__':
#    main()

### FIXED CODE ###

#  def II(): return int(input())
#def LI(): return [int(i) for i in input().split()]

#N, K = LI()
#H = LI()

#cost = [0] * N
#cost[0] = 0
#for n in range(1, N):
#  cost[n] = min([ cost[n-k]+abs(H[n-k]-H[n]) for k in range(1, min(n+1, K+1)) ])

#print(cost[-1])

def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * n
    a[0] = 0
    for i in range(1, n):
        a[i] = min([a[j] + abs(h[i] - h[j]) for j in range(max(0, i - k), i)])
    print(a[-1])
 
if __name__ == '__main__':
    main()
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break
    else:3 <= n < 100
    print([1 if sum(n, x) == x else 0 for i in input.combinations(range(1, n + 1), 3)])

### FIXED CODE ###

while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n - 1):
        for m in range(s + 1, n):
            for e in range(m + 1, n + 1):
                if x == sum([s, m, e]):
                    count += 1

    print(count)
import math
H,S = map(int,input().split())
i=1
if(H<=S):
  print(1)
elif(H>S):
  N = math.floor(H/S)
print(N)

### FIXED CODE ###

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

i = 0

while h > 0:
    h = h - a
    i += 1

print(i)