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

from itertools import combinations

n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
mod = 10 ** 9 + 7

# bit DP...?
dp = [[0] * (2 ** n) for i in range(n + 1)]
dp[0][0] = 1

bitcal = sorted([pow(2, i) for i in range(n)], reverse=True)
bitlist = [[i] for i in range(n)]  # 1が少ない順に作りたい...
for i in range(1, n):
    bitlist.extend(combinations(range(n), i + 1))

for bit in bitlist:
    i = len(bit)
    j = sum(bitcal[k] for k in bit)
    for num in bit:
        dp[i][j] += dp[i - 1][j - 2 ** (n - num - 1)] * a[i - 1][num] % mod
    dp[i][j] %= mod

print(dp[n][2 ** n - 1])


### FIXED CODE ###

mod = 10**9+7
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
dp = [0]*(1 << n)
dp[0] = 1
for i in range(1, 1 << n):
    k = bin(i).count("1")
    for j in range(n):
        if i >> j & 1 and a[k-1][j]:
            dp[i] += dp[i ^ (1 << j)]
    dp[i] %= mod
print(dp[(1 << n)-1])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
C - K-th Substring
https://beta.atcoder.jp/contests/abc097/tasks/arc097_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(s, K):
    l = len(s)
    substrings = set()
    for i in range(l):
        for j in range(l+1):
            t = s[i:j]
            if len(t):
                substrings.add(t)
    ans = list(substrings)
    ans.sort()
    return ans[K - 1]


def main(args):
    s = input().strip()
    K = int(input())
    ans = solve(s, K)
    print(ans)

if __name__ == '__main__':
    main(sys.argv[1:])


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
C - K-th Substring
https://beta.atcoder.jp/contests/abc097/tasks/arc097_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(s, K):
    l = len(s)
    substrings = set()
    for i in range(l):
        for j in range(i+K+1):
            t = s[i:j]
            if len(t):
                substrings.add(t)
    ans = list(substrings)
    ans.sort()
    return ans[K - 1]


def main(args):
    s = input().strip()
    K = int(input())
    ans = solve(s, K)
    print(ans)

if __name__ == '__main__':
    main(sys.argv[1:])
### BUGGY CODE ###

# coding:utf-8

import copy

Black = "#"
White = "."

dir_x = [1, 0, -1, 0]
dir_y = [0, 1, 0, -1]


def main():
    H, W = map(int, input().split())
    masu = []
    for i in range(H):
        masu.append(input().rstrip())
    step = 0
    count = W*H
    memo = [[-1]*W for i in range(H)]

    steplist = []
    for y in range(H):
        for x in range(W):
            if masu[y][x] == Black:
                memo[y][x] = 0
                count -= 1
                steplist.append([y, x])

    while count > 0:
        temp_step = step
        step += 1
        next_list = []
        for l in steplist:
            y = l[0]
            x = l[1]
            for i in range(4):
                temp_x = x + dir_x[i]
                temp_y = y + dir_y[i]
                if temp_x >= 0 and temp_x < W and temp_y >= 0 and temp_y < H and memo[temp_y][temp_x] < 0:
                    memo[temp_y][temp_x] = step
                    count -= 1
                    next_list.append([temp_y, temp_x])
        steplist = copy.deepcopy(next_list)
    print(step)


if __name__ == "__main__":
    main()


### FIXED CODE ###

# coding:utf-8

Black = "#"
White = "."

dir_x = [1, 0, -1, 0]
dir_y = [0, 1, 0, -1]


def main():
    H, W = map(int, input().split())
    step = 0
    count = W*H
    memo = [[-1]*W for i in range(H)]
    steplist = []

    for y in range(H):
        temp_in = input()
        for x in range(W):
            if temp_in[x] == Black:
                memo[y][x] = 0
                count -= 1
                steplist.append([y, x])

    while count > 0:
        step += 1
        next_list = []
        for l_yx in steplist:
            for i in range(4):
                temp_x = l_yx[1] + dir_x[i]
                temp_y = l_yx[0] + dir_y[i]
                if temp_x >= 0 and temp_x < W and temp_y >= 0 and temp_y < H:
                    if memo[temp_y][temp_x] < 0:
                        memo[temp_y][temp_x] = step
                        count -= 1
                        next_list.append([temp_y, temp_x])
        steplist = next_list
    print(step)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

from typing import List


def main():
    n = int(input())
    m = xyz(n)
    for i in m:
        print(i)


def f(x, y, z):
    return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x


def xyz(n: int) -> List[int]:
    rs = []
    for i in range(1, n + 1):
        r = 0
        for x in range(1, 100):
            for y in range(1, 100):
                for z in range(1, 100):
                    if f(x, y, z) > i:
                        break
                    elif f(x, y, z) == i:
                        r += 1
        rs.append(r)

    return rs


if __name__ == '__main__':
    main()


### FIXED CODE ###

from typing import List


def main():
    n = int(input())
    m = xyz(n)
    for i in m:
        print(i)


def f(x, y, z):
    return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x


def xyz(n: int) -> List[int]:
    result = [0] * n
    for x in range(1, 100):
        for y in range(1, 100):
            for z in range(1, 100):
                m = f(x, y, z)
                if m > n:
                    break
                result[m - 1] += 1

    return result


if __name__ == '__main__':
    main()
### BUGGY CODE ###

# coding: utf-8
from __future__ import unicode_literals
from __future__ import print_function
import sys
import itertools

def main():
    k,s = map(int,sys.stdin.read().split())
    ans = []
    for x in xrange(k+1):
        for y in xrange(k+1):
            if x + y <= s:
                z = s - (x + y)
                if(z>=0 and z <= k):
                    ans.append([x,y,z])
            else:
                break
    sys.stdout.write("%d" % len(ans))

if __name__ == '__main__':
    main()  


### FIXED CODE ###

# coding: utf-8
from __future__ import unicode_literals
from __future__ import print_function
import sys
import itertools

def main():
    k,s = map(int,sys.stdin.read().split())
    ans = []
    count = 0
    for x in xrange(k+1):
        for y in xrange(k+1):
            if x + y <= s:
                z = s - (x + y)
                if(z>=0 and z <= k):
                    count += 1
                    # ans.append([x,y,z])
            else:
                break
    # sys.stdout.write("%d" % len(ans))
    sys.stdout.write("%d" % count)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

if k >= n:
    print(h[-1]-h[0])
    exit()
dp = [0] * n
dp[0] = 0
for i in range(1, k):
    dp[i] = abs(h[0]-h[i])

for i in range(k, len(dp)):
    dp[i] = min(abs(h[i]-h[i-j])+dp[i-j] for j in range(1, k+1))
print(dp[-1])



### FIXED CODE ###

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

if k >= n:
    print(h[-1]-h[0])
    exit()
dp = [0] * n
dp[0] = 0
for i in range(1, k):
    dp[i] = abs(h[0]-h[i])

for i in range(k, len(dp)):
    dp[i] = min(abs(h[i]-h[i-j])+dp[i-j] for j in range(1, k+1))
print(dp[-1])
### BUGGY CODE ###

import bisect
x = int(input())
a = [1]
s = 1
for i in range(2, x+1):
    s += i
    a.append(s)

if x in a:
    print(a.index(x) + 1)
    exit()

print(bisect.bisect_right(a, x)+1)



### FIXED CODE ###

import bisect
from math import sqrt
x = int(input())
a = [1]
s = 1
for i in range(2, 2*int(sqrt(x))):
    s += i
    a.append(s)

if x in a:
    print(a.index(x) + 1)
    exit()

print(bisect.bisect_right(a, x)+1)
### BUGGY CODE ###

import numpy as np
N, K = map(int, input().split())
c = []
for _ in range(N):
    a, b= map(int, input().split())
    c += [a] * b
    

print(sorted(c)[K-1])

### FIXED CODE ###

N, K = map(int, input().split())
num = [0]*(10**5+1)
for i in range(N):
    a, b= map(int, input().split())
    num[a] += b
for i in range(1, 10**5+1):
    if K <= num[i]:
        print(i)
        exit()
    K -= num[i]
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
BC = [[int(x) for x in input().split()] for _ in range(M)]
for i in BC:
    B, C = i
    A += [C] * B
A.sort()
print(sum(A[len(A) - N:]))

### FIXED CODE ###

import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
BC = [[int(x) for x in input().split()] for _ in range(M)]
BC = sorted(BC, reverse = True, key = lambda x:x[1])
N2 = N
D = []
for i in BC:
    temp = min(N2,i[0])
    D += [i[1]] * temp
    N2 -= temp
    if not N2:
        break
A += D
A.sort()
print(sum(A[len(A) - N:]))
### BUGGY CODE ###

import copy

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

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

if n>2:
    memo = list([])

    for k in range(n):
        t = copy.copy(s_all)
        t.pop(k)

        c = gcd(t[0], t[1])

        for i in t:
            c = gcd(c,i)

        memo.append(c)

    print(max(memo))

if n==2:
    print(max(s_all))

### FIXED CODE ###

import numpy as np

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

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

l = [0]*n
r = [0]*n

for i in range(1,n):
    l[i]=gcd(l[i-1],s[i-1])

tmp = list(range(0,n-1))
tmp.reverse()
for i in tmp:
    r[i]=gcd(r[i+1],s[i+1])
    
m = list([])

for i in range(n):
    m.append(gcd(l[i],r[i]))

print(max(m))
### BUGGY CODE ###

from sys import stdin
import sys
sys.setrecursionlimit(100000)

def permutations_count(n, r):
  nCr = {}
  if r == 0 or r == n: return 1
  if r == 1: return n
  if (n,r) in nCr: return nCr[(n,r)]
  nCr[(n,r)] = permutations_count(n-1,r) + permutations_count(n-1,r-1)
  return nCr[(n,r)]

N,K = map(int,stdin.readline().split())
mod = pow(10,9)+7

frame = N-K+1
for i in range(1,K+1):
  select=permutations_count(frame, i) % mod
  pattern=permutations_count(K-1, i-1) % mod
  print((select * pattern) % mod )

### FIXED CODE ###

from sys import stdin
from math import factorial

def permutations_count(n, r):
  return factorial(n) // factorial(r) // factorial(n - r)

N,K = map(int,stdin.readline().split())
mod = pow(10,9)+7

frame = N-K+1
for i in range(1,K+1):
  if K == N:
    if i == 1:
      print("1")
    else:
      print("0")
  else:
    if i > frame:
      print("0")
    else:
      select=permutations_count(frame, i) % mod
      pattern=permutations_count(K-1, i-1) % mod
      print((select * pattern) % mod )
### BUGGY CODE ###

from collections import deque
INF = 10**18

def append_dq(i, x, dq, dp1):
    while True:
        if not len(dq):
            dq.append(i)
            break
        lxi = dq[-1]
        if x > dp1[lxi]:
            dq.append(i)
            break
        dq.pop()
    return dq
dq = deque()
N,M = map(int, input().split())
S = input().strip()
dp1 = [0] + [INF]*N
dp2 = [[] for _ in range(N+1)]
dq.append(0)
for i, c in enumerate(S[1:]):
    i+=1
    dq = append_dq(i, dp1[i], dq, dp1)
    idx = dq[0]
    if c != "1" and dp1[idx] != INF:
        dp1[i] = dp1[idx] + 1
        dp2[i] = dp2[idx] + [i-idx]
    if i >= M:
        sxi = dq[0]
        if sxi == (i - M):
            dq.popleft()
if dp1[-1] == INF:
    print(-1)
else:
    print(" ".join(map(str, dp2[-1])))


### FIXED CODE ###

from collections import deque
INF = 10**18

def append_dq(i, x, dq, dp1):
    while True:
        if not len(dq):
            dq.append(i)
            break
        lxi = dq[-1]
        if x > dp1[lxi]:
            dq.append(i)
            break
        dq.pop()
    return dq
dq = deque()
N,M = map(int, input().split())
S = input().strip()
dp1 = [0] + [INF]*N
dp2 = [-1 for _ in range(N+1)]
dq.append(0)
for i, c in enumerate(S[1:]):
    i+=1
    dq = append_dq(i, dp1[i], dq, dp1)
    idx = dq[0]
    if c != "1" and dp1[idx] != INF:
        dp1[i] = dp1[idx] + 1
        dp2[i] = idx
    if i >= M:
        sxi = dq[0]
        if sxi == (i - M):
            dq.popleft()
if dp1[-1] == INF:
    print(-1)
else:
    r = []
    s = N
    while True:
        if s == 0:
            break
        ns = dp2[s]
        r.append(s-ns)
        s = ns
    print(" ".join(map(str, r[::-1])))
### BUGGY CODE ###

'''
制約
2≦K≦2500
0≦S≦3K
K,S は整数である。



'''
# from collections import deque # キュー、スタックに利用

# sys.stdin.readline() # 標準入力の高速化に利用
import sys
input = sys.stdin.readline

# import numpy as np

is_debug = False


k, s = list(map(int, input().split()))

def main():
    '''メイン処理'''
    counter = 0
    # x,y,zは全て0～kの値を取る。 x+y+z = sを満たす。
    for x in range(k+1):
        for y in range(k+1):
            for z in range(k+1):
                if (x+y+z) == s:
                    if is_debug:
                        print(x,y,z)
                    counter += 1

    print(counter)


if __name__ == "__main__":
    # ファイル実行時に、main()関数を実行
    main()


### FIXED CODE ###

'''
制約
2≦K≦2500
0≦S≦3K
K,S は整数である。

'''
# from collections import deque # キュー、スタックに利用

# sys.stdin.readline() # 標準入力の高速化に利用
import sys
input = sys.stdin.readline

# import numpy as np


def main():
    '''メイン処理'''
    k, s = map(int, input().split())

    counter = 0
    # x,y,zは全て0～kの値を取る。 x+y+z = sを満たす。
    for x in range(k+1):
        if x > s:
            # 合計がsを超えたら、このforループでは条件を満たせないのでbreak
            break

        for y in range(k+1):
            if x+y > s:
                # 合計がsを超えたら、このforループでは条件を満たせないのでbreak
                break
            
            # 3重ループではTLEになる。x+y+z = s なので、z=s-x-yとなるzがあればカウントする
            z = s-x-y
            if z >= 0 and z <= k:
                counter += 1

    print(counter)


if __name__ == "__main__":
    # ファイル実行時に、main()関数を実行
    main()
### BUGGY CODE ###

n = int(input())
a = []
for _ in range(n):
  a_ = int(input())
  a.append(a_)
  
for i in range(n):
  res = a[i]
  a[i] = 0
  print(max(a))
  a[i] = res


### FIXED CODE ###

n = int(input())
a = []
for _ in range(n):
  a_ = int(input())
  a.append(a_)
a1 = sorted(a)
ans1 = a1[-1]
ans2 = a1[-2]
for i in range(n):
  if a[i] == ans1:
    print(ans2)
  else:
    print(ans1)
### BUGGY CODE ###

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



"""
import sys


def solve(H, W, grid):
    res_x = [[0]*W for _ in range(H)]
    x, y = 0, 0
    while y < H:
        while x < W:
            if grid[y][x] == '#':
                x += 1
                continue
            rx = x
            while rx < W and grid[y][rx] != '#':
                rx += 1
            for xx in range(x, rx):
                res_x[y][xx] = rx-x
            x = rx
        x = 0
        y += 1

    res_y = [[0]*W for _ in range(H)]
    x, y = 0, 0
    while y < H:
        while x < W:
            if grid[y][x] == '#':
                x += 1
                continue
            dy = y
            while dy < H and grid[dy][x] != '#':
                dy += 1
            for yy in range(y, dy):
                if res_y[yy][x] == 0:
                    res_y[yy][x] = dy-y
            x += 1
        x = 0
        y += 1

    ans = 0
    for y in range(H):
        for x in range(W):
            t = res_x[y][x] + res_y[y][x] - 1
            if t > ans:
                ans = t
    return ans


def main(args):
    H, W = map(int, input().split())
    grid = [input() for _ in range(H)]
    ans = solve(H, W, grid)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


### FIXED CODE ###

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



"""
import sys


def solve(H, W, grid):
    res_x = [[0]*W for _ in range(H)]
    x, y = 0, 0
    while y < H:
        while x < W:
            if grid[y][x] == '#':
                x += 1
                continue
            rx = x
            while rx < W and grid[y][rx] != '#':
                rx += 1
            for xx in range(x, rx):
                res_x[y][xx] = rx-x
            x = rx
        x = 0
        y += 1

    res_y = [[0]*W for _ in range(H)]
    x, y = 0, 0
    while y < H:
        while x < W:
            if grid[y][x] == '#' or res_y[y][x] != 0:
                x += 1
                continue
            dy = y
            while dy < H and grid[dy][x] != '#':
                dy += 1
            for yy in range(y, dy):
                if res_y[yy][x] == 0:
                    res_y[yy][x] = dy-y
            x += 1
        x = 0
        y += 1

    ans = 0
    for y in range(H):
        for x in range(W):
            t = res_x[y][x] + res_y[y][x] - 1
            if t > ans:
                ans = t
    return ans


def main(args):
    H, W = map(int, input().split())
    grid = [input() for _ in range(H)]
    ans = solve(H, W, grid)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
### BUGGY CODE ###

n, m = map(int,input().split())
List = list(map(int,input().split()))

List.sort()
for i in range(m):
  List[n -1] = (List[n - 1]/2)//1
  List.sort()

print(int(sum(List)))

### FIXED CODE ###

import heapq
n, m = map(int,input().split())
List = list(map(int,input().split()))

List = list(map(lambda x: x*(-1), List))  # 各要素を-1倍

heapq.heapify(List)
for i in range(m):
  max = heapq.heappop(List)
  heapq.heappush(List, int(max/2))  # 要素の挿入
print(sum(List)*(-1))
### BUGGY CODE ###

l = list(input())
amari = [0]*len(l)
mod = 2019
import math
for i in range(len(l)):
    amari[i] = int(l[i])*(10**(len(l)-1-i)) % mod
rui = [0]*len(l)
rui[len(l)-1] = amari[-1]
for i in range(len(l)-2,-1,-1):
    rui[i] = (rui[i+1] + amari [i])%mod
count = [0]*2020
for i in range(len(l)):
    count[rui[i]] += 1
ans = 0
for i in range(1,2020):
    if count[i] == 0 or count[i] == 1:
        continue
    ans += count[i] * (count[i]-1)//2
ans += count[0]
print(ans)

### FIXED CODE ###

S = input()
N = len(S)
P = 2019
num = [0] * P
num[0] = 1
now, ans = 0, 0
_10 = 1
for i in range(N-1, -1, -1):
    now = (now + int(S[i]) * _10) % P
    _10 *= 10
    _10 %= P
    ans += num[now]
    num[now] += 1
print(ans)
### BUGGY CODE ###

def sort_list():
    _ = input()
    K = [int(x) for x in input().split()]
    ans = 0
    n_lst = tuple(sorted(K, reverse=True))
    for idx in range(len(K)-2):
        for diff_idx in range(idx+1, len(K)-1):
            diff = n_lst[idx] - n_lst[diff_idx]
            for search in reversed(range(diff_idx+1, len(K))):
                if n_lst[search] > diff:
                    ans += search - diff_idx
                    break
    print(ans)


if __name__ == "__main__":
    sort_list()


### FIXED CODE ###

import bisect


def sort_list():
    _ = input()
    K = [int(x) for x in input().split()]
    ans = 0

    len_k = len(K)
    n_lst = sorted(K)

    for idx in reversed(range(2, len_k)):
        for diff_idx in range(1, idx):
            diff = n_lst[idx] - n_lst[diff_idx]
            insert_index = bisect.bisect_right(n_lst, diff)
            if insert_index < diff_idx:
                # print(n_lst, diff, idx, diff_idx, insert_index)
                ans += diff_idx - insert_index
    print(ans)


if __name__ == "__main__":
    sort_list()
### BUGGY CODE ###

t_at, t_hp, a_at, a_hp = map(int, input().split())

while True:
  a_hp -= t_at
  if a_hp <= 0:
    print("Yes")
  
  t_hp -= a_at
  if t_hp <= 0:
    print("No")
    

### FIXED CODE ###

t_hp, t_at, a_hp, a_at = map(int, input().split())

while True:
    a_hp -= t_at
    if a_hp <= 0:
        print("Yes")
        exit()

    t_hp -= a_at
    if t_hp <= 0:
        print("No")
        exit()
### BUGGY CODE ###

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

cs_a, cnt = [0] * n, 0
for i in range(n):
    cnt += a[i]
    cs_a[i] = cnt

dp = [[0] * (n + 1) for i in range(k + 1)]

for i in range(k + 1):
    for j in range(1, n + 1):
        if i > cs_a[j - 1]:
            dp[i][j] = 0
        elif i == 0:
            dp[i][j] = 1
        elif i == 1:
            dp[i][j] = dp[i][j - 1] + min(1, a[j - 1])
        else:
            dp[i][j] = sum(dp[i - x][j - 1] for x in range(a[j - 1] + 1))

print(dp[k][n] % (10 ** 9 + 7))


### FIXED CODE ###

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

cs_a, cnt = [0] * n, 0
for i in range(n):
    cnt += a[i]
    cs_a[i] = cnt
dp = [[0] * (k + 1) for i in range(n + 1)]

for i in range(n + 1):
    for j in range(k + 1):
        if j == 0:
            dp[i][j] = 1
        elif (i == 0) or (j > cs_a[i - 1]):
            dp[i][j] = 0
        elif j == 1:
            dp[i][j] = dp[i - 1][j] + min(a[i - 1], 1)
        elif j - a[i - 1] - 1 < 0:
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
        else:
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - a[i - 1] - 1]
        dp[i][j] %= 10 ** 9 + 7

print(dp[n][k])
### BUGGY CODE ###

import sys
input = sys.stdin.readline

# C - XYZ Triplets
def get_f(n):
	count = 0
	
	for x in range(1, n):
		if x ** 2 > n:
			return count
		else:
			for y in range(1, n):
				if x ** 2 + y ** 2 < n:
					for z in range(1, n):
						calc = x ** 2 + y ** 2 + x * y
						
						if calc < n:
							if z ** 2 + y * z + z * x == n - calc:
								count += 1
		
	return count


N = int(input())

for n in range(1, N + 1):
	print(get_f(n))

### FIXED CODE ###

import sys
input = sys.stdin.readline

# C - XYZ Triplets
def calc(x, y, z):
	return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x


N = int(input())
ans = [0] * (N + 1)

for x in range(1, 100):
	for y in range(1, 100):
		for z in range(1, 100):
			i = calc(x, y, z)
			
			if i > N:
				break
			else:
				ans[i] += 1

for i in range(1, N + 1):
	print(ans[i])
### BUGGY CODE ###

l,r = map(int,input().split())
r = min(r,l+2019*2)
mini = 2018
for i in range(l,r):
  for j in range(i+1,r+1):
    ans = ( i*j )% 2019
    mini = min(ans,mini)
print(mini)


### FIXED CODE ###

l,r = map(int,input().split())
if (r-l)>=2019:
  print(0)
else:
  mini = 2018
  for i in range(l,r+1):
    for j in range(i+1,r+1):
      ans = ( i*j )% 2019
      mini = min(ans,mini)
  print(mini)
### BUGGY CODE ###

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

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

print(dp[-1])

### FIXED CODE ###

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

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

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

s = [input() for i in range(2)] 
li = list(map(int, s[1].split()))
s0 = int(s[0])
f1 = 1
for i in range(s0):
    f1 = f1 * li[i]
if f1 <= 1000000000000000000:
    print(f1)
if f1 > 1000000000000000000:
    print(-1)

### FIXED CODE ###

s = [input() for i in range(2)] 
li = list(map(int, s[1].split()))
s0 = int(s[0])
f1 = 1
if 0 in li:
    print(0)
if 0 not in li:
    for i in range(s0):
        f1 = f1 * li[i]
        if f1 > 1000000000000000000:
            print(-1)
            break
    if f1 <= 1000000000000000000:
        print(f1)
### BUGGY CODE ###

from collections import Counter
P = [0] * 100001
Q = [0] * 100002
P[0] = 1
P[1] = 1

for i in range(2, 100000):
    if P[i] == 0:
        for j in range(i*2, 100000, i):
            P[j] += 1

n = int(input())
num = [list(map(int,input().split())) for _ in range(n)]

for k in range(3, 100000, 2):
    if P[k] == 0 and P[(k + 1) // 2] == 0:
        Q[k] = 1

for l in range(n):
    print(sum(Q[:num[l][1]+1]) - sum(Q[:num[l][0]]))

### FIXED CODE ###

from collections import Counter
P = [0] * 100001
Q = [0] * 100002
P[0] = 1
P[1] = 1

for i in range(2, 100000):
    if P[i] == 0:
        for j in range(i*2, 100000, i):
            P[j] += 1

n = int(input())
num = [list(map(int,input().split())) for _ in range(n)]

for k in range(3, 100000, 2):
    if P[k] == 0 and P[(k + 1) // 2] == 0:
        Q[k] = 1
for l in range(100000):
    Q[l+1] += Q[l]

for m in range(n):
    l, r = num[m][0], num[m][1]
    print(Q[r] - Q[l-1])