Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s = [ord(c) - 97 for c in input()]
t = [ord(c) - 97 for c in input()]
sl = len(s)
tl = len(t)
rr = [[0] * (tl) for _ in range(sl)]
t0 = t[0]

# init
for i in range(sl):
    if s[i] == t0:
        for k in range(i,sl):
            rr[k][0] = 1
        break

rr0 = rr[0]
s0 = s[0]
for j in range(tl):
    if s0 == t[j]:
        for k in range(j,tl):
            rr0[k] = 1
        break

# solve
ta = [(i,t[i]) for i in range(1, tl)]
for i in range(1, sl):
    rri = rr[i]
    rri1 = rr[i-1]
    si = s[i]
    for j, tj in ta:
        if si == tj:
            rri[j] = rri1[j-1] + 1
        else:
            rri[j] = rri1[j]
            if rri[j] < rri[j-1]:
                rri[j] = rri[j-1]

# restore
i = sl-1
j = tl-1
r = []
while i >= 0 and j >= 0:
    if s[i] == t[j]:
        r.append(s[i] + 97)
        i -= 1
        j -= 1
        continue
    if rr[i][j] == 0:
        break
    if i > 0 and rr[i-1][j] == rr[i][j]:
        i -= 1
    else:
        j -= 1

print(''.join(map(chr,r[::-1])))

"""
https://atcoder.jp/contests/dp/submissions/3972219
より。

愚直な実装で、エッジケース考え始めると大変そうだが…？
numpyと比べてオーバーヘッドが少なくs,tの小さいテストケースでは早い。
"""


Fixed submission:
import numpy as np

t = np.array(list(input()), dtype='U1')
s = np.array(list(input()), dtype='U1')

ls = len(s)
lt = len(t)

eq = s[:, None] == t[None, :]
dp = [np.zeros(lt+1, dtype=np.int16)]

# solve
for i in range(ls):
    prev = dp[-1].copy()
    np.maximum(prev[1:], prev[:-1] + eq[i], out = prev[1:])
    np.maximum.accumulate(prev, out = prev)
    dp.append(prev)

# print([list(line) for line in dp])

# restore
l = dp[-1][-1]
res = ''
i, j = ls, lt
while i > 0 and j > 0:
    if eq[i-1][j-1]:
        res += s[i-1]
        i, j = i-1, j-1
        continue
    
    if dp[i-1][j] > dp[i][j-1]:
        i -= 1
    else:
        j -= 1

print(res[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
p = list(map(float, input().split()))

head = [1] + [0]*(n)
for i in range(n):
  for j in range(i, -1, -1):
    head[j+1] += head[j] * (1 - p[i])
    head[j] = head[j] * p[i]

print(sum(head[:n//2+1]))


Fixed submission:
import numpy as np
n = int(input())
p = np.array(list(map(float, input().split())))

head = np.zeros(n+1)
head[0] = 1
for i in range(n):
  #print(head)
  mask = np.r_[np.ones(i+1), np.zeros(n-i)]
  h1 = head * (1 - p[i]) * mask
  h2 = head * p[i] * mask
  head = h1 + np.r_[np.zeros(1), h2[:-1]]

print(sum(head[n//2+1:]))
Buggy python submission (verdict: Time Limit Exceeded):
import math, string, fractions, heapq, re, array, bisect, sys, random, time, copy
import itertools as it
import collections as cl
import functools as ft
import numpy as np

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def count_lr(n, m, a):
    count = 0
    for l in range(n):
        for r in range(l, n):
            if not sum(a[l:r+1]) % m:
                count += 1
    return count


if __name__ == "__main__":
    n, m = LI()
    a = LI()

    print(count_lr(n, m, a))


Fixed submission:
import math, string, fractions, heapq, re, array, bisect, sys, random, time, copy
import itertools as it
import collections as cl
import functools as ft
import numpy as np

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def count_lr_old(n, m, a):
    count = 0
    for l in range(n):
        for r in range(l, n):
            if not sum(a[l:r+1]) % m:
                count += 1
    return count


def count_lr(n, m, a):
    b_acm = 0
    mod_m_counts = {}
    for ai in a:
        b_acm = (b_acm + ai) % m
        mod_m_counts.setdefault(b_acm, 0)
        mod_m_counts[b_acm] += 1

    # print(mod_m_counts)

    # print('len a:', len(a))
    count = 0
    all_ = 0
    for k, v in mod_m_counts.items():
        all_ += v
        count += v * (v - 1) // 2
        if k == 0:
            count += v

    # print('all_', all_)
    return count


if __name__ == "__main__":
    n, m = LI()
    a = LI()

    print(count_lr(n, m, a))
Buggy python submission (verdict: Runtime Error):
n, k = LI()
a = LI()
l = len(a[:a.index(1)]) + 1
r = len(a[a.index(1):])

if l == 1:
    left = 0
elif l < k:
    left = 1
else:
    left = math.ceil((l - k) / (k - 1)) + 1

if r == 1:
    right = 0
elif r < k:
    right = 1
else:
    right = math.ceil((r - k) / (k - 1)) + 1

print(left + right)

Fixed submission:
import math, sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]


n, k = LI()
a = LI()

result = math.ceil((n - k) / (k - 1)) + 1

print(result)

Buggy python submission (verdict: Runtime Error):
n, k = LI()
a = LI()
l = len(a[:a.index(1)])
r = len(a[a.index(1):])

if l == 0:
    left = 0
elif l < k:
    left = 1
else:
    left = math.ceil((l - k) / (k - 1)) + 1

if r == 0:
    right = 0
elif r < k:
    right = 1
else:
    right = math.ceil((r - k) / (k - 1)) + 1

print(left + right)

Fixed submission:
import math, sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]


n, k = LI()
a = LI()

result = math.ceil((n - k) / (k - 1)) + 1

print(result)

Buggy python submission (verdict: Runtime Error):
import math

def LI(): return [int(x) for x in sys.stdin.readline().split()]

n, k = LI()
a = LI()
l = len(a[:a.index(1)])
r = len(a[a.index(1):])

left = math.ceil((l - k) / (k - 1)) + 1
right = math.ceil((r - k) / (k - 1)) + 1

print(left + right)

Fixed submission:
import math, sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]


n, k = LI()
a = LI()

result = math.ceil((n - k) / (k - 1)) + 1

print(result)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

if __name__ == "__main__":
	n, w = map(int,input().split())
	v, w = [], []

	for i in range(n):
		w_, v_ = map(int,input().split())
		w.append(w_)
		v.append(v_)

	nap_memo = {}
	def nap(i,j):
		key = str(i)+':'+str(j)

		if key in nap_memo:
			return nap_memo[key]

		r = 0
		if i == n:
			r = 0
		elif j < w[i]:
			r = nap(i+1,j)
		else:
			r = max(nap(i+1, j),
					nap(i+1, j-w[i]) + v[i])

		nap_memo[key] = r
		return r

	print(nap(0,w))


Fixed submission:
# coding: utf-8

if __name__ == "__main__":
	n, w = map(int, input().split())
	vs, ws = [], []

	for i in range(n):
		w_, v_ = map(int, input().split())
		ws.append(w_)
		vs.append(v_)

	nap_memo = {}
	def nap(i, j):
		key = str(i)+':'+str(j)

		if key in nap_memo:
			return nap_memo[key]

		r = 0
		if i == n:
			r = 0
		elif j < ws[i]:
			r = nap(i+1, j)
		else:
			r = max(nap(i+1, j),
					nap(i+1, j-ws[i]) + vs[i])

		nap_memo[key] = r
		return r

	print(nap(0, w))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
import numpy as np


if __name__ == "__main__":
	n, w = map(int, input().split())
	ws, vs = [], []
	for _ in range(n):
		w_, v_ = map(int, input().split())
		ws.append(w_)
		vs.append(v_)

	def rec(i, j, memo = [[-1 for _ in range(w+1)] for _ in range(n+1)]):


		if memo[i][j] != -1:
			return memo[i][j]

		result = 0
		if i == n:
			result = 0

		elif j < ws[i]:
			result = rec(i+1, j)

		else:
			result = max(
				rec(i+1, j),
				rec(i+1, j-ws[i]) + vs[i]
				)

		memo[i][j] = result

		#print(np.array(memo))
		#print('--------------------------')

		return memo[i][j]

	print(rec(0, w))


Fixed submission:
# coding: utf-8

if __name__ == "__main__":
	n, w = map(int, input().split())
	vs, ws = [], []

	for i in range(n):
		w_, v_ = map(int, input().split())
		ws.append(w_)
		vs.append(v_)

	nap_memo = {}
	def nap(i, j):
		key = str(i)+':'+str(j)

		if key in nap_memo:
			return nap_memo[key]

		r = 0
		if i == n:
			r = 0
		elif j < ws[i]:
			r = nap(i+1, j)
		else:
			r = max(nap(i+1, j),
					nap(i+1, j-ws[i]) + vs[i])

		nap_memo[key] = r
		return r

	print(nap(0, w))
Buggy python submission (verdict: Runtime Error):
n = int(input())
import sys
sys.setrecursionlimit(100000)
def fa(n, memo=dict()):
	if n==0 or n == 1:
		return 1
	elif n in memo.keys():
		return memo[n]
	else:
		temp = fa(n-1)*n %int(10**9+7)
		memo[n] = temp
		return temp

print(fa(n))

Fixed submission:
import math
n = int(input())
print(math.factorial(n)%int(10**9+7))

Buggy python submission (verdict: Runtime Error):
n = int(input())
import sys
sys.setrecursionlimit(100000)
def fa(n, memo=dict()):
	if n==0 or n == 1:
		return 1
	elif n in memo.keys():
		return memo[n]
	else:
		temp = fa(n-1)*n
		memo[n] = temp
		return temp

print(fa(n))

Fixed submission:
import math
n = int(input())
print(math.factorial(n)%int(10**9+7))

Buggy python submission (verdict: Runtime Error):
def f(n, memo = dict()):
	if n == 0 or n == 1:
		return 1
	elif n in memo.keys():
		return memo[n]
	else:
		temp = (f(n-1) * n) % int(10e9+7)
		memo[n] = temp
		return temp

n = int(input())
print(f(n))

Fixed submission:
import math
n = int(input())
print(math.factorial(n)%int(10**9+7))
Buggy python submission (verdict: Runtime Error):


# if a > b return true
def compare(a, b): # a also b are both string
	l = max(len(a), len(b))
	a_ = a.rjust(l, '0')
	b_ = b.rjust(l, '0')
	return a_ > b_


def divide(num, den): # den is integer
	quo = ''; resi = 0
	digit = len(num) if int(num[0]) >= den else len(num)-1
	for i in range(len(num)):
		temp = (int(num[i])+resi*10)//den
#		print('temp', temp)
		resi = (int(num[i])+resi*10)%den
#		print('resi', resi)
		quo += str(temp) if temp != 0 else ''
	return quo.ljust(digit, '0')

def multi(a, n):
	s = ''; resi = 0
	for i in range(len(a))[::-1]:
		temp = (int(a[i])*n + resi)%10
#		print('temp', temp)
		resi = (int(a[i])*n + resi)//10
#		print('resi', resi)
		s = str(temp) + s
	return s


def plus(a, b):
	l = max(len(a), len(b))
	a_ = a.rjust(l, '0')
	b_ = b.rjust(l, '0')

	s = ''; resi = 0
	for i in range(l)[::-1]:
		temp = (int(a_[i]) + int(b_[i]) + resi)%10
#		print('temp', temp)
		resi = (int(a_[i]) + int(b_[i]) + resi)//10
#		print('resi', resi)
		s = str(temp) + s
	return s

# a is higher than b
def minus(a, b):
	l = max(len(a), len(b))
	a_ = a.rjust(l, '0')
	b_ = b.rjust(l, '0')

	s = ''; bollow = 0
	for i in range(l)[::-1]:
		temp = int(a_[i]) - int(b_[i]) - bollow
#		print('temp', temp)
		bollow = 0
		if temp >= 0:
			s = str(temp) + s
		else:
			bollow = 1
			s = str(temp + 10) + s
	return s

if compare(s, divide(c, 2)) or s == c:
	print(divide(c, 2))
else:
	print(plus(s, divide(minus(c, multi(s, 2)), 4)))



Fixed submission:
s, c = input().split()
s = int(s); c = int(c)
if s >= c//2:
	print(c//2)
else:
	print(s+(c-s*2)//4)

Buggy python submission (verdict: Runtime Error):
s, c = map(int, ip().split())
if s >= c//2:
	print(c//2)
else:
	print(s + (c-s*2)//4)

Fixed submission:
s, c = input().split()
s = int(s); c = int(c)
if s >= c//2:
	print(c//2)
else:
	print(s+(c-s*2)//4)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a, b = [], []
for i in range(n):
	a[i], b[i] = map(int, input().split())

ans = 0
for i in range(n)[::-1]:
	a_, b_ = a[i] + ans, b[i]
	if a_%b_ != 0:
		ans += ((a_ // b_ + 1) * b_ - a_)

print(ans)


Fixed submission:
n = int(input())
ab = []
for i in range(n):
	a, b = map(int, input().split())
	ab.append((a, b))

ans = 0
for i in range(n)[::-1]:
	a, b = ab[i][0]+ans, ab[i][1]
	if a%b != 0:
		ans += ((a//b + 1)*b - a)

print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a, b = [], []
for i in range(n):
	a[i], b[i] = map(int, input().split())

ans = 0
for i in range(n)[::-1]:
	a_, b_ = a[i] + ans, b[i]
	if a_%b_ != 0:
		ans += ((a_ // b_ + 1) * b_ - a_)

print(p)


Fixed submission:
n = int(input())
ab = []
for i in range(n):
	a, b = map(int, input().split())
	ab.append((a, b))

ans = 0
for i in range(n)[::-1]:
	a, b = ab[i][0]+ans, ab[i][1]
	if a%b != 0:
		ans += ((a//b + 1)*b - a)

print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a, b = [0]*n, [0]*n
for i in range(n):
	a[i], b[i] = map(int, input().split())

ans = 0
for i in range(n)[::-1]:
	a_, b_ = a[i] + p, b[i]
	if a_%b_ != 0:
		ans += (a_ // b_ + 1) * b_ - a_

print(p)


Fixed submission:
n = int(input())
ab = []
for i in range(n):
	a, b = map(int, input().split())
	ab.append((a, b))

ans = 0
for i in range(n)[::-1]:
	a, b = ab[i][0]+ans, ab[i][1]
	if a%b != 0:
		ans += ((a//b + 1)*b - a)

print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a, b = [0]*n, [0]*n
for i in range(n):
	a[i], b[i] = map(int, input().split())

ans = 0
for i in range(n)[::-1]:
	a_, b_ = a[i] + p, b[i]
	if a%b != 0:
		ans += (a_ // b_ + 1) * b_ - a_

print(p)

Fixed submission:
n = int(input())
ab = []
for i in range(n):
	a, b = map(int, input().split())
	ab.append((a, b))

ans = 0
for i in range(n)[::-1]:
	a, b = ab[i][0]+ans, ab[i][1]
	if a%b != 0:
		ans += ((a//b + 1)*b - a)

print(ans)
Buggy python submission (verdict: Runtime Error):
n = input()
print((n+1)/2)

Fixed submission:
print((int(input())+1)//2)
Buggy python submission (verdict: Runtime Error):
a=input()
print(input()+a)

Fixed submission:
s = input().split()
print(s[1]+s[0])
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

n,m = map(int, input.split())

if n == m:
    print('Yes')
else:
    print('No')

Fixed submission:
# coding: utf-8
# Your code here!

n,m = map(int, input().split())

if n == m:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import math

a,b = sorted(map(int, input().split()))

gcd = math.gcd(a,b)

print(a//gcd * b)

Fixed submission:
# coding: utf-8
a,b = map(int, input().split())

def lcm(x, y):
    return (x * y) // gcd(x, y)

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

print(lcm(a, b))

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import math

a,b = map(int, input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))



Fixed submission:
# coding: utf-8
a,b = map(int, input().split())

def lcm(x, y):
    return (x * y) // gcd(x, y)

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

print(lcm(a, b))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
c = 1
for i in range((n%2)+2,n+1,2):
    c *= i
    S = str(c)
    j = 0
    for s in S[::-1]:
        if s == '0':
            ans += 1
            j += 1
        else:
            break
    if j:
        c = int(S[0:-j])
    else:
        c = int(S)
print(ans)

Fixed submission:
n = int(input())
if n%2 == 1:
    print(0)
else:
    ans = 0
    i = 10
    while i <= n:
        ans += n//i
        i *= 5
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
print(sum(range(n)))

Fixed submission:
n = int(input())
print((n)*(n-1)//2)

Buggy python submission (verdict: Runtime Error):
n = int(input())+1
l1 = range(1,n+1)
l2 = list(l1[1:n-1])
l2.append(1)
total = 0
for a,b in zip(l1,l2):
    total += a%b
print(total)

Fixed submission:
n = int(input())
print((n)*(n-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
 
N = int(input())
data = [''.join(sorted(input().rstrip())) for n in range(N)]
count = 0
while data:
    number = data.count(data[0])
    if number > 1:
        count += number - 1
    del data[0]
    
print(count)

Fixed submission:
import sys
input = sys.stdin.readline
 
N = int(input())
words = {}
while N > 0:
    word = ''.join(sorted(input().rstrip()))
    if word in words:
        words[word] += 1
    else:
        words[word] = 1
    N -= 1

count = 0
for n in words.values():
    if n > 1:
        count += n*(n-1) // 2

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
 
N = int(input())
data = sorted([''.join(sorted(input().rstrip())) for n in range(N)])
count = 0
while data:
    number = data.count(data[0])
    if number > 1:
        count += number - 1
    del data[0]
    
print(count)

Fixed submission:
import sys
input = sys.stdin.readline
 
N = int(input())
words = {}
while N > 0:
    word = ''.join(sorted(input().rstrip()))
    if word in words:
        words[word] += 1
    else:
        words[word] = 1
    N -= 1

count = 0
for n in words.values():
    if n > 1:
        count += n*(n-1) // 2

print(count)
Buggy python submission (verdict: Runtime Error):
def solve():
    a,b,c = map(int, input().split())
   return c-(a-b)

if __name__ == '__main__':
    print(solve())

Fixed submission:
def solve():
    a,b,c = map(int, input().split())
    return max(c-(a-b),0)

if __name__ == '__main__':
    print(solve())
Buggy python submission (verdict: Runtime Error):
N = int(input())
ps = list(map(int, input().split()))
 
count = 0
 
for p,n in zip(ps,range(N)):
    if p != n:
        count += 1
if count == 2:
    print('YES')
else:
    print('NO')

Fixed submission:
a,b = map(int, input().split())

if (a+b) % 2 != 0:
    print('IMPOSSIBLE')
else:
    print((a+b)//2)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n = int(input())
numbers = [int(input()) for i in range(n)]

for i in range(n):
    temporary_list = list(numbers)
    temporary_list.pop(i)
    print(max(temporary_list))

Fixed submission:
import sys
input = sys.stdin.readline
 
n = int(input())
data = [int(input()) for k in range(n)]
m1,m2 = sorted(data, reverse=1)[:2]
b = [m2 if x==m1 else m1 for x in data]
print('\n'.join(map(str,b)))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
numbers = [int(input()) for i in range(n)]

for i in range(n):
    temporary_list = list(numbers)
    temporary_list.pop(i)
    print(max(temporary_list))

Fixed submission:
import sys
input = sys.stdin.readline
 
n = int(input())
data = [int(input()) for k in range(n)]
m1,m2 = sorted(data, reverse=1)[:2]
b = [m2 if x==m1 else m1 for x in data]
print('\n'.join(map(str,b)))
Buggy python submission (verdict: Runtime Error):
import sys

def solve():
    n,d = map(int, input().split())
    l = [[int(x) for x in sys.stdin.readlines()] for _ in range(n)]
    count = 0
    for i in range(n):
        Y = l[i]
        for Z in l[i+1:]:
            total = 0
            for y,z in zip(Y,Z):
                total += (y-z)**2
            d = total**0.5
            if d == int(d):
                count += 1
    return count

if __name__ == '__main__':
    print(solve())

Fixed submission:
def solve():
    n,d = map(int, input().split())
    L = [[int(x) for x in input().split()] for _ in range(n)]
    count = 0
    for i in range(n):
        y = L[i]
        for z in L[i+1:]:
            total = 0
            for a,b in zip(y,z):
                total += (a-b)**2
            if total**0.5 == int(total**0.5):
                count += 1
    return count
    
if __name__ == '__main__':
    print(solve())
Buggy python submission (verdict: Runtime Error):
def solve():
    x = int(input())
    l = [i**j for i in range(1,x+1) for j in range(1,x+1) if i**j<=x]
    return max(l)
        
if __name__ == '__main__':
    print(solve())

Fixed submission:
def solve():
    l,r = map(int, input().split())
    if r-l<2019:
        arr = [i*j%2019 for i in range(l,r) for j in range(i+1,r+1)]
        return min(arr)
    else:
        return 0


if __name__ == '__main__':
    print(solve())
Buggy python submission (verdict: Runtime Error):
def solve():
    N,M = map(int, input().split())
    
    l = [-1]*(N+1)
    for m in range(M):
        a = int(input())
        l[a] = 0
    if l[1] == 0 and l[2] == 0:
        return 0
    elif l[1] == 0 and l[2] != 0:
        l[2] = 1
    elif l[1] != 0 and l[2] == 0:
        l[1] = 1
    else:
        l[1] = 1
        l[2] = 2
    
    if N == 1:
        return 1
    if N == 2:
        return 2
    
    l.pop(0)
    for i in range(2,N):
        if l[i] == 0:
            continue
        else:
            l[i] = l[i-1] + l[i-2]
    
    return l[-1]%1000000007


if __name__ == '__main__':
    print(solve())

Fixed submission:
def solve():
    N,M = map(int, input().split())
    if N == 1 and M == 0:
        return 1
    elif N == 1 and M == 1:
        return 0
    elif N == 2 and M == 0:
        return 2
    elif N == 2 and M == 1:
        return 1
    elif N == 2 and M == 2:
        return 0
    
    l = [-1]*(N+1)
    for m in range(M):
        a = int(input())
        l[a] = 0
    if l[1] == 0 and l[2] == 0:
        return 0
    elif l[1] == 0 and l[2] != 0:
        l[2] = 1
    elif l[1] != 0 and l[2] == 0:
        l[1] = 1
    else:
        l[1] = 1
        l[2] = 2
    
    l.pop(0)
    for i in range(2,N):
        if l[i] == 0:
            continue
        else:
            l[i] = l[i-1] + l[i-2]
    
    return l[-1]%1000000007


if __name__ == '__main__':
    print(solve())

Buggy python submission (verdict: Runtime Error):
import sys

def solve():
    N,M = map(int, input().split())
    
    l = [-1]*(N+1)
    for m in range(M):
        a = int(input())
        l[a] = 0
    if l[1] == 0 and l[2] == 0:
        return 0
    elif l[1] == 0 and l[2] != 0:
        l[2] = 1
    elif l[1] != 0 and l[2] == 0:
        l[1] = 1
    else:
        l[1] = 1
        l[2] = 2
    
    if N == 1:
        return 1
    if N == 2:
        return 2
    
    l.pop(0)
    for i in range(2,N):
        if l[i] == 0:
            continue
        else:
            l[i] = l[i-1] + l[i-2]
    
    return l[-1]%1000000007


if __name__ == '__main__':
    print(solve())

Fixed submission:
def solve():
    N,M = map(int, input().split())
    if N == 1 and M == 0:
        return 1
    elif N == 1 and M == 1:
        return 0
    elif N == 2 and M == 0:
        return 2
    elif N == 2 and M == 1:
        return 1
    elif N == 2 and M == 2:
        return 0
    
    l = [-1]*(N+1)
    for m in range(M):
        a = int(input())
        l[a] = 0
    if l[1] == 0 and l[2] == 0:
        return 0
    elif l[1] == 0 and l[2] != 0:
        l[2] = 1
    elif l[1] != 0 and l[2] == 0:
        l[1] = 1
    else:
        l[1] = 1
        l[2] = 2
    
    l.pop(0)
    for i in range(2,N):
        if l[i] == 0:
            continue
        else:
            l[i] = l[i-1] + l[i-2]
    
    return l[-1]%1000000007


if __name__ == '__main__':
    print(solve())
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N,M = map(int, input().split())
cards = [1] * N
for _ in range(M):
    l,r = map(int, input().split())
    for i in range(l-1):
        cards[i] = 0
    for i in range(r,N):
        cards[i] = 0
print(sum(cards))

Fixed submission:
N,M = map(int, input().split())
l = 0
r = N
for m in range(M):
    L,R = map(int, input().split())
    if L > l:
        l = L
    if R < r:
        r = R
print(max(r-l+1,0))