Does there exist a surjective function $f:\mathbb{R} \rightarrow \mathbb{R}$ for which

$f(x+y)-f(x)-f(y)$

takes only 0 and 1 for values for random $x$ and $y$?
To determine if there exists a surjective function \( f: \mathbb{R} \rightarrow \mathbb{R} \) such that \( f(x+y) - f(x) - f(y) \) takes only the values 0 and 1 for any \( x \) and \( y \), we will analyze the given function:

\[ f(x) = \begin{cases} 
x & \text{if } x < 0 \\
x - 1 & \text{if } x \geq 0 
\end{cases} \]

We need to check if this function satisfies the condition \( f(x+y) - f(x) - f(y) \in \{0, 1\} \) for all \( x, y \in \mathbb{R} \).

1. **Case 1: \( x < 0 \) and \( y < 0 \)**

   \[
   f(x+y) = x + y
   \]
   \[
   f(x) = x
   \]
   \[
   f(y) = y
   \]
   \[
   f(x+y) - f(x) - f(y) = (x + y) - x - y = 0
   \]

2. **Case 2: \( x < 0 \) and \( y \geq 0 \) (or \( x \geq 0 \) and \( y < 0 \))**

   Without loss of generality, assume \( x < 0 \) and \( y \geq 0 \):
   \[
   f(x+y) = \begin{cases} 
   x + y & \text{if } x + y < 0 \\
   x + y - 1 & \text{if } x + y \geq 0 
   \end{cases}
   \]
   \[
   f(x) = x
   \]
   \[
   f(y) = y - 1
   \]
   We need to consider two sub-cases:
   - If \( x + y < 0 \):
     \[
     f(x+y) = x + y
     \]
     \[
     f(x+y) - f(x) - f(y) = (x + y) - x - (y - 1) = 1
     \]
   - If \( x + y \geq 0 \):
     \[
     f(x+y) = x + y - 1
     \]
     \[
     f(x+y) - f(x) - f(y) = (x + y - 1) - x - (y - 1) = 0
     \]

3. **Case 3: \( x \geq 0 \) and \( y \geq 0 \)**

   \[
   f(x+y) = x + y - 1
   \]
   \[
   f(x) = x - 1
   \]
   \[
   f(y) = y - 1
   \]
   \[
   f(x+y) - f(x) - f(y) = (x + y - 1) - (x - 1) - (y - 1) = 1
   \]

From the above cases, we see that \( f(x+y) - f(x) - f(y) \) only takes the values 0 and 1 for all \( x, y \in \mathbb{R} \). Therefore, the function \( f(x) = \begin{cases} x & \text{if } x < 0 \\ x - 1 & \text{if } x \geq 0 \end{cases} \) satisfies the given condition and is surjective.

The final answer is \( \boxed{ f(x) = \begin{cases} x & \text{if } x < 0 \\ x - 1 & \text{if } x \geq 0 \end{cases} } \)