Harryxun/stf_run huggingface dataset:
import math
A,B,H,M=map(int,input().split())

C=[]
for i in range(10):
    if 0<abs(360*i-abs(30*H+int(M/2)-6*M))<180:
        a=abs(360*i-abs(30*H+int(M/2)-6*M))
        c=abs((180-abs(360*i-abs(30*H+int(M/2)-6*M))))
        break
b=min(a,c)

print("{:.12f}".format(((A**2+B**2-2*A*B*(math.cos(b*(math.pi/180))))**(1/2))))


### FIXED CODE ###

import math
A,B,H,M=map(int,input().split())

for i in range(10):
    if 0<=abs(360*i-abs(30*H+(M/2)-6*M))<360:
        a=abs(360*i-abs(30*H+(M/2)-6*M))
        c=abs(360-abs(360*i-abs(30*H+(M/2)-6*M)))
        break
b=min(a,c)

print("{:.9f}".format(((A**2+B**2-2*A*B*(math.cos(b*(math.pi/180))))**(1/2))))
# -*- coding: utf-8 -*-
"""
Created on Thu May 14 16:15:19 2020

@author: shinba
"""

n,t = map(int,input().split())

T = list(map(int,input().split()))
T.append(10**10)
R = []
for i in range(n-1):
    R.append(T[i+1]-T[i])

ans = 0
start = T[0]

for i in range(n):
    if R[i] <= t:
        continue
    ans += t+(T[i]-start)
    start = T[i+1]
    
print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Thu May 14 16:15:19 2020

@author: shinba
"""

n,t = map(int,input().split())

T = list(map(int,input().split()))
T.append(10**10)
R = []
for i in range(n):
    R.append(T[i+1]-T[i])

ans = 0
start = T[0]

for i in range(n):
    if R[i] <= t:
        continue
    ans += t+(T[i]-start)
    start = T[i+1]
    
print(ans)
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vpii = vector<pii>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

int main() {
	int a, b;
	cin >> a >> b;
	if (a % 2 == 0 || b % 2 == 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


### FIXED CODE ###

A, B = map(int, input().split())
if A % 2 is 0 or B % 2 is 0:
    print('No')
else:
    print("Yes")
n,l =map(int,input().split())
s=sorted([input(),for i in range(n)])
print(*s,sep='')


### FIXED CODE ###

n,l=map(int,input().split())
s=sorted([input() for i in range(n)])
print(*s,sep="")
N = int(input())
f = [list(map(int, input().split())) for _ in range(N)]
p = [list(map(int, input().split())) for _ in range(N)]

ans = -(10 ** 7)
stk = []

stk.append([0] * N)

for i in range(10):
    len_stk = len(stk)
    for j in range(len_stk):
        total = 0
        arr = []
        for k in range(N):
            open_cnt = stk[j][k] + f[k][i]
            arr.append(open_cnt)
            total += p[k][open_cnt]
        ans = max(ans, total)
        stk.append(arr)

print(ans)


### FIXED CODE ###

N = int(input())
params = [list(map(int, input().split())) for _ in range(N - 1)]

for i in range(N - 1):
    time = 0
    for j in range(i, N - 1):
        c = params[j][0]
        s = params[j][1]
        f = params[j][2]
        if s > time:
            time += s - time + c
        else:
            time += (s - time) % f + c
    print(time)
    
print(0)
import sys
import  math
from heapq import *
import fractions
from collections import defaultdict
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=int(input())
A=nl()
A.sort()
A_MAX=10**6+5
p_l=[0]*(A_MAX)
c=0

for i in range(len(A)):
    if(i==0):
        if(A[i]==A[i+1]):
            continue
    elif(i==(len(A)-1)):
        if(A[i]==A[i-1]):
            continue
    else:
        if(A[i]==A[i-1] or A[i]==A[i+1]):
            continue 
    if(p_l[A[i]]==0):
        c+=1
        for k in range(A[i]*2,A_MAX,A[i]):
            if(p_l[k]):
                continue
            p_l[k]=1

print(c)
        
    
    


### FIXED CODE ###

import sys
import  math
from heapq import *
import fractions
from collections import defaultdict
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=int(input())
A=nl()
A.sort()
A_MAX=10**6+5
p_l=[0]*(A_MAX)
c=0
if(len(A)==1):
    print(1)
    sys.exit(0)

for i in range(len(A)):
    if(p_l[A[i]]!=0):
        continue
    for k in range(A[i],A_MAX,A[i]):
        if(p_l[k]):
            continue
        p_l[k]=1
    if(i<(len(A)-1) and A[i]==A[i+1]):
        continue
    c+=1
    

print(c)
S = input()
T = input()
m, n = len(S), len(T)
C = [[0 for j in range(n+1)] for i in range(m+1)]
for i in range(m):
    for j in range(n):
        if S[i] == T[j]:
            C[i+1][j+1] = C[i][j] + 1
        else:
            C[i+1][j+1] = max(C[i][j+1], C[i+1][j])
X = ''
i, j, k = 0, 0, 0
while k < C[m][n]:
    if S[i] == T[j]:
        X = X + S[i]
        i += 1
        j += 1
        k += 1
    elif C[i+1][j] == C[i][j]:
        i += 1
    else:
        j += 1
print(X)


### FIXED CODE ###

S = input()
T = input()
m, n = len(S), len(T)
C = [[0 for j in range(n+1)] for i in range(m+1)]
for i in range(m):
    for j in range(n):
        if S[i] == T[j]:
            C[i+1][j+1] = C[i][j] + 1
        else:
            C[i+1][j+1] = max(C[i][j+1], C[i+1][j])
l = C[m][n]
X = ''
while l:
    if S[m-1] == T[n-1]:
        X = S[m-1]+X
        m -= 1
        n -= 1
        l -= 1
    elif C[m][n] == C[m-1][n]:
        m -= 1
    else:
        n -= 1
print(X)
W, A, B = map(int, input().split())

if B >= A+W:
  print(abs(A+W-b))
elif B+W <= A:
  print(abs(B+W-A))
else:
  print(0)


### FIXED CODE ###

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

if B >= A+W:
  print(abs(A+W-B))
elif B+W <= A:
  print(abs(B+W-A))
else:
  print(0)
def checkFunction(c):
    
    if (not 'WR' in c):
        return 0
    while True:
        if c[0] == 'R':
            c = c[1:]
        else:
            break
    while True:
        if c[-1] == 'W':
            c = c[:-1]
        else:
            break

    if c.index('R') + 1 != len(c):
        c2 = c.replace('WR', 'RR',1)[:-1]
        return checkFunction(c2) + 1
    return 1


N = int(input())
c= input()

print(checkFunction(c))


### FIXED CODE ###


def check(N, c):
    RinRight = c.count('R')
    WinLeft = 0
    r = RinRight
    for i in range(N):
        if c[i] == 'R':
            RinRight -= 1
        else: # c[i] == 'W'
            WinLeft +=1
        r = min(r, max(RinRight,WinLeft))

    return r


N = int(input())
c= input()
print(check(N,c))
n,y = map(int,input().split())

for i in range(y // 10000 + 1):
    for j in range(y // 5000 + 1):
        k = n - i - j
        if 0 <= k and 10000 * i + 5000 * j + 1000 * k == y:
            print(i,j,k,sep=" ")
            exit()
print("-1 " + "-1" + " -1")

### FIXED CODE ###

print("2018" + input()[4:])
a,b=input().split()
print(int(a)*int(b)+" "+(int(a)*2+int(b)*2))

### FIXED CODE ###

x=input().split()
a=int(x[0])
b=int(x[1])
print(a*b,(a*2+b*2))
s,t =,map(str,input().split())

x = str(t) + str(s)

print(x)


### FIXED CODE ###

s,t = map(str,input().split())

print(t+s)
n,k = [int(x) for x in input().split()]
if n % k == 0:
  prtint(0)
else :
  print(1)

### FIXED CODE ###

n,k = [int(x) for x in input().split()]
if n % k == 0:
  print(0)
else :
  print(1)
K , X = map (int , input().split())

min = X - K + 1
max = X + K - 1

for i in range(min , max + 1):
    print("{} "). format(i)

### FIXED CODE ###

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

min = X - K + 1
max = X + K 

for i in range(min , max ):
    print("{} ". format(i))
import numpy as np
N, M, X = map(int, input().split())
prices = []
effects = []
for i in range(N):
    c, *a = map(int, input().split())
    prices.append(c)
    effects.append(list(a))

prices = np.array(prices)
effects = np.array(effects)


ans = float("inf")

pats = []
for i in range(2 ** N):
    pat = bin(i).replace("0b", "")
    pat += "0" * (N - len(pat))
    pat = list(map(int, list(pat)))
    pats.append(pat)
    
pats = np.array(pats)
total_price = np.dot(pats, prices)
total_effects = np.dot(pats, effects)
cond = ((total_effects >= X).sum(axis=1) == M)


ans = int(total_price[cond == 1].min())
print(ans)

### FIXED CODE ###

import numpy as np
N, M, X = map(int, input().split())
prices = []
effects = []
for i in range(N):
    c, *a = map(int, input().split())
    prices.append(c)
    effects.append(list(a))
 
prices = np.array(prices)
effects = np.array(effects)
 
 
ans = float("inf")
 
pats = []
for i in range(2 ** N):
    pat = bin(i).replace("0b", "")
    pat = "0" * (N - len(pat)) + pat
    pat = list(map(int, list(pat)))
    pats.append(pat)
    
pats = np.array(pats)
total_price = np.dot(pats, prices)
total_effects = np.dot(pats, effects)
cond = ((total_effects >= X).sum(axis=1) == M)
 
final = total_price[cond == 1]
if len(final) > 0:
    ans = int(final.min())
    print(ans)
else:
    print(-1)
A, B, C, K = map(int, input().split())
P = 0
S = 0
while S==0:
    P += A
    K -= A
    if K < 0:
        P = K
        break
    elif K == 0:
        break

    K -= B
    if K <= 0:
        break

    P -= C
    K -= C
    if K <= 0:
        P += abs(K)
        break
    S=1
if P >= 0:
    print(P)
else:
    print("0")





### FIXED CODE ###

S = input()
T = input()
if S[:]==T[:-1]:
    print("Yes")
else:
    print("No")
def combi(x, y):
    if x < y:
        return 0
    if (x,y) in memo:
        return memo[(x,y)]
    else:
        memo[(x,y)]  = math.factorial(x) / (math.factorial(x - y) * math.factorial(y))
        return memo[(x,y)]
import math
memo = dict()
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
mod = 10**9+7
ans = 0
for i in range(n):
    #今回の数字が、最小値として数えられる数の合計
    ans -= a[i] * combi(n - i - 1, k-1)
    #今回の数字が、最大値として数えられる数の合計
    ans += a[i] * combi(i,k-1)
    ans %= mod
print(int(ans))

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
mod = 10**9+7
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]
# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
#a/b = a*(b`)となるb`を求める
def mod_inv(a,mod):
    x = extgcd(a,mod)[0]
    return (mod+x%mod)%mod
factorial = [1 for i in range(n+1)]
factorial[0] = 1
for i in range(1,n + 1):
    factorial[i] = factorial[i-1] * i
    factorial[i] %= mod
def mod_combi(a,b):
    if b == 0:
        return 1
    elif a == 0 or a < b:
        return 0
    elif a == b:
        return 1
    else:
        return (factorial[a] * mod_inv(factorial[b], mod) * mod_inv(factorial[a-b],mod)) % mod
ans = 0
#それぞれについて、最小になる場合と最大になる場合をもとめ、ans に加算する。
for i in range(n):
    patt_max = mod_combi(i, k-1)
    patt_min = mod_combi(n-i-1, k-1)
    ans += (patt_max - patt_min) * a[i]
    ans %= mod
print(ans)
import math
M = 256
while 1:
    N = int(raw_input())
    if N == 0: break
    H = 10**10
    l = map(int,raw_input().split())
    for S in range(16):
        for A in range(16):
            for C in range(16):
                R = S
                O = [0]*N
                for i in range(N):
                    R = (A*R+C)%M
                    O[i] = (l[i]+R)%M
                tmp = -sum(1.0*O.count(x)/N*math.log(1.0*O.count(x)/N) for x in set(O))
                if tmp < H:
                    H = tmp
                    ans = [S,A,C]
    print " ".join(map(str,ans))

### FIXED CODE ###

import math,itertools as it
M = 256
while 1:
    N = int(raw_input())
    if N == 0: break
    H = 1e10
    I = map(int,raw_input().split())
    for S,A,C in it.product(range(16),repeat=3):
        R = S
        O = [0]*M
        for i in I:
            R = (A*R+C)%M
            O[(i+R)%M] += 1
        tmp = -sum(1.0*x/N*math.log(1.0*x/N,2) for x in O if x > 0)
        if tmp < H:
            H = tmp
            ans = [S,A,C]
    print " ".join(map(str,ans))
S=input()
total=0

for i in range(2**(len(S)-1)):
    a = int(S[0])
    t=format(i,'b').zfill(len(S)-1)
    for j in range(len(t)):
        if t[j]=='0':
            a=a*10+int(S[j+1])
        else:
            total+=a
            a=int(S[j+1])
    total+=a

print(total)


### FIXED CODE ###

S=input()
total=0
if len(S)==1:
    print(S)
    exit(0)
for i in range(2**(len(S)-1)):
    a = int(S[0])
    t=format(i,'b').zfill(len(S)-1)
    for j in range(len(t)):
        if t[j]=='0':
            a=a*10+int(S[j+1])
        else:
            total+=a
            a=int(S[j+1])
    total+=a

print(total)
a,b=map(int,input().split())
c=int("a"+"b")
if c**.5 % 1 !=0:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

c=int(input().replace(" ",""))
if c**0.5 % 1 !=0:
  print("No")
else:
  print("Yes")
X=input()
s=int(X[-1])+int(X[-2])*10

b=s//5
b_=s%5
c=b_//4
c_=b_%4
d=c_//3
d_=c_%3
e=d_//2
e_=d_%2
f=e_//1
f_=e_//1

sum=b+c+d+e+f
sum_=105*b+104*c+103*d+102*e+101*f

if 2100<int(X):
    print(1)
elif sum_>int(X):
    print(0)
else:
    print(1)

### FIXED CODE ###

X=input()
if len(X)==1:
    s=int(X)
else:
    s=int(X[-1])+int(X[-2])*10
    

b=s//5
b_=s%5
c=b_//4
c_=b_%4
d=c_//3
d_=c_%3
e=d_//2
e_=d_%2
f=e_//1
f_=e_//1

sum=b+c+d+e+f
sum_=105*b+104*c+103*d+102*e+101*f

if sum_>int(X):
    print(0)
else:
    print(1)
n,k=map(int,input())
s=[i for i in range input()]
num=0
for i in range(len(s)):
    if s[i]==s[i+1]:
        num+=1
print(min(n-1,num+2*k))

### FIXED CODE ###

n,k=map(int,input().split())
s=[i for i in input()]
num=0
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        num+=1
print(min(n-1,num+2*k))
def solve():
    # n, k = map(int, input().split())
    # stns = [int(x) for x in input().split()]
    n,k = map(int,input().split())
    stns = list(map(int, input().split()))

    INF = 10**9
    dp = [INF] * n
    dp[0] = 0

    for i in range(n):
        for j in range(1, k + 1): # consider more than one step
            j = i + j # step i + 1, i + 2
            if j < n:
                # min(existing min, new path using i)
                dp[j] = min(dp[j], dp[i] + abs(stns[i] - stns[j]))
    print(dp[n-1])

solve()


### FIXED CODE ###

import sys
def solve(stns, idx, mem):

    if idx >= len(stns) -1:
        return 0

    if idx in mem: 
        return mem[idx]

    if idx == len(stns) - 2: 
        # can take only one step
        # print(idx)  
        # final_step = solve(stns, idx + 1, mem) + abs(stns[idx] - stns[idx+1])
        final_step = abs(stns[idx] - stns[idx+1])
        mem[idx] = final_step
        return final_step
    else: 
        # step: i + 11
        step1 = solve(stns, idx + 1, mem) + abs(stns[idx] - stns[idx+1])
        # step: i + 2
        step2 = solve(stns, idx + 2, mem) + abs(stns[idx] - stns[idx+2])

        min_cost = min(step1, step2)
        mem[idx] = min_cost 

        return min_cost



def take_input():
    # n = input()
    # stns = [int(x) for x in input().split(' ')]



    reader = (s.rstrip() for s in sys.stdin)
    input = reader.__next__
    sys.setrecursionlimit(1000000)
    # do magic here
    n = int(input())
    stns = [int(x) for x in input().split()]
    mem = {}
    res = solve(stns, 0, mem)
    print(res)

take_input()
#![allow(unused_imports, non_snake_case)]
use proconio::{
    input, fastout,
    marker::{Chars, Bytes, Usize1}
};

macro_rules! max {($ a : expr $ (, ) * ) => {{$ a } } ; ($ a : expr , $ b : expr $ (, ) * ) => {{std :: cmp :: max ($ a , $ b ) } } ; ($ a : expr , $ ($ rest : expr ) ,+ $ (, ) * ) => {{std :: cmp :: max ($ a , max ! ($ ($ rest ) ,+ ) ) } } ; }

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }
    let mut dp = vec![vec![0; 3]; n+4];
    for i in 0..n{
        dp[i + 4][0] = dp[i + 2][0] + a[i];
        dp[i + 4][1] = max!(dp[i+2][1], dp[i+1][0]) + a[i];
        if n & 1 > 0 {
            dp[i + 4][2] = max!(dp[i + 2][2], dp[i + 1][1], dp[i][0]) + a[i];
        }
    }
    if n & 1 > 0 {
        println!("{}", max!(dp[n+1][0], dp[n+2][1], dp[n+3][2]));
    } else {
        println!("{}", max!(dp[n+2][0], dp[n+3][1]));
    }
}

### FIXED CODE ###

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()
a = nl()
dp = [[0]*3 for _ in range(n+5)]
t = n%2
for i in range(n):
    dp[i][0] = dp[i-2][0] + a[i]
    dp[i][1] = max(dp[i-2][1], dp[i-3][0]) + a[i]
    if t:
        dp[i][2] = max(dp[i-2][2], dp[i-3][1], dp[i-4][0]) + a[i]
if t:
    print(max(dp[n-3][0], dp[n-2][1], dp[n-1][2]))
else:
    print(max(dp[n-2][0], dp[n-1][1]))
N,M=map(int,input().split())
Xa={}
ans=0
for i in range(N):
    V,S=map(int,input().split())
    Xa[V]=S
Xb=sorted(Xa.items())
for i in range (N) :
    M -= Xb[i][1]
    ans += Xb[i][0]*Xb[i][1]
    if M <= 0 :
        ans -= abs(M)*Xb[i][0]
        break

print(ans)

### FIXED CODE ###

N,M=map(int,input().split())
Xa={}
ans=0
for i in range(N):
    V,S=map(int,input().split())
    if V in Xa :
        Xa[V] += S
    else :
        Xa[V]=S
Xb=sorted(Xa.items())
for i in range (len(Xb)) :
    M -= Xb[i][1]
    ans += Xb[i][0]*Xb[i][1]
    if M <= 0 :
        ans -= abs(M)*Xb[i][0]
        break
 
print(ans)
n, W = map(int, input().split())
MAX_V = 100000
dp = [0] + [float('INF')]*MAX_V
for _ in range(n):
    tmp_dp = [0]*(MAX_V+1)
    w, v = map(int, input().split())
    for sum_v in range(MAX_V+1):
        if sum_v >= v:
            tmp_dp[sum_v] = min(dp[sum_v], dp[sum_v - v] + w)
        else:
            tmp_dp[sum_v] = min(dp[sum_v], w)
    dp = tmp_dp

ans = 0
while dp[ans+1] <= W:
    ans +=1
print(ans)

### FIXED CODE ###

N, W = map(int, input().split())
MAX_V = 10**5+1
dp = [float('inf')] * MAX_V
dp[0] = 0
for _ in range(N):
    w, v = map(int, input().split())
    for sum_v in range(MAX_V)[::-1]:
        if sum_v >= v:
            dp[sum_v] = min(dp[sum_v - v] + w, dp[sum_v])
        else:
            dp[sum_v] = min(dp[sum_v], w)
ans = 0
for v in range(MAX_V)[:: -1]:
    if dp[v] <= W:
        ans = v
        break
print(ans)
import bisect
n = int(input())
a = list(map(int, input()))
b = list(map(int, input()))
c = list(map(int, input()))
a.sort()
ans = 0
for i in b:
  d = bisect.bisect_left(a, i)
  e = bisect.bisect_right(c, i)
  if d > 0 and e < len(c):
    ans += d*(n-e)
print(ans)

### FIXED CODE ###

import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for i in b:
  d = bisect.bisect_left(a, i)
  e = bisect.bisect_right(c, i)
  if d > 0 and e < len(c):
    ans += d*(n-e)
print(ans)
n = int(input())
a = int(input())
if n % 500 =< a:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n = int(input())
a = int(input())
if a >= n % 500:
  print('Yes')
else:
  print('No')
import collections

N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]

pq = []
cost = N

for xyi in xy:
    for xyj in xy:
        pq.append((xyi[0]-xyj[0], xyi[1]-xyj[1]))

count = collections.Counter(pq)
if (count.most_common()[0][0] == (0,0)):
    print(N - count.most_common()[1][1])
else:
    print(N - count.most_common()[0][1])


### FIXED CODE ###

import collections

N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]

if (N==1):
    print(1)
    quit()

pq = []
cost = N

for xyi in xy:
    for xyj in xy:
        pq.append((xyi[0]-xyj[0], xyi[1]-xyj[1]))

count = collections.Counter(pq)
if (count.most_common()[0][0] == (0,0)):
    print(N - count.most_common()[1][1])
else:
    print(N - count.most_common()[0][1])
S=input()
l=len(S)
def solve(s,h):
    if h==1:
        return 1
    elif h==2:
        if s[0]==s[1]:
            return 1
        else:
            return 2
    elif h==0:
        return 0
    else:
        if s[h-1]==s[h-2]:
            return solve(s,h-3)+2
        else:
            return solve(s,h-1)+1
print(solve(S,l))
        

### FIXED CODE ###

S=input()
cnt=0
pre=''
tmp=''
for s in S:
    tmp+=s
    if tmp!=pre:
        pre=tmp
        tmp=''
        cnt+=1
print(cnt)
#3
#8
n=int(input())
ai=list(map(int(),input.split()))
        
for a in ai:
  count =0
  while a%2==0 :
    count+=1
    a/=2
  b.append(count)
print(min(b))

### FIXED CODE ###

#3
#8 12 40
n=int(input())
ai=list(map(int,input().split()))
b=[]
for a in ai:
  count =0
  while a%2==0 :
    count+=1
    a/=2
  b.append(count)
print(min(b))
n=int(input())
d = [[0] * 10 for i in range(10)]

ans = 0
for i in range(1,n+1):
    s=str(i)
    if s[0]=="0" or s[-1]=="0":
        continue
    else:
        d[int(s[0])][int(s[-1])] += 1

ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += d[i][j] * d[j][i]

print(ans)
n = int(input())

d = [[0] * 10 for i in range(10)]

ans = 0
for i in range(1,n + 1):
    s = str(i)
    if s[0] == "0" or s[-1] == "0":
        continue
    else:
        d[int(s[0])][int(s[-1])] += 1

ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += d[i][j] * d[j][i]

print(ans)

### FIXED CODE ###

n=int(input())
d = [[0] * 10 for i in range(10)]

ans = 0
for i in range(1,n+1):
    s=str(i)
    if s[0]=="0" or s[-1]=="0":
        continue
    else:
        d[int(s[0])][int(s[-1])] += 1

ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += d[i][j] * d[j][i]

print(ans)
import math
from itertools import accumulate

def eratosthenes(n):
    prime_list = []
    num_list=[i for i in range(2, n+1)]
    limit = math.sqrt(n)
    while True:
        if limit <= num_list[0]:
            return prime_list + num_list
        prime_list.append(num_list[0])
        num_list = [e for e in num_list if e % num_list[0] != 0]

er_list = eratosthenes(100000)
count = []

j = 0
for i in range(er_list[-1]):
    if i == er_list[j]:
        j += 1
        if (i+1)//2 in er_list:
            count.append(1) 
        else:
            count.append(0)
    else:
        count.append(0)
count = list(accumulate(count))
            
Q = int(input())
for i in range(Q):
    l, r = map(int, input().split())
    print(count[r]-count[l-1])

### FIXED CODE ###

q = int(input())
    
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

ls = [0]

for i in range(1,100000):
    if is_prime(i) and is_prime((i+1)//2):
        ls.append(ls[i-1]+1)
    else:
        ls.append(ls[i-1])
        
for i in range(q):
    l,r = map(int,input().split())
    if l == r:
        if is_prime(l) and is_prime((l+1)//2):
            print(1)
        else:
          print(ls[r]-ls[l-1])  
    else:
        print(ls[r]-ls[l-1])