<garvit244>1005_1.py
def largestSumAfterKNegations( A, K):
    A.sort()
    index = 0
    while K > 0:
        if A[index] < 0:
            A[index] *= -1
            if A[index+1] < A[index] and index < len(A)-1:
                index += 1
        else:
            A[index] *= -1
        K -= 1
    return sum(A)
def sample_funcname ( var_0 , var_1 ) :
    var_0.sort ( )
    var_4 = 0
    while var_1 > 0 :
        if var_0 [ var_4 ] < 0 :
            var_0 [ var_4 ] *= - 1
            if var_0 [ var_4 + 1 ] < var_0 [ var_4 ] and var_4 < len ( var_0 ) - 1 :
                var_4 += 1
        else :
            var_0 [ var_4 ] *= - 1
        var_1 -= 1
    return sum ( var_0 )
