Nested If, working like an excel SUMIF for two unequal lists summing the distance if GPS timestamp meets criteria
For me, the problem starts with the nested loops showing no specification of what is to be achieved, not even a suggested abstraction (being the body of a function given a name).  

Observations:


the output does seem to depend on the order of elements of lista
(even beyond its order: lista[3][i-1])
• hope lista[2][i] &gt;= listc[1][j] is never True for i 0
 (unless you want lista[3][-1] accessed)
the output does not seem to depend on the order of elements of listc  
both lista and listc are not changed
→ the "range conditions" won't change unless at least one index changes  
all of "the increments" share the condition lista[0][i] == listc[0][j]
the conditions between lista[6/7][i] and listc[1][j] are not complementary for including equality in both cases


implying red/green possibly getting incremented twice in a single iteration (not using else)



idea:  


document, in the code, what is to be achieved
Python supports this with docstrings
use telling names
have a tool help you sticking to The Python Style Guide
order listc
for each i, iterate only that part of the ordered listc where lista[0][i] == listc[0][j]
ignore if lista and listc are not "rectangular":


food for thought: untested result of refactoring (get tool support for such, too)
(here extracting local variables, mostly)

list_c = sorted(listc)
for i in range(len(lista[1])):
    red = green = black = 0
    a0i = lista[0][i]
    first = bisect_left(list_c[1], a0i)
    beyond = bisect_right(list_c[1], a0i, first)
    if first &lt; beyond:
        a2i = lista[2][i]
        a3i = lista[3][i]
        c2i = list_c[2][i]
        a8i_intended = lista[8][i] == 'intended value'
        for j in range(first, beyond):
            c1j = list_c[1][j]
            if (c1j &lt;= a3i or c1j &gt;= a2i):
                if lista[7][i] &gt;= c1j and lista[6][i] &lt;= c1j and a8i_intended:
                    red += c2i
                if a3i &gt;= c1j and lista[7][i] &lt;= c1j and not a8i_intended:
                    red += c2i
                if lista[6][i] &gt;= c1j and a2i &lt;= c1j and a8i_intended:
                    green += c2i
                if lista[7][i] &gt;= c1j and a2i &lt;= c1j and not a8i_intended:
                    green += c2i
                if a2i &gt;= c1j and lista[3][i - 1] &lt;= c1j:
                    black += c2i
    toc = timeit.default_timer()
    if i % 100 == 0:
        print('processing algorithm: {}'.format(toc - tic))
        print('we are at row {}'.format(i))
    output[0].append(lista[1][i])
    output[1].append(red)
    output[2].append(green)
    output[3].append(black)


afterthought:  it may be better to handle listc[1][j] &lt;= lista[3][i] and lista[2][i] &lt;= listc[1][j] separately