# Сравнивает исходный код контракта токена
# Комментарии в коде в расчет не берутся

import re
import requests

API_KEY = "<TRUFFLEHOG_REDACTED_BSCSCAN>"
BASE_URL = "https://api.bscscan.com/api"

def remove_comments(source_code):
    # Remove single-line comments
    source_code = re.sub(r"//.", "", source_code)

    # Remove multi-line comments
    source_code = re.sub(r" / *[\s\S]? * / ", "", source_code)

    return source_code

def get_contract_source_code(address):
    params = {
    "module": "contract",
    "action": "getsourcecode",
    "address": address,
    "apiKey": API_KEY
    }

    response = requests.get(BASE_URL, params=params)
    data = response.json()

    if data["status"] == "1":
        source_code = data["result"][0]["SourceCode"]
        return remove_comments(source_code)
    else:
        return None


def find_similar_contracts(reference_addresses, candidate_addresses):
    reference_source_codes = {}
    for reference_address in reference_addresses:
        source_code = get_contract_source_code(reference_address)
        if source_code is not None:
            reference_source_codes[reference_address] = source_code

    if not reference_source_codes:
        print("No source code found for reference contracts")
        return []

    similar_contracts = {}
    for address in candidate_addresses:
        candidate_source_code = get_contract_source_code(address)
        if candidate_source_code is not None:
            for reference_address, reference_source_code in reference_source_codes.items():
                if candidate_source_code == reference_source_code:
                    if reference_address not in similar_contracts:
                        similar_contracts[reference_address] = [address]
                    else:
                        similar_contracts[reference_address].append(address)

    return similar_contracts


if __name__ == "__main__":
    # Replace this list with a list of reference contract addresses to check
    reference_addresses = ["0x4401E60E39F7d3F8D5021F113306AF1759a6c168", "0x2023aa62a7570ffd59f13fde2cac0527d45abf91",
                           "0x445645eC7c2E66A28e50fbCF11AAa666290Cd5bb", "0x1f5FbCF2787140b2F05081Fd9f69Bc0F436B13C1",
                           "0x735204a9420af122142a18F03464Bc311CDEA95B", "0x82b12a2ca1B8003ED7249C88Bb2B7221809AcAc4",
                           "0x03c5610C0749a16f2B05C53A26220cc872918fd4"]

    # Replace this list with a list of candidate contract addresses to check
    # For example, you can fetch a list of contracts created recently using another BscScan API endpoint
    candidate_addresses = ["0x4401E60E39F7d3F8D5021F113306AF1759a6c168"]

    similar_contracts = find_similar_contracts(reference_addresses, candidate_addresses)
    print("Contracts with similar source code (ignoring comments):")
    for reference_address, similar_addresses in similar_contracts.items():
        print(f"Reference contract: {reference_address}")
        for address in similar_addresses:
            print(f"Similar contract: {address}")

The code above only detects contracts that are completely identical to each other.
Change the code so that it also detects contracts that are as similar as possible to each other