Problem p02725 (python)

Fixed submission:
def main():
    input1 = input()
    input2 = input()
    k , n = map(int , input1.split())
    al = list(map(int , input2.split()))
    arg = [[k,n],al]
    ans = process(arg)
    print(ans)
    
def process(arg):
    ans = 0
    ensyu = arg[0][0]
    kensu = arg[0][1]
    aida = list()
    for x in range(arg[0][1]):
        mae = arg[1][x-1]
        b = arg[1][x]
        if x == 0:
            # 1件目は演習
            w = b + ensyu - arg[1][kensu-1]
        else:
            w = b - mae
        aida.append(w)

    m = max(aida)
    flg = False
    for y in aida:
        if flg == True or y != m :
            ans = ans + y
        else:
            flg = True
    return ans

def getInput(input):

    return 

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    # arg = getInput(1)
    arg = getInput(input())
    ans = process(arg)
    print(ans)
    
def process(arg):
    ans = 0
    ensyu = arg[0][0]
    kensu = arg[0][1]
    aida = list()
    for x in range(arg[0][1]):
        mae = arg[1][x-1]
        b = arg[1][x]
        if x == 0:
            w = b + arg[1][kensu-1]
        else:
            w = b - mae
        aida.append(w)

    m = max(aida)
    for y in aida:
        if y != m:
            ans = ans + y
    return ans

def getInput(input):
    k , n = map(int , input().split())
    al = list(map(int , input().split()))

    return [[k,n],al]

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    # arg = getInput(1)
    arg = getInput(input())
    ans = process(arg)
    print(ans)
    
def process(arg):
    ans = 0
    ensyu = arg[0][0]
    kensu = arg[0][1]
    aida = list()
    for x in range(arg[0][1]):
        mae = arg[1][x-1]
        b = arg[1][x]
        if x == 0:
            w = b + arg[1][kensu-1]
        else:
            w = b - mae
        aida.append(w)

    m = max(aida)
    for y in aida:
        if y != m:
            ans = ans + y
    return ans

def getInput(input):
    # 行数
    n = 2
    # 戻り値
    ret = None
    ret2 = None
    if n == 1:
        pass
        # ret = input
        # ret = list(input)
        # ret = int(input)
        # ret = input.split()
        # ret = list(map(int, input.split()))
        # ret = input.split('T')
    else:
        for x in range(n):
            # 取得したい形式に変換
            ret = list(map(int, input[x].split()))

    return ret

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    # arg = getInput(1)
    arg = getInput(input())
    ans = process(arg)
    print(ans)
    
def process(arg):
    ans = 0
    ensyu = arg[0][0]
    kensu = arg[0][1]
    aida = list()
    for x in range(arg[0][1]):
        mae = arg[1][x-1]
        b = arg[1][x]
        if x == 0:
            w = b + arg[1][kensu-1]
        else:
            w = b - mae
        aida.append(w)

    m = max(aida)
    for y in aida:
        if y != m:
            ans = ans + y
    return ans

def getInput(input):
    # 行数
    n = 2
    # 戻り値
    ret = None
    ret2 = None
    if n == 1:
        pass
        # ret = input
        # ret = list(input)
        # ret = int(input)
        # ret = input.split()
        # ret = list(map(int, input.split()))
        # ret = input.split('T')
    else:
        for x in range(n):
            # 取得したい形式に変換
            if x == 1:
                ret = list(map(int, input[x].split()))
                # ret = list(map(int, '20 3'.split()))
            else:
                ret2 = list(map(int, input[x].split()))
                # ret2 = list(map(int, '5 10 15'.split()))

    return [ret, ret2]

if __name__ == '__main__':
    main()