Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
txy = [list(map(int, input().split())) for _ in range(N)]

result = True

for pol in txy:
    
    if(abs(pol[1]) + abs(pol[2]) not in list(range(pol[0], -1, -2))):
        result = False

print(("No", "Yes")[result])

Fixed submission:
N = int(input())
txy = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
result = True

for i in range(N):
    dt = txy[i + 1][0] - txy[i][0]
    dist = abs(txy[i + 1][1] - txy[i][1]) + abs(txy[i + 1][2] - txy[i][2])
    
    if(dist > dt): result = False
    if(dist % 2 != dt % 2): result = False

print(("No", "Yes")[result])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
txy = [list(map(int, input().split())) for _ in range(N)]

result = True

for pol in txy:
    
    if(abs(pol[1]) + abs(pol[2]) not in list(range(pol[0], -1, -2))):
        result = False

print(("No", "Yes")[result])

Fixed submission:
N = int(input())
txy = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
result = True

for i in range(N):
    dt = txy[i + 1][0] - txy[i][0]
    dist = abs(txy[i + 1][1] - txy[i][1]) + abs(txy[i + 1][2] - txy[i][2])
    
    if(dist > dt): result = False
    if(dist % 2 != dt % 2): result = False

print(("No", "Yes")[result])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
result = True

for _ in range(N):
    a = list(map(int, input().split()))
    
    if(abs(a[1]) + abs(a[2]) not in list(range(a[0] + 1))[a[0] % 2 == 1: : 2]):
        result = False
    
print(('No', 'Yes')[result])

Fixed submission:
N = int(input())
txy = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
result = True

for i in range(N):
    dt = txy[i + 1][0] - txy[i][0]
    dist = abs(txy[i + 1][1] - txy[i][1]) + abs(txy[i + 1][2] - txy[i][2])
    
    if(dist > dt): result = False
    if(dist % 2 != dt % 2): result = False

print(("No", "Yes")[result])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
result = True

for a in A:
    
    if(a[0] % 2 == 0):
        
        if(abs(a[1]) + abs(a[2]) in list(range(a[0] + 1))[0: : 2]):
            result = result and True
        
        else:
            result = False
    
    else:
        if(abs(a[1]) + abs(a[2]) in list(range(a[0] + 1))[1: : 2]):
            result = result and True
        
        else:
            result = False

print(('No', 'Yes')[result])

Fixed submission:
N = int(input())
txy = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
result = True

for i in range(N):
    dt = txy[i + 1][0] - txy[i][0]
    dist = abs(txy[i + 1][1] - txy[i][1]) + abs(txy[i + 1][2] - txy[i][2])
    
    if(dist > dt): result = False
    if(dist % 2 != dt % 2): result = False

print(("No", "Yes")[result])
Buggy python submission (verdict: Runtime Error):
n, y = map(int, input().split())

for a in range(n+1):
    for b in range(n-a+1):
        c = n-a-b
            
        if(and 10000*a + 5000*b + 1000*c == y):
            print(a, b, c)
            quit()

print("-1 -1 -1")

Fixed submission:
N, Y = map(int, input().split())
break_flag = False

for i in range(N + 1):
    
    for j in range(i, N + 1):
        a, b, c = i, j - i, N - j
        
        if(10000 * a + 5000 * b + 1000 * c == Y):
            print(a, b, c)
            
            break_flag = True
            break
    
    if break_flag: break

if not break_flag: print('-1 -1 -1')

Buggy python submission (verdict: Runtime Error):
n, y = map(int, input().split())

for a in range(n+1):
    for b in range(n+1):
        for c in range(n+1):
            
            if(a+b+c==n and 1000*a + 5000*b + 10000*c == 45000):
                result = str(c) + " " + str(b) + " " + str(a)

print(result)

Fixed submission:
N, Y = map(int, input().split())
break_flag = False

for i in range(N + 1):
    
    for j in range(i, N + 1):
        a, b, c = i, j - i, N - j
        
        if(10000 * a + 5000 * b + 1000 * c == Y):
            print(a, b, c)
            
            break_flag = True
            break
    
    if break_flag: break

if not break_flag: print('-1 -1 -1')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
cnt = 0

while(True):
    
    if all(a % 2 == 0 for a in A):
        A = list(map(lambda x: x / 2, A))
        cnt += 1
    
    else: break

print(cnt)

Fixed submission:
print(input().count('1'))

Buggy python submission (verdict: Runtime Error):
cnt = 0

while(True):
    
    if all(a % 2 == 0 for a in A):
        A = list(map(lambda x: x / 2, A))
        cnt += 1
    
    else: break

print(cnt)

Fixed submission:
print(input().count('1'))
Buggy python submission (verdict: Runtime Error):
cnt = 0

while(True):
    
    if all(a % 2 == 0 for a in A):
        A = list(map(lambda x: x / 2, A))
        cnt += 1
    
    else: break

print(cnt)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
cnt = 0

while(True):
    
    if all(a % 2 == 0 for a in A):
        A = list(map(lambda x: x / 2, A))
        cnt += 1
    
    else: break

print(cnt)
Buggy python submission (verdict: Runtime Error):
A, B, C, D = input()
for p in itertools.product(['+', '-'], repeat = 3):
    equ = A + p[0] + B + p[1] + C + p[2] + D
    
    if(eval(equ) == 7):
        print(equ + '=7')
        break

Fixed submission:
import itertools

A, B, C, D = input()
for p in itertools.product(['+', '-'], repeat = 3):
    equ = A + p[0] + B + p[1] + C + p[2] + D
    
    if(eval(equ) == 7):
        print(equ + '=7')
        break
Buggy python submission (verdict: Runtime Error):
n = int(input())

odd = 0
two = 0
four = 0

for i in range(n):
    a = int(input())
    if(a%2): odd += 1
    else:
        if(a%4==0):four+=1
        else: two += 1


if(two):
    if(odd<=four): print("Yes")
    else: print("No")

else:
    if(odd-1<=four): print("Yes")
    else: print("No")

Fixed submission:
n = int(input())
A = list(map(int, input().split()))

odd = 0
two = 0
four = 0

for a in A:
    if(a%2): odd += 1
    else:
        if(a%4==0):four+=1
        else: two += 1


if(two):
    if(odd<=four): print("Yes")
    else: print("No")

else:
    if(odd-1<=four): print("Yes")
    else: print("No")
Buggy python submission (verdict: Runtime Error):
S = input()
ans = 0
for p in itertools.product(['', '+'], repeat = len(S) - 1):
    cmd = ''.join([s + t for s, t in zip(S, p)]) + S[-1]
    ans += eval(cmd)
print(ans)

Fixed submission:
import itertools
S = input()
ans = 0
for p in itertools.product(['', '+'], repeat = len(S) - 1):
    cmd = ''.join([s + t for s, t in zip(S, p)]) + S[-1]
    ans += eval(cmd)
print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
d = list(map(int, input().split()))

def is_ok(num):
  s = str(num)
  for ng in d:
    if ng in s: return False
  
  return True

while True:
  if is_ok(n):
    print(n)
    exit()
  
  n += 1
  

Fixed submission:
n, k = map(int, input().split())
d = input().split()

def is_ok(num):
  s = str(num)
  for ng in d:
    if ng in s: return False
  
  return True

while True:
  if is_ok(n):
    print(n)
    exit()
  
  n += 1
Buggy python submission (verdict: Runtime Error):
def Gcd(a,b):
	if a<b:
		return Gcd(b,a)
	else:
		if a%b:
			return Gcd(b, a%b):
		else:
			return b
N = int(input())
arr = list(map(int,input().split()))
gcd = arr[0]
for i in arr:
	gcd = Gcd(gcd, i)
print(gcd)

Fixed submission:
def gcd(a, b):
    if a%b ==0:
        return b
    else:
        return gcd(b, a%b)

n = int(input())
a = list(map(int, input().split()))
a.sort()
for i in range(n-1):
    a[i+1]  = gcd(a[i], a[i+1])
print(a[n-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
j = 0
A.sort()
for n in A:
	if n%2 == 1:
		j = 1
a = 0
for n in range(1, len(A)-1):
	if A[n] % A[0] == 1
		a = 1
if a == 0:
	j = 3
if A[0] == A[-1]:
	j = 2
if j == 0:
	print(2)
elif j == 1:
	print(1)
elif j == 3:
	print(A[0])
else:
	print(A[0])

Fixed submission:
def gcd(a, b):
    if a%b ==0:
        return b
    else:
        return gcd(b, a%b)

n = int(input())
a = list(map(int, input().split()))
a.sort()
for i in range(n-1):
    a[i+1]  = gcd(a[i], a[i+1])
print(a[n-1])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
X = list(map(int, input().split()))
x = sorted(X)
B = []
for i in range(0, M-1):
	B.append(x[i+1]-x[i])
B.sort(reverse=True)
for l in range(N-1):
	B.pop(0)
print(sum(B))

Fixed submission:
N, M = map(int, input().split())
X = list(map(int, input().split()))
if N < M:
	x = sorted(X)
	B = []
	for i in range(0, M-1):
		B.append(x[i+1]-x[i])
	B.sort(reverse=True)
	for l in range(N-1):
		B.pop(0)
	print(sum(B))
else:
	print(0)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
count = 0
for i in range(K+1):
	for l in range(K+1):
		for m in range(K+1):
			if i + l + m == S:
				count = count + 1
print(count)

Fixed submission:
K, S = map(int, input().split())
count = 0
for i in range(K+1):
	for l in range(K+1):
		if S - i - l <= K and S - i - l >=0: 
			count = count + 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    k = i_input()

    if k % 2 == 0:
        print(-1)
        exit()

    if k == 999983:
        print(999982)
        exit()

    tmp = 7
    count = 1        

    while count < 10 ** 6:
        if int(tmp) % k == 0:
            print(count)
            exit()
        count += 1
        tmp = tmp * 10  + 7

    print(-1)

if __name__ == '__main__':
    main()


Fixed submission:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    k = i_input()

    if k % 2 == 0:
        print(-1)
        exit()

    tmp = 7
    count = 1        

    while count < 10 ** 6:
        tmp %= k
        if tmp == 0:
            print(count)
            exit()
        count += 1
        tmp = tmp * 10  + 7

    print(-1)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n, k = i_map()
    num_list = i_list()

    ans_list = []
    tmp = 1
    after_score = num_list[0]
    for i in range(k):
        tmp *= num_list[i]

    ans_list.append(tmp)

    for i in range(n-k):
        ima = tmp / after_score
        ima *= num_list[i+k]
        after_score = num_list[i+1]
        
        if ima > tmp:
            print('Yes')
        else:
            print('No')
        tmp = ima



if __name__ == '__main__':
    main()


Fixed submission:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n, k = i_map()
    num_list = i_list()

    for i in range(n-k):
        if num_list[i] < num_list[i+k]:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    num_list = i_list()

    sum_d = num_list[0] ^ num_list[1] ^ num_list[2] ^ num_list[3]

    ans_list = []
    for num in num_list:
        ans_list.append(sum_d ^ num)

    print(*ans_list)

if __name__ == '__main__':
    main()


Fixed submission:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    num_list = i_list()

    sum_d = 0
    for num in num_list:
        sum_d ^= num

    ans_list = []
    for num in num_list:
        ans_list.append(sum_d ^ num)

    print(*ans_list)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    x, n = i_map()
    if n == 0:
        print(x)
        exit()
    num_list = i_list()

    num_list.sort()

    abs_num = INF
    ans_list = []

    for i in range(1,101):
        if i in num_list:
            continue
        if abs_num > abs(i-x):
            ans_list = []
            abs_num = abs(i-x)
            ans_list.append(i)
        elif abs_num == abs(i-x):
            ans_list.append(i)

    ans_list.sort()

    print(ans_list[0])

if __name__ == '__main__':
    main()


Fixed submission:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    x, n = i_map()
    if n == 0:
        print(x)
        exit()
    num_list = i_list()

    abs_num = INF
    ans_list = []

    for i in range(0,102):
        if i in num_list:
            continue
        if abs_num > abs(i-x):
            ans_list = []
            abs_num = abs(i-x)
            ans_list.append(i)
        elif abs_num == abs(i-x):
            ans_list.append(i)

    ans_list.sort()

    print(ans_list[0])

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    n = i_input()
    num_list = i_list()

    ans = 1

    for num in num_list:
        ans *= num

    if ans > 10**18:
        print(-1)
    else:
        print(ans)
            
if __name__ == '__main__':
    main()


Fixed submission:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    n = i_input()
    num_list = i_list()

    zero_c = num_list.count(0)

    if zero_c >= 1:
        print(0)
        exit()

    ans = 1

    max_num = 10**18

    for num in num_list:
        ans *= num
        if ans > max_num:
            print(-1)
            exit()

    print(ans)
            
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = input()

    len_s = len(s)

    if len_s <=3:
        print(0)
        exit()
    
    count = 0

    for i in range(0,len_s-3):
        for j in range(i+3,len_s):
            if int(s[i:j+1]) % 2019 == 0:
                count += 1
                break

    print(count)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    S = input()[::-1]

    count = 0

    mods = [0] * 2019
    mods[0] = 1
    current = 0
    x = 1
    for s in S:
        current = (current + x * int(s)) % 2019
        count += mods[current % 2019]
        mods[current % 2019] += 1
        x = x * 10 % 2019

    print(count)

if __name__ == '__main__':
    main()