text:
Modulus Summation
I call this sequence "the Jesus sequence", because it is the sum of mod.</pun>
For this sequence, you take all the positive integers m less than the input n, and take the sum of n modulo each m. In other words:
$$a_n = \sum_{m=1}^{n-1}{n\bmod m}$$
For example, take the term 14:
14 % 1 = 0
14 % 2 = 0
14 % 3 = 2
14 % 4 = 2
14 % 5 = 4
14 % 6 = 2
14 % 7 = 0
14 % 8 = 6
14 % 9 = 5
14 % 10 = 4
14 % 11 = 3
14 % 12 = 2
14 % 13 = 1
0+0+2+2+4+2+0+6+5+4+3+2+1=31

Your goal here is to write a function that implements this sequence. You should take the sequence term (this will be a positive integer from 1 to 231) as the only input, and output the value of that term. This is OEIS A004125.
As always, standard loopholes apply and the shortest answer in bytes wins!

05AB1E, 3 bytes
L%O

Try it online!

Haskell, 22 bytes
f x=sum$mod x<$>[1..x]

Try it online!
Explanation
Yes.

Great explanation

Funky, 25 bytes
n=>fors=~-i=1i<n)s+=n%i++

Just the Naïve answer, seems to work.
Try it online!
Desmos, 25 bytes.
f(x)=\sum_{n=1}^xmod(x,n)

Paste into Desmos, then run it by calling f.
When pasted into Desmos, the latex looks like this

The graph however looks like

Although it looks random and all over the place, that's the result of only supporting integers.
RProgN 2, 9 bytes
x=x³x\%S+

Explained
x=x³x\%S+
x=          # Store the input in "x"
  x         # Push the input to the stack.
   ³x\%     # Define a function which gets n%x
       S    # Create a stack from "x" with the previous function. Thus this gets the range from (1,x), and runs (i%x) on each element.
        +   # Get the sum of this stack.

Try it online!
ReRegex, 71 bytes
#import math
(_*)_a$/d<$1_>b$1a/(\d+)b/((?#input)%$1)+/\+a//u<#input
>a

Try it online!
ARBLE, 19 bytes
sum(range(1,a)|a%i)

Try it online!
MaybeLater, 56 bytes
whenf is*{n=0whenx is*{ifx>0{n=n+f%x x--}elseprintn}x=f}

Try it online!

Will the submissions to this challenge ever end? So far I've been getting a new one every 40 minutes :P

@StephenLeppik Oh I've still got more coming, don't worry.

@StephenLeppik I'd rather not, because they're of various quality across various languages.

@StephenLeppik I've combined them for you, begrudgingly.

Thanks! Now you get an upvote because all this is lots of effort.

Please don't do this. Separate languages -- even separate approaches -- should go in separate answers.

@Dennis Although I agree with you, OP said to do it this way, so I've done it this way.

Ruby, 28 27 23 bytes
-4 bytes thanks to @daniero.
->n{(1..n).sum{|i|n%i}}

Try it online!
Ruby, 28 bytes
f=->n{n>($.+=1)?n%$.+f[n]:0}

Try it online!

Jelly, 3 bytes
%RS

Explanation
%RS
 R   Range(input)  [1...n]
%    Input (implicit) modulo [1...n]->[n%1,n%2...n%n]
  S  Sum of the above

Try it online!

MATL, 4 bytes
t:\s

Try it online!
Explanation:
t      % Duplicate input. Stack: {n, n}
 :     % Range 1...n. Stack: {n, [1...n]}
  \    % Modulo. Stack: {[0,0,2,2,4,...]}
   s   % Sum. Implicitly display result.

R, 20 bytes
sum((n=scan())%%1:n)

Try it online!

Ohm v2, 4 bytes
D@%Σ

Try it online!

APL (Dyalog), 5 bytes
+/⍳|⊢

Try it online!
How?
Monadic train -
+/ - sum
⊢ - n
| - vectorized modulo
⍳ - the range of n

Python 2, 44 bytes
lambda n:sum(map(lambda x:x%(n-x),range(n)))

Try it online!
EDIT: Changed range(0,n) to range(n)

Hello, and welcome to the site! range implicitly takes a first argument of 0, so you could shorten this by two bytes by doing range(n) instead.

Oh wow! I didn't even think of that. Thanks

Welcome to PPCG! You can use a list comprehension instead of map for 38 bytes: Try it online!

You are right, but that was used in Neil's answer, so I wasn't sure if copying it would have been the best thing. Unless I am missing something here of course. I wanted to post the alternative, even if it was a bit longer.

Rust, 27 characters
|n|(1..n).map(|i|n%i).sum()

Based on Should rust anonymous functions fully specify parameter types? I assume that return type inference is also fine.
Try it online!

Julia 1.0, 16 bytes
~x=sum(x.%(1:x))

Try it online!

JavaScript (ES6), 26 bytes
f=(n,k=n)=>n&&k%n+f(n-1,k)

Demo

f=(n,k=n)=>n&&k%n+f(n-1,k)

for(n = 1; n < 30; n++) {
  console.log('a(' + n + ') = ' + f(n))
}

Python 3, 37 bytes
lambda a:sum(a%k for k in range(1,a))

Try it online!

4 answers in 10 minutes? Wow.

Must be some very gifted programmers. ;)

Japt, 6 5 bytes
Saved 1 byte thanks to @Shaggy
Æ%XÃx

Test it online!
How it works
         Implicit: U = input number
Æ        Create the range [0, U),
 %XÃ       mapping each item X to U%X. U%0 gives NaN.
    x    Sum, ignoring non-numbers.
         Implicit: output result of last expression

Charcoal, 9 bytes
ＩΣＥＮ﹪Ｉθ⊕ι

Try it online!
Link is to the verbose version of the code:
Print(Cast(Sum(Map(InputNumber(),Modulo(Cast(q),++(i))))));

Standard ML (MLton), 53 51 bytes
fn& =>let fun f 1a=a|f%a=f(% -1)(a+ &mod%)in f&0end

Try it online!
Ungolfed:
fn n =>
   let fun f 1 a = a
         | f x a = f (x-1) (a + n mod x)
   in
       f n 0
   end

Previous 53 byte version:
fn n=>foldl op+0(List.tabulate(n-1,fn i=>n mod(i+1)))

Try it online!
Explanation:
List.tabulate takes an integer x and a function f and generates the list [f 0, f 1, ..., f(x-1)]. Given some number n, we call List.tabulate with n-1 and the function fn i=>n mod(i+1) to avoid dividing by zero. The resulting list is summed with foldl op+0.

Java (OpenJDK 8), 45 bytes
n->{int m=n,s=0;for(;m-->1;)s+=n%m;return s;}

Try it online!

+1 For using the goes to (-->) operator.

Mathematica, 18 bytes
#~Mod~i~Sum~{i,#}&

Try it online!

same bytes Tr[#~Mod~Range@#]&

T-SQL, 80 79 bytes
-1 byte thanks to @MickyT
WITH c AS(SELECT @ i UNION ALL SELECT i-1FROM c WHERE i>1)SELECT SUM(@%i)FROM c

Receives input from an integer parameter named @, something like this:
DECLARE @ int = 14;

Uses a Common Table Expression to generate numbers from 1 to n. Then uses that cte to sum up the moduluses.
Note: a cte needs a ; between the previous statement and the cte. Most code I've seen puts the ; right before the declaration, but in this case I can save a byte by having it in the input statement (since technically my code by itself is the only statement).
Try it (SEDE)

The less "SQL-y" way is only 76 bytes. This time the input variable is @i instead of @ (saves one byte). This one just does a while loop.
DECLARE @ int=2,@o int=0WHILE @<@i BEGIN SELECT @o+=@i%@,@+=1 END PRINT @o

4, 67 bytes
4 doesn't have any modulo built in.
3.79960101002029980200300023049903204040310499040989804102020195984

Try it online!

Vyxal, 3 bytes
ɽ%∑

Try it Online!
Vyxal s, 2 bytes
ɽ%

Try it Online!

05AB1E, 6 bytes
ÎGIN%+

Try it online!
My first 05AB1E program ;)
Btw I got two 39s, 1 for JS6 and 1 for python, but I was too late
Explanation:
ÎGIN%+
Î                      # Push 0, then input, stack = [(accumulator = 0), I]
 G                     # For N in range(1, I), stack = [(accumulator)]
  IN                   # Push input, then N, stack = [(accumulator), I, N]
    %                  # Calculate I % N, stack = [(accumulator), I % N]
     +                 # Add the result of modulus to accumulator

Pyth, 5 bytes
s%LQS

s%LQS - Full program, inputs N from stdin and prints sum to stdout
s     - output the sum of
 %LQ  - the function (elem % N) mapped over
    S - the inclusive range from 1..N

Try it online!

Oh actually I found a different 5 byter than you, didn't read yours correctly

Windows Batch (CMD), 63 bytes
@set s=0
@for /l %%i in (1,1,%1)do @set/as+=%1%%%%i
@echo %s%

Previous 64-byte version:
@set/ai=%2+1,s=%3+%1%%i
@if %i% neq %1 %0 %1 %i% %s%
@echo %s%

Ruby, 23 bytes
->n{(1..n).sum{|i|n%i}}

Try it online!

Julia 0.4, 15 bytes
x->sum(x%[1:x])

Try it online!

Add++, 14 bytes
L,RAdx$p@BcB%s

Try it online!
How it works
L,   - Create a lambda function.
     - Example argument:     [7]
  R  - Range;        STACK = [[1 2 3 4 5 6 7]]
  A  - Argument;     STACK = [[1 2 3 4 5 6 7] 7]
  d  - Duplicate;    STACK = [[1 2 3 4 5 6 7] 7 7]
  x  - Repeat;       STACK = [[1 2 3 4 5 6 7] 7 [7 7 7 7 7 7 7]]
  $p - Swap and pop; STACK = [[1 2 3 4 5 6 7] [7 7 7 7 7 7 7]]
  @  - Reverse;      STACK = [[7 7 7 7 7 7 7] [1 2 3 4 5 6 7]]
  Bc - Zip;          STACK = [[7 1] [7 2] [7 3] [7 4] [7 5] [7 6] [7 7]]
  B% - Modulo each;  STACK = [0, 1, 1, 3, 2, 1, 0]
  s  - Sum;          STACK = [8]

PHP, 61 bytes
-2 bytes for removing the closing tag
<?php $z=fgets(STDIN);for($y=1;$y<$z;$y++){$x+=$z%$y;}echo$x;

Try it online!

Japt -mx, 3 bytes
N%U

Try it online!

Brachylog, 9 bytes
⟨gz⟦₆⟩%ᵐ+

Try it online!

Ruby, 23 bytes
->n{eval [*0..n]*"+n%"}

Try it online!
Evaluates a string like 0+n%1+n%2+n%3+n%4+n%5 for n=5.

Nim, 52 bytes
import sugar,sequtils
n=>toSeq(1..n).foldl(a+n%%b,0)

Attempt This Online!

K (ngn/k), 13 12 bytes
-1 byte from @ovs' improvement
+/1_!'/|1!:\

Try it online!

|1!:\ generate a two-item list containing (0..n; n)
!'/ mod n by each of 0..n
1_ drop the first result, corresponding to n % 0
+/ take the sum and (implicitly) return

Going tacit saves a byte: f:+/1_!'/|1!:\

Husk, 5 bytes
ΣṠM%ḣ

Try it online!
Explanation
ΣṠM%ḣ  -- implicit input x, example: 5
 ṠM%   -- map (mod x) over the following..
    ḣ  -- ..the range [1..x]: [5%1,5%2,5%3,5%4,5%5] == [0,1,2,1,0]
Σ      -- sum: 0+1+2+1+0 == 4

Perl 5, 23 + 1 (-p) = 24 bytes
//;map$\+=$'%$_,1..$_}{

Try it online!

Neim, 3 bytes
Try It Online!

Explanation:
      # Inclusive range
     # Modulo each element with input
      # Sum the list

APL+WIN, 10 bytes
+/(⍳n)|n←⎕

Prompts for screen input.

Pari/GP, 17 bytes
n->sum(m=1,n,n%m)

Try it online!

Perl 6, 21 16 bytes
{sum $_ «%«(1..$_)}
{sum $_ X%1..$_}

Try it online!
-5 bytes (!) thanks to Brad Gilbert.

This challenge is getting way more submissions than I anticipated.

@StephenLeppik It's because it's easy... xD

{sum $_ X%1..$_}

Brain-Flak, 70 62 bytes
(([{}])<>)({<<>(({})<<>{(({})){({}())<>}{}}>)<>>{}[({}())]}{})

Try it online!
It turns out that the straightforward approach is better.  Also, keeping a copy of n on the third stack instead of the first stack saves bytes.
(([{}])<>)                                                      Initialize both stacks with -n
           {                                              }{}   For all k from n down to 1:
             <>(({})<                      >)                   Store -n on third stack
                     <>{(({})){({}())<>}{}}                     Main part of standard modulus program
                                                                (except that the arguments are negative)
                                             <>
            <                                  >                Ignore evaluation of -n
                                                {}[({}())]      Recover n mod k, and decrement k for the next iteration
          (                                                  )  Sum over all iterations and push

Although we already had the modulo challenge... this one seems different. +1. Explanation?

Labyrinth - 45 Characters
?:}}""):={%={{+
     ;        "
@!{{{-{=:}}}::}

Basically, it sets up by taking the input of the number that we are modulo summing. It then starts at one, takes the modulo of that number, and checks if it has reached the target number yet. If it hasn't, take the modulo again and add it to the previous one.
(I left out a lot of stack manipulations if you hadn't guessed, and yes, it actually does output the sum of the modulus up to that number)

Clean, 39 bytes
Literally just Bruce Forte's Haskell answer, but in Clean.
import StdEnv
@x=sum(map((rem)x)[1..x])

Try it online!

Well there's pretty much only one (short) way to solve this task.. Btw. using Haskell would save you 17 bytes ;P

Forth (gforth), 35 bytes
: f 0 over 1 do over i mod + loop ;

Try it online!
Explanation
Loops over all numbers from 1 to n-1 and adds n%i to the sum
Code Explanation
: f            \ start a new word definition
  0 over       \ add a 0 to the stack and place a copy of n above it
  1 do         \ start a counted loop from 1 to n-1
    over i     \ copy n to the the top of the stack and place the loop index above it
    mod +      \ take n%i and add it to the sum
  loop         \ end the counted loop
;              \ end the word definition

Labyrinth, 38 bytes
?_"):}}:{%={
@ ;        {
!{{=-{:}}:}+

Try it online!
Slight improvement to existing answer.
How it works
Stack notation is a b ... c | d e ... f where a b ... c part is the main stack, d e ... f is auxiliary, and c and d are the top of two stacks. I found this notation useful in developing and explaining the answer.
        Start at the top left
?_"     Push input and a 0, going straight through the junction
        n i=0 | sum=0
)       Increment i
:}}     n | i i sum
:{%=    n i | n%i sum
{{+}    n i | sum'=sum+n%i
:}}:{-  n n-i | i sum'
={      n i n-i | sum'
;       If n-i is nonzero, turn right and discard n-i, continuing the loop
{!@     Otherwise go straight, print sum and terminate

Starting from n%n and counting down to zero works better for 24 bytes. I suspect the loop can still be golfed

PowerShell Core, 37 30 bytes
param($a)1..$a|%{$r+=$a%$_}
$r

Try it online!
-7 bytes thanks to @mazzy!

sum is shorter Try it online!

Knight, 30 bytes
;=x+=s=y 0P;W>x=y+yT=s+s%x yOs

Try it online!
Pretty straightforward.
# init x with input converted to number,
# and sum and y to 0
; = x + (= sum = y 0) PROMPT
# for 1..x
; WHILE (> x (= y + y 1))
    # sum += x % y
    : = sum + s (% x y)
: OUTPUT sum

J-uby, 24 bytes
Equivalent to my Ruby answer.
(:-&(:& &:%|:+&:sum))%:+

Attempt This Online!

K (ngn/k), 16 bytes (Non-competitive)
{+/{x!g}'1+!g-1}

Try it online!
Non-competitive, because required the use of a global variable called g to get input. The reason is because lambda functions in K cannot access variables  of another function if they are in that function.
Explanation:
{+/{x!g}'1+!g-1}    Main function. Takes g as input (g=14)
           !        Generate a range from 0 to
            g-1     g - 1 (exclusive)               (g-1=13=>range=0..12)
         1+         + 1 for each element            (range=1..13)
        '           For each element
   {   }            Execute a function that returns
    x!g             g mod x (x = element)
 +/                 Sum

Go, 52 bytes
func(n int)(o int){for k:=1;k<=n;k++{o+=n%k};return}

Attempt This Online!

Mathematica, 20 bytes
Sum[Mod[#,i],{i,#}]&

View it on Wolfram Cloud!

Mod[#,]~Sum~{,#}&

Thunno 2 S, 2 bytes
R%

Attempt This Online!
Explanation
R%  # Implicit input.
R   # Range. Push [1..input].
 %  # Mod. Vectorises.
    # S flag sums.
    # Implicit output.

Rockstar, 91 bytes
listen to N
D's 0
O's 0
while N-D
let D be+1
let M be N/D
turn M down
let O be+N-M*D

say O

Try it (Code will need to be pasted in)

Trilangle, 45 bytes
<'?0'1...Lj2'<.zj2'.......L-)S+%,7#..@!,,,/^S

Try it on the online interpreter!
TODO: add colorized explanation
<'?0'1...Lj2'<.zj2'.......L-)S+%,7#..@!,,,/^S

  ?                                           Get number from stdin
   0'                                         Start sum at 0
 '   1                                        Start counter at 1
          j2'  zj2'       L-     7            Compare the counter and the input
                                     @!,,,/   If they're the same, print the sum and exit
                            )S+%,           S Otherwise, add one iteration and increment the counter
             <      .             #        ^  Loop

Uiua, 7 bytes
/+◿+1⇡.

Try it!
/+◿+1⇡.
      .  # duplicate
     ⇡   # range
   +1    # plus one
  ◿      # mod
/+       # sum

APL(Dyalog Unicode), 8 bytes SBCS
+/⊢|⍨1↓⍳

Try it on APLgolf!

C, 43 bytes
s,m;f(n){for(s=m=0;m++<n;s+=n%m);return s;}

Try it online!
C (gcc), 38 bytes
s,m;f(n){for(s=m=0;m++<n;s+=n%m);s=s;}

Try it online!

That's my best, too: a;i;f(n){a=0;for(i=n;--i;)a+=n%i;return a;}

J, 9 bytes
-~1#.i.|]

How it works
        ] - the argument
       |  - mod
     i.   - list from 0 to argument - 1
  1#.     - sum (base 1 conversion)
-~        - subtract the argument (to get rid of the n mod 0)

Try it online!

Pip, 7 bytes
$+a%\,a

Try it online!
         a is 1st cmdline arg
    \,a  Inclusive range from 1 through a
  a%     Take a mod each of those numbers (a%a is 0, so doesn't affect the sum)
$+       Fold on +
         Output (implicit)

MATLAB, 19 bytes
@(n)sum(mod(n,1:n))

Very straightforward, mod calculates n%x for each natural number below n. and sum just sums them all. Test:
@(n)sum(mod(n,1:n))
ans(14)
ans =

    @(n)sum(mod(n,1:n))
ans =
    31.0000e+000

Gaia, 8 bytes
@:…)¦%¦Σ

Try it online!

SNOBOL4 (CSNOBOL4), 69 68 bytes
	N =INPUT
A	I =I + 1
	S =LT(I,N) S + REMDR(N,I)	:S(A)
	OUTPUT =S
END

Try it online!
	N =INPUT				;* read in input
A	I =I + 1				;* I is initialized to 0 so this increments it to 1
	S =LT(I,N) S + REMDR(N,I)	 :S(A)	;* similarly with S, add to the remainder
	LT(I,N) :S(A)				;* on success (I < N), goto A
	OUTPUT =S				;* output the sum
END						;* terminate the program

Clojure, 38 bytes
#(apply +(for[i(range 1 %)](mod % i)))

Well this is boring, I was hoping #(apply +(map mod(repeat %)(range 1 %))) would have been shorter as mod gets rarely used in map context.

J, 14 Bytes
M=:+/@:|~}.@i.

How it works:
M=:                 | Define the verb M
            i.      | Get integers in the range [0, input)
         }.@        | Remove the leading 0
       |~           | Take the original input mod each of these integers, making a new array
   +/@:             | Sum this array

Example:
    M 14
31
    M"0 >:i.20    NB. Apply M to each of the integers from 1-20 inclusive
0 0 1 1 4 3 8 8 12 13 22 17 28 31 36 36 51 47 64 61

Common Lisp, 50 47 bytes
(lambda(n)(loop as i from 1 to n sum(mod n i)))

Try it online!

Befunge-93, 36 bytes
p&:10p1>-#1:_$v_g.@
 :p00+g00%\g01<^

Try It Online

Pushy, 13 bytes
&1{:2d%vh;OS#

Try it online!
&1{                 \ Make the stack [n, 1, n]
   :     ;          \ n times do (this consumes last n):
    2d              \    Copy the last two items
      %v            \    Get remainder and put result on stack
        h           \    Increment divisor
          OS        \ Sum the second stack
            #       \ Output the result

dc, 31 bytes
[dz%rdz<B]sBd1<B0*0[+z1<C]dsCxp

Try it online!
Assume our input is the only value on the stack. Macro B duplicates top of stack, calculates stack depth, and performs modulo. Runs until stack depth is equal to the input. This works for numbers greater than 1, so we don't run B automatically, but instead only if it's greater than 1 (d1<B). B leaves the input value on top-of-stack, so we multiply by 0. Since 0 is the desired result for an input of 1, this is fine for 1 as well. However, 1 doesn't leave us enough items on the stack to do the initial summation in macro C, so we put another 0 on the stack just in case. Macro C simply adds the two values on top of the stack, and keeps going until the stack only has a single value. Finally, we print.

F#, 35 bytes
let s v=Seq.sumBy(fun x->v%x){1..v}

Try it online!
Pretty straight-forward.

Ahead, 21 bytes
I&l@O+K<
~>td-! ntd%~

Try it online!

MMIX, 32 bytes (8 instrs)
00000000: c1020000 e3010000 1cff0002 25020201  Ḋ£¡¡ẉ¢¡¡÷”¡£%££¢
00000010: feff0006 200101ff 5b02fffc f8020000  “”¡© ¢¢”[£”‘ẏ£¡¡

modsum  SET  $2,$0              // i = n
        SET  $1,0               // s = 0
0H      DIV  $255,$0,$2
        SUB  $2,$2,1
        GET  $255,rR
        ADD  $1,$1,$255         // loop: s += n % i--
        PBNZ $2,0B              // if(i) goto loop
        POP  2,0                // return [s,n]

Ly, 15 13 bytes
ns,[:lf%f,]&+

Try it online!
Thanks LyricLy for the tip that dropped 2 chars.
This generates the modulo numbers on a stack, then sums them and relies on the default action to print the stack to show the answer.
ns,             # Read the N req from STDIN, stash it away, then decrement
    [     ,]    # Loop to decrement the top of stack and exit then that's 0
     :l         # Duplicate the top of stack, restore N from backup cell
       f%f      # Flip top two stack enrtries, do modulo math, flip again
             &+ # Sum the stack
                # Ends with one entry on the stack, which prints as a number

, is a shorthand for 1- that saves 2 bytes here.

Factor + math.unicode, 33 bytes
[ dup [1,b) [ mod ] with map Σ ]

Try it online!

dup Duplicate the input.
Stack: (e.g.) 14 14

[1,b) Make a range from 1 inclusive to 14 exclusive.
Stack: 14 { 1 2 ... 13 }

[ mod ] with map Do 14 1 mod, 14 2 mod, 14 3 mod, etc. and collect the results in a sequence the same length as the range.
Stack: { 0 0 2 2 4 2 0 6 5 4 3 2 1 }

Σ Sum.
Stack: 31

Arturo, 21 bytes
$->n[∑map n'x->n%x]

Try it!

Malbolge Unshackled, 1,828,225 bytes.
Available on GitHub as StackExchange does not allow posting answers this long.
Use as, having obtained fast20 or any Malbolge Unshackled interpreter:
$ echo -ne "\xFF" | time ./fast20 150563.mb | xxd
00000000: c3

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Keep Decoding This Number!
This challenge posed an algorithm for encoding an integer n as another integer r. What follows is a succinct explanation of that algorithm, using n=60 as an example.
The original algorithm

First, we encode the number as a string of brackets.

If n = 1, return an empty string.
Otherwise, we take n's prime decomposition sorted ascending and replace each element with its prime index (1-indexed) in brackets. 60 = 2*2*3*5 => [1][1][2][3]
Do this recursively until all we have are brackets. [1][1][2][3] => [][][[1]][[2]] => [][][[]][[[1]]] => [][][[]][[[]]]

Once we have our string of brackets, we convert that into an integer with the following process.

Convert each opening bracket to a 1 and each closing bracket to a 0. [][][[]][[[]]] => 10101100111000
Remove all trailing 0s and the final 1. 10101100111000 => 1010110011
Convert the final string of 0s and 1s from binary to an integer. 1010110011 => 691

Decoding this encoding
An interesting property of this algorithm is that it is not surjective. Not every integer can be the result of this encoding.

Firstly, the binary representation of the result r, must be balance-able in that the number of 0s must never exceed the number of 1s. A short falsey test case is 4, which is 100 in binary.
Secondly, the brackets in the binary representation must be sorted ascending when the final 1 and trailing 0s are appended once more. A short falsey test case is 12 <= 1100 <= 110010 <= (())().

However, just determining if a number is decode-able in this way would make for a short challenge. Instead, the challenge is to repeatedly decode a given input until either an un-decode-able number or a cycle is reached, and returning the resulting sequence of numbers.
The challenge

Given a number 1 <= r <= 2**20 = 1048576, return the sequence of numbers that r successively decodes into, starting with r itself and ending with an un-decode-able number or a cycle.
If an un-decode-able number is given as input, such as 4 or 12, will return a list containing only the input.
A sequence ending in a cycle should be indicated in some way, either by appending or prepending a marker (pick any non-positive integer, string, list, etc. as a marker, but keep it consistent), or by repeating the cycle in some way (repeating the first element, repeating the whole cycle, repeating infinitely, etc.).
On the off chance that any of the sequences are infinite (by increasing forever, for example), consider it undefined behavior.
This is code golf. Smallest number of bytes wins.

A worked example of decoding
   1 -> 1 -> 1100 -> [[]] -> [2] -> 3
-> 3 -> 11 -> 111000 -> [[[]]] -> [[2]] -> [3] -> 5
-> 5 -> 101 -> 101100 -> [][[]] -> 2*[2] -> 2*3 -> 6
-> 6 -> 110 -> 110100 -> [[][]] -> [2*2] -> [4] -> 7
-> 7 -> 111 -> 11110000 -> [[[[]]]] -> [[[2]]] -> [[3]] -> [5] -> 11
-> 11 -> 1011 -> 10111000 -> [][[[]]] -> 2*[[2]] -> 2*[3] -> 2*5 -> 10
-> 10 -> 1010 -> 101010 -> [][][] -> 2*2*2 -> 8
-> 8 -> 1000  ERROR: Unbalanced string

Test cases
4 -> [4]
12 -> [12]
1 -> [1, 3, 5, 6, 7, 11, 10, 8]
2 -> [2, 4]
13 -> [13, 13]    # cycle is repeated once
23 -> [23, 22, 14, 17]
51 -> [51, 15, 31, 127, 5381]
691 -> [691, 60]
126 -> [126, 1787, 90907]
1019 -> [1019, 506683, 359087867, 560390368728]

Suggestions and feedback for this challenge are most welcome. Good luck and good golfing!

Sandbox.

How does 1 give 3?

@LeakyNun 1 --(append an 1 and trailing zeros)--> 1100 --> [[]] --> [[1]] --> [2] --> 3

6->110->110100 which isn't valid, right? So should input 1 give [1,3,5,6]?

And for 7: 7->111->11110000->[[[[]]]]->4th prime = 7? Maybe I don't understand the algorithm

@dylnan 6 -> 110 -> 110100 -> [[][]] -> [2*2] -> [4] -> 7 -> 111 -> 11110000 -> [[[[]]]] -> [[[2]]] -> [[3]] -> [5] -> 11. I hope this helps you understand the algorithm better.

Yes it does, thank you

Python 3, 379 358 339 337 327 310 304 bytes
Conjecture: Is 13 the only number that will lead to a cycle? (There are no exceptions smaller than 106.)
Fixed a bug and -7 bytes thanks to Sherlock9.-3 byte thanks to Jonathan Frech.-16 bytes thanks to ovs.-6 bytes thanks to Mr. Xcoder.
If there is a cycle, it will repeat the whole cycle.
def p(a,x=0,n=1):
 while a:x+=1;a-=n%x;n*=x*x
 return x
def g(a):
 c=i=0
 for v in a:
  c+=int(v)*2-1
  if c<0:return 0,0
  if c<1:break
  i+=1
 if a:x=p(g(a[1:i])[0]);b,c=g(a[i+1:]);return(x>c>0)*(0,0)or(x*b,x)
 return 1,0
def f(a):
 x=a,
 while(x.count(a)<3)*a:a,t=g(bin(a-~a)[2:]);x+=a,
 return x[:-1]

Try it online!
Explanation:
def p(a,x=0,n=1):     # return the a-th prime
 while a:             # magical way to enumerate primes
  x+=1
  a-=n%x
  n*=x*x
 return x

def g(a):             # decode a 0/1 string
 c=i=0
 for v in a:
  c+=int(v)*2-1       # +1 if 1, -1 if 0
  if c<0: return(0,0) # c<0: unbalanced parentheses
  if c<1: break       # first outermost parentheses
  i+=1
 if a:
   x=p(g(a[1:i])[0])  # recursive solve those inside the parentheses ...
   b,c=g(a[i+1:])     # and the remaining
   if x>c and c:      # if not ascending
    return (0,0)
   return (x*b,x)     # return (result, value of first closed parentheses)
 return (1,0)         # empty string

def f(a):
 x=a,
 while a and x.count(a)<3: # detect non-decodable or cycle
  a,t=g(bin(a-~a)[2:])     # a-~a is a*2+1
  x+=a,
 return x[:-1]

Pyth, 62 bytes
L?b**FKme.fP_Zyd)bSIK1fTseB.u.xyvs@L,"],"\[++JjN2 1m0h-/J1/J00

Test suite
Indicates a cycle by repeating the final number.
L?b**FKme.fP_Zyd)bSIK1    Define y to decode from list format. 0 if invalid.

fTseB.u.xyvs@L,"],"\[++JjN2 1m0h-/J1/J00
     .u                                     Repeat the following until it cycles
                                            Collecting the values in a list.
                     ++JjN2 1m0h-/J1/J0     Convert the number to expanded binary
            @L,"],"\[                       Map 0 to "],", 1 to "["
           s                                Flatten to a string.
          v                                 Evaluate as a Python object.
       .x                              0    If evaluation fails, return 0.
         y                                  Otherwise decode.
  seB                                       Duplicate the final number
fT                                          Remove all 0s.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
The working time calculator
This is based on how my company deals with the monitoring of the working times for every employee. Each one of us has a card that can be passed in front of a sensor, so that a clock registers the times at which the employees check in or out the office. Every time register is linked to a code:

Code 0: the employee arrives at (or returns to) the office.
Code 1: the employee leaves the office for lunch.
Code 2: the employee leaves the office at the end of the day.
Code 3: the employee leaves the office for work reasons.
Code 4: the employee leaves the office for personal reasons.

Code 0 registers will sometimes be referred to as "zero registers", and code 1 to code 4 registers will sometimes be referred to as "non-zero registers".
So, a normal day for a worker would generate a register list like this:
Code/Time
------------
0   8:17  // The employee arrives at the office
4  11:34  // The employee leaves the office to smoke
0  11:41  // The employee returns to the office
1  13:37  // The employee leaves the office to have lunch
0  14:11  // The employee returns to the office
3  15:02  // The employee leaves the office to visit a client
0  16:48  // The employee returns to the office
2  17:29  // The employee leaves the office to go home

Nonetheless, the employees sometimes make mistakes. The following errors are automatically fixed by the system:

There are two consecutive non-zero records. If the first non-zero record has a code 4, an automatic code 0 register is added 15 minutes after, or 1 minute before the next registers if it has been registered less than 15 minutes after. If the first non-zero record has a code 3, an automatic code 0 register is always added 1 minute before the next register. Every other case produces an error. Examples:
Code/Time
------------
0   8:17  // The employee arrives at the office
4  11:34  // The employee leaves the office to smoke
1  13:37  // The employee leaves the office to have lunch
// Automatic register with code 0 added at 11:49.

Code/Time
------------
0   8:17  // The employee arrives at the office
4  11:34  // The employee leaves the office to smoke
4  11:39  // The employee leaves again the office for personal reasons
// Automatic register with code 0 added at 11:38.

Code/Time
------------
0   8:17  // The employee arrives at the office
3  11:34  // The employee leaves the office to visit a client
1  14:09  // The employee leaves the office to have lunch
// Automatic register with code 0 added at 14:08.

The employee registered two code 1 registers or two code 2 registers. As these two are in fact interchangeable, that does not count as an error. If the code 1 or code 2 registers sum more than 2 registers, that produces an error.

The challenge
The main objective is to calculate how many hours and minutes the employee has spent in the office. This is done after fixing (if needed and possible) the input register list. Note that a proper register list will alternate zero registers with non-zero registers.
So, the algorithm will receive the list of registers for an employee and a give day, and will return the time spent working for that day. If the time cannot calculate the time spent in case of errors, it will return 0 hours, 0 minutes.
Rules:

The time spent is the sum of the time spent between every code 0 register and the following non-zero register. If the non-zero code is a 3, the time spent between that register and the following code 0 register will also be counted.
You can assume that the input register list will be in ascending time order, and that all the registers will be from the same day (nobody will work beyond midnight).
The input register won't be empty.
The input format can be anything your code needs, as long as the time is expressed with the hour value and the minute value (a floating-point number of hours won't be a valid input). Examples: A list with the codes and a list with the time as strings, both lists being the same lenght; a list of lists of integers, being the integers the code, the hour and the minutes of the registers...
The output can be a string with the time (in any format you want: H:mm, HH:mm, H:m...); a list of two integers with the hours and minutes calculated; anything that can be interpreted as an hour-minute tuple (a floating-point number with the hours spent won't be allowed). Or you can print the result to STDOUT.

Test cases
Code/Time
------------
0   8:17  // Check in
4  11:34  // Check out. Time spent since check in:  3:17
0  11:41  // Check in
1  13:37  // Check out. Time spent since check in:  1:56
0  14:11  // Check in
3  15:02  // Check out. Time spent since check in:  0:51
0  16:48  // Check in.  Time spent working outside: 1:46
2  17:29  // Check out. Time spent since check in:  0:41
// Total time (value returned): 8:31

Code/Time
------------
0   8:17
4  11:34  // Time spent: 3:17
1  15:52  // Time spent since 11:49 (automatic register 15 minutes after
          // a code 4 register): 4:03
// Total time: 7:20

Code/Time
------------
0   8:17
4  15:47  // Time spent: 7:30
1  15:52  // Time spent since 15:51 (automatic register after a code 4
          // register 1 minute before the next register as it is too
          // close in time): 0:01
// Total time: 7:31

Code/Time
------------
0   8:17
1  13:34  // Time spent: 5:17
0  14:04
1  17:55  // Time spent: 3:51 (last code 1 should be a code 2 but it does not matter)
// Total time: 9:08

Code/Time
------------
0   8:17
1  13:34
0  14:04
1  17:05
0  17:08
2  17:44
// Total time: 0:00 (too many code 1 and code 2 registers)

Code/Time
------------
0   8:17
1  13:34  // A code 1 register does not generate an automatic code 0 register
2  17:41
// Total time: 0:00 (there's a code 0 register missing)

Code/Time
------------
0   8:17
0  13:34  // what happened between these two check in registers?
2  17:41
// Total time: 0:00 (there's a check out register missing)

Code/Time
------------
0   8:17
0  13:37  // This should probably be a code 1 register, but we cannot be sure
0  14:11
2  17:29
// Total time: 0:00

I know this can be confusing (the real-world problem had even more cases to consider, so I do know that). Please, do not hesitate to ask for more examples.
This is code-golf, so may the shortest code for each language win!

You can comment how to improve the system if you want, but that's not the point. My boss is not prone to spend time changing it. :-)

Sandbox.

Python 3, 327 322 318 317 bytes
Thanks for @JonathanFrech and @Mr.Xcoder for getting rid of some bytes.
Takes input as list of codes (C) and list of times (T) ((hours, minutes) tuples). Returns a (hours, minutes) tuple.
def f(C,T):
 T,L=[m+h*60for h,m in T],C.count
 for z in range(len(C))[::-1]:
  c=C[~-z]
  if c*C[z]:
   if c<3:return 0,0
   C.insert(z,0);b=~-T[z];T.insert(z,b if c-4else min(T[~-z]+15,b))
 while L(3):i=C.index(3);del C[i:i+2],T[i:i+2]
 return(0,0)if L(1)+L(2)>2or 0in C[1::2]else divmod(sum(T[1::2])-sum(T[::2]),60)

Verified against given examples.
Ungolfed
def f(C, T):
    # use minutes since midnight instead of (hours, minutes)
    T=[m+h*60 for h,m in T]

    # error correction
    for z in range(len(C))[::-1]:
        if C[z-1] and C[z]:
            if C[z-1]<3:
                return 0,0

            C.insert(z,0)
            b=T[z]-1
            T.insert(z, b if C[z-1] != 4 else min(T[z-1]+15, b))

    # simplification (remove work trips (code 3))
    while L(3): # 3 in C
        i=C.index(3)
        del C[i:i+2]
        del T[i:i+2]

    # error check
    if 0 in C[1::2] or 2 < C.count(1) + C.count(2):
        return 0,0

    # sum
    s = sum(T[1::2])-sum(T[::2])

    # to (hours, minutes)
    return divmod(s, 60)

318 bytes.

That negation I didn't think about. Nice tricks.

you can use L(3) instead of 3in C.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Characteristic polynomial
The characteristic polynomial of a square matrix \$A\$ is defined as the polynomial \$p_A(x) = \det(Ix-A)\$ where \$I\$ is the identity matrix and \$\det\$ the determinant. Note that this definition always gives us a monic polynomial such that the solution is unique.
Your task for this challenge is to compute the coefficients of the characteristic polynomial for an integer valued matrix, for this you may use built-ins but it is discouraged.
Rules

input is an \$N\times N\$ (\$N \ge 1\$) integer matrix in any convenient format
your program/function will output/return the coefficients in either increasing or decreasing order (please specify which)
the coefficients are normed such that the coefficient of \$x^N\$ is 1 (see test cases)
you don't need to handle invalid inputs

Testcases
Coefficients are given in decreasing order (ie. \$x^N, x^{N-1}, ..., x^2, x, 1\$):
[0] -> [1 0]
[1] -> [1 -1]
[1 1; 0 1] -> [1 -2 1]
[80 80; 57 71] -> [1 -151 1120]
[1 2 0; 2 -3 5; 0 1 1] -> [1 1 -14 12]
[4 2 1 3; 4 -3 9 0; -1 1 0 3; 20 -4 5 20] -> [1 -21 -83 559 -1987]
[0 5 0 12 -3 -6; 6 3 7 16 4 2; 4 0 5 1 13 -2; 12 10 12 -2 1 -6; 16 13 12 -4 7 10; 6 17 0 3 3 -1] -> [1 -12 -484 3249 -7065 -836601 -44200]
[1 0 0 1 0 0 0; 1 1 0 0 1 0 1; 1 1 0 1 1 0 0; 1 1 0 1 1 0 0; 1 1 0 1 1 1 1; 1 1 1 0 1 1 1; 0 1 0 0 0 0 1] -> [1 -6 10 -6 3 -2 0 0]

Related. Related.

Related

Can I output a polynomial?

@alephalpha: Sure.

May I output as [  1.00000000e+00  -1.51000000e+02   1.12000000e+03], for instance?

@Mr.Xcoder: Why not, go ahead!

"x^(N+1)" should be "x^N" everywhere it occurs; the characteristic polynomial of an NxN matrix has degree N. (There are N+1 coefficients to return.)

@MishaLavrov: True, not sure how I was counting :S Fixed now.

SageMath, 3 bytes
5 bytes saved thanks to @Mego
fcp

Try it online!
Takes a Matrix as input.
fcp stands for factorization of the characteristic polynomial,
which is shorter than the normal builtin charpoly.

Octave, 16  4 bytes
@BruteForce just told me that one of the functions I was using in my previous solution can actually do the whole work:
poly

Try it online!
16 Bytes: This solution computes the eigenvalues of the input matrix, and then proceeds building a polynomial from the given roots.
@(x)poly(eig(x))

But of course there is also the boring
charpoly

(needs a symbolic type matrix in Octave, but works with the usual matrices in MATLAB.)
Try it online!

Pari/GP, 8 bytes
charpoly

Try it online!

Pari/GP, 14 bytes
m->matdet(x-m)

Try it online!

GP promotes x to a matrix of the appropriate dimension? Nice!

R, 53 bytes
function(m){for(i in eigen(m)$va)T=c(0,T)-c(T,0)*i
T}

Try it online!
Returns the coefficients in increasing order; i.e., a_0, a_1, a_2, ..., a_n.
Computes the polynomial by finding the eigenvalues of the matrix.
R + pracma, 16 bytes
pracma::charpoly

pracma is the "PRACtical MAth" library for R, and has quite a few handy functions.

Mathematica, 22 bytes
Det[MatrixExp[0#]x-#]&

-7 bytes from  alephalpha
-3 bytes from Misha Lavrov
Try it online!
and... of course...
Mathematica, 29 bytes
#~CharacteristicPolynomial~x&

Try it online!
both answers output a polynomial

Haskell, 243 223 222 bytes
s=sum
(&)=zip
z=zipWith
a#b=[[s$z(*)x y|y<-foldr(z(:))([]<$b)b]|x<-a]
f a|let c=z pure[1..]a;g(u,d)k|m<-[z(+)a b|(a,b)<-a#u&[[s[d|x==y]|y<-c]|x<-c]]=(m,-s[s[b|(n,b)<-c&a,n==m]|(a,m)<-a#m&c]`div`k)=snd<$>scanl g(0<$c<$c,1)c

Try it online!
Thanks to @ØrjanJohansen for helping me golf this!
Explanation
This uses the Faddeev–LeVerrier algorithm to compute the coefficients. Here's an ungolfed version with more verbose names:
-- Transpose a matrix/list
transpose b = foldr (zipWith(:)) (replicate (length b) []) b

-- Matrix-matrix multiplication
(#) :: [[Int]] -> [[Int]] -> [[Int]]
a # b = [[sum $ zipWith (*) x y | y <- transpose b]|x<-a]

-- Faddeev-LeVerrier algorithm
faddeevLeVerrier :: [[Int]] -> [Int]
faddeevLeVerrier a = snd <$> scanl go (zero,1) [1..n]
  where n = length a
        zero = replicate n (replicate n 0)
        trace m = sum [sum [b|(n,b)<-zip [1..n] a,n==m]|(m,a)<-zip [1..n] m]
        diag d = [[sum[d|x==y]|y<-[1..n]]|x<-[1..n]]
        add as bs = [[x+y | (x,y) <- zip a b] | (b,a) <- zip as bs]
        go (u,d) k = (m, -trace (a#m) `div` k)
          where m = add (diag d) (a#u)

Note: I took this straight from this solution

One more byte here: c=z pure[1..]a.

Damn, that's clever!

Thanks! I just found f a|let c=z pure[0..]a;g(u,d)k|m<-[z(+)a b|(a,b)<-a#u&[[s[d|x==y]|y<-c]|x<-c]]=(m,-s[a#m!!n!!n|n<-c]`div`(k+1))=snd<$>scanl g(0<$c<$c,1)c, something similar should work on the other one too.

Python 2 + numpy, 23 bytes
from numpy import*
poly

Try it online!

MATL, 4 bytes
1$Yn

Try it online!
This is merely a port of flawr's Octave answer, so it returns the coefficients in decreasing order, i.e., [a_n, ..., a_1, a_0]
1$Yn          # 1 input Yn is "poly"

CJam (48 bytes)
{[1\:A_,{1$_,,.=1b\~/A@zf{\f.*1fb}1$Aff*..+}/;]}

Online test suite
Dissection
This is quite similar to my answer to Determinant of an integer matrix. It has some tweaks because the signs are different, and because we want to keep all of the coefficients rather than just the last one.
{[              e# Start a block which will return an array
  1\            e#   Push the leading coefficient under the input
  :A            e#   Store the input matrix in A
  _,            e#   Take the length of a copy
  {             e#     for i = 0 to n-1
                e#       Stack: ... AM_{i+1} i
    1$_,,.=1b   e#       Calculate tr(AM_{i+1})
    \~/         e#       Divide by -(i+1)
    A@          e#       Push a copy of A, bring AM_{i+1} to the top
    zf{\f.*1fb} e#       Matrix multiplication
    1$          e#       Get a copy of the coefficient
    Aff*        e#       Multiply by A
    ..+         e#       Matrix addition
  }/
  ;             e#   Pop AM_{n+1} (which incidentally is 0)
]}

Python 3 and my dronery library, 476 bytes
λ M: C(λ f: λ t,m: t if len(t)==len(M) else f(f)(t+[n:=-sum(map(λ i: m[i][i],range(len(M))))/len(t)],matmul(M,lap(laph(__add__),m,lap(λ i: i*[0]+(n,)+(len(M)+~i)*[0],range(len(M)))))))([1],deepcopy(M))

(also using the Faddeev-LaVerrier algorithm)

Maxima, 8 bytes
charpoly

A : matrix( [0, 5, 0, 12, -3, -6], [6, 3, 7, 16, 4, 2], [4, 0, 5, 1, 13, -2], [12, 10, 12, -2, 1, -6], [16, 13, 12, -4, 7, 10], [ 6, 17, 0, 3, 3, -1] );
ans:  expand (charpoly (A, lambda));
print(ans);

Try it online!

Maple, 39 bytes
LinearAlgebra[CharacteristicPolynomial]

M := <<1, 0, 0, 1, 0, 0, 0> | <1, 1, 0, 0, 1, 0, 1> | <1, 1, 0, 1, 1, 0, 0> | <1, 1, 0, 1, 1, 0, 0> | <1, 1, 0, 1, 1, 1, 1> | <1, 1, 1, 0, 1, 1, 1> | <0, 1, 0, 0, 0, 0, 1>>;
LinearAlgebra[CharacteristicPolynomial](M, x);

GAP, 24 bytes
CharacteristicPolynomial

m := [[4,2,1,3],[4,-3,9,0],[-1,1,0,3],[20,-4,5,20]];;
chPolynomial := CharacteristicPolynomial(m);
coup := CoefficientsOfUnivariatePolynomial(chPolynomial);
Print(chPolynomial , "\n");
Print(coup , "\n");

Try it online!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Intersection of two triangles
Given 4 points on the 2D planes A, B, C, D, calculate the area of the intersection region of the triangles OAB and OCD, where O is the center of the plane, having coordinate (0, 0).
Algorithms that runs in constant time complexity (in terms of arithmetic operations) are encouraged, but not forced.
Rules

Each point is represented as two real numbers, denotes their X and Y coordinate.

Optionally, if your programming language (or some library of your programming language) has built-in Point type or equivalent, it is allowed to take Point object as input.

The input is given as 4 points, in the formats, including but not limited to:

A list of 8 coordinates.
A list of 4 points, each point can be represented in any convenient format.
Two lists of 2 points.
etc.

You cannot assume particular ordering of the points (counter-clockwise order or clockwise order)
You cannot assume that the point O is passed as input. In other word, program must not take and use extraneous input.
You cannot assume all the points are different. In other words, the triangles may be degenerate. You need to also handle that case (see test cases below)
The absolute or relative difference must be less than 10-3 for the sample test cases below.

Winning criteria
This is code-golf, the shortest answer in bytes win!
Sample test cases
Ax Ay Bx By Cx Cy Dx Dy area

5 1 1 3 -1 0 0 -1 0
5 1 1 3 -1 0 0 0 0
5 1 1 3 0 0 0 0 0
5 1 1 3 3 4 4 -3 4.50418
5 1 1 3 1 2 2 1 1.5
5 1 1 3 -2 5 4 -2 1.74829
5 1 1 3 -2 5 5 4 2.96154
5 1 1 3 3 5 5 4 1.88462
5 1 1 3 3 5 3 1 3.92308
5 1 1 3 3 5 4 -1 5.26619
5 1 1 3 5 1 4 -1 0
5 1 1 3 5 1 1 3 7
1 3 1 3 5 1 1 3 0
1 3 1 3 1 3 1 3 0
4 8 4 -1 -2 6 -2 -3 0

1.2 3.4 -0.3 4.2 5 7.6 -1.1 2.4 2.6210759326188535
3.1 0.6 0.1 7.2 5.2 0.7 0.9 8 9.018496993987977

If anyone want, here are the outputs for the first test case group in exact form:
0
0
0
46375/10296
3/2
1792/1025
77/26
49/26
51/13
23345/4433
0
7
0
0
0

Illustration image for test case 5 1 1 3 3 4 4 -3 (the area of the green quadrilateral is the expected output):
[]

One of your test cases has 9 inputs rather than 8.  1.2 3.4 -0.3 4.2 5 3 7.6 -1.1 2.4 0

@KellyLowder Fixed.

Wolfram Language (Mathematica), 55 bytes
0&@@Area@BooleanRegion[And,Simplex[{0{,}}~Join~#]&/@#]&

Try it online!
Shaved a few bytes off the trivial answer.
%@{{{5, 1}, {1, 3}}, {{3, 4}, {4, -3}}} yields 46375/10296 or 4.504176379

Replacing Area with DiscretizeRegion will show the intersection.

By the way, this will work with any simplexes, not just triangles.
-1 Byte thanks to JungHwan Min
@user202729's suggestion added 4 bytes but makes it yield 0 for degenerate triangles

Polygon can be substituted in for Simplex as well

One more byte: {{0,0}} to {0{,}} (this works because the expression evaluates to {Times[0, {Null, Null}]} )

Fail for this test case, which is listed in sample test cases.

Already noted that this does NOT work on TIO.  Not sure what they have under the hood.

It doesn't work locally for me, either.

What they have

Also if you want to talk about tio.run / tryitonline.net , go to talk.tryitonline.net.

I see that it doesn't work for the intersection of two lines. My bad for skipping that test case.  Technically these are not triangles.  I suppose if we're going to get that technical, maybe you should change the title of the post as well as the first sentence.  We could also have a really esoteric discussion about whether area is even defined for a one dimensional object, but I'd rather not.

The 5th rule specifically says "the triangles may be degenerate". Meanwhile you may need to do something with the answer...?

As a note, this works for degenerate triangles at +19 bytes, or this at +4.

Python 2 + PIL, 341 318 313 284 270 bytes
Special thanks to Dennis that promptly added PIL on TIO
-23 bytes thanks to Mr. Xcoder

import PIL.Image as I,PIL.ImageDraw as D
l=[i*1000for i in[0,0]+input()+[0,0]]
z=zip(*[[i-min(t)for i in t]for t in l[::2],l[1::2]])
print sum(map(int.__mul__,*map(lambda i,c:D.Draw(i).polygon(c,1)or i.getdata(),map(I.new,'11',[[max(l)-min(l)]*2]*2),[z[:3],z[3:]])))/1e6

Try it online! or Try all test cases
To calculate the diference this literally draw the triangles and check the amount of pixels that are painted in both images.
This method inserted a rounding error, that is softened by increasing the image size.
Explanation
#the image/triangles are enlarged to increase the precision
#a pair of zeros are inserted in the start and at the end, this way "l" will have all 6 points to draw the triangles
l=[i*1000for i in[0,0]+input()+[0,0]]
#split the input in x and y, where x=l[::2] and y=l[1::2]
#get the smallest number on each list, that will be "0" if there is no negative number, to be used as offset.
#this will be used to overcome the fact that PIL won't draw on negative coords
#zip "x" and "y" lists, to create a list containing the points
z=zip(*[[i-min(t)for i in t]for t in x,y])
#create 2 (B&W) blank images
#where the size is the difference between the smallest and the largest coord.
map(I.new,'11',[[max(l)-min(l)]*2]*2)
#draw both triangles and return the pixel list of each image
map(lambda i,c:D.Draw(i).polygon(c,1)or i.getdata(),<result of previous line>,[z[:3],z[3:]])
#count the amount of overlapping pixels by summing the color of each pixel, if the pixel is "1" in both images, then the triangles are overlapping, then the amount of pixels is divided by the initial enlarging factor squared (1e6)
print sum(map(int.__mul__,*<result of previous line>))/1e6


text:
Play a game of Dice Cricket
Dice Cricket is a game I was introduced to as a child and have used as a way to pass time for years since. I couldn't find a Wikipedia page so I'll explain the rules below.
Dice Cricket Rules
Premise
Dice Cricket is a game similar to scoring a game of cricket as you watch it but rather than watching and recording the result, you are rolling a die and recording the result.
The results are recorded in a table as displayed at the bottom.
Display
Dice Cricket uses a specific display to show all the information happening.
The table has 11 rows. Each row represents a batter. The layout of the row is explained below.
+------+------------------------------+---------+-----+
| Name |    Runs                      | How Out |Score|
+------+------------------------------+---------+-----+

Name: The name must be a string made up entirely of letters, upper or lower case
Runs: A batter can face 30 balls. Each ball can be one of 1 2 4 6 . /. This will be explained in more detail below
How Out: The way the batter was out. Can be any of Bowled, LBW (Leg Before Wicket), Caught, Retired or Not Out
Score: The sum of all numbers in Runs

How the Game Works
In a game, there are always 2 batters out on the pitch. The first player is by default the current batter and the second in the "off" batter.
A game is made up of "balls": each ball in a cricket match is represented by a dice roll. Each roll does a different command:

1,2,4 and 6 make the batter score that much. If 1 is rolled, the current batter becomes the "off" batter and the "off" batter becomes the current
3 is a "dot ball", meaning that nothing happens. It is represented in the Runs section as a . and scores 0. A 0 may not be used to represent it.
5 is a wicket. If 5 is rolled, the current batter is "out", This means that a / is added to the runs and from then on, the batter cannot score anymore runs. The batter is then swapped with the next batter who has not batted. The How Out section is a random choice of the possible ways to get out: Bowled, LBW, Caught

Example for a wicket (this is just for clarity, this isn't how its outputted)
player a is on 4,6,2,6,4
player b is on 6,4,2,6,6
player c hasn't batted
player a is current batter

WICKET!!!

player a is on 4,6,2,6,4,/
player b in on 6,4,2,6,6
player c is on NOTHING
player c is current batter

Every 6 balls, the two batters switch; the current batter becomes the "off" batter and the "off" batter becomes the current batter
If the Runs section is filled (30 balls), the batter is out and the How Out section is set to Retired. A / isn't placed at the end of the Runs box.
Actual Challenge (yes all that was rules of the game)
Your challenge is to output a completed table (like the example at the end), given a list of names. The contents of the output should contain only the table and/or leading or trailing whitespace.
Rules

Standard loopholes are disallowed
All 11 players should have something in the Runs section.
Only 1 player can be Not Out. Every other non-retired player should be out of a choice of [Bowled, LBW, Caught]
The names can be any length between 1 and 6 that matches the regex A-Za-z
The final line in the table should be the total line (see example)
You don't have to align the text in the table in any way, but the row and column separators must be aligned.

Example
Input:
['Fred', 'Sonya', 'David', 'Ben', 'Cody', 'Hazel', 'Nina', 'Kim', 'Cath', 'Lena', 'Will']
Output:
+------+------------------------------+---------+-----+
| Name | Runs                         | How Out |Total|
+------+------------------------------+---------+-----+
|Fred  |.662/                         | Caught  | 14  |
+------+------------------------------+---------+-----+
|Sonya |1164/                         | Caught  | 12  |
+------+------------------------------+---------+-----+
|David |/                             |   LBW   |  0  |
+------+------------------------------+---------+-----+
|Ben   |424/                          |   LBW   | 10  |
+------+------------------------------+---------+-----+
|Cody  |62/                           | Bowled  |  8  |
+------+------------------------------+---------+-----+
|Hazel |/                             |   LBW   |  0  |
+------+------------------------------+---------+-----+
|Nina  |161.6226166..44261442/        | Caught  | 64  |
+------+------------------------------+---------+-----+
|Kim   |11/                           | Caught  |  2  |
+------+------------------------------+---------+-----+
|Cath  |6.21/                         |   LBW   |  9  |
+------+------------------------------+---------+-----+
|Lena  |/                             | Bowled  |  0  |
+------+------------------------------+---------+-----+
|Will  |2                             | Not Out |  2  |
+------+------------------------------+---------+-----+
|               Total Runs                      | 121 |
+-----------------------------------------------+-----+

Sandbox

Heh, I used to play a similar variant of this called "Hand cricket".

What determines when the game ends? Is it when a batter is out and there is no one left to replace him?

@KSmarts Correct.

@JonathanAllan Yeah, it isn't a good requirement. Removed

Python 3, 650 621 582 572 588 bytes
from random import*
h=str
c=h.center
a='+'.join(map('-'.__mul__,[0,6,30,9,5,0]))+'\n'
b=lambda x,r=6:x.ljust(r,' ')
j=''.join
t=lambda a:sum(map(int,a[:-1].replace(*'.0')))
P=print
def s(i=30):
 while i:x=choice('12.4/6');yield x;i=('/'!=x)*~-i
def f(n,T=0):
 n=[*map(b,n)]
 P(a+f'| Name | Runs{" "*25}| How Out |Total|')
 for x in n[:-1]:S=j(s());T+=t(S);P(a,x,b(S,30),c(choice(['Bowled','LBW','Caught']),9),c(h(t(S)),5),sep='|',end='|\n')
 S=j(s());P(a,n[-1],b(S,30),' Not Out ',c(h(t(S)),5),sep='|',end='|\n');P(a+f'|{15*" "}Total Runs{15*" "}       |{c(h(T),5)}|\n+{47*"-"}+{5*"-"}+')

Try it online!
Well, it's been over 24 hours and this took me about an hour to whip up, so I hope I'm not FGITW'ing anyone, and I haven't golfed in Python in a while, so this was fun (although this is the second time I've answered one of my own questions with a long Python answer)
Please feel free to post golf suggestions, Python isn't my best language for golfing.
-68 bytes thanks to FlipTack!
-8 bytes thanks to Mr. Xcoder
+16 bytes due to a bug

At first glance, I can see quite a few golfs... 1) In one instance you still use print instead of P. 2) sum can directly take a map object, no need to convert it to a list. 3) Rather than writing yield x twice, why not yield x and then break if necessary? 4) T=0 could be placed inside the function header. 5) In your last function, you've used several newlines where you could just use one line with semicolons, for example the first three statements, the last three statements, and the statements in the for loop.

@FlipTack Nice golfs, and thanks!

You can golf s considerably... def s(i=30): and then
while i:x=choice('12.4/6');yield x;i=('/'!=x)*~-i. Also, you only call o() once, so there's no need to even declare it, just use the statement directly.

The same applies to b ^^

@FlipTack Added the golfs. Thanks!

574

@Mr.Xcoder Managed to save another two bytes from that. Thanks!

I think your output has two + characters in the last line which should both be - characters.

@JonathanFrech Indeed it did. Fixed.

-18 bytes

You can convert the map on line 4 to a generator expression, which let you save the extra parentheses as well.

Charcoal, 277 255 bytes
≔Ｅ¹¹⟦⟦⟧⁰Ｓ⟧θ≔⮌θηＷ⊖Ｌη«≔⊟ηι≔‽12.4/6ζ⊞υζ⊞§ι⁰ζ≔⎇⁼ζ/⁺²‽³⁼³⁰Ｌ§ι⁰ζ¿ζ§≔ι¹ζ⊞ηι¿⊖Ｌη¿⁼¬﹪Ｌυ⁶¬εＦ⟦⊟η⊟η⟧⊞ηκ»”|⁴Ｂ\[⎇⁻℅↧Ｔ`⁵·5ＫＭＫ⟲M≦»→´⁶_⭆∨Ｒ▷↥l⁹KＧ…≦”Ｆθ«◨⊟ι⁷◨Σ§ι⁰¦³²§⪪”(3⪪⪫⧴πＺJL:∨ＸＩ±ＵＲＤ↗Σ9⟦FZ∕↖l⪪”⁷⊟ι◧ＩΣＥ⊟ιΣκ⁶⸿⸿»”|ＱºWＰD⟧zＮφ[v？Π'vＧ”◧ＩΣＥυΣι²⁸Ｊ±¹±¹ＦＥ¹³⁻²⁷⊗ι«Ｂ⁵⁵ιＢ⁴⁹ι¿‹ι²⁷«Ｂ³⁹ιＢ⁸ι

Try it online! Link is to verbose version of code. Explanation:
≔Ｅ¹¹⟦⟦⟧⁰Ｓ⟧θ

Read in the 11 names (input is flexible: JSON, space separated, or newline separated) and create an array q of 11 batters, represented by their balls (as an array), status (as an integer) and name.
≔⮌θη

Create a reversed copy of the batters h. This represents the batters that are not out. The last two elements are the off and current batters.
Ｗ⊖Ｌη«

Repeat while there are at least two batters available.
≔⊟ηι

Extract the current batter to i.
≔‽12.4/6ζ

Generate a random ball in z.
⊞υζ

Add it to the overall list of balls using the predefined empty list u.
⊞§ι⁰ζ

Add it to the current batter's balls.
≔⎇⁼ζ/⁺²‽³⁼³⁰Ｌ§ι⁰ζ

If the ball is a /, then generate a random status 2..4, otherwise if this is the batter's 30th ball then set the status to 1 otherwise 0.
¿ζ§≔ι¹ζ⊞ηι

If the batter is out then store the batter's status otherwise put the batter back in to bat.
¿⊖Ｌθ¿⁼¬﹪ΣＥηＬκ⁶¬ζ

If there are at least two batters left, and the batter was out xor 6 balls have been played, then...
Ｆ⟦⊟η⊟η⟧⊞ηκ»

...take the off and current batters and put them back in reverse order.
”|⁴Ｂ\[⎇⁻℅↧Ｔ`⁵·5ＫＭＫ⟲M≦»→´⁶_⭆∨Ｒ▷↥l⁹KＧ…≦”

Print the header.
Ｆθ«

Loop over the batters.
◨⊟ι⁷

Print the batter's name.
◨Σ§ι⁰¦³²

Print the batter's balls.
§⪪”(3⪪⪫⧴πＺJL:∨ＸＩ±ＵＲＤ↗Σ9⟦FZ∕↖l⪪”⁷⊟ι

Print the batter's status by indexing into the string Not OutRetiredBowled Caught   LBW split into substrings of length 7.
◧ＩΣＥ⊟ιΣκ⁶

Print the batter's score.
⸿⸿»

Move to the start of the next line but one.
”|ＱºWＰD⟧zＮφ[v？Π'vＧ”◧ＩΣＥυΣι²⁸

Print the total.
Ｊ±¹±¹ＦＥ¹³⁻²⁷⊗ι«Ｂ⁵⁵ιＢ⁴⁹ι¿‹ι²⁷«Ｂ³⁹ιＢ⁸ι

Draw boxes around everything.


text:
Binary Sequences
Given a binary number A as input with d > 1 digits, output a binary number B with d digits according to the following rules for finding the nth digit of B:

The first digit of B is zero if the first and second digits of A are equal; otherwise, it is one.
If 1 < n < d, then if the (n-1)th, nth and (n+1)th digits of A are equal, then the nth digit of B is zero; otherwise, it is one.
The dth digit of B is zero if the (d-1)th and dth digits of A are equal; otherwise, it is one.

Rules
String/list input/output format is fine. Another allowed way of input/output is an integer followed by the number of preceding zeros (or following the number of preceding zeros).
Make your code as short as possible.
Test Cases
00 -> 00
01 -> 11
11 -> 00
010111100111 -> 111100111100
1000 -> 1100
11111111 -> 00000000
01010101 -> 11111111
1100 -> 0110

You should have waiting 10 more minutes, then you would have got a hat. Nice challenge though!

@cairdcoinheringaahing I remember those last year... oh, well. :-(

Suggested test case: 1100 -> 0110 (the first 2 digits of the output are always identical in all other test cases; ditto for the last 2 digits)

It's nice to see that no downvotes have been cast on this challenge or on its twenty-five answers. Well done, everyone!

Jelly, 9 bytes
.ịṚjṡ3E€¬

Try it online!
I/O as list of digits.
Explanation:
.ịṚjṡ3E€¬
.ịṚ       Get first and last element
   j      Join the pair with the input list, thus making a list [first, first, second, ..., last, last]
    ṡ3    Take sublists of length 3
      E€  Check if each has all its elements equal
        ¬ Logical NOT each

Almost the same with my attempt :P

@LeakyNun it's quite common to get identical code in easier challenges ;p

Could you add an explanation?

@cairdcoinheringaahing You most likely understand the code, but I am adding this as a reference for everyone until Erik adds one (if he does): .ị - Gets the element at index 0.5. Since floor(0.5) ≠ ceil(0.5), ị returns the elements at indexes 0 and 1. Jelly is one indexed, thus 0 actually grabs the last element. Ṛ reverses the pair (because they are returned as last, first). Then j joins the pair on the input and ṡ3 splits it into overlapping slices of length 3. E€ checks (for each list) if all the elements are equal, and ¬ logically negates each.

Haskell, 59 58 54 bytes
f s=[1-0^(a-b+a-c)^2|a:b:c:_<-scanr(:)[last s]$s!!0:s]

Try it online!
f s=                        -- input is a list of 0 and 1
          s!!0:s            -- prepend the first and append the last number of s to s
      scanr(:)[last s]      --   make a list of all inits of this list
     a:b:c:_<-              -- and keep those with at least 3 elements, called a, b and c
    1-0^(a-b+a-c)^2         -- some math to get 0 if they are equal or 1 otherwise

Edit: @Ørjan Johansen saved 4 bytes. Thanks!

If you don't mind switching to string output, then "0110"!!(a+b+c) saves a byte.

@Laikoni: Thanks, but I've found also a byte in my math.

[last s] can be moved to the scanr initial value.

wow. inits (with the import); abs; if-then-else; map (take 3); zipWith; takeWhile (not.null) ; chunksOf (with its import) ... all golfed away! is there a hall of golfing fame, somewhere, anywhere?

05AB1E, 6 bytes
¥0.ø¥Ā

I/O is in form of bit arrays.
Try it online!
How it works
¥       Compute the forward differences of the input, yielding -1, 0, or 1 for each
        pair. Note that there cannot be two consecutive 1's or -1's.
 0.ø    Surround the resulting array with 0‘s.
    ¥   Take the forward differences again. [0, 0] (three consecutive equal
        elements in the input) gets mapped to 0, all other pairs get mapped to a
        non-zero value.
     Ā  Map non-zero values to 1.

05AB1E, 11 bytes
¬s¤)˜Œ3ù€Ë_

Try it online!
or as a Test suite
Explanation
¬             # get head of input
 s            # move it to the bottom of the stack
  ¤           # get the tail of the input
   )˜         # wrap in list ([head,input,tail])
     Œ3ù      # get sublists of length 3
        €Ë    # check each sublists for equality within the list
          _   # logical negation

Haskell, 66 61 59 bytes
g t@(x:s)=map("0110"!!)$z(x:t)$z t$s++[last s]
z=zipWith(+)

Try it online! Input is a list of zeros and ones, output is a string. Usage example: g [0,1,0,1,1,1,1,0,0,1,1,1] yields "111100111100".

Previous 61 byte solution:
g s=["0110"!!(a+b+c)|(a,b,c)<-zip3(s!!0:s)s$tail s++[last s]]

Try it online!

J, 26 14 bytes
Credit to Emigna's 05AB1E solution
2=3#@=\{.,],{:

Try it online!
Original attempt
2|2#@="1@|:@,,.@i:@1|.!.2]

Try it online!
             ,.@i:@1              -1, 0, 1
                    |.!.2]         shift filling with 2
  2         ,                      add a row of 2s on top
         |:                        transpose
   #@="1                           count unique elements in each row
2|                                 modulo 2

Clever way of making infixes of 3 at the start and end.

Husk, 15 11 bytes
Ẋȯ¬EėSJ§e←→

Takes input as a list, try it online! Or try this one that uses strings for I/O.
Explanation
Ẋ(¬Eė)SJ§e←→ -- implicit input, for example [1,0,0,0]
      SJ     -- join self with the following
        §e   --   listify the
                  first and
                  last element: [1,0]
             -- [1,1,0,0,0,0]
Ẋ(   )       -- with each triple (eg. 1 0 0) do the following:
    ė        --   listify: [1,1,0]
   E         --   are all equal: 0
  ¬          --   logical not: 1
             -- [1,1,0,0]

Python 3, 58 bytes
lambda a:[len({*a[i and~-i:i+2]})-1for i in range(len(a))]

Try it online!

Jelly, 8 bytes
I0;;0In0

I/O is in form of bit arrays.
Try it online!
How it works
I0;;0In0  Main link. Argument: A (bit array of length d)

I         Increments; compute the forward differences of all consecutive elements
          of A, yielding -1, 0, or 1 for each pair. Note that there cannot be
          two consecutive 1's or -1's.
 0;       Prepend a 0 to the differences.
   ;0     Append a 0 to the differences.
     I    Take the increments again. [0, 0] (three consecutive equal elements in A)
          gets mapped to 0, all other pairs get mapped to a non-zero value.
      n0  Perform not-equal comparison with 0, mapping non-zero values to 1.

I arrived at a funny alternative, maybe you can draw inspiration from this: I0,0jI¬¬

JavaScript (ES6), 45 bytes
Takes input as an array of characters. Returns an array of integers.
a=>a.map((v,i)=>(i&&v^p)|((p=v)^(a[i+1]||v)))

Test cases

let f =

a=>a.map((v,i)=>(i&&v^p)|((p=v)^(a[i+1]||v)))

console.log(JSON.stringify(f([..."00"])))           // -> 00
console.log(JSON.stringify(f([..."01"])))           // -> 11
console.log(JSON.stringify(f([..."11"])))           // -> 00
console.log(JSON.stringify(f([..."010111100111"]))) // -> 111100111100
console.log(JSON.stringify(f([..."1000"])))         // -> 1100
console.log(JSON.stringify(f([..."11111111"])))     // -> 00000000
console.log(JSON.stringify(f([..."01010101"])))     // -> 11111111
console.log(JSON.stringify(f([..."1100"])))         // -> 0110

Commented
a =>                  // given the input array a
  a.map((v, i) =>     // for each digit v at position i in a:
    (                 //   1st expression:
      i &&            //     if this is not the 1st digit:
           v ^ p      //       compute v XOR p (where p is the previous digit)
    ) | (             //   end of 1st expression; bitwise OR with the 2nd expression:
      (p = v) ^       //     update p and compute v XOR:
      (a[i + 1] ||    //       the next digit if it is defined
                   v) //       v otherwise (which has no effect, because v XOR v = 0)
    )                 //   end of 2nd expression
  )                   // end of map()

Jelly, 16 bytes
ḣ2W;ṡ3$;ṫ-$W$E€¬

Try it online!
I was going to golf this but Erik has a shorter solution already and golfing mine would just bring mine closer to his. I'm still golfing but I won't update unless I can beat him or find a unique idea.
Explanation
ḣ2W;ṡ3$;ṫ-$W$E€¬  Main Link
ḣ2                First 2 elements
  W               Wrapped into a list (depth 2)
   ;              Append
    ṡ3$           All overlapping blocks of 3 elements
       ;          Append
        ṫ-$W$     Last two elements wrapped into a list
             E€   Are they all equal? For each
               ¬  Vectorizing Logical NOT

Using less money and isn't any more similar to Erik's

Mathematica, 56 bytes
Boole[!Equal@@#&/@Partition[ArrayPad[#,1,"Fixed"],3,1]]&

Try it online!

Japt, 14 13 12 bytes
Partly ported from Dennis' Jelly solution. Input & output are arrays of digits.
ä- pT äaT mg

Saved a byte thanks to ETHproductions.
Try it

Explanation
Implicit input of array U. ä- gets the deltas of the array. pT pushes 0 to the end of the array. äaT first adds another 0 to the start of the array before getting the absolute deltas. mg maps over the elements of the array returning the sign of each element as -1 for negative numbers, 0 for 0 or 1 for positive numbers.

Hmm, I wonder if there's a good way to make a method that puts an item at the beginning and end of an array, like .ø in the 05AB1E answer. I think that would make it 1 byte shorter...

@ETHproductions, for the likes of A.ä() which prepends its second argument, you could add a 3rd argument that gets appended. So, in this case, pT äaT could become äaTT for a 2 byte saving.

Perl 5, 62 + 1 (-n) = 63 bytes
s/^.|.$/$&$&/g;for$t(0..y///c-3){/.{$t}(...)/;print$1%111?1:0}

Try it online!

Shortened to 49 bytes: Try it online!

You should post it as an answer.  I don't want to take credit for your work.
That s;..$; construct at the end is nifty.  I'll have to remember that one.

Husk, 10 bytes
Ẋo±≠↔Θ↔ΘẊ-

Try it online!
Thanks to Zgarb for -1 byte.

Ẋo±≠ saves a byte.

Python 3, 54 bytes
lambda x:[n^1in x[i-(i>0):i+2]for i,n in enumerate(x)]

I/O is in form of Boolean arrays.
Try it online!

J, 32 Bytes
B=:2&(+./\)@({.,],{:)@(2&(~:/\))

How it works:
B=:                              | Define the verb B
                       2&(~:/\)  | Put not-equals (~:) between adjacent elements of the array, making a new one
            ({.,],{:)            | Duplicate the first and last elements
   2&(+./\)                      | Put or (+.) between adjacent elements of the array

I left out some @s and parenthesis, which just make sure it goes together nicely.
A step by step example:
    2&(~:/\) 0 1 0 1 1 1 1 0 0 1 1 1
1 1 1 0 0 0 1 0 1 0 0

    ({.,],{:) 1 1 1 0 0 0 1 0 1 0 0
1 1 1 1 0 0 0 1 0 1 0 0 0

    2&(+./\) 1 1 1 1 0 0 0 1 0 1 0 0 0
1 1 1 1 0 0 1 1 1 1 0 0

    B 0 1 0 1 1 1 1 0 0 1 1 1
1 1 1 1 0 0 1 1 1 1 0 0

Pyth, 15 bytes
mtl{d.:++hQQeQ3

Try it here!
Alternatively:

mtl{d.:s+hQeBQ3.
.aM._M.+++Z.+QZ.

This prepends the first element and appends the last element, then gets all overlapping substrings of length 3, and finally takes the number of distinct elements in each sublist and decrements it. This mess has been done on mobile at midnight so I wouldn’t be surprised if there are some easy golfs.

Retina, 35 bytes
(.)((?<=(?!\1)..)|(?=(?!\1).))?
$#2

Try it online! Link includes test cases. Explanation: The regex starts by matching each input digit in turn. A capture group tries to match a different digit before or after the digit under consideration. The ? suffix then allows the capture to match 0 or 1 times; $#2 turns this into the output digit.

Gaia, 9 bytes
ọ0+0¤+ọ‼¦

Try it online!
Explanation

ọ0+0¤+ọ‼¦ ~ A program accepting one argument, a list of binary digits.

ọ         ~ Deltas.
 0+       ~ Append a 0.
   0      ~ Push a zero to the stack.
    ¤     ~ Swap the top two arguments on the stack.
     +    ~ Concatenate (the last three bytes basically prepend a 0).
      ọ   ~ Deltas.
        ¦ ~ And for each element N:
       ‼  ~ Yield 1 if N ≠ 0, else 0.

Gaia, 9 bytes
ọ0¤;]_ọ‼¦

Try it online!

C, 309 bytes
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(int argc,char** argv){int d=strlen(argv[1]);char b[d + 1];char a[d + 1];strcpy(a, argv[1]);b[d]='\0';b[0]=a[0]==a[1]?'0':'1';for(int i=1;i<d-1;i++){b[i]=a[i]==a[i+1]&&a[i]==a[i - 1]?'0':'1';}b[d-1]=a[d-1]==a[d-2]?'0':'1';printf("%s\n",b);}

Not exactly a language fit for golfing, but worth an answer none-the-less.
Try it out here!
Explanation
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char** argv) {
    /* Find the number of digits in number (taken in as a command line argument) */
    int d = strlen(argv[1]);

    /* d + 1 to account for d digits plus the null character */
    char b[d + 1];
    char a[d + 1];

    /* Saves having to type argv[1] every time we access it. */
    strcpy(a, argv[1]);

    /* Set the null character, so printf knows where our string ends. */
    b[d] = '\0';

    /* First condition */
    /* For those not familiar with ternary operators, this means b[0] is equal to '0' if a[0] equals a[1] and '1' if they aren't equal. */
    b[0] = a[0] == a[1] ? '0' : '1';

    /* Second condition */
    for(int i = 1; i < d - 1; i++) {
        b[i] = a[i] == a[i+1] && a[i] == a[i - 1] ? '0' : '1';
    }

    /* Third condition */
    b[d - 1] = a[d - 1] == a[d - 2] ? '0' : '1';

    /* Print the answer */
    printf("%s\n", b);
}

Welcome to PPCG :)

APL+WIN, 29 bytes
(↑b),(×3|3+/v),¯1↑b←×2|2+/v←⎕

Prompts for screen input as a vector of digits and outputs a vector of digits.
Explanation
b←×2|2+/v signum of 2 mod sum of successive pairs of elements

×3|3+/v signum of 3 mod sum of successive triples of elements

(↑b),...., ¯1↑b concatenate first and last elements of b for end conditions

SNOBOL4 (CSNOBOL4), 273 bytes
	I =INPUT
	D =SIZE(I)
N	P =P + 1
	EQ(P,1)	:S(S)
	EQ(P,D)	:S(E)
	I POS(P - 2) LEN(2) . L
	I POS(P - 1) LEN(2) . R
T	Y =IDENT(L,R) Y 0	:S(C)
	Y =Y 1
C	EQ(P,D) :S(O)F(N)
S	I LEN(1) . L
	I POS(1) LEN(1) . R :(T)
E	I RPOS(2) LEN(1) . L
	I RPOS(1) LEN(1) . R :(T)
O	OUTPUT =Y
END

Try it online!
	I =INPUT			;* read input
	D =SIZE(I)			;* get the string length
N	P =P + 1			;* iNcrement step; all variables initialize to 0/null string
	EQ(P,1)	:S(S)			;* if P == 1 goto S (for Start of string)
	EQ(P,D)	:S(E)			;* if P == D goto E (for End of string)
	I POS(P - 2) LEN(2) . L		;* otherwise get the first two characters starting at n-1
	I POS(P - 1) LEN(2) . R		;* and the first two starting at n
T	Y =IDENT(L,R) Y 0	:S(C)	;* Test if L and R are equal; if so, append 0 to Y and goto C
	Y =Y 1				;* otherwise, append 1
C	EQ(P,D) :S(O)F(N)		;* test if P==D, if so, goto O (for output), otherwise, goto N
S	I LEN(1) . L			;* if at start of string, L = first character
	I POS(1) LEN(1) . R :(T)	;* R = second character; goto T
E	I RPOS(2) LEN(1) . L		;* if at end of string, L = second to last character
	I RPOS(1) LEN(1) . R :(T)	;* R = last character; goto T
O	OUTPUT =Y			;* output
END

C (tcc), 64 62 56 bytes
c,p;f(char*s){for(p=*s;c=*s;p=c)*s=p-c==c-(*++s?:c)^49;}

I/O is in form of strings. The function f modifies its argument s in place.
Try it online!

Common Lisp, 134 bytes
(lambda(a &aux(x(car a))(y(cadr a)))`(,#1=(if(= x y)0 1),@(loop for(x y z)on a while y if z collect(if(= x y z)0 1)else collect #1#)))

Try it online!


text:
Parse a list of signed unary numbers
Unary numbers typically only represent nonnegative integers, but we can extend them to represent all integers as follows:

A positive integer N is represented as N 1's: 5 -> 11111
A negative integer -N is represented as a 0 followed by N 1's: -5 -> 011111
Zero is represented as 0

We can then represent a list of these numbers unambiguously if we use 0 as the separator:
3,-2,0,1
111,011,0,1
111 0 011 0 0 0 1
11100110001

Your task: take a string representing such a list of signed unary numbers, and translate it into a list of decimal numbers.
Details
You may assume that the input is a complete list of signed unary numbers. In particular, your program will not have to handle 1) empty input or 2) input that ends with a separator.
You may assume that the magnitude of each number will not exceed 127. For languages with maximum sizes of strings or lists, you may assume that the input and output will fit in your language's data structures, but your algorithm should theoretically work for a list of any size.
Your program or function may perform I/O in any of the standard ways. Input may be a string or a list of characters, single-character strings, integers, or booleans. You may use any two characters to represent 1 and 0; if you don't use 1 and 0, please specify which characters you're using.
Output must be decimal numbers in any reasonable list format (in particular, there must be some kind of a separator between numbers). Negative numbers should be indicated with a minus sign, although if your language has a different format for negative integers I will also accept that. Zero may be represented in the output as 0 or -0.
Test cases
1 -> 1
0 -> 0 (or -0, and similarly for the other test cases)
011 -> -2
1101 -> 2,1
1100 -> 2,0
11001 -> 2,-1
110001 -> 2,0,1
11100110001 -> 3,-2,0,1
00000001 -> 0,0,0,-1
01111011111111001111111111111110111111111111111100111111111111111111111110111111111111111111111111111111111111111111 -> -4,8,-15,16,-23,42
01111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -> -127

Nitpick: Since this contains '0's, it isn't technically unary. Good challenge though!

@DJMcMayhem Nitpick to the nitpick: I technically never said it was unary. It is an extension of unary which I am calling "signed unary." ;)

@DJMcMayhem IMO, the challenge is specifically that the separator (0) and the negative sign prefix (0) are the same, although it's still unambiguous, since you can't have negative signs in the middle of a number (is 182--693-1 a number? no, and neither is 1111011000101111 for the exact same reason).

Is it okay if the outputted list is in reverse order of the input?

well technically decimal isn't decimal either since it uses the ' - ' symbol

@DJMcMayhem No, it should be the same list and therefore in the same order.

Doesn't input of 0 end in a separator?

@Giuseppe No, for the same reason that input of 011 doesn't begin with a separator: 0 is not considered a separator when it's part of a number.

Python 2, 73 70 bytes
A function that takes a string as input and returns a string representation of a Python list. Zero can be represented both by 0 and -0 (when it comes last):
lambda s:`map(len,s.split('0'))`.replace('0, ','-').replace('--','0,')

Explanation

split the input string s on zeroes.
Take the length of each string in the resulting list (using map).

That takes us a long way. Zeroes were separators after all. And the numbers were unary, so len conveniently converts those to decimal. But now we've messed up all the non-separator uses of 0. Luckily, all non-separator uses were leading zeroes so they came after a separator-zero and gave us zero-length strings ('00'.split('0') == ['', '', '']). Those zero-length strings then also became 0 because of the len.

Turn the list into a string (using "reverse quotes"), so we can fix up the mess more easily.
replace each zero that precedes another number by a negative sign on that number instead. That fixes the use of 0 as a sign but it breaks the literal zeroes. Literal zeroes were also preceded by a separator, so they've now become pairs of extra dashes on the next number.
replace each -- back into a 0 element in the "list".

Welcome to PPCG!

Retina, 23 21 bytes
(.)0
$1
01
-1
1+
$.&

Try it online!
The first stage (.)0<newline>$1<space> matches any character followed by a 0. The match is replaced by the first character followed by a space. This splits the string in the individual numbers.
The second stage 01<newline>-1 replaces 0's before a block of 1's to to the - sign.
The last stage 1+<newline>$.& matches all blocks of 1's and replaces them with the length of the group.
Here is an example with the output of the individual stages.

Very nice - all of my ideas seem to clock in at 24 bytes...

Could you please add an explanation? I don't speak Retina.

@Dopapp added an explanation

Vim, 56 bytes
:s/\v(0?1*)0?/\1\r/g|%s/0/-/|%s/1*$/\=len(submatch(0))
D

Try it online!
I haven't posted in vim in a while. I'm mostly using vim because V is a pain sometimes. Because the count command, which is perfect for getting the number of '1's on the line will overwrite any '0's on the line, so we can't negate it afterwards.
Explanation:
This is one byte shorter then the straightforward way:
:s/\v(0?1*)0?/\1\r/g
:%s/0/-
:%s/1*$/\=len(submatch(0))
D

due to command chaining. Since that one separates the commands, I'll use it for the explanation.
:s/                     " Substitute
                        " Search for...
   \v                   "   Enable 'magic'. This determines whether certain atoms require a backslash or not.
                        "   Without it we would have: '\(0\?1*\)0\?', which is 2 bytes longer
      0?                "   An optional 0
        1*              "   Followed by any number of '1's
     (    )             "   (call that group 1)
           0?           "   Followed by another optional 0
             /          " Replace it with...
              \1        "   Subgroup 1
                \r      "   A newline
                  /g    " Do this for every match on the current line.

Now, each signed unary number is on an individual line. Using '11100110001' as an example, at this point we'll have:
111
011
0
1

:%s/0   " Replace every 0
     /- " With a dash

:%s/1*$/                    " Replace every run of 1's at the end of a line
        \=len(submatch(0))  " With the length of said run

Since we added newlines at the end of each match, we had an empty line before running that. After running that, we'll have a '0' (because it matched a run of 0 '1's). So we just call D to delete this line, leaving it blank

Ugh. :%s/1+$/ would get you one byte shorter if not for the need to backslash the + :(

@NieDzejkob I don't understand why that would be shorter. And also, that would give - instead of 0 or -0

I wanted to eliminate the last line that way :P, never mind.

Haskell, 68 66 bytes
f(x:r)|(a,b)<-span(>0)r=([(0-),(1+)]!!x$sum a):[z|_:t<-[b],z<-f t]

Try it online! Takes input as a list of zeros and ones. Example usage: f [0,0,0,1,1] yields [0,-2].
Explanation:
The pattern matching in f(x:r)|(a,b)<-span(>0)r binds x to the first element of the input, a to a (potentially empty) list of following 1s, and b to the rest of the input. Given an input [0,1,1,1,0,0,1], we get x=0, a=[1,1,1] and b=[0,0,1].
The current number is then either the sum of a negated if x=0, or the sum of a plus one if x=1. This is achieved by indexing with x into a list containing a negation and increment function, and applying the resulting function to the sum of a: [(0-),(1+)]!!x$sum a.
The rest list b is either empty or contains a separating zero and the next number. The list comprehension [z|_:t<-[b],z<-f t] tries to match b on the pattern _:t, that is forget the head element and bind the rest of the list to t. If b is empty this match fails and the list comprehension evaluates to [], which is the base case for the recursion. Otherwise the function f is recursively applied to t and the list comprehension evaluates to all elements z from the result of f t.

Perl 5, 40 + 1 (-n) = 41 bytes
print'-'x/00/.y/1//.$"for"0$_"=~/00?1*/g

Try it online!

Husk, 20 18 17 15 14 bytes
Γ~:?Σṁ_Πȯ₀tΣġ/

Try it online!
Explanation
Γ~:?Σṁ_Πȯ₀tΣġ/  Input is a list, say x = [0,1,1,0,0,0,1,1]
            ġ   Group by
             /  division.
                This splits x right before each 0: [[0,1,1],[0],[0],[0,1,1]]
Γ               Deconstruct into head y = [0,1,1] and tail z = [[0],[0],[0,1,1]]
   ?Σṁ_Π        Apply to y:
       Π         Product: 0
   ?Σ            If that is nonzero, take sum of y,
     ṁ_          else take sum of negated elements of y: u = -2
        ȯ₀tΣ    Apply to z:
           Σ     Concatenate: [0,0,0,1,1]
          t      Drop first element: [0,0,1,1]
         ₀       Recurse: [0,2]
 ~:             Tack u to the front: [-2,0,2]

The splitting works like this.
ġ/ splits its argument between each pair of elements a,b for which /a b is falsy.
/a b is division with flipped arguments, so b divided by a.
The relevant values in this program are these:

/1 1 gives 1 (truthy).
/1 0 gives 0 (falsy).
/0 1 gives Inf (positive infinity, truthy).
/0 0 gives Any (a special NaN-like value, falsy).

Jelly,  19  18 bytes
There must be a better way...
®ḢN$Ḣ©?ṄEȧ
ṣ0L€ÇL¿

A full program printing each number followed by a linefeed.
Try it online!
How?
®ḢN$Ḣ©?ṄEȧ - Link 1, print first number and yield next input: list of numbers, X
           -                              e.g. [8,0,15,16,...] or [0,4,8,0,15,16,...]
      ?    - if...
    Ḣ      - condition: yield head and modify  8([0,15,16,...])   0([4,8,0,15,16,...])
     ©     -            (copy to register)     8                  0
®          - then: recall from the register    8
   $       - else: last two links as a monad:
 Ḣ         -         yield head and modify                        4([8,0,15,16,...])
  N                  negate                                      -4
       Ṅ   - print that and yield it           8                 -4
        E  - all equal (to get 0 to be truthy) 1                  1
         ȧ - AND the (modified) input          [0,15,16,...]      [8,0,15,16,...]
           -   (ready to be the input for the next call to this link)

ṣ0L€ÇL¿ - Main link: list e.g. [0,1,0,0,0,0,1,1]
ṣ0      - split at zeros       [[],[1],[],[],[],[1,1]
  L€    - length of €ach       [0,1,0,0,0,2]
      ¿ - while...
     L  - condition: length                           1  1  1  0  ([0,1,0,0,0,2], [0,0,0,2], [0,2], [])
    Ç   - action: call the last link (1) as a monad  -1  0 -2     ( - 1            - 0        - 2)

Wolfram Language (Mathematica), 80 bytes
StringCases[#<>"0",x_~~Shortest@y___~~"0":>(If[x=="0",-#,#+1]&)@StringLength@y]&

Try it online!
Abuses the mechanic of StringCases, since it does not check overlapping patterns. Since we search from left to right, without overlaps, we always get only the integers we need.
Explanation
#<>"0"

Append a zero at the end
StringCases

Find all of the following pattern...
x_~~Shortest@y___~~"0"

A single character (call it x), followed by the shortest possible zero-length or longer string (call it y), followed by a zero.
(If[x=="0",-#,#+1]&)@StringLength@y

Apply to matching pattern: take the length of y. If x is zero, then negate the value. Else, increment one.
This covers 00 as well, since y would be an empty string, and we would compute -0 ( == 0).

Brain-Flak, 94 (70?) bytes
([]){{}({(<()>)()}{}(<>)<>{<([{}]<>{})><>})
{{}<>([{}])(<>)}{}{}([])}{}<>([]){{}({}<>)<>([])}<>

Try it online!
This is actually surprisingly terse for brain-flak.
Here is a commented/readable version:
([])

{

    #Pop the Stack height
    {}

    (
        #If there isn't a leading 0, evaluate to 1...
        {
            (<()>)

            ()
        }

        #Pop the 0
        {}

        #Push a 0 onto the alternate stack
        (<>)
        <>

        #Run of '1's
        {
            #Decrement the alternate stack
            <([{}]<>{})>
            <>
        }

        #And push it here
    )

    #Was there a not leading 0?

    {
        {}

        #Invert the value on the alternate stack
        <>([{}])(<>)
    }

    #Pop 2 zeros
    {}{}

    ([])

}{}<>

#Push stack height
([])

#Reverse the stack
{

    {}

    ({}<>)

    <>([])

}<>

If the output can be in reverse, we can do this for 70 instead:
([]){{}({(<()>)()}{}(<>)<>{<([{}]<>{})><>}){{}<>([{}])(<>)}{}{}([])}<>

This tip of mine is almost perfect for this situation. But it doesn't quite work since we have to push a 0 before doing the operation (counting the '1's), and the operation happens in a loop. The shortest I could come up with utilizing this tip is:
([]){{}({(<()>)()}{}(<>)<>{<([{}]<>{})><>})
{{}<>([{}])(<>)}{}{}(<>())<>([])}{}<>{{}({}<>)<>}<>

which is also 94 bytes.

Acc!!, 252 237 bytes
N
Count i while _/48 {
Count n while 48/_ {
Write 45
50+N
}
_+49/_*50
Count u while _%50/49 {
_+100-_%50+N
}
_/50-1
Count h while _/200 {
Write _/200+48
_%200+1
}
Count t while _/20+_%2 {
Write _/20+48
_%20-_%2
}
Write _/2+48
Write 9
N
}

Uses -0. Outputs numbers separated by tab characters, with a trailing tab. Try it online!
Amount of time writing the actual algorithm: 20 minutes. Amount of time debugging my decimal output code: 45 minutes. :^P
With comments
I don't know if these comments explain the code very well--they're based on my notes to myself while I was writing it, so they assume some understanding of how Acc!! works. If anything needs more explanation, let me know and I'll try to make it clearer.
# We partition the accumulator _ as [number][flag][nextchar]
# [flag] is a 2-value slot and [nextchar] a 50-value slot
# So [nextchar] is _%50, [flag] is _/50%2, [number] is _/100
# [flag] is 1 if we're in the middle of reading a number, 0 if we're between numbers
# It is also used for outputting as decimal (see below)
# Possible input characters are 0, 1, and newline, so [nextchar] is 48, 49, or 10

# Read the first character
N
# Loop while the character we just read is 0 or 1 and not newline
Count i while _/48 {
  # What we do in the loop depends on the combination of [flag] and [nextchar]:
  # 0,48 (start of number, read 0) => write minus sign, [flag] = 1, read another char
  # _,49 (read 1) => increment [number], [flag] = 1, read another char
  # 1,48 (middle of number, read 0) => write/clear [number], status = 0, read another
  #      char
  # 1,10 (middle of number, read <cr>) => ditto; the next read will be 0 for eof, which
  #      means the acc will be less than 48 and exit the loop

  # Process leading 0, if any
  Count n while 48/_ {
    # acc is 48: i.e. [number] is 0, [flag] is 0, [nextchar] is 48 (representing a 0)
    # Output minus sign
    Write 45
    # Set [flag] to 1 (thereby exiting loop) and read [nextchar]
    50+N
  }
  # If number starts with 1, then we didn't do the previous loop and [flag] is not set
  # In this case, acc is 49, so we add (50 if acc <= 49) to set [flag]
  _+49/_*50

  # Process a run of 1's
  Count u while _%50/49 {
    # [nextchar] is 49 (representing a 1)
    # Increment [number] and read another
    _+100-_%50+N
  }

  # At this stage, we know that we're at the end of a number, so write it as decimal
  # This is "easier" (ha) because the number has at most three digits
  # We shift our partitioning to [number][flag] and set [flag] to 0
  _/50-1

  # Output hundreds digit if nonzero
  # Since [number] is _/2, the hundreds digit is _/200
  Count h while _/200 {
    Write _/200+48
    # Mod 200 leaves only tens and units; also, set [flag] to 1
    _%200+1
  }
  # Output tens digit (_/20) if nonzero OR if there was a hundreds digit
  # In the latter case, [flag] is 1
  Count t while _/20+_%2 {
    Write _/20+48
    # Mod 20 leaves only units; clear [flag] if it was set
    _%20-_%2
  }
  # Write units unconditionally
  Write _/2+48

  # Write a tab for the separator
  Write 9
  # Read another character
  N
}

Python 2, 96 92 bytes
lambda s:[[len(t),-len(t)+1]['1'>t]for t in s.replace('10','1 ').replace('00','0 ').split()]

Try it online!
Thx to ovs and DLosc for 2 bytes each.

R, 119 bytes
function(x){n=nchar
y=regmatches(x,regexec("(0?)(1*)0?([01]*)",x))[[1]]
cat((-1)^n(y[2])*n(y[3]),"")
if(y[4]>0)f(y[4])}

Try it online!
The code uses this solution from stackoverflow for a related problem (Thanks to jeales for the idea). The output is a space-separated string printed to stdout.

sed, 227 bytes
s/^.o*/<&>/
:a
s/>z\(.o*\)/><\1>/
ta
:b
s/z>/0>/g
y/z/-/
s/oooooooooo/x/g
s/ooooooooo/m9/g
s/oooooooo/m8/g
s/ooooooo/m7/g
s/oooooo/m6/g
s/ooooo/m5/g
s/oooo/m4/g
s/ooo/m3/g
s/oo/m2/g
s/o/m1/g
s/x\([^xm]\)/x0\1/g
s/m//g
y/x/o/
tb

Try it online!
Usage
0 and 1 for input are replaced with z and o respectively.
Input is given from stdin, on every line.
With comments
# first integer
s/^.o*/<&>/
# find each item
:a
s/>z\(.o*\)/><\1>/
ta
# below: to decimal
:b
# to zero
s/z>/0>/g
# minus sign
y/z/-/
# to decimal others
# m letter indicates that converting a digit is done
s/oooooooooo/x/g
s/ooooooooo/m9/g
s/oooooooo/m8/g
s/ooooooo/m7/g
s/oooooo/m6/g
s/ooooo/m5/g
s/oooo/m4/g
s/ooo/m3/g
s/oo/m2/g
s/o/m1/g
# not converted yet? then to 0
s/x\([^xm]\)/x0\1/g
s/m//g
y/x/o/
# repeat until every unary is converted
tb

TODO. Use tips on this thread.

QBasic, 88 86 bytes
1u$=INPUT$(1)
z=u$<"1
IF n*z THEN?(1-2*s)*(n-s):s=0:n=0ELSE s=s-z:n=n+1
IF"!"<u$GOTO 1

This was fun. Multiple revisions starting from a 107-byte version resulted in one of the most obfuscated bits of QBasic I think I've ever written. (Edit: Oddly enough, I was able to golf 2 bytes by making the code clearer.)
Note: this program reads user input one character at a time without echoing it to the screen (a result of using INPUT$(1) instead of the usual INPUT statement). So as you're typing, you won't see the 1's and 0's, but the decimal numbers will appear as they are calculated. Make sure to hit Enter at the end of the input to see the last number and end the program.
Ungolfed version
sign = 0
num = 0
DO
  digit$ = INPUT$(1)
  isZero = (digit$ < "1")
  IF num > 0 AND isZero THEN
    PRINT (1 - 2 * sign) * (num - sign)
    sign = 0
    num = 0
  ELSE
    IF isZero THEN sign = 1
    num = num + 1
  END IF
LOOP WHILE "!" < digit$

Explanation
(AKA "What?? That still makes no sense!")
The base strategy is to run a loop that grabs one character from INPUT$(1) each time through, does stuff with it, and keeps looping as long as the character has an ASCII value greater than that of ! (i.e., wasn't a newline).
We keep track of numbers-in-progress using two variables. num is the number of characters in the current signed unary number (including any leading zero). sign is 1 if the number had a leading zero, 0 if not. Both of these need to be initialized to 0, which is great for the golfed version because numeric variables in QBasic are automatically initialized to 0.
Whenever we read a character, the first thing is to determine whether it's 1 or 0. We'll use this result twice, so we store it in isZero. Technically, that name is misleading, since the value will also be truthy if the character is a newline. Note that truthy in QBasic is -1 and falsey is 0.
Now, if we're in the middle of reading a number (num > 0) and we hit a zero or end of input (isZero), we need to calculate which number we've finished reading.

sign stores 0 for positive, 1 for negative. To get 1 for positive and -1 for negative, we need 1-2*sign.
num stores the correct magnitude for positives but one more than the magnitude for negatives (since it includes the sign marker). So we can use num-sign for the magnitude.

Multiply these together and print; then reset sign and num to 0 in preparation for reading the next number.
Otherwise (if we haven't hit a zero, or if we've hit a zero at the beginning of a number), we update sign and num as follows:

sign becomes 1 if we're looking at a leading zero; otherwise, if we're looking at a one, it stays at whatever it already was. The golfed code is s=s-z, which amounts to the same thing:

If this is a leading zero, z is -1. Since s is guaranteed to be 0 (because this is the start of a new number), s-z will be 1.
If this is a one, z is 0. Then s-z stays at whatever value s had previously.

num is incremented.

That's it!

Jelly, 15 bytes
Ż¬<\œp$ḊLCṛ¡ḢƊ€

Try it online!
Although it's something of an improvement over the previous solution, this feels clumsy. (Though not as clumsy now that it doesn't use k.)
Input as a list of zeroes and ones.
Ż                  Prepend a leading zero to the input.
 ¬                 Flip 0 <-> 1.
    œp$            Split that around the corresponding locations of truthy elements of
  <\               it cumulatively reduced by greater than.
       Ḋ           Remove the leading empty slice,
             Ɗ€    then for each remaining slice:
        L          take the length,
         C         and subtract it from 1
           ¡       a number of times equal to
          ṛ Ḣ      the first element.

Lua, 58 bytes
(...):gsub("(0?)(1*)0?",function(s,n)print(#n-2*#s*#n)end)

Try it online!
Full program, takes input from the command line and prints the numbers to stdout separated by newlines.

JavaScript (ES6), 60 bytes
Returns a space-separated list of integers.
s=>(0+s).replace(/00?1*/g,s=>(l=s.length,+s[1]?l-1:2-l)+' ')

Test cases

let f =

s=>(0+s).replace(/00?1*/g,s=>(l=s.length,+s[1]?l-1:2-l)+' ')

console.log(f("1")) // 1
console.log(f("0")) // 0
console.log(f("011")) // -2
console.log(f("1101")) // 2,1
console.log(f("1100")) // 2,0
console.log(f("11001")) // 2,-1
console.log(f("110001")) // 2,0,1
console.log(f("11100110001")) // 3,-2,0,1
console.log(f("00000001")) // 0,0,0,-1
console.log(f("01111011111111001111111111111110111111111111111100111111111111111111111110111111111111111111111111111111111111111111")) // -4,8,-15,16,-23,42
console.log(f("01111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")) // -127