Harryxun/stf_run huggingface dataset:
import math

s=input()
k=int(input())

logk=math.log10(k)

ss=[]
for i in range(len(s)):
    if s[i]!="1":
        ss.append(int(s[i]))
    
n=5000*10000**3

logketa=n*math.log10(ss[0])
if logketa>logk:
    print(ss[0])
else:
    print(ss[1])


### FIXED CODE ###

import math

s=input()
k=int(input())

ss=[]
cont0=0
cont1=0
for i in range(len(s)):
    if s[i]!="1":
        ss.append(int(s[i]))
    else:
        if len(ss)==0:
            cont0=cont0+1
        else:
            cont1=cont1+1
        
k=k-cont0
    
n=5000*10000**3

if len(ss)==0:
    print(1)
elif k<=0:
    print(1)
else:
    logk=math.log10(k)

    logketa=n*math.log10(ss[0])
    if logketa>logk:
        print(ss[0])
    else:
        print(ss[1])
n = int(input())
A = list(map(int, input().split()))
 
ans = 1

if 0 in A:
  ans = 0
  break    
else:
  for i in A:
    ans = ans*i
    if ans > 10**18:
      ans = -1
      break
      
print(ans)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
 
ans = 1
 
if 0 in A:
  ans = 0
else:
  for i in A:
    ans = ans*i
    if ans > 10**18:
      ans = -1
      break
print(ans)
for i in range(0,7)
a,b=map(int,input(),split())
print(a-b)

### FIXED CODE ###

for i in range(7):
 a,b=map(int,input().split())
 print(a-b)
n,k=map(int,input().split())
a=list(map(int,input().split()))
d=[1]
t=a[0]
for i in range(1,k):
    d.append(t)
    if(a[t-1] in d):
        break
    t=a[t-1] 
idx=d.index(a[t-1])
d=d[idx:]
print(d[(k-i-1)%len(d)])

### FIXED CODE ###

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

s=[]
d=[-1]*(n+1)

v=1
while(d[v]==-1):
    d[v]=len(s)
    s.append(v)
    v=a[v-1]
c=len(s)-d[v]
l=d[v]

if(k<l):print(s[k])
else:
    k-=l
    k%=c
    print(s[k+l])
a, b = map(int, input().split())

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

g = gcd(a, b)

common = []
for i in range(1, int(g**0.5)+1):
    if g%i == 0:
        common.append(i)
        common.append(g//i)
    
import math
def Eratosthenes(n):
    if n < 2:
        return [1]
    prime = [1, 2]
    limit = math.ceil(n**0.5)
    data = list(range(3, n+1, 2))
    p = -1
    while p < limit:
        p = data[0]
        prime.append(p)
        data = [d for d in data if d%p != 0]
    return prime + data

prime = Eratosthenes(max(common))

print(len(set(common) & set(prime)))

### FIXED CODE ###

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
 
a, b = map(int, input().split())
print(len(set(prime_factorize(a)) & set(prime_factorize(b))) + 1)
import sys
sys.setrecursionlimit(10000)
s=input()
n=len(s)
def mod10(x):
    p=x//100
    q=x%100
    if p==0:
        return (10**q)%2019
    return (mod10(q)+mod10(p))%2019


def T(i):
    if i==n-1:
        return int(s[n-1])
    return T(i+1)+10**(n-1-i)*int(s[i])
dict={}
def modi(i,dict):
    if i in dict.keys():
        return dict[i]
    else:
        if i==n-1:
            dict[i]=int(s[i])
            return int(s[i])
        else:
           # c=modi(i+1,dict)+(10**(n-1-i)*int(s[i]))
            c=modi(i+1,dict)+(mod10(n-1-i)*int(s[i]))
            c=c%2019
            dict[i]=c
            return c

modnum={}
for i in range(n):
    #print(T(i))
    if int(s[i])==0:
        continue
    x=modi(i,dict)
 #   print(T(i),x)
    if x not in modnum.keys():
        modnum[x]=1
    else:
        modnum[x]+=1
sum=0
for md in modnum.keys():
    a=modnum[md]
    if md==0:
        sum+=a
        sum+=-(a*(a-1)//2)
   # print(a*(a-1)//2)
    sum+=a*(a-1)//2
#print(modnum)
print(sum)

### FIXED CODE ###

import sys
import collections as coun
sys.setrecursionlimit(10000000)
s=input()
n=len(s)
def mod10(x):
    return (10**(x%224))%2019
dp=[-1]*n
tmp=0
for i in reversed(range(n)):
    if i==n-1:
        dp[i]=int(s[i])
    else:
        dp[i]=(dp[i+1]+int(s[i])*pow(10,n-1-i,2019))%2019

#print(dp)
p=-1
for i in range(len(dp)-1):
    if dp[i]==dp[i+1]:
        dp[i]=p
        p=p-1

#print(dp)

c=coun.Counter(dp)
sum=0
for v in c.values():
    sum+=v*(v-1)//2
#print(sum)
for i in dp:
    if i==0:
        sum+=1
#print(sum)
if dp[-1]==0:
    sum=sum-1
print(sum)
N = int(input())
A = list(map(int, input().split()))
l = []
for i in range(N):
    l.append(0)
for x in A:
    l(x-1) += 1
for s in l:
    print(s)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    b.append(0)
for i in a:
    b[i-1]+=1
for i in b:
    print(i)
# -*- coding: utf-8 -*-

import math

A,B = input().split(" ")
s = str(input())

s_sp = s.split("-")

if (len(s_sp) != 2):
    print("No")
    exit

if (len(s_sp[0]) != int(A)) | (len(s_sp[1]) != int(B)):
    print("No")
    exit

if ((s_sp[0].isdigit()) & (s_sp[1].isdigit())):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

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

import math
import sys

A,B = input().split(" ")
s = str(input())

s_sp = s.split("-")

if (len(s_sp) != 2):
    print("No")
    sys.exit()

if (len(s_sp[0]) != int(A)) | (len(s_sp[1]) != int(B)):
    print("No")
    sys.exit()

if ((s_sp[0].isdigit()) & (s_sp[1].isdigit())):
    print("Yes")
else:
    print("No")
inp = input().split(" ")
a = inp[0]
b = inp[1]
 
c = (a - b) % 2 
if c == 0:
  abs_a = abs(a)
  abs_b = abs(b)
 
  m = (max(abs_a, abs_b) - min(abs_a, abs_b)) /2
  ans = max(abs_a, abs_b) - m
  print(int(ans))
else:
  print("IMPOSSIBLE")

### FIXED CODE ###

inp = input().split(" ")
a = int(inp[0])
b = int(inp[1])
 
c = (a - b) % 2 
if c == 0:
  abs_a = abs(a)
  abs_b = abs(b)
 
  m = (max(abs_a, abs_b) - min(abs_a, abs_b)) /2
  ans = max(abs_a, abs_b) - m
  print(int(ans))
else:
  print("IMPOSSIBLE")
from collections import deque

def bfs(maze, h, w, si, sj):
    q = deque([[si, sj]])
    score = [[0] * w for i in range(h)]

    pattern = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    while len(q) > 0:
        i, j = q.popleft()
        for move in pattern:
            ni, nj= i + move[0], j + move[1]
            if ni < 0 or h <= ni or nj < 0 or w <= nj:
                continue
            p = maze[ni][nj]
            if p == '#':
                continue
            if p == '.' and not score[ni][nj]:
                score[ni][nj] = score[i][j] + 1
                q.append([ni, nj])
    return max(sum(score, []))
  
h, w = map(int, input().split())
maze = [input() for i in range(h)]
scores = []
for si  in range(h):
    for sj in range(w):
        memo.append((si, sj))
        if maze[si][sj] == "#":
            continue
        scores.append(bfs(maze, h, w, si, sj))
print(max(scores))

### FIXED CODE ###

from collections import deque

def bfs(maze, h, w, si, sj):
    q = deque([[si, sj]])
    score = [[-1] * w for i in range(h)]
    score[si][sj] = 0
    pattern = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    while len(q) > 0:
        i, j = q.popleft()
        for move in pattern:
            ni, nj= i + move[0], j + move[1]
            if ni < 0 or h <= ni or nj < 0 or w <= nj:
                continue
            p = maze[ni][nj]
            if p == '#':
                continue
            if p == '.' and score[ni][nj] == -1:
                score[ni][nj] = score[i][j] + 1
                q.append([ni, nj])
    return max(map(max, score))

h, w = map(int, input().split())
maze = [input() for i in range(h)]
scores = []
for si in range(h):
    for sj in range(w):
        if maze[si][sj] == "#":
            continue
        scores.append(bfs(maze, h, w, si, sj))
print(max(scores))
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

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

### FIXED CODE ###

import fractions

def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)

a,b=map(int,input().split())
print(lcm(a,b))
n=int(input())
c=list(input())
numW=0
numR=c.count("R")
W=n-numR
a=[]
if numR==0 or W==0:
    print(0)
else:
    for i in range(n):
        if c[i]=="W":
            numW+=1
        else:
            numR-=1
        a.append(max(numR,numW))
print(min(a))

### FIXED CODE ###

n=int(input())
c=list(input())
numW=0
numR=c.count("R")
W=n-numR
a=[]
if numR==0 or W==0:
    print(0)
else:
    for i in range(n):
        if c[i]=="W":
            numW+=1
        else:
            numR-=1
        a.append(max(numR,numW))
    print(min(a))
H, N = map(int,input().split())
data = []

for i in range(N):
    data.append([0, 0])
    a, b = map(int,input().split())
    data[i][0] = a
    data[i][1] = b
data.sort
cost = [float("inf")] * (H + data[-1][0])
cost[0] = 0
for i in range(1, H + data[-1][0]):
    for magic in data:
        if i < magic[0]:
            break
        if cost[i] > cost[i - magic[0]] + magic[1]:
            cost[i] = cost[i - magic[0]] + magic[1]
print(min(cost[H:]))
print(2/0)

### FIXED CODE ###

H, N = map(int,input().split())
data = []

for i in range(N):
    data.append([0, 0])
    a, b = map(int,input().split())
    data[i][0] = a
    data[i][1] = b
data.sort(key=lambda x: x[0])
cost = [float("inf")] * (H + data[-1][0])
cost[0] = 0
for i in range(1, H + data[-1][0]):
    for magic in data:
        if i < magic[0]:
            break
        if cost[i] > cost[i - magic[0]] + magic[1]:
            cost[i] = cost[i - magic[0]] + magic[1]
print(min(cost[H:]))
n, m, k = map(int, input().split())

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

time = 0
count = 0
for _ in range(n + m):
    if len(a) > 0and len(b)>0:
        if a[-1] < b[-1]:
            time += a[-1]
            a = a[:-1]
        else:
            time += b[-i-1]
            b = b[:-1]
    elif len(a) == 0 and len(b) > 0:
        time += b[-1]
        b = b[:-1]
    elif len(b) == 0 and len(a) > 0:
        time += a[-1]
        a = a[:-1]
    if time > k:
        break
    else:
        count += 1
        
        
print(count)

### FIXED CODE ###

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

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

a, b = [0], [0]
for  i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i] + B[i])

ans, j = 0, m
for i in range(n+1):
    if a[i]>k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
 
assert K == 3
assert N < 100
 
print(114514)

### FIXED CODE ###

input_line = input().split()

num_array = int(input_line[0])
num_equal = int(input_line[1])

input_line = input() # 無視

equalized = 1
i = 0
while equalized < num_array:
    equalized += (num_equal - 1)
    # print(i, equalized)
    i += 1

print(str(i))
H, W = input().split()
array = list()
header = ""
for i in range(H):
    array[i] = "#" + input() + "#"
for i in range(0, W+2):
    header += "#"
    
print(header)
for p in array:
    print(p)
print(header)



### FIXED CODE ###

H, W = map(int, input().split())
array = list()
header = ""
for i in range(0, H):
    array.append("#" + input() + "#")
for i in range(0, W + 2):
    header += "#"

print(header)
for p in array:
    print(p)
print(header)
a = int(input())
print(3*(a**2)

### FIXED CODE ###

a = int(input())
print(3*(a*a))
def sakujo();
seq1 = raw_input()
seq2 = raw_input()

a, b = len(seq1), len(seq2)
x1 = [0 for i in range(b+1)]
for i in range(a):
e1 = seq1[i]
x2 = x1+[]
for j in range(b):
if e1 == seq2[j]:
x1[j+1] = x2[j] + 1
elif x1[j+1] < x1[j]:
x1[j+1] = x1[j]
return x1[-1]


n=input()
for ix in range(n):
def sakujo

### FIXED CODE ###

def longest():
    alps1 = raw_input()
    alps2 = raw_input()
    
    x, y = len(alps1), len(alps2)
    k = [0 for i in range(y+1)]
    for i in range(x):
        e1 = alps1[i]
        l = k+[]
        for j in range(y):
            if e1 == alps2[j]:
                k[j+1] = l[j] + 1
            elif k[j+1] < k[j]:
                k[j+1] = k[j]
 
    return k[-1]
    
n = input()
for i in range(n):
    print longest()
#A-Harmony
X=map(int, input().split())
K=(X[0]+X[1])/2
if (X[0]+X[1])%2==0:
    print(K)
else:
    print("IMPOSSIBLE")

### FIXED CODE ###

#A-Harmony
X=list(map(int, input().split()))
K=(X[0]+X[1])/2
if (X[0]+X[1])%2==0:
    print(int(K))
else:
    print("IMPOSSIBLE")
def merge(A, left, mid, right, c):
    n1 = mid - left
    n2 = right - mid
    L = [0]*(n1+1)
    R = [0]*(n2+1)
    for i in range(n1):
        L[i] = A[left + i]
    for i in range(n2):
        R[i] = A[mid + i]
    L[n1] = float("inf")
    R[n2] = float("inf")
    i = 0
    j = 0
    for k in range(left,right): 
        if L[i] <= R[j]:
            c = c+1
            A[k] = L[i]
            i = i + 1
        else:
            c = c+1
            A[k] = R[j]
            j = j + 1

def mergeSort(A, left, right, c):
  if left+1 < right:
    mid = (left + right)//2;
    mergeSort(A, left, mid, c)
    mergeSort(A, mid, right, c)
    merge(A, left, mid, right, c)
    
### Main Function
n = int(input())
S = list(map(int,input().split()))


mergeSort(S, 0, n, c)

print(S)
print(c)



### FIXED CODE ###

def merge(A,left,mid,right):
    n1=mid-left
    n2=right-mid
    L = A[left:mid]
    R = A[mid:right]
    L.append(float("inf"))
    R.append(float("inf"))
    """
    L=[0]*(n1+1)
    R=[0]*(n2+1)
    for i in range(n1):
        L[i]=A[left+i]
    for i in range(n2):
        R[i]=A[mid+i]
    L[n1]=float("inf")
    R[n2]=float("inf")
    """
    i=0
    j=0
    for k in range(left,right):
        global cnt
        cnt+=1
        if L[i]<=R[j]:
            A[k]=L[i]
            i=i+1
        else:
            A[k]=R[j]
            j=j+1

def mergeSort(A,left,right):
    if left+1<right:
        mid=(left+right)//2
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)

n=int(input())
S=list(input().split())
for i in range(n):
    S[i]=int(S[i])
cnt=0
mergeSort(S,0,n)
for i in range(n):
    if i==n-1:
        print(S[i])
    else:
        print(S[i],end=" ")
print(cnt)
def get_map():
  map = []
  while True:
    try:
      tmp = list(raw_input())
      if len(tmp) != 12: break
      map.append(tmp)
    except:
      break
  return map
def remove_island(x, y, map):
  map[x][y] = 0
  move = [[1, 0], [0, 1], [-1, 0], [0, -1]]
  for i, j in move:
    if 0 <= x + i <= 11 and 0 <= y + j <= 11 and map[x + i][y + j] == '1':
      map = remove_island(x + i, y + j, map)
  return map[:]
while True:
  map = get_map()
  if len(map) != 12: break
  count = 0
  for x in range(12):
    for y in range(12):
      if map[x][y] == '1':
        count += 1
        map = remove_island(x, y, map)
  print count


### FIXED CODE ###

def counter():#島の数をカウントする
    count=0
    #12*12個の値をひとつずつ調べる
    for x in range(len(is_data)):
        for y in range(len(is_data)):
            if is_data[x][y] == '1':#島が発見されたら
                dfs(x,y)
                count+=1
    return count
def dfs(x,y):
    if x<0 or x == len(is_data) or y<0 or y == len(is_data):
        return
    if is_data[x][y] == '1':
        is_data[x][y] = '0'
        dfs(x+1,y)
        dfs(x,y+1)
        dfs(x-1,y)
        dfs(x,y-1)

is_data=[]
while True:
    try:
        s = list(input())#入力
        if not s:#空入力のとき
            print(counter())
            is_data=[]
            s = []
        else:
            is_data.append(s)
    except EOFError:
        print(counter())
        break
n = input()
a = map(int, raw_input().split())
   
for i in range(0, n):
   print a(n-i-1),

### FIXED CODE ###

n = input()
a = map(int, raw_input().split())
    
for i in range(0, n):
   print a[n-i-1],
# AOJ ITP1_8_C

def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    counts = []
    for i in range(26): counts.append(0)

    while(string = input()):
        for i in len(string):
            c = string[i]
            if 97 <= ord(c) <= 122:
                counts[ord(c) - 97] += 1
            elif 65 <= ord(c) <= 90:
                counts[ord(c) - 65] += 1

    # 結果を出力。
    for i in range(26):
        print(chr(97 + i) + " : " + str(counts[i]))

if __name__ == "__main__":
    main()


### FIXED CODE ###

# AOJ ITP1_8_C

import sys

def main():
    counts = []
    for i in range(26): counts.append(0)

    lines = sys.stdin.readlines()

    for i in range(len(lines)):
        string = lines[i]
        for k in range(len(string)):
            c = string[k]
            if 97 <= ord(c) <= 122:
                counts[ord(c) - 97] += 1
            elif 65 <= ord(c) <= 90:
                counts[ord(c) - 65] += 1

    # 結果を出力。
    for i in range(26):
        print(chr(97 + i) + " : " + str(counts[i]))

if __name__ == "__main__":
    main()

# Accepted.
N,X = map(int,input().split())
mi=[int(input()) for _ in range(N)]
  
print(N+(X-sum(mi))//min(mi))

### FIXED CODE ###

inp = input()
print(inp.count("1"))
A = input()
B = len(A)
print(x*B)

### FIXED CODE ###

A = input()
B = len(A)
print("x"*B)
num = int(input())
 
s1,s2 = input().split()
 
ans = ''
 
for i in range(num):
	ans = ans + s1[i]
	ans = ans + s2[i]
    
print(ans)

### FIXED CODE ###

number1 = int(input())
number2 = int(input())

n_list = [1,2,3]

n_list.remove(number1)
n_list.remove(number2)

print(n_list[0])
daude = input()
daude1 = input()
return daude == daude1[:-1]

### FIXED CODE ###

daude1 = input()
daude2 = input()
if daude1 == daude2[:-1]:
    print('Yes')
else:
    print('No')
m1, d1 = map(int, input().split())
    m2, d2 = map(int, input().split())
    if m1 == m2:
      print('0')
    else:
      print('1')

### FIXED CODE ###

m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())
if m1 == m2:
    print('0')
else:
    print('1')
a, b, c = map(int, input().split())

if a < b and b < c:
    print "Yes"
else:
    print "No" 

### FIXED CODE ###

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

if (a < b < c):
    print "Yes"
else:
    print "No"
N, M = map(int, input().split())

tree = [[] for i in range(N+1)]
for i in range(N-1):
  x, y = map(int, input().split())
  tree[x].append(y)
  tree[y].append(x)

dp1 = [0] * (N+1)
dp2 = [0] * (N+1)
parents = [-1] * (N+1)
leaf_nodes = []

def solve1(node, parent):
  global dp1
  global parents
  global leaf_nodes
  parents[node] = parent
  if dp1[node] > 0:
    return dp1[node]
  else:
    children = tree[node]
    t = 1
    for child in children:
      if child == parent:
        continue
      
      t *= (solve1(child, node) + 1)
      t %= M
    
    if t == 1:
      leaf_nodes.append(node)
    
    dp1[node] = t
    return t


def solve2(node):
  global dp2
  global parents
  parent = parents[node]
  if dp2[node] > 0:
    return dp2[node]
  else:
    children = tree[node]
    t = 1
    for child in children:
      if child == parent:
        t *= (solve2(parent)//(dp1[node] + 1) + 1)
        t %= M
      else:
        t *= (dp1[child] + 1)
        t %= M
    
    dp2[node] = t
    return t
  

_ = solve1(1, 0)
for leaf in leaf_nodes:
  _ = solve2(leaf)

print(*dp2[1:], sep='\n')

### FIXED CODE ###

# 参考 -> https://atcoder.jp/contests/dp/submissions/8271798

import itertools
import sys
input = sys.stdin.readline

N, MOD = map(int, input().split())
XY = [list(map(int, input().split())) for i in range(N-1)]
prod = lambda x, y: x*y%MOD

tree = [[] for i in range(N)]
for x, y in XY:
  tree[x-1].append(y-1)
  tree[y-1].append(x-1)

root = 0
parent = [-1] * (N+1)
order = []
stack = [root]
while stack:
  node = stack.pop()
  order.append(node)
  for child in tree[node]:
    if child == parent[node]:
      continue
    parent[child] = node
    stack.append(child)

# dp_down[i] : 頂点iを黒く塗ったときの子側の塗り方
dp_down = [0] * N
for node in order[::-1]: # 葉から根に向かって伝搬させる
  res = 1
  for child in tree[node]:
    res *= dp_down[child] + 1
    res %= MOD
  dp_down[node] = res

# dp_up[i] : 頂点iを黒く塗ったときの親側の塗り方
dp_up = [1] * N
for node in order: # 根から葉に向かって伝搬させる
  par = parent[node]
  arr = [dp_down[c]+1 if c!=par else dp_up[node] for c in tree[node]]
  # それぞれの子(=c)について、自身を根とする下側の部分木を除いた積
  left = [1] + list(itertools.accumulate(arr, prod))[:-1]
  right = list(itertools.accumulate(reversed(arr), prod))[-2::-1] + [1]
  upper_cases = [l*r%MOD for l, r in zip(left, right)]
  for c, res in zip(tree[node], upper_cases):
    if c != par:
      dp_up[c] = res + 1 # (+1 : cより上側が全て白である場合を足し合わせる)

ans = [d*u%MOD for d, u in zip(dp_down, dp_up)]
print(*ans, sep='\n')
import math
a,b=map(int,input().split())
print(a*b//math.gcd(a,b))

### FIXED CODE ###

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

a,b=map(int,input().split())
print(a*b//gcd(a,b))
import numpy as np
import math
a, b = map(int, input().split())
gcd = np.gcd(a, b)

def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass, is_prime

ass, is_prime = primes(gcd)
is_prime[1] = True

ans = 0
for p, isprime in enumerate(is_prime):
    
    if p == 0:
        continue
    if is_prime[p] == True and a%p==0 and b%p==0:
#         print(p, isprime)
        ans += 1
print(ans)

### FIXED CODE ###

import numpy as np
a, b = map(int, input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
n = gcd(a, b)

table = []
i = 2
while i*i <= n:
    if n%i == 0:
        table.append(i)
        n //= i
    else:
        i += 1
if n > 1:
    table.append(n)

print(len(set(table))+1)
N,K=list(map(int,input().split()))
A=list(map(int,input().split()))

INF=float("inf")

dp=[INF]*N

for i in range(0, N-1):
  for k in range(1, K+1):
    if i+k <= N-1:
      dp[i+k]=min(dp[i+k],dp[i]+abs(A[i]-A[i+k]))
print(dp[N-1])


### FIXED CODE ###

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

def solve():
    N = int(input())
    H = list(map(int, input().split()))

    INF = 10**4+10
    dp = [INF]*(N+10)
    dp[0] = 0
    dp[1] = abs(H[1] - H[0])
    for i in range(2, N):
        dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2]))
    
    print(dp[N-1])


if __name__ == "__main__":
    solve()
for i in range(1,10):
    for j in range(1,10):
        print "".join([i,"x",j,"=",i*j])

### FIXED CODE ###

for i in range(1,10):
    for j in range(1,10):
        print str(i) + "x" + str(j) + "=" + str(i*j)
def lineFromPoints(P,Q): 
  
    a = Q[1] - P[1] 
    b = P[0] - Q[0]  
    c = a*(P[0]) + b*(P[1])  
  
    if(b<0):  
        print("The line passing through points P and Q is:", 
              a ,"x ",b ,"y = ",c ,"\n")  
    else: 
        print("The line passing through points P and Q is: ", 
              a ,"x + " ,b ,"y = ",c ,"\n")  
  
if __name__=='__main__': 
    n = int(input("Enter size of array:")) 
    P=[]
    Q=[]
    for i in range(n): 
        temp = int(input('Enter number to add to P:\n')) 
        P.append(temp)
    for i in range(n): 
        temp = int(input('Enter number to add to Q:\n')) 
        Q.append(temp)
     
    lineFromPoints(P,Q)  

### FIXED CODE ###

import math
N,D= map(int, input().split(" "))
count = 0
for i in range(0,N):
    X,Y= map(int, input().split(" "))
    d= math.sqrt(pow(X,2)+pow(Y,2))
    if d<= D:
        count = count+1
print(count)
n = int(input())
k = int(input())

if k == 1:
    print("0")

else:
    print(n - k)

### FIXED CODE ###

x = input().split()
n = int(x[0])
k = int(x[1])

if k == 1:
    print("0")

else:
    print(n - k)
N,M=map(int,input().split())
A=list(map(int, input().split()))

list.sort(A,reverse=True)

sumnum = sum(A)

if A[M] > (sumnum/(4*M)):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

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

list.sort(A,reverse=True)

sumnum = sum(A)
if A[M-1] >= (sumnum/(4*M)):
    print("Yes")
else:
    print("No")