Buggy python submission (verdict: Runtime Error):

import sys


def max_sum_seq(lis):
    r = []
    l = len(lis)
    for n in range(1, l+1):
        r = r + every_slice(lis, n)
    return max(map((lambda r1: reduce((lambda x, y: x + y), r1, 0)), r))

def every_slice(lis, n):
    r = []
    l = len(lis)
    for i in range(l-n+1):
        r.append(lis[i:i+n])
    return r


#input_file = open(sys.argv[1], "r")

while True:
#    n = int(input_file.readline())
    n = int(sys.stdin.readline())
    if n == 0:
        break
    lis = []
    for i in range(n):
        lis.append(int(input_file.readline()))
    print max_sum_seq(lis)

Fixed submission:

import sys


def max_sum_seq(lis):
    m = 0
    lis = compress(lis)
    l = len(lis)

    max_val = lis[0]
    for i in xrange(0, l):
        for j in xrange(i, l):
            if j == i:
                tmp_val = lis[j]
            else:
                tmp_val = tmp_val + lis[j]
            max_val = max(max_val, tmp_val)
    return max_val

def compress(tmp_lst):
    lim = len(tmp_lst)
    lst = []
    index = 0
    while index < lim:
        tmp = tmp_lst[index]
        index += 1
        while tmp > 0 and index < lim and tmp * tmp_lst[index] > 0:
            tmp += tmp_lst[index]
            index += 1
        lst.append(tmp)
    return lst


while True:
    n = int(sys.stdin.readline())
    if n == 0:
        break
    lis = []
    for i in range(n):
        lis.append(int(sys.stdin.readline()))
    print max_sum_seq(lis)

Buggy python submission (verdict: Time Limit Exceeded):

import sys


def max_sum_seq(lis):
#    r = []
    m = 0
    l = len(lis)
    for n in range(1, l+1):
        for s in every_slice(lis, n):
            sm = sum(s)
            if sm > m:
                m = sm
    return m
#        r = r + every_slice(lis, n)
#    return max(map((lambda r1: reduce((lambda x, y: x + y), r1, 0)), r))

def every_slice(lis, n):
#    r = []
    l = len(lis)
    for i in range(l-n+1):
        yield lis[i:i+n]
#    return r


#input_file = open(sys.argv[1], "r")

while True:
    n = int(sys.stdin.readline())
    if n == 0:
        break
    lis = []
    for i in range(n):
        lis.append(int(sys.stdin.readline()))
    print max_sum_seq(lis)

Fixed submission:

import sys


def max_sum_seq(lis):
    m = 0
    lis = compress(lis)
    l = len(lis)

    max_val = lis[0]
    for i in xrange(0, l):
        for j in xrange(i, l):
            if j == i:
                tmp_val = lis[j]
            else:
                tmp_val = tmp_val + lis[j]
            max_val = max(max_val, tmp_val)
    return max_val

def compress(tmp_lst):
    lim = len(tmp_lst)
    lst = []
    index = 0
    while index < lim:
        tmp = tmp_lst[index]
        index += 1
        while tmp > 0 and index < lim and tmp * tmp_lst[index] > 0:
            tmp += tmp_lst[index]
            index += 1
        lst.append(tmp)
    return lst


while True:
    n = int(sys.stdin.readline())
    if n == 0:
        break
    lis = []
    for i in range(n):
        lis.append(int(sys.stdin.readline()))
    print max_sum_seq(lis)

Buggy python submission (verdict: Time Limit Exceeded):

import sys


def max_sum_seq(lis):
    m = 0
    l = len(lis)
    for n in range(1, l+1):
        for s in every_slice(lis, n):
            sm = sum(s)
            if sm > m:
                m = sm
    return m

def every_slice(lis, n):
    l = len(lis)
    for i in range(l-n+1):
        yield lis[i:i+n]


while True:
    n = int(sys.stdin.readline())
    if n == 0:
        break
    lis = []
    for i in range(n):
        lis.append(int(sys.stdin.readline()))
    print max_sum_seq(lis)

Fixed submission:

import sys


def max_sum_seq(lis):
    m = 0
    lis = compress(lis)
    l = len(lis)

    max_val = lis[0]
    for i in xrange(0, l):
        for j in xrange(i, l):
            if j == i:
                tmp_val = lis[j]
            else:
                tmp_val = tmp_val + lis[j]
            max_val = max(max_val, tmp_val)
    return max_val

def compress(tmp_lst):
    lim = len(tmp_lst)
    lst = []
    index = 0
    while index < lim:
        tmp = tmp_lst[index]
        index += 1
        while tmp > 0 and index < lim and tmp * tmp_lst[index] > 0:
            tmp += tmp_lst[index]
            index += 1
        lst.append(tmp)
    return lst


while True:
    n = int(sys.stdin.readline())
    if n == 0:
        break
    lis = []
    for i in range(n):
        lis.append(int(sys.stdin.readline()))
    print max_sum_seq(lis)

Buggy python submission (verdict: Time Limit Exceeded):

import sys


def max_sum_seq(lis):
    m = 0
    lis = compress(lis)
    l = len(lis)
    for n in range(1, l+1):
        for s in every_slice(lis, n):
            sm = sum(s)
            if sm > m:
                m = sm
    return m

def every_slice(lis, n):
    l = len(lis)
    for i in range(l-n+1):
        yield lis[i:i+n]

def compress(tmp_lst):
    lim = len(tmp_lst)
    lst = []
    index = 0
    while index < lim:
        tmp = tmp_lst[index]
        index += 1
        while tmp > 0 and index < lim and tmp * tmp_lst[index] > 0:
            tmp += tmp_lst[index]
            index += 1
        lst.append(tmp)
    return lst


while True:
    n = int(sys.stdin.readline())
    if n == 0:
        break
    lis = []
    for i in range(n):
        lis.append(int(sys.stdin.readline()))
    print max_sum_seq(lis)

Fixed submission:

import sys


def max_sum_seq(lis):
    m = 0
    lis = compress(lis)
    l = len(lis)

    max_val = lis[0]
    for i in xrange(0, l):
        for j in xrange(i, l):
            if j == i:
                tmp_val = lis[j]
            else:
                tmp_val = tmp_val + lis[j]
            max_val = max(max_val, tmp_val)
    return max_val

def compress(tmp_lst):
    lim = len(tmp_lst)
    lst = []
    index = 0
    while index < lim:
        tmp = tmp_lst[index]
        index += 1
        while tmp > 0 and index < lim and tmp * tmp_lst[index] > 0:
            tmp += tmp_lst[index]
            index += 1
        lst.append(tmp)
    return lst


while True:
    n = int(sys.stdin.readline())
    if n == 0:
        break
    lis = []
    for i in range(n):
        lis.append(int(sys.stdin.readline()))
    print max_sum_seq(lis)