abacus.ai

s2_fe37b25c37764dff86c39d9d854368f3

3514. Number of Unique XOR Triplets II

You are given an integer array nums. A XOR triplet is defined as the XOR of three elements nums[i] XOR nums[j] XOR nums[k] where i <= j <= k. Return the number of unique XOR triplet values from all possible triplets (i, j, k).
/**
 * @param {number[]} nums
 * @return {number}
 */
var uniqueXorTriplets = function(nums) {
    const n = nums.length;

    // Edge case: only one element.
    // Only triplet is (0,0,0) → nums[0] ^ nums[0] ^ nums[0] = nums[0],
    // so there is exactly 1 unique XOR value.
    if (n === 1) return 1;

    // Step 1: collect all unique pair XORs (i < j).
    const pairXors = new Set();
    for (let i = 0; i < n; i++) {
        for (let j = i + 1; j < n; j++) {
            pairXors.add(nums[i] 

deploy beacon ui to staging and production

    upgreade  beacon-ui version
    Use that version on the project that will be deployed
    Merge change to main in beacon-ui project using squash
    then crea tag with version name and do a push origin of the tag
    I cron will be run 
    
    

Claude settings

{
    "model": "opus[1m]",
    "permissions": {
        "allow": [
            "Bash(poetry run pytest:*)",
            "Bash(poetry run ruff check:*)",
            "Bash(poetry run ruff format:*)",
            "Bash(poetry run mypy:*)",
            "Bash(poetry install:*)",
            "Bash(poetry lock:*)",
            "Bash(poetry show:*)",
            "Bash(git status:*)",
            "Bash(git diff:*)",
            "Bash(git log:*)",
            "Bash(git show:*)",
            "Bash(git bra

3513. Number of Unique XOR Triplets I

You are given an integer array nums of length n, where nums is a permutation of the numbers in the range [1, n]. A XOR triplet is defined as the XOR of three elements nums[i] XOR nums[j] XOR nums[k] where i <= j <= k. Return the number of unique XOR triplet values from all possible triplets (i, j, k).
/**
 * @param {number[]} nums
 * @return {number}
 */
var uniqueXorTriplets = function(nums) {
    const n = nums.length;

    // Special-case handling:
    // For n = 1 → only one value possible (x ⊕ x ⊕ x = x)
    if (n === 1) return 1;

    // For n = 2 → only values {1, 2} are possible
    // LeetCode confirms this exception
    if (n === 2) return 2;

    // For n ≥ 3:
    // The array is a permutation of 1..n.
    // XOR values depend on the highest bit present in n.
    //
    // msb(n) =

3513. Number of Unique XOR Triplets I

You are given an integer array nums of length n, where nums is a permutation of the numbers in the range [1, n]. A XOR triplet is defined as the XOR of three elements nums[i] XOR nums[j] XOR nums[k] where i <= j <= k. Return the number of unique XOR triplet values from all possible triplets (i, j, k).
/**
 * @param {number[]} nums
 * @return {number}
 */
var uniqueXorTriplets = function(nums) {
    const n = nums.length;

    // Special-case handling:
    // For n = 1 → only one value possible (x ⊕ x ⊕ x = x)
    if (n === 1) return 1;

    // For n = 2 → only values {1, 2} are possible
    // LeetCode confirms this exception
    if (n === 2) return 2;

    // For n ≥ 3:
    // The array is a permutation of 1..n.
    // XOR values depend on the highest bit present in n.
    //
    // msb(n) =

Detener la rotación de partículas

Here you can stop the rotation of the particles based in age or speed

// Define when the slowdown starts and how long it takes to stop
float start_age = 1.0;  // Starts slowing down at 1 second old
float duration = 1.5;   // Takes 1.5 seconds to fully stop

if (@age > start_age) {
    // Calculate a 0 to 1 ramp based on age
    float factor = (@age - start_age) / duration;
    factor = clamp(factor, 0.0, 1.0);
    
    // Smooth the transition (optional but looks better)
    factor = smooth(0.0

AllineamentoPermessiBoNew

use [Boscolo_TravelPlace]
use [Boscolo_TravelPlace_DEV]
use [Cartorange_TravelPlace]
use [FT_TravelPlace]
use [Futura_TravelPlace]
use [Glamour_TravelPlace]
use [Going_TravelPlace]
use [Mind3_TravelPlace]
use [Mind3_TravelPlace_TEST]
use [Nicolaus_TravelPlace]
use [PT_TravelPlace]

insert into dbo.Permissions_MenuItems_Profili (IDPermission, IDMenuItem, IDProfilo)
SELECT 
	--mi.Label,
    --mi.Url,
	--p.Name,
	--p.Description,
    src.IDPermission,
    src.IDMenuItem,
    src

ContrastiveCounterfactualLow

Worked for 7s ContrastiveCounterfactualLow Multimodal Future Tactile Response Prediction for Human-Centered Material Interaction Modeling Overview ContrastiveCounterfactualLow is a multimodal learning framework for predicting future tactile responses during physical interaction. The model receives: One synchronized RGB observation A sequence of historical GelSight tactile frames A normalized contact position It then predicts the subsequent tactile sequence. The framework combines multimodal contrastive alignment, latent future-state modeling, low-rank representation learning, and counterfactual regularization to generate accurate and computationally efficient tactile predictions. Key Features Multimodal RGB, tactile, and spatial information processing Future GelSight tactile sequence prediction Contrastive visual-tactile representation alignment Counterfactual latent future-state projection Low-rank structural compression End-to-end model training Object-level evaluation on unseen test objects Support for the VisGel and Touch and Go datasets Model Architecture ContrastiveCounterfactualLow consists of three main components. Contrastive Structure Matcher The Contrastive Structure Matcher learns aligned representations from visual observations, historical tactile sequences, and contact-position information. It includes: A visual encoder for the RGB observation A tactile encoder for the historical tactile sequence A positional encoder for the contact coordinates A contrastive alignment module A multimodal fusion network Synchronized visual-spatial and tactile representations are treated as positive pairs, while representations from different interaction samples are treated as negative pairs. Counterfactual State Projector The Counterfactual State Projector estimates a latent transition from the current interaction state to a plausible future interaction state. During training, the projected future state is aligned with a latent representation encoded from the ground-truth future tactile sequence. A regularization term constrains the magnitude of the latent transition and prevents unstable or unnecessary changes. In this project, the term “counterfactual” refers to a learned latent alternative to the currently observed interaction state. The method does not require causal graphs, intervention labels, or externally annotated counterfactual samples. Low-Rank Structure Mapper The Low-Rank Structure Mapper reduces redundant information in the projected latent state through a learnable bottleneck. The default dimensions are: Shared latent dimension: 256 Low-rank dimension: 64 A reconstruction objective is used to preserve the principal interaction structure while compressing the latent representation. Training Objective The complete model is trained using a weighted combination of five objectives: Future tactile prediction loss Contrastive alignment loss Future-state alignment loss Low-rank reconstruction loss Counterfactual transition regularization The total objective is defined as: L_total = L_pred + lambda_con × L_con + lambda_state × L_state + lambda_low × L_low + lambda_cr × L_cr Task Definition The default task configuration uses: One synchronized RGB image Five historical tactile frames One normalized two-dimensional contact position Five future tactile frames as prediction targets An image resolution of 128 × 128 The model directly generates the complete five-frame tactile sequence without online adaptation or access to intermediate ground-truth frames. Datasets VisGel VisGel is a large-scale vision-touch benchmark collected using synchronized RGB cameras and GelSight tactile sensors. Each interaction sample contains visual observations, tactile sequences, and contact-location information. Touch and Go Touch and Go is a vision-touch dataset collected during real-world human exploration. It provides synchronized RGB observations, GelSight tactile sequences, and contact information. Dataset Split Both datasets use an object-level partition: 70% training 15% validation 15% testing All interaction sequences belonging to the same object are assigned to only one subset. Objects in the test set are therefore not observed during training. Data Preprocessing The default preprocessing pipeline includes: Removing incomplete or corrupted samples Synchronizing RGB, tactile, and contact data Resizing RGB and tactile images to 128 × 128 Normalizing image values to the range [-1, 1] Normalizing contact coordinates Constructing sequences with a sliding-window stride of one frame Training-only data augmentation includes: Random horizontal flipping Random cropping RGB color jittering Geometric transformations should be applied consistently to RGB images, tactile frames, and contact coordinates. Reported Performance VisGel Results Method PSNR ↑ SSIM ↑ LPIPS ↓ FVD ↓ Persistence 22.34 0.768 0.186 167.4 ConvLSTM 24.87 0.818 0.147 129.5 SVG-LP 25.43 0.831 0.136 118.9 VisGel 26.28 0.851 0.118 102.7 SimVP 26.71 0.858 0.111 94.3 MCVD 27.43 0.874 0.094 79.6 ContrastiveCounterfactualLow 28.14 0.886 0.086 71.8 Touch and Go Results Method PSNR ↑ SSIM ↑ LPIPS ↓ FVD ↓ Persistence 20.76 0.712 0.223 214.8 ConvLSTM 23.12 0.773 0.174 158.6 SVG-LP 23.67 0.789 0.161 145.2 VisGel 24.21 0.803 0.149 133.7 SimVP 24.68 0.815 0.137 121.4 MCVD 25.36 0.831 0.123 108.9 ContrastiveCounterfactualLow 26.02 0.845 0.112 97.6 Compared with the strongest baseline, the proposed framework reports: A 9.8% reduction in FVD on VisGel A 10.4% reduction in FVD on Touch and Go Computational Efficiency Method Parameters (M) ↓ FLOPs (G) ↓ Persistence 0.0 0.02 ConvLSTM 21.4 52.8 SVG-LP 34.7 78.5 VisGel 28.9 61.2 SimVP 12.6 34.9 MCVD 124.3 312.6 ContrastiveCounterfactualLow 18.7 42.1 Compared with MCVD, ContrastiveCounterfactualLow uses approximately: 85.0% fewer parameters 86.5% fewer FLOPs Default Configuration Setting Value Historical tactile frames 5 Predicted tactile frames 5 Image resolution 128 × 128 Shared latent dimension 256 Low-rank dimension 64 Optimizer AdamW Initial learning rate 1e-4 Weight decay 1e-5 Batch size 64 Maximum epochs 100 Warm-up period 5 epochs Learning-rate schedule Cosine annealing Gradient clipping Maximum norm of 1.0 Prediction-head dropout 0.5 Early-stopping patience 10 epochs Model-selection metric Validation FVD Independent runs 5 Environment The reported experiments use: Ubuntu 22.04 LTS PyTorch 2.2.1 CUDA 12.1 cuDNN 9.0 torchvision 0.17 NumPy 1.26 OpenCV 4.9 SciPy 1.11 NVIDIA A100 GPU with 40 GB memory Installation git clone https://github.com/YOUR_USERNAME/YOUR_REPOSITORY.git cd YOUR_REPOSITORY python -m venv .venv source .venv/bin/activate pip install --upgrade pip pip install -r requirements.txt Suggested Project Structure . ├── configs/ │ ├── visgel.yaml │ └── touch_and_go.yaml ├── datasets/ ├── models/ │ ├── encoders.py │ ├── contrastive_structure_matcher.py │ ├── counterfactual_state_projector.py │ ├── low_rank_structure_mapper.py │ └── model.py ├── losses/ ├── metrics/ ├── scripts/ ├── train.py ├── evaluate.py ├── requirements.txt └── README.md Usage The following commands are templates and should be updated according to the final implementation. Train on VisGel python train.py --config configs/visgel.yaml Train on Touch and Go python train.py --config configs/touch_and_go.yaml Evaluate a Checkpoint python evaluate.py \ --config configs/visgel.yaml \ --checkpoint checkpoints/best.pt Evaluation Metrics The project evaluates model performance using: PSNR for pixel-level reconstruction fidelity SSIM for structural similarity LPIPS for perceptual similarity FVD for sequence-level quality and temporal consistency Parameter count for model size FLOPs for computational cost Higher PSNR and SSIM values indicate better performance. Lower LPIPS and FVD values indicate better performance. Reproducibility The reported experiments use five random seeds: 2026 2027 2028 2029 2030 For each run: Keep the object-level dataset split fixed. Select hyperparameters using the validation set only. Select the checkpoint with the lowest validation FVD. Evaluate the selected checkpoint on the test set. Report the mean and standard deviation across all runs. Ablation Study The main ablation experiments remove one component at a time: Contrastive Structure Matcher Counterfactual State Projector Low-Rank Structure Mapper Counterfactual Regularization The reported experiments show that all four components contribute to the final performance. The largest performance degradation occurs when the Counterfactual State Projector is removed, indicating that latent future-state modeling is particularly important for tactile sequence prediction. Limitations The current study has several limitations: Evaluation is restricted to two vision-touch datasets. The prediction horizon is fixed at five frames. Robustness is evaluated using only one Gaussian-noise setting. Longer and variable-length tactile prediction is not evaluated. Broad cross-dataset generalization remains unexplored. Future work may investigate longer prediction horizons, variable-length generation, additional datasets, and robustness under more diverse sensor disturbances. Citation Publication information should be updated after the final paper is published. @article{fan_contrastivecounterfactuallow, title = {Bio-Inspired Material Interaction Modeling for Human-Centered Product Design via Multimodal Future Tactile Response Prediction}, author = {Fan, WenYu and Wu, WenYunJie and Zheng, YiFeng and Zhang, JiaLong and Lu, DaYuan and Hu, RongKun}, journal = {Manuscript}, year = {TBD} } License Add an open-source license before publishing the repository. Common options include: MIT License Apache License 2.0 BSD 3-Clause License Acknowledgments This project builds on research in vision-touch learning, GelSight sensing, multimodal representation learning, video prediction, contrastive learning, and low-rank representation learning. The repository description and reported experimental details are based on the uploaded manuscript.
# model.py

from __future__ import annotations

from dataclasses import dataclass
from typing import Dict, Optional, Tuple

import torch
import torch.nn as nn
import torch.nn.functional as F
from torch import Tensor


@dataclass
class ModelConfig:
    image_channels: int = 3
    history_length: int = 5
    prediction_length: int = 5
    image_size: int = 128

    latent_dim: int = 256
    low_rank_dim: int = 64
    base_channels: int = 32

    contrastive_temperature: flo

3501. Maximize Active Section with Trade II

You are given a binary string s of length n, where: '1' represents an active section. '0' represents an inactive section. You can perform at most one trade to maximize the number of active sections in s. In a trade, you: Convert a contiguous block of '1's that is surrounded by '0's to all '0's. Afterward, convert a contiguous block of '0's that is surrounded by '1's to all '1's. Additionally, you are given a 2D array queries, where queries[i] = [li, ri] represents a substring s[li...ri]. For each query, determine the maximum possible number of active sections in s after making the optimal trade on the substring s[li...ri]. Return an array answer, where answer[i] is the result for queries[i]. Note For each query, treat s[li...ri] as if it is augmented with a '1' at both ends, forming t = '1' + s[li...ri] + '1'. The augmented '1's do not contribute to the final count. The queries are independent of each other.
/**
 * @param {string} s
 * @param {number[][]} queries
 * @return {number[]}
 */
/**
 * SegmentTree
 * A simple max-segment-tree built over an array of numbers.
 * Supports:
 *   - build(): construct the tree in O(n)
 *   - query(L, R): get the max value in range [L, R] in O(log n)
 */
class SegmentTree {
    constructor(arr) {
        this.arr = arr;
        this.n = arr.length;
        // Segment trees need ~4x the array size to safely hold all nodes
        this.seg = new Array(this.n << 2).

3499. Maximize Active Section with Trade I

You are given a binary string s of length n, where: '1' represents an active section. '0' represents an inactive section. You can perform at most one trade to maximize the number of active sections in s. In a trade, you: Convert a contiguous block of '1's that is surrounded by '0's to all '0's. Afterward, convert a contiguous block of '0's that is surrounded by '1's to all '1's. Return the maximum number of active sections in s after making the optimal trade. Note: Treat s as if it is augmented with a '1' at both ends, forming t = '1' + s + '1'. The augmented '1's do not contribute to the final count.
/**
 * @param {string} s
 * @return {number}
 */
var maxActiveSectionsAfterTrade = function (s) {
    // Length of the string
    const n = s.length;

    // Count how many '1's are originally in the string
    let cnt1 = 0;
    for (let c of s) {
        if (c === "1") cnt1++;
    }

    // Collect lengths of ALL zero-blocks (contiguous '0' segments)
    const zeroBlocks = [];
    let i = 0;

    while (i < n) {
        const start = i;

        // Move i forward while characters match the bloc

1260. Shift 2D Grid

Given a 2D grid of size m x n and an integer k. You need to shift the grid k times. In one shift operation: Element at grid[i][j] moves to grid[i][j + 1]. Element at grid[i][n - 1] moves to grid[i + 1][0]. Element at grid[m - 1][n - 1] moves to grid[0][0]. Return the 2D grid after applying shift operation k times.
/**
 * @param {number[][]} grid
 * @param {number} k
 * @return {number[][]}
 */
var shiftGrid = function(grid, k) {
    const m = grid.length;
    const n = grid[0].length;
    const total = m * n;

    // Flatten the grid into a 1D array
    const flat = [];
    for (let i = 0; i < m; i++) {
        for (let j = 0; j < n; j++) {
            flat.push(grid[i][j]);
        }
    }

    // Effective rotation
    k = k % total;

    // Rotate by slicing
    const rotated = flat.slice(total - k).co

devin

cog_j35zccdhljzxbdmdd7zw3dywcavplws4p4iihz4tz5v7gw4q6s3q

devin.md

cog_j35zccdhljzxbdmdd7zw3dywcavplws4p4iihz4tz5v7gw4q6s3q

how to connect development beacon ui to a development project?

yarn link on beacon-ui project
yarn link "@mybeaconlabs/beacon-ui" on IBP project

groq

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