Corrija os erros e print apenas as mudanças: Count_arenizacao_interna: Layer error: User memory limit exceeded.
arenizacao_externa: Layer error: User memory limit exceeded.
Count_arenizacao_externa: Layer error: User memory limit exceeded.
arenizacao_interna: Layer error: User memory limit exceeded.
Aqui está o script: var geometry2 = 
    /* color: #98ff00 */
    /* shown: false */
    /* displayProperties: [
      {
        "type": "rectangle"
      }
    ] */
    geometry4,
    geometry3 = 
    /* color: #bf04c2 */
    /* displayProperties: [
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      }
    ] */
    geometry3,
    geometry4 = 
    /* color: #ff0000 */
    /* displayProperties: [
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      }
    ] */
    geometry2,
    geometry = 
    /* color: #00ff00 */
    /* displayProperties: [
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      }
    ] */
    geometry;


// Configurar o mapa
Map.setOptions('SATELLITE');

// Importar a coleção Planet NICFI Americas
var nicfi = ee.ImageCollection('projects/planet-nicfi/assets/basemaps/americas')
  .map(function(img) { return img.clip(geometry2); });

print(nicfi.limit(10), 'nicfi');

// Bandas da coleção
var Bands = ee.List(['B', 'G', 'R', 'N', 'NDVI', 'NDWI']);
var BandsNDWI = ee.List(['B', 'G', 'R', 'N', 'NDVI', 'NDWI']);

// Adicionar função para calcular NDVI
function calculateNDVI(image) {
  var ndvi = image.normalizedDifference(['N', 'R']).rename('NDVI');
  return image.addBands(ndvi).copyProperties(image, ['system:time_start']);
}

// Adicionar função para calcular NDWI
function calculateNDWI(image) {
  var ndwi = image.normalizedDifference(['N', 'B']).rename('NDWI');
  return image.addBands(ndwi).copyProperties(image, ['system:time_start']);
}

// Filtrar a coleção de mapas base por data e adicionar NDVI e NDWI
var filteredImages = nicfi
  .filter(ee.Filter.date('2015-01-01', '2024-12-31'))
  .map(calculateNDVI)
  .map(calculateNDWI);

// Função para obter valores de pixel em listas
function getPixelValuesList(image, geometry, bands) {
  var pixelValues = image.reduceRegion({
    reducer: ee.Reducer.toList(),
    geometry: geometry,
    scale: 5,
    maxPixels: 1e13,
    tileScale: 16
  });
  
  var pixelLists = bands.map(function(band) {
    return pixelValues.get(ee.String(band));
  });
  
  return pixelLists;
}

// Função para aplicar a máscara lógica baseada em valores de listas
function applyMasking(image, geometry, pixelLists) {
  var mask = Bands.iterate(function(band, currentMask) {
    band = ee.String(band);
    currentMask = ee.Image(currentMask);
    
    var index = Bands.indexOf(band);
    var bandPixels = ee.List(pixelLists.get(index));
    
    var bandMask = image.select(band).eq(bandPixels);
    
    return currentMask.and(bandMask);
  }, ee.Image(1));
  
  return image.updateMask(mask);
}

// Função para remover elementos de uma lista de outra lista
var removerElementos = function(listaPrincipal, listaRemover) {
  var setPrincipal = ee.List(listaPrincipal);
  var setRemover = ee.List(listaRemover);
  
  return setPrincipal.removeAll(setRemover);
};

// Obter valores de pixel para as bandas
var pixelLists = getPixelValuesList(filteredImages.first(), geometry3, Bands);
// Obter valores de pixel específicos para NDWI
var pixelListsNDWI = getPixelValuesList(filteredImages.first(), geometry2, BandsNDWI);

// Remover valores NDWI de pixelLists
var cleanPixelLists = Bands.map(function(band, index) {
  return removerElementos(ee.List(pixelLists.get(index)), pixelListsNDWI.get(0));
});

// Aplicar a função de mascaramento para valores de interesse
var maskedImages = filteredImages.map(function(image) {
  return applyMasking(image, geometry3, cleanPixelLists);
});

var count = maskedImages.reduce(ee.Reducer.count());
var countNDWI = count.select('NDWI_count').updateMask(count.select('NDWI_count').gte(35));

// Aplicar a função de mascaramento para valores NDWI
var maskedImagesNDWI = filteredImages.map(function(image) {
  return applyMasking(image, geometry, pixelListsNDWI);
});

var count2 = maskedImagesNDWI.reduce(ee.Reducer.count());
var countNDWI2 = count2.select('NDWI_count').updateMask(count2.select('NDWI_count').gte(35));

Map.addLayer(count.select('NDWI_count'), {
  min: 1, max: 54,
  palette: ['#9400D3','#4B0082','#0000FF', '#00FF00', '#FFFF00', '#FF7F00', '#FF0000']
}, 'Count_arenizacao_interna', true);

Map.addLayer(count2.select('NDWI_count'), {
  min: 1, max: 54,
  palette: ['#9400D3','#4B0082','#0000FF', '#00FF00', '#FFFF00', '#FF7F00', '#FF0000']
}, 'Count_arenizacao_externa', true);


Map.addLayer(countNDWI, {
  min: 1, max: 54,
  palette: ['#9400D3','#4B0082','#0000FF', '#00FF00', '#FFFF00', '#FF7F00', '#FF0000']
}, 'arenizacao_interna', true);

Map.addLayer(countNDWI2, {
  min: 1, max: 54,
  palette: ['#9400D3','#4B0082','#0000FF', '#00FF00', '#FFFF00', '#FF7F00', '#FF0000']
}, 'arenizacao_externa', true);