def smartSum ( x , key , value ) : if key not in list ( x . keys ( ) ) : x [ key ] = value else : x [ key ] += value
python does add and remove element to dictionary increase the cost
create a new page in x if key is not a page of x otherwise add value to x [ key ]
def smartSum(x,key,value):
    """ create a new page in x if key is not a page of x
        otherwise add value to x[key] """
    if key not in list(x.keys()):
        x[key] = value
    else:   x[key]+=value