```python
def bin_coff(n, r):
    """
    Counts sequences of a given length having non-negative prefix sums.

    This function is interpreted to solve the following problem:
    Count the number of sequences of length 'n' containing 'r' instances of -1
    and 'n-r' instances of +1, such that all prefix sums of the sequence
    are non-negative.

    This is a classic combinatorial problem related to Dyck paths. A necessary
    condition for any such sequence to exist is that the total sum is non-negative.
    The total sum is (n - r) - r = n - 2r. Thus, we must have n >= 2r.
    If this condition is not met, the function returns 0.

    For cases where n >= 2r, the number of such valid sequences is given by
    the formula C(n, r) - C(n, r-1), where C(n, k) is the binomial coefficient
    "n choose k". This formula can be derived using André's reflection principle.
    """
    
    def _combinations(n_comb, k_comb):
        """
        Calculates the binomial coefficient C(n, k), or "n choose k".
        """
        if k_comb < 0 or k_comb > n_comb:
            return 0
        if k_comb == 0 or k_comb == n_comb:
            return 1
        if k_comb > n_comb // 2:
            k_comb = n_comb - k_comb
        
        res = 1
        for i in range(k_comb):
            res = res * (n_comb - i) // (i + 1)
        return res

    # A necessary condition for non-negative prefix sums is a non-negative total sum.
    # Total sum = (number of +1s) - (number of -1s) = (n - r) - r = n - 2r.
    # So, n - 2r >= 0, which means n >= 2r.
    if n < 2 * r:
        return 0
    
    # The number of valid sequences is C(n, r) - C(n, r-1).
    return _combinations(n, r) - _combinations(n, r - 1)

```