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

S = input()
rest = [0] * (len(S) + 1)
rest[0] = 0
for i in range(len(S)):
    rest[i+1] = (rest[i] + int(S[-(i+1)]) * 10 ** i) % 2019
    # print(i, rest[i+1], rest[i], int(S[-(i+2)]), int(S[-(i+2)]) * 10 ** (i+1))
# print(rest)
cnt = [0] * (2019 + 1)
for i in rest: cnt[i] += 1
ans = 0
for i in range(2020):
    ans += cnt[i] * (cnt[i] - 1) // 2
print(ans)

### FIXED CODE ###

S = list(input())
rest = [0] * (len(S) + 1)
rest[0] = 0
rd = 1
for i in range(len(S)):
    rest[i+1] = (rest[i] + int(S[-(i+1)]) * rd) % 2019
    rd *= 10
    rd %= 2019
    # print(i, rest[i+1], rest[i], int(S[-(i+2)]), int(S[-(i+2)]) * 10 ** (i+1))
# print(rest)
cnt = [0] * (2019 + 1)
for i in rest: cnt[i] += 1
ans = 0
for i in range(2020):
    ans += cnt[i] * (cnt[i] - 1) // 2
print(ans)
### BUGGY CODE ###

n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
count = 0
for i in range(n-2):
    for j in range(n-i-2):
        L = l[i]
        M = l[i+j+1]
        joken = L - M + 1
        for k in range(len(l[i+j+2::])):
            nl = l[i+j+2::]
            if nl[k] >= joken:
                count += 1
print(count)


### FIXED CODE ###

import bisect

n = int(input())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        short_2hen = l[i] + l[j]
        bis = bisect.bisect_left(l, short_2hen)
        count += bis - j - 1
print(count)
### BUGGY CODE ###

N,M = [int(i) for i in input().split()]
data = [int(i) for i in input().split()]
data.sort(reverse = True)
#print(data)
while M != 0:
    x = max(data)
    data[data.index(x)] //= 2
    M -= 1
    #print(data)

print(sum(data))

### FIXED CODE ###

import heapq


N,M = [int(i) for i in input().split()]
data = [int(i) for i in input().split()]
data = list(map(lambda x: x*(-1), data))
heapq.heapify(data)
#print(data)
while M != 0:
    x = heapq.heappop(data)*(-1)
    heapq.heappush(data,-1*(x//2))
    M -= 1
    #print(data)
 
print(-sum(data))
### BUGGY CODE ###

INF = 10**9

N, M, R = list(map(int, input().split()))
r = list(map(int, input().split()))
W = [[INF for _ in range(N+1)] for __ in range(N+1)]

for _ in range(M):
    x = list(map(int, input().split()))
    A, B, C = x
    W[A][B] = C
    W[B][A] = C


for k in range(1, N+1):
     for j in range(1, N+1):
         if k == j:
             continue
         for i in range(j+1, N+1):
             W[i][j] = min(W[i][j], W[i][k]+W[k][j])
             W[j][i] = W[i][j]

from itertools import permutations

ans = INF
for r_ in permutations(r):
    count = 0
    for i in range(R-1):
        x = W[r_[i]][r_[i+1]]
        if x >= INF:
            break
        count += x
        if count >= ans:
            break
    else:
        ans = count
print(ans)

### FIXED CODE ###

INF = 10**9

N, M, R = list(map(int, input().split()))
r = list(map(int, input().split()))
W = [[INF for _ in range(N+1)] for __ in range(N+1)]
for i in range(1, N+1):
    W[i][i] = 0

for _ in range(M):
    A, B, C = list(map(int, input().split()))
    W[A][B] = C
    W[B][A] = C

import heapq

for i in range(1, N+1):
    heap = []
    checked = [False for _ in range(N+1)]
    for j in range(1, i+1):
        heapq.heappush(heap, (W[i][j], j))
    while len(heap) > 0:
        wij, j = heapq.heappop(heap)
        if checked[j]:
            continue
        for k in range(i+1, N+1):
            wik = wij + W[j][k]
            if wik <= W[i][k]:
                W[i][k] = wik
                W[k][i] = wik
                heapq.heappush(heap, (wik, k))
        checked[j] = True

from itertools import permutations

ans = INF
for r_ in permutations(r):
    count = 0
    for i in range(R-1):
        x = W[r_[i]][r_[i+1]]
        if x >= INF:
            break
        count += x
        if count >= ans:
            break
    else:
        ans = count
print(ans)
### BUGGY CODE ###

import collections

n, m = map(int, input().split())
ans = []

def addNum(ans):
    a, b = map(int, input().split())
    for i in range(a, b+1):
        ans.append(i)

for i in range(m):
    addNum(ans)

res = collections.Counter(ans)

count = 0
for i in res.values():
    if i == m:
        count += 1

print(count)

### FIXED CODE ###

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

maxNum = 0
minNum = 0

for i in range(m):
    a, b = map(int, input().split())
    if maxNum == 0:
        maxNum = b
    else:
        if maxNum > b:
            maxNum = b

    if minNum == 0:
        minNum = a
    else:
        if minNum < a:
            minNum = a

if maxNum - minNum >= 0:
    print(maxNum - minNum + 1)
else:
    print(0)
### BUGGY CODE ###

import numpy as np
from sys import stdin

def main():
    readline = stdin.readline
    N = int(readline())
    a = list(map(int, readline().split()))
    a = np.sort(a)
    count = 0
    idxes = np.arange(len(a))
    while len(idxes):
        idx = idxes[0]
        idxes = np.delete(idxes, 0)
        var = a[idx]
        if len(np.where(a[idxes] == var)[0]) == 0:
            count += 1
        idxes = idxes[np.where(a[idxes] % var != 0)[0]]
    print(count)

main()

### FIXED CODE ###

from sys import stdin

import numpy as np

U = 10 ** 6 + 10


def main():
    readline = stdin.readline
    N = int(readline())
    a = list(map(int, readline().split()))
    ret = 0
    exist_counts = [0] * U
    for x in a:
        if exist_counts[x]:
            exist_counts[x] = 2
            continue
        idx = x
        while idx < U:
            exist_counts[idx] += 1
            idx += x
    for x in a:
        ret += exist_counts[x] == 1
    print(ret)
main()
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
l = []
r = []
for _ in range(q):
    lq, rq = map(int, input().split())
    l.append(lq)
    r.append(rq)
    
for i in range(q):
    print(s[l[i]-1:r[i]].count('AC'))

### FIXED CODE ###

N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1:i+1]=="AC":count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])
### BUGGY CODE ###

from heapq import heapify, heappush, heappop
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
roadworks = [tuple(map(int, input().split())) for _ in range(N)]
Ds = [int(input()) for _ in range(Q)]

events = []
for iR, (S, T, X) in enumerate(roadworks):
    events.append((S-X, 0, X, iR))
    events.append((T-X, 1, -X, iR))
events.sort()

iE = 0
isActives = [False] * N
anss = []
PQ = []
for D in Ds:
    while iE < 2*N and events[iE][0] <= D:
        tm, ST, x, iR = events[iE]
        if ST == 0:
            isActives[iR] = True
            heappush(PQ, (x, iR))
        else:
            isActives[iR] = False
        iE += 1

    xMin = -1
    while PQ:
        x, iR = heappop(PQ)
        if isActives[iR]:
            xMin = x
            heappush(PQ, (x, iR))
            break
    anss.append(xMin)

print('\n'.join(map(str, anss)))


### FIXED CODE ###

from heapq import heapify, heappush, heappop
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
events = []
for iR in range(N):
    S, T, X = map(int, input().split())
    events.append((S-X, T-X, X))
events.sort()

iE = 0
anss = []
PQ = []
for _ in range(Q):
    D = int(input())
    while iE < N and events[iE][0] <= D:
        tmSt, tmEn, x = events[iE]
        heappush(PQ, (x, tmEn))
        iE += 1

    xMin = -1
    while PQ:
        x, tmEn = heappop(PQ)
        if tmEn > D:
            xMin = x
            heappush(PQ, (x, tmEn))
            break
    anss.append(xMin)

print('\n'.join(map(str, anss)))
### BUGGY CODE ###

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

c = 0
for i in range(N-1):
  for j in range(i+1,N):
    if a[i] == j+1 and a[j] == i+1:
      c += 1
print(c)
    

### FIXED CODE ###

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

c = 0
for i in range(N):
  if a[a[i]-1]-1 == i:
    c += 1
print(c//2)
### BUGGY CODE ###

n=int(input())
L=list(map(int,input().split()))
ans=1
for i in range(n):
    ans=ans*L[i]
    if L[i]==0:
        break

if ans > 1e18:
    print(-1)
else:
    print(ans)



### FIXED CODE ###

n=int(input())
L=list(map(int,input().split()))
L.sort()
if L[0]==0:
    print(0)
else:
    ans=1
    for i in range(n-1,-1,-1):
        ans=ans*L[i]
        if ans >1e18:
            print(-1)
            break
    else:
        print(ans)
### BUGGY CODE ###

x = int(input())

if x == 1:
    ans = 1
elif x == 2:
    ans = 2
else:    
    num = [3]
    for i in range(3, x, 2):
        for j in num:
            if (i % j) == 0:
                break
        else:
            num.append(i)
    last_num = i
    k = i + 1
    while True:
        for j in num:
            if (k % j) == 0:
                k += 1
                break
        else:
            ans = k
            break
print(ans)

### FIXED CODE ###

# ABC149C
import math

def check_prime(num):
    for i in range(2, math.ceil(math.sqrt(num))):
        if num % i == 0:
            return False
    else:
        return True

x = int(input())
while True:
    if check_prime(x):
        print(x)
        break
    x += 1
### BUGGY CODE ###

from collections import deque
H, W = map(int, input().split())
m = [[-1 if c == "." else 0 for c in input() + "#"] for _ in range(H)]
m.append([0] * (W + 1))
todo = deque(((h, w) for h in range(H) for w in range(W) if m[h][w] == 0))
ans = 0
while todo:
    h, w = todo.popleft()
    count = m[h][w] + 1
    for dh, dw in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        nh = h + dh
        nw = w + dw
        if m[nh][nw] == -1:
            m[nh][nw] = count
            todo.append((nh, nw))
            ans = count
print(ans)

### FIXED CODE ###

from collections import deque
H, W = map(int, input().split())
m = [[-1 if c == "." else 0 for c in input() + "#"] for _ in range(H)]
m.append([0] * (W + 1))
todo = deque(((h, w) for h in range(H) for w in range(W) if m[h][w] == 0))
ans = 0
while todo:
    h, w = todo.popleft()
    count = m[h][w] + 1
    for dh, dw in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        nh = h + dh
        nw = w + dw
        if m[nh][nw] == -1:
            m[nh][nw] = count
            todo.append((nh, nw))
            ans = count
print(ans)
### BUGGY CODE ###

S = input()
K = int(input())
n = len(S)

ans = []
st = set()

for i in range(n):
    for j in range(i + 1, n + 1):
        sub = S[i:j]
        # print(sub)
        if sub in st:
            continue
        st.add(sub)
        ans.append(sub)
        ans.sort()
        # print(ans)
        if len(ans) > K:
            ans = ans[:K]

print(ans[-1])


### FIXED CODE ###

S = input()
K = int(input())
n = len(S)

ans = []
st = set()

for i in range(n):
    for j in range(i + 1, min(n + 1, i + 1 + K)):
        sub = S[i:j]
        # print(sub)
        if sub in st:
            continue
        st.add(sub)
        ans.append(sub)
        ans.sort()
        # print(ans)
        if len(ans) > K:
            ans = ans[:K]

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

import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
S = input()
lr = [list(map(int, input().split())) for _ in range(Q)]

for l, r in lr:
    sub = S[l-1:r]
    dp = [0 for _ in range(len(sub))]
    for i in range(len(dp)):
        if sub[i:i+2] == "AC":
            dp[i] = 1
    print(sum(dp))

### FIXED CODE ###

import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
S = input()
lr = [list(map(int, input().split())) for _ in range(Q)]

ac = [0] * N
cnt = 0
for i in range(1, N):
    if S[i-1:i+1] == "AC":
        cnt += 1
    ac[i] = cnt
    
for l, r in lr:
    print(ac[r-1] - ac[l-1])
### BUGGY CODE ###

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a

#targetまでの素数の数
import math
def sieve_of_eratosthenes2(target):
    dest = int(math.sqrt(target))
    target_list = [i for i in range(2, target+1) if target%i==0]
    prime_num = 0
 
    while True:
        num_min = min(target_list)
        if num_min > dest:
            prime_num += len(target_list)
            break
        prime_num += 1        
        target_list = [i for i in target_list if i%num_min!=0]
        if target_list==[]:
            break
 
    return prime_num   

a, b = map(int, input().split())
gcd = xgcd(a, b)
if gcd == 1:
    print(1)
else:
    ans = sieve_of_eratosthenes2(gcd)    
    print(ans+1)

### FIXED CODE ###

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a


import random
def is_prime(q, k=50):
    q = abs(q)
    if q == 2:
        return True
    if q < 2 or q % 2 == 0:
        return False

    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True

def prime_num(target):
    ra = 2
    prime = 0
    while target>1:
        if target%ra == 0:
            prime += 1
            while target%ra==0:
                target = target//ra
            if is_prime(target):
                prime += 1
                break
        if ra == 2:
            ra += 1
        else:
            ra += 2
    return prime   
        
a, b = map(int, input().split())
gcd = xgcd(a, b)
if gcd == 1:
    print(1)
elif is_prime(gcd):
    print(2)
else:
    ans = prime_num(gcd)    
    print(ans+1)
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

h, w = map(int, readline().split())
grid = [[0]*(w) for _ in range(h)]

black = []
for i in range(h):
    for j, k in enumerate(readline()):
        if k == "#":
            black.append((i, j))
            grid[i][j] = 1

ans = 0
d = ((0, 1),
     (1, 0),
     (0, -1),
     (-1, 0),)
while True:
    paint = []
    while black:
        x, y = black.pop()
        for nx, ny in d:
            if x+nx == -1 or x+nx == h or y+ny == -1 or y+ny == w:
                continue
            if not grid[nx + x][ny + y]:
                grid[nx + x][ny + y] = 1
                paint.append((nx + x, ny + y))

    if len(paint) == 0:
        break
    black = paint[:]
    ans += 1

print(ans)


### FIXED CODE ###

h, w = map(int, input().split())
grid = [[0]*(w+2) for _ in range(h+2)]

black = []
for i in range(h):
    for j, k in enumerate(input()):
        if k == "#":
            black.append((i + 1, j + 1))
            grid[i+1][j+1] = 1

ans = 0
d = ((0, 1),
     (1, 0),
     (0, -1),
     (-1, 0),)
while True:
    paint = []
    while black:
        x, y = black.pop()
        if x == 0 or x == h + 1 or y == 0 or y == w + 1:
            continue
        else:
            for nx, ny in d:
                if not grid[nx + x][ny + y]:
                    if x+nx == 0 or x+nx == h + 1 or y+ny == 0 or y+ny == w + 1:
                        continue
                    grid[nx + x][ny + y] = 1
                    paint.append((nx + x, ny + y))

    if len(paint) == 0:
        break
    black = paint[:]
    ans += 1

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

# setting
import numpy as np
from collections import deque

#------------------
# input part
n, m, q = map(int, input().split())

LR = np.array([[0 for _ in range(n)] for i in range(n)])
for i in range(m):
    l, r = map(int, input().split())
    LR[l-1][r-1] += 1

res = list()
for i in range(q):
    p,q = list(map(int, input().split()))
    res.append(np.sum(LR[p-1:q, p-1:q]))
#------------------

#------------------
# print part
for r in res:
    print(r)
#------------------

### FIXED CODE ###

# setting
from itertools import accumulate

#------------------
n, m, q = map(int, input().split())

LR = [[0 for _ in range(n-i)] for i in range(n)]
for i in range(m):
    l, r = map(int, input().split())
    LR[l-1][r-l] += 1

for i in range(n-2, -1, -1):
    for j, acc in enumerate(accumulate(LR[i])):
        LR[i][j] = acc  + (0 if j == 0 else LR[i+1][j-1])

res = list()
for i in range(q):
    p,q = map(int, input().split())
    res.append(LR[p-1][q-p])

for r in res:
    print(r)
### BUGGY CODE ###

from collections import deque

H,W = map(int,input().split())
C_pos=list(map(lambda x:int(x)-1,input().split()))
D_pos=list(map(lambda x:int(x)-1,input().split()))
Grid=[[c for c in input()] for _ in range(H)]

Dist=[[float("inf")]*W for _ in range(H)]

DX=[0,0,1,-1]

Q=deque()
Q.append((C_pos[0],C_pos[1]))
Dist[C_pos[0]][C_pos[1]]=0

while Q:
    cx,cy = Q.pop()

    for dx,dy in zip(DX,reversed(DX)):
        nx=cx+dx
        ny=cy+dy

        if 0<=nx<H and 0<=ny<W and Grid[nx][ny]=="." and Dist[nx][ny]>Dist[cx][cy]:
            Dist[nx][ny]=Dist[cx][cy]
            Q.append((nx,ny))


    for dx in range(-2,3):
        for dy in range(-2,3):
            nx=cx+dx
            ny=cy+dy
            if dx==0 and dy==0:
                continue

            if 0<=nx<H and 0<=ny<W and Grid[nx][ny]=="." and Dist[nx][ny]==float("inf"):
                Dist[nx][ny]=Dist[cx][cy]+1
                Q.appendleft((nx,ny))


ans=Dist[D_pos[0]][D_pos[1]]
if ans==float("inf"):
    print(-1)
else:
    print(ans)




### FIXED CODE ###

from collections import deque
import sys
input=sys.stdin.readline
H,W = map(int,input().split())
C_pos=list(map(lambda x:int(x)-1,input().split()))
D_pos=list(map(lambda x:int(x)-1,input().split()))
Grid=[[c for c in input()] for _ in range(H)]
Dist=[[float("inf")]*W for _ in range(H)]

DX=[0,0,1,-1]
DY=[1,-1,0,0]

Q=deque()
Q.append((C_pos[0],C_pos[1]))
DX=[-1,1,0,0]
visited=set()
prev_visited=set()

dist=0
while True:
    prev_visited=set(v for v in Q)
    if len(Q)==0:
        print(-1)
        exit()

    #できる限りbfs
    while Q:
        cx,cy=Q.pop()
        if cx==D_pos[0] and cy==D_pos[1]:
            print(dist)
            exit()

        visited.add((cx,cy))
        for dx,dy in zip(DX,reversed(DX)):
            nx = cx+dx
            ny=cy+dy
            if 0<=nx<H and 0<=ny<W and Grid[nx][ny]=="." and (nx,ny) not in visited:
                visited.add((nx,ny))
                prev_visited.add((nx,ny))
                Dist[nx][ny]=dist
                Q.append((nx,ny))
                if nx==D_pos[0] and ny==D_pos[1]:
                    print(dist)
                    exit()

    Q=deque()
    for cx,cy in prev_visited:
        for dx in range(-2,3):
            for dy in range(-2,3):
                if dx==0 and dy==0:
                    continue
                nx = cx+dx
                ny=cy+dy
                if (nx,ny) in visited:
                    continue
                if 0<=nx<H and 0<=ny<W and Grid[nx][ny]==".":
                    Q.append((nx,ny))
    dist+=1
### BUGGY CODE ###

n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0
for a in range(n-2):
    for b in range(a+1,n-1):
        for c in range(b+1,n):
            if l[c]<l[a]+l[b]:
                if l[b]<l[a]+l[c]:
                    if l[a]<l[b]+l[c]:
                        ans += 1
            else:
                break
print(ans)

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        a = l[i]
        b = l[j]
        x = (a+1) - b
        y = (b+1) - a
        z = max(x,y)
        a = j+1
        b = n-1
        c = (a+b) // 2
        while a <= b:
            if l[c] == z:
                a += 1
            elif l[c] > z:
                a = c + 1
            elif l[c] < z:
                b = c - 1
            else:
                pass
            c = (a+b) // 2
        ans += c-j
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()
INF = 10**6+1
lis = [1]*INF
exist = [0]*INF
for i in range(N):
    a = A[i]
    exist[a] += 1
    if lis[a]:
        q = 2
        while a*q < INF:
            lis[a*q] = 0
            q += 1
cnt = 0
for a in A:
    if lis[a] and exist[a] == 1:
        cnt += 1
print(cnt)

### FIXED CODE ###

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

INF = 10**6

A.sort()
check = [False] + [True]*(INF)

setA = list(set(A))
length = len(setA)
for i in range(length):
    x = setA[i]
    for j in range(2, int(INF/x)+1):
        check[x*j] = False

prev = 0
count = 0
flag = False #重複チェック
for i in range(N):
    x = A[i]
    if check[x]:
        if x != prev:
            count += 1
            flag = True
        elif flag:
            count -= 1
            flag = False
        prev = x
print(count)
### BUGGY CODE ###

from bisect import bisect_left,bisect_right

TO_ACII = 97

N = int(input())
S = ["0"] + list(input())
Q = int(input())

ABC = [[]for i in range(0,26,1)]#該当文字a:0 b:1 ...z:26 が何文字目に出てきたかを保持する配列

for i in range(1,N+1,1):
    ABC[ord(S[i])-TO_ACII].append(i)

ans = []
for i in range(0,Q,1):
    q = list(input().split())
    if q[0]=="1":#文字変更
        changed = S[int(q[1])]
        ABC[ord(changed)-TO_ACII].pop(bisect_left(ABC[ord(changed)-TO_ACII],int(q[1])))
        ABC[ord(q[2])-TO_ACII].insert(bisect_left(ABC[ord(q[2])-TO_ACII],int(q[1])),int(q[1]))
        S[int(q[1])]=q[2]
    else:
        tmpans = 0
        for i in range(0,26,1):

            if bisect_right(ABC[i],int(q[1])-1)<len(ABC[i]) and int(q[2]) >= ABC[i][bisect_right(ABC[i],int(q[1])-1)]:
                tmpans+=1
        ans.append(tmpans)

for i in range(0,len(ans),1):
    print(ans[i])


### FIXED CODE ###

def main():
    from bisect import bisect_left,bisect
    n = int(input())
    s = list(input())
    q = int(input())
    al=[[] for i in range(26)]
    for i in range(n):
        al[ord(s[i])-97].append(i)
    ans = []
    for i in range(q):
        a , b , x = input().split()
        if a == "1":
            al[ord(s[int(b)-1])-97].pop(bisect_left(al[ord(s[int(b)-1])-97],int(b)-1))
            al[ord(x)-97].insert(bisect_left(al[ord(x)-97],int(b)-1),int(b)-1)
            s[int(b)-1] = x
        elif a == "2":
            b = int(b)-1
            x = int(x)-1
            cou = 0
            for j in range(26):
                l = bisect_left(al[j],b)
                r = bisect(al[j],x)
                if l != r:
                    cou += 1
            ans.append(cou)
    for i in ans:
        print(i)

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

from numpy import*
*s,=map(int,input())
dp=zeros((len(s)+1,2019),int)
r=arange(2019)
a=0
for i,c in enumerate(s):
  dp[i+1,(r*10+c)%2019]+=dp[i,r]
  dp[i+1,c]+=1
print(sum(dp[:,0]))

### FIXED CODE ###

a,*d=[0]*2020
for i in map(int,input()):
  p=[0]*2019
  for j in range(2019):p[(j*10+i)%2019]+=d[j]
  d=p
  d[i]+=1
  a+=d[0]
print(a)
### BUGGY CODE ###

N = int(input())

for n in range(1, N+1):
    ans = 0
    for x in range(1, N+1):
        for y in range(1, N+1):
            for z in range(1, N+1):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    ans += 1
    print(ans)


### FIXED CODE ###

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

for x in range(1, int(N**0.5)+1):
    for y in range(1, int(N**0.5)+1):
        for z in range(1, int(N**0.5)+1):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if n <= N:
                ans[n-1] += 1

for n in range(N):
    print(ans[n])
### BUGGY CODE ###

import itertools
costs = []
N = int(input())
x, y = [], []
# (x,y)の値を取得
for n in range(N):
    temp = list(map(int, input().split()))
    x.append(temp[0])
    y.append(temp[1])
# コスト計算
for n, perm in enumerate(itertools.permutations(zip(x,y), N)):
    sol = 0
    cost = 1
    for i in range(1, N):
        if i == 1:
            sol = [perm[i][0] - perm[i-1][0], perm[i][1] - perm[i-1][1]]
        else:
            if perm[i][0] - sol[0] == perm[i-1][0] and perm[i][1] - sol[1] == perm[i-1][1]:
                cost += 0
            else:
                cost += 1
    costs.append(cost)
print(min(costs))

### FIXED CODE ###

N = int(input())
arr = sorted([list(map(int, input().split())) for _ in range(N)])
cnt = {}
for i in range(N):
    for j in range(i+1,N):
        pq = (arr[j][0] - arr[i][0], arr[j][1] - arr[i][1])
        cnt.setdefault(pq, 0)
        cnt[pq] += 1
print(1 if cnt == {} else N - max(cnt.values()))