λFPAI
Practice/Implement mean squared error

Implement mean squared error

Easy

Problem Description

Given two lists of predictions and targets (same length), compute the mean squared error: (1/n) * sum((pred[i] - target[i])^2).

Input: Two lines. First: space-separated predictions. Second: space-separated targets.

Output: One number (MSE), rounded to 4 decimal places.

Example:

  • Input: 1 2 3 and 1 2 4
  • Output: 0.3333 (only last element differs: (3-4)^2 = 1, mean = 1/3)

Input & Output Format

INPUT:
Two lines. First line: space-separated numbers for vector a.
Second line: space-separated numbers for vector b.
OUTPUT:
A single number (the dot product).

Example

Input:
1 2 3
4 5 6
Output:
32
Explanation: 1×4 + 2×5 + 3×6 = 4 + 10 + 18 = 32
Loading editor...

Output

Run or submit to see output.