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


def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n,k=n1()
H=n1()

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

print(dp[n-1])

### FIXED CODE ###


def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n,k=n1()
H=n1()

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

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

def main():
  n,*a=map(int,open(0).read().split())
  c=0
  for i in range(61):
    i=2**i
    t=sum(i&b>0for b in a)
    c=(c+t*(n-t)*i)%(10**9+7)
  print(c)
main()

### FIXED CODE ###

n,*a=map(int,open(0).read().split())
b=[0]*61
for c in a:
  for i in range(61):b[i]+=2**i&c>0
print(sum(2**i*c*(n-c)for i,c in enumerate(b))%(10**9+7))
### BUGGY CODE ###

lastday=[-1]*26
def last(d):
  sum=0
  for i in range(26):
    sum+=c[i]*(d-lastday[i])
  return sum

def myFunc(i,Score,depth,lastday):
  tmp_score=Score
  tmp_max_choice=0
  tmp_score-=last(i)
  tmp_max_score=tmp_score
  tmp_deep_score=tmp_score
  
  for k,j in enumerate(s[i]):
    if depth==0 or i==D-1:      
      if tmp_max_score<tmp_score+j+c[k]*(i-lastday[k]):
        tmp_max_choice=k
        tmp_max_score=tmp_score+j+c[k]*(i-lastday[k])
    else:
      l=lastday.copy()
      l[k]=i
      score,choice=myFunc(i+1,tmp_score+j+c[k]*(i-lastday[k]),depth-1,l)
      if tmp_deep_score<score:
        tmp_max_choice=k
        tmp_max_score=tmp_score+j+c[k]*(i-lastday[k])
        tmp_deep_score=score

  return tmp_max_score,tmp_max_choice

D=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(D):
  s.append(list(map(int,input().split())))
Score=0
for i in range(D):
  score,choice=myFunc(i,Score,2,lastday)
  Score=score
  lastday[choice]=i
  print(choice+1)


### FIXED CODE ###

for i in range(365):
  print(i%26+1)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))
IJK = [0,0,0]
for i in range(N):
    IJK[a[i]-1]+=1

dp = [[[0]*(N+3) for _ in range(N+3)] for _ in range(N+3)]

for k in range(N+1):
    for j in range(N+1):
        for i in range(N+1):
            if i+j+k > N: continue
            if i+j+k == 0: continue
            dp[i][j][k] += N
            if i>0: dp[i][j][k] += i*dp[i-1][j][k]
            if j>0: dp[i][j][k] += j*dp[i+1][j-1][k]
            if k>0: dp[i][j][k] += k*dp[i][j+1][k-1]
            dp[i][j][k]/=(i+j+k)
print(dp[IJK[0]][IJK[1]][IJK[2]])




### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))
IJK = [0,0,0]
for i in range(N):
    IJK[a[i]-1]+=1

dp = [[[0.0]*(N+3) for _ in range(N+3)] for _ in range(N+3)]

for k in range(N+1):
    for j in range(N+1):
        for i in range(N+1):
            if i+j+k > N: continue
            if i+j+k == 0: continue
            tmp = 1.0*N
            if i>0: tmp += i*dp[i-1][j][k]
            if j>0: tmp += j*dp[i+1][j-1][k]
            if k>0: tmp += k*dp[i][j+1][k-1]
            dp[i][j][k] = tmp/(i+j+k)
print(dp[IJK[0]][IJK[1]][IJK[2]])
### BUGGY CODE ###

from functools import reduce
from operator import mul

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

ans = reduce(mul,List)
print(ans if ans<=10**18 else -1)

### FIXED CODE ###

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

List.sort()
ans = 1
for i in List:
    ans *= i
    if ans > 10**18:
        print(-1)
        break
else:
    print(ans)
### BUGGY CODE ###

n,m = map(int,input().split())
ls = list(map(int,input().split()))
dir = [list(map(int,input().split())) for _ in range(m)]
k = 0
for i in range(1,n+1):
    new = [e for e in dir if i in e]
    if new == []:
        k += 1
    else:
        for j in range(len(new)):
            if new[j][0] != i:
                (new[j][0],new[j][1]) = (new[j][1],new[j][0])
            if ls[i-1]<=ls[new[j][1]-1]:
                break
        else:
            k += 1
print(k)
                


### FIXED CODE ###

n,m = map(int,input().split())
ls = list(map(int,input().split()))
pos = [1]*(n)
for i in range(m):
    a,b = map(int,input().split())
    if ls[a-1] > ls[b-1]:
        pos[b-1] = 0
    elif ls[a-1] < ls[b-1]:
        pos[a-1] = 0
    else:
        pos[a-1] = 0
        pos[b-1] = 0
print(sum(pos))
### BUGGY CODE ###

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

n,m = mapinput()
rootlist = []
delist = []
flag = [False for i in range(n)]
for i in range(m):
    rootlist.append(list(mapinput()))

que = [1]
while len(que) != 0:
    for root in rootlist:
        if que[0] in root:
            for i in [j for j in root if j != que[0]]:
                if flag[i-1]:
                    break
                else:
                    flag[i-1] = que[0]
                    que.append(i)

    for root in delist:
        rootlist.remove(root)
    delist = []
    que.pop(0)


print('Yes')
for i,root in enumerate(flag):
    if i == 0:
        continue
    print(root)


### FIXED CODE ###

from collections import deque

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

n,m = mapinput()
rootlist = [[] for i in range(n)]
flag = [False for i in range(n)]

for i in range(m):
    a,b= mapinput()
    rootlist[a-1].append(b)
    rootlist[b-1].append(a)

que = deque()
que.append(1)
while len(que) !=0:
    now = que.popleft()
    for room in rootlist[now-1]:
        if flag[room-1] == False:
            flag[room-1] = now
            que.append(room)

print('Yes')
for i,root in enumerate(flag):#スライスで実装
    if i == 0:
        continue
    print(root)
### BUGGY CODE ###

import bisect
def main():
    n=int(input())
    l=sorted(list(map(int,input().split(' '))))
    ans = 0
    for n,i in enumerate(l):
        for m,j in enumerate(l[n+1:]):
                ans +=bisect.bisect_left(l,i+j) - bisect.bisect_right(l,abs(i-j))
                if abs(i-j)<i<i+j:
                    ans -=1
                if abs(i-j)<j<i+j:
                    ans -=1
    print(ans//3)
if __name__ == '__main__':
    main()


### FIXED CODE ###

import bisect
def main():
    n=int(input())
    l=sorted(list(map(int,input().split(' '))))
    ans = 0
    for n,i in enumerate(l):
        for m,j in enumerate(l[n+1:]):
                ans +=bisect.bisect_left(l,i+j) - bisect.bisect_right(l,abs(i-j))
                if abs(i-j)<i<i+j:
                    ans -=1
                if abs(i-j)<j<i+j:
                    ans -=1
    print(ans//3)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

from collections import deque

n, m = map(int, input().split())
uv  =[[] for _ in range(n)]
for _ in range(m):
    u, v = map(int, input().split())
    uv[u - 1].append(v - 1)
s, t = map(int, input().split())
s -= 1
t -= 1
uv3 = [[] for _ in range(n)]

for i, lst in enumerate(uv):
    for j in lst:
        lst2 = uv[j]
        for k in lst2:
            lst3 = uv[k]
            for l in lst3:
                uv3[i].append(l)
queue = deque()
queue.append(s)
queue.append(1)
check = [False for _ in range(n)]
check[s] = True

while queue:
    pos = queue.popleft()
    ans = queue.popleft()
    for next_pos in uv3[pos]:
        if next_pos == t:
            print(ans)
            exit()
        if check[next_pos]:
            continue
        check[next_pos] = True
        queue.append(next_pos)
        queue.append(ans + 1)
print(-1)
    

### FIXED CODE ###

from collections import deque

n, m = map(int, input().split())
uv  =[[] for _ in range(n)]
for _ in range(m):
    u, v = map(int, input().split())
    uv[u - 1].append(v - 1)
s, t = map(int, input().split())
s -= 1
t -= 1

queue = deque()
queue.append(s)
queue.append(1)
queue.append(0)
check = [[False for _ in range(3)] for _ in range(n)]
check[s][0] = True

while queue:
    pos = queue.popleft()
    ans = queue.popleft()
    kkp = queue.popleft()
    for next_pos in uv[pos]:
        if next_pos == t and kkp == 2:
            print(ans // 3)
            exit()
        if check[next_pos][(kkp + 1) % 3]:
            continue
        check[next_pos][(kkp + 1) % 3] = True
        queue.append(next_pos)
        queue.append(ans + 1)
        queue.append((kkp + 1) % 3)
print(-1)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(4100000)

N, Q = map(int,input().split())
edge = [[] for i in range(N+1)]

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

subtree = [[] for i in range(N+1)]

def dfs(parent,i):
    if [parent] == edge[i]:
        subtree[i].append(i)
        return subtree[i]
    for k in edge[i]:
        if k != parent:
            subtree[i].extend(dfs(i,k))
    subtree[i].append(i)
    return subtree[i]
        
dfs(-1,1)

ans = [0 for i in range(N)]

for i in range(Q):
    p, x = map(int,input().split())
    for i in subtree[p]:
        ans[i-1] += x

print(*ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
 
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
 
value = [0] * (N+1)
for p,x in PX:
    value[p] += x

def dfs(parent,i,add):
    for k in graph[i]:
        if k != parent:
            value[k] += add
            dfs(i,k,value[k])
    

dfs(0,1,value[1])

ans = value[1:]

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

import numpy as np
m = 10**9 + 7
n = int(input())
an = list(map(int, input().split()))

row = np.array([])
col = np.array([])
summary = 0
for i in range(0, n-1):
    for j in range(i+1, n):
        row = np.append(row, an[i])
        col =  np.append(col, an[j])
print(int(np.dot(row, col) % m))

### FIXED CODE ###

m = 10**9 + 7
n = int(input())
an = list(map(int, input().split()))
wa = []
total = 0
for i in reversed(range(1, len(an))):
    total = total + an[i]
    wa.append(total)
wa = sorted(wa, reverse=True)
ans = 0
for i in range(0, n-1):
#     print(an[i] * wa[i])
    ans = ans + an[i] * (wa[i]%m)
    ans = ans % m
print(ans)
### BUGGY CODE ###

l,n=map(int,input().split())
tree=[int(input()) for i in range(n)]
def solve(i):
  tree_copy=[i for i in tree]
  if i!=0:
    del tree_copy[:i-1]
  ans=tree_copy.pop(0)
  stack=ans
  flag=False
  while len(tree_copy)>0:
    if flag:
      ans+= stack + tree_copy[0]
      stack= tree_copy.pop(0)
      flag=False
    else:
      ans+= stack + (l-tree_copy[-1])
      stack= l-tree_copy.pop(-1)
      flag=True
  return ans
got=0
for i in range(n):
  got=max(got,solve(i))
tree=[l-i for i in reversed(tree)]
for i in range(n):
  got=max(got,solve(i))
print(got)

### FIXED CODE ###

import sys
from collections import deque
l,n=map(int,input().split())
c=n
tree1=[int(i) for i in sys.stdin]
reversed_tree1=[l-i for i in reversed(tree1)]
tree=deque(tree1)
reversed_tree=deque(reversed_tree1)
if n%2 == 0:
  ans= sum(tree1)*2 + l*(n-1) +tree1[n//2] - sum(tree1[n//2:])*4
  ans2= sum(reversed_tree1)*2 + l*(n-1) +reversed_tree1[n//2] - sum(reversed_tree1[n//2:])*4
  n-=1
  c-=1
  ans3= ans-tree.popleft()*2-l+tree[n//2]*2
  ans= max(ans,ans3)
  ans4= ans2-reversed_tree.popleft()*2-l+(reversed_tree[n//2])*2
  ans2= max(ans2,ans4)
else:
  ans= sum(tree1)*2 + l*(n-1) - tree1[n//2] - sum(tree1[((n//2)+1):])*4
  ans3=ans
  ans2= sum(reversed_tree1)*2 + l*(n-1) - reversed_tree1[n//2] - sum(reversed_tree1[((n//2)+1):])*4
  ans4=ans2
for i in range(n//2):
  n-=1
  ans_stack= ans3-tree.popleft()*2-l+tree[(n-1)//2]+tree[(n+1)//2]
  ans= max(ans_stack,ans)
  ans3=ans_stack
  n-=1
  ans_stack= ans3-tree.popleft()*2-l+tree[n//2]*2
  ans=max(ans_stack,ans)
  ans3=ans_stack
n=c
for i in range(n//2):
  n-=1
  ans_stack= ans4-reversed_tree.popleft()*2-l+reversed_tree[(n-1)//2]+reversed_tree[(n+1)//2]
  ans2=max(ans_stack,ans2)
  ans4=ans_stack
  n-=1
  ans_stack= ans4-reversed_tree.popleft()*2-l+reversed_tree[n//2]*2
  ans2=max(ans2,ans_stack)
  ans4=ans_stack
print(max(ans,ans2))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import heapq

n,m,s,t = map(int, input().split())
s -= 1
t -= 1
e = [[] for _ in range(n)]
for _ in range(m):
    v,u,a,b = map(int, input().split())
    v -= 1
    u -= 1
    e[v].append((u,(a,b)))
    e[u].append((v,(a,b)))


def dijkstra(s,cu):
    inf = 10**18
    d = [inf]*n
    d[s] = 0
    q = [s]
    heapq.heapify(q)

    while len(q)>0:
        v = heapq.heappop(q)
        for u,ud in e[v]:
            if d[u]<=d[v]+ud[cu]:
                continue
            d[u] = d[v] + ud[cu]
            heapq.heappush(q, u)
    return d


da = dijkstra(s,0)
db = dijkstra(t,1)
res = [0]*n
res[n-1] = da[n-1]+db[n-1]
for i in range(n-2,-1,-1):
    res[i] = min(res[i+1], da[i]+db[i])

x = 10**15
for i in range(n):
    print(x - res[i])

### FIXED CODE ###

# -*- coding: utf-8 -*-
import heapq
n,m,s,t = map(int, input().split())
g = [[] for _ in range(n+1)]
for _ in range(m):
    u,v,a,b = map(int, input().split())
    g[u].append((v,(a,b)))
    g[v].append((u,(a,b)))

inf = 10**18
def dijkstra(s, currency):
    d = [inf]*(n+1)
    d[s] = 0

    que = [(d[s],s)]
    heapq.heapify([que])
    while len(que)>0:
        _,v = heapq.heappop(que)
        for u,c in g[v]:
            if d[v]+c[currency]>=d[u]:
                continue
            d[u] = d[v]+c[currency]
            heapq.heappush(que, (d[u], u))
    return d

yen_c = dijkstra(s,0)
snuuk_c = dijkstra(t,1)

res = [0]*n
res[n-1] = yen_c[n] + snuuk_c[n]
for i in range(n-2,-1,-1):
    res[i] = min(res[i+1], yen_c[i+1]+snuuk_c[i+1])

for r in res:
    print(10**15-r)
### BUGGY CODE ###

n = int(input())
prices = [int(input()) for i in range(n)]
ans = 1 - (10 ** 9)
for x in range(n-1):
    for y in range(x+1, n):
        ans = max(ans, prices[y] - prices[x])
print(ans)



### FIXED CODE ###

n = int(input())
min_v = int(input())
ans = 1 - min_v
for i in range(1, n):
    j = int(input())
    ans = max(ans, j - min_v)
    min_v = min(min_v, j)
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10000000)
s=input()
n=len(s)
def mod10(x):
    p=x//10000000
    q=x-10000000*p
    if p==0:
        return (10**q)%2019
    return ((10**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)
### BUGGY CODE ###

numbers = input().split()
x = input().split()
y = input().split()
z = input().split()


x.sort(reverse=True)
y.sort(reverse=True)
z.sort(reverse=True)

answer = []

for i in x:
    for j in y:
        for k in z:
            price = int(i)+int(j)+int(k)
            answer.append(price)

answer.sort(reverse=True)
del answer[int(numbers[3])::]

for l in answer:
    print(l)


### FIXED CODE ###

numbers = input().split()
x = input().split()
y = input().split()
z = input().split()

k = int(numbers[3])

answer = []
for i in x:
    for j in y:
        price = int(i)+int(j)
        answer.append(price)
answer.sort(reverse=True)
del answer[k::]
f_ans = []
for m in answer:
    for n in z:
        price = m + int(n)
        f_ans.append(price)

f_ans.sort(reverse=True)
del f_ans[k::]

for l in f_ans:
    print(l)
### BUGGY CODE ###

H = int(input())
i = 1
result = 0

while True:
    H //= 2
    result += 2**i
    i += 1
    if H == 1:
        break

print(result+1)

### FIXED CODE ###

H = int(input())
i = 0
result = 0
 
while True:
    result += 2**i
    H //= 2
    i += 1
    if H == 0:
        break
 
print(result)
### BUGGY CODE ###

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

output = 1
if a[0] != 0:
    print(0)
elif max(a) == 1:
    print(1)
else:
    for i in range(2, max(a)+1):
        if a.count(i) != 0:
            output *= a.count(i-1)**a.count(i)
            output %= 998244353
    print(output)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
cnt = [0]*n
for i in a:
    cnt[i] += 1

output = 1
if a[0] != 0 or cnt[0] != 1:
    print(0)
elif max(a) == 1:
    print(1)
else:
    for i in range(2, n):
        output *= cnt[i-1]**cnt[i]
        output %= 998244353
    print(output)
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
keiro = [1]
flag = True
now = 1
start = 0
loopN = 0
loop_list = []
not_loop = False
for i in range(N):
    now = A[now - 1]
    if now in keiro:
        # flag = False
        start = keiro.index(now)
        loop_list = keiro[start:]
        loopN = len(loop_list)
        break
    else:
        keiro.append(now)
    if len(keiro) > K:
        not_loop = True
        break
if not_loop:
    print(keiro[K])
elif K - start >= 0:
    print(loop_list[(K - start) % loopN])
else:
    print(keiro[K])


### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
keiro = [1]
keiro_set = {1}
flag = True
now = 1
start = 0
loopN = 0
loop_list = []
not_loop = False
for i in range(N):
    now = A[now - 1]
    if now in keiro_set:
        start = keiro.index(now)
        loop_list = keiro[start:]
        loopN = len(loop_list)
        break
    else:
        keiro.append(now)
        keiro_set.add(now)
    if i + 2 > K:
        not_loop = True
        break
if not_loop:
    print(keiro[K])
elif K - start >= 0:
    print(loop_list[(K - start) % loopN])
else:
    print(keiro[K])
### BUGGY CODE ###

A, B, C, D = map(int, input().split())
num = 0
for i in range(A, B+1):
    if i % C != 0 and i % D != 0:
        num += 1
print(num)


### FIXED CODE ###

A, B, C, D = map(int, input().split())
def gcd(a, b):
    if a < b:
        a, b = b, a
    a, b = b, a % b
    if b == 0 :
        return a
    else:
        return gcd(a, b)
cd = C * D //gcd(C, D)
print(B - B // C - B // D + B // cd - A + 1 + (A - 1) // C + (A - 1)// D - (A - 1)// cd)
### BUGGY CODE ###

N=int(input())
cnt=0
for i in range(1,N+1):
    s=str(i)
    if "3" in s and "5" in s and "7" in s:
        if len(set(s))==3:
            cnt+=1
print(cnt)


### FIXED CODE ###

N=int(input())
import queue
que=queue.Queue()
que.put(3);que.put(5);que.put(7)
num=[3,5,7]
cnt=0
while not que.empty():
    v=que.get()
    for n in num:
        nv=v*10+n
        if nv<=N:
            que.put(nv)
            nv_str=str(nv)
            if "3" in nv_str and "5" in nv_str and "7" in nv_str and len(set(nv_str))==3:
                cnt+=1
print(cnt)
### BUGGY CODE ###

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

a = [min(p[:i+1]) for i in range(N)]
ans = 0
for i in range(N):
  if p[i] == a[i]:
    ans += 1
    
print(ans)

### FIXED CODE ###

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

ans = 0
p_min = N + 1
for i in range(N):
  p_min = min(p_min,p[i])
  if p_min == p[i]:
    ans += 1
    
print(ans)
### BUGGY CODE ###

import sys
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
from numba import jit

@jit
def solve():
    m = a[-1]+1
    ava = [0]*m
    for rep in a:
        ava[rep] += 1
        if ava[rep]==1:
            for item in range(2*rep,m,rep):
                ava[item] += 2

    print(ava.count(1))
    return

if __name__=='__main__':
    n = I()
    a = list(IL())
    a.sort()
    solve()

### FIXED CODE ###

import sys

def solve(a,n):
    m = a[-1]+1
    ava = [0]*m
    for rep in a:
        ava[rep] += 1
        if ava[rep]:
            for i in range(2*rep,m,rep):
                ava[i] += 2
    return ava.count(1)
 
if __name__=='__main__':
    n = int(sys.stdin.readline().rstrip())
    a = list(map(int,sys.stdin.readline().rstrip().split()))
    a.sort()
    print(solve(a,n))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

import heapq
N,M = (int(x) for x in input().split())
pref = [[] for _ in range(N)]
ans = [0] * M
prefnumber = 0
for i in range(M):
    P,Y = (int(x) for x in input().split())
    pref[P-1].append((Y,i))
for p in pref:
    prefnumber += 1
    count = 1
    while p:
        heapq.heapify(p)
        temp = heapq.heappop(p)
        ans[temp[1]] = ''.join([str(prefnumber).zfill(6),str(count).zfill(6)])
        count += 1
print('\n'.join(ans))


### FIXED CODE ###

import sys
input = sys.stdin.readline

import heapq
N,M = (int(x) for x in input().split())
pref = [[] for _ in range(N)]
ans = [0] * M
prefnumber = 0
for i in range(M):
    P,Y = (int(x) for x in input().split())
    pref[P-1].append((Y,i))
for p in pref:
    prefnumber += 1
    count = 1
    if p:
        heapq.heapify(p)
        while p:
            temp = heapq.heappop(p)
            ans[temp[1]] = ''.join([str(prefnumber).zfill(6),str(count).zfill(6)])
            count += 1
print('\n'.join(ans))
### BUGGY CODE ###

A,B,C = map(int,input().split())
N = A*B*C
cmin = N
for a in range(1,A):
    cmin = min(cmin,abs(2*a*B*C-N))
for b in range(1,B):
    cmin = min(cmin,abs(2*b*C*A-N))
for c in range(1,C):
    cmin = min(cmin,abs(2*c*A*B-N))
print(cmin)

### FIXED CODE ###

import math
A,B,C = map(int,input().split())
a = (math.ceil(A/2)-A//2)*B*C
b = (math.ceil(B/2)-B//2)*C*A
c = (math.ceil(C/2)-C//2)*A*B
print(min(a,b,c))