Summing all keys in the leaves of a tree
return sum(my_list)



You don't need to calculate the sum every time.  Do it just when count is 1:

if count == 1:
    return sum(my_list)


You have a recursive function, but your function doesn't care what itself returns.  All it cares about is the side-effect: mylist.append(K).  Just changing that (without any other changes) made the second example take less than a second.  It would be best to return my_list and let whatever is calling the function decide if it wants the sum.

In two places you say:


A, B, M, L1, L2, L3, D, R = list(map(int, inputs))



You don't need to convert to a list just to iterate.  That is what A, B, M, ... = ... does.  Just use A, B, M, ... = map(int, inputs).  That prevents the unnecessary storage of the numbers in memory.



Enough about efficiency.  Let's talk about other things.

Your naming is not ideal.  How does someone looking at your program know what A, B, M, etc. are?  They are just letters.  To tell you the truth, I have no idea what this program is doing.  If you had more descriptive names, it would be easier for future readers (possibly including you) to read the code.  PEP 8, the Python style guide, recommends snake_case for normal variables.

It is better not to use global variables.  I would suggest passing my_list as an argument to sum_keys() instead of relying on the existence of a global variable.