var depends = document.querySelectorAll('.depend');
        
              [].forEach.call(depends, function(depend) {
                depend.onchange = function() {
                  s(this, this.value);
                  c(this);
                }
              });
                  
              function c(current) {
                var input = +current.value;
                var max = 100;
                var delta = max - input;
                var sum = 0;
                var partial = 0;
                var siblings = [];
                /////////////////// <--- UPDATE
                var last = 0;
                /////////////////// <--- END UPDATE
        
                    // Sum of all siblings
                [].forEach.call(depends, function (depend) {
                  if (current != depend) {
                    siblings.push(depend); // Register as sibling
                    sum += +depend.value;
                  }
                });
        
                // Update all the siblings
                siblings.forEach(function (subling, i) {
                
                  var val = +subling.value;
                  var fraction = 0;
        
                  // Calculate fraction
                  if (sum <= 0) {
                    fraction = 1 / (depends.length - 1)
                  } else {
                    fraction = val / sum;
                  }
        
                  // The last element will correct rounding errors
                  if (i >= depends.length - 1) {
                    val = max - partial;
                  } else {
                    val = Math.round(delta * fraction);
                    partial += val;
                  }
                  
                  /////////////////// <--- UPDATE
                  if(input + last + val >= 100) {
                    val = 100 - (input + last);
                  }
        
                  last = val;
                  /////////////////// <--- END UPDATE
                  
                  s(subling, val);
                });
              }

              function s(el, value) {
                var label = document.getElementById(el.id+'_value')
                label.innerHTML = value;
                el.value = value;
              }