Buggy python submission (verdict: Time Limit Exceeded):
import sys
 
n=0
m=0
id_list=[]

n, m  = map(int, input().split())
for i in range(0, m):
  gate_min, gate_max = map(int, input().split())
  id_list.append([gate_min, gate_max])
 

result = 0
for i in range(1, n+1):
  is_passed = True
  for gate in id_list:
    if not((i >= gate[0]) and (i <= gate[1])) :
      is_passed = False
      break

  if is_passed:
    result = result + 1	
print(result)
sys.exit(0)

Fixed submission:
import sys
n=0
m=0

n, m  = map(int, input().split())
_min, _max  = map(int, input().split())
for i in range(1, m):
  gate_min, gate_max = map(int, input().split())
  if (_max > gate_max):
    _max = gate_max
   
  if _min < gate_min:
    _min = gate_min
 
result_list = list(filter(lambda x : (_min <= x) and (x <= _max), range(1, n+1)))
result = len(result_list)

print(result)
sys.exit(0)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
 
n=0
m=0
id_list=[]

n, m  = map(int, input().split())
for i in range(0, m):
  gate_min, gate_max = map(int, input().split())
  id_list.append([gate_min, gate_max])
 

result = 0
for i in range(1, n+1):
  is_passed = True
  for gate in id_list:
    if not((i >= gate[0]) and (i <= gate[1])) :
      is_passed = False
      break

  if is_passed:
    result = result + 1	
print(result)
sys.exit(0)

Fixed submission:
import sys
n=0
m=0

n, m  = map(int, input().split())
_min, _max  = map(int, input().split())
for i in range(1, m):
  gate_min, gate_max = map(int, input().split())
  if (_max > gate_max):
    _max = gate_max
   
  if _min < gate_min:
    _min = gate_min
 
result_list = list(filter(lambda x : (_min <= x) and (x <= _max), range(1, n+1)))
result = len(result_list)

print(result)
sys.exit(0)

Buggy python submission (verdict: Time Limit Exceeded):
def calculate(n, m, id_list):
  result = 0
  for i in range(1, n+1):
    is_passed = True
    for gate in id_list:
      if not((i >= gate[0]) and (i <= gate[1])) :
        is_passed = False
        break
        
    if is_passed:
      result = result + 1
    
  return result
  
  
import sys
 
n=0
m=0
id_list=[]
is_arg_ok = False
try:
  n, m  = map(int, input().split())
  for i in range(0, m):
    gate_min, gate_max = map(int, input().split())
    id_list.append([gate_min, gate_max])
  is_arg_ok = True
  
except:
  print('arg error')
  sys.exit(1)
 
calculated_num = calculate(n, m, id_list)
print(calculated_num)
sys.exit(0)

Fixed submission:
import sys
n=0
m=0

n, m  = map(int, input().split())
_min, _max  = map(int, input().split())
for i in range(1, m):
  gate_min, gate_max = map(int, input().split())
  if (_max > gate_max):
    _max = gate_max
   
  if _min < gate_min:
    _min = gate_min
 
result_list = list(filter(lambda x : (_min <= x) and (x <= _max), range(1, n+1)))
result = len(result_list)

print(result)
sys.exit(0)

Buggy python submission (verdict: Time Limit Exceeded):
def calculate(n, m, id_list):
  result = 0
  for i in range(1, n+1):
    is_passed = True
    for id_list_index in range(0, m):
      if not((i >= id_list[id_list_index][0]) and (i <= id_list[id_list_index][1])) :
        is_passed = False
        break
        
    if is_passed:
      result = result + 1
    
  return result
  
  
import sys
 
n=0
m=0
id_list=[]
is_arg_ok = False
try:
  n, m  = map(int, input().split())
  for i in range(0, m):
    gate_min, gate_max = map(int, input().split())
    id_list.append([gate_min, gate_max])
  is_arg_ok = True
  
except:
  print('arg error')
  sys.exit(1)
 
calculated_num = calculate(n, m, id_list)
print(calculated_num)
sys.exit(0)

Fixed submission:
import sys
n=0
m=0

n, m  = map(int, input().split())
_min, _max  = map(int, input().split())
for i in range(1, m):
  gate_min, gate_max = map(int, input().split())
  if (_max > gate_max):
    _max = gate_max
   
  if _min < gate_min:
    _min = gate_min
 
result_list = list(filter(lambda x : (_min <= x) and (x <= _max), range(1, n+1)))
result = len(result_list)

print(result)
sys.exit(0)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
 
n=0
m=0
id_list=[]
 
def calculate(x):
  _x = x + 1
  for id_list_index in range(0, m):
    if not((_x >= id_list[id_list_index][0]) and (_x <= id_list[id_list_index][1])) :
      return False
 
  return True
  
  
is_arg_ok = False
try:
  n, m  = map(int, input().split())
  for i in range(0, m):
    gate_min, gate_max = map(int, input().split())
    id_list.append([gate_min, gate_max])
  is_arg_ok = True
  
except:
  print('arg error')
  sys.exit(1)
 
 
result = len(list(filter(lambda n: calculate(n), range(0, n))))
print(result)
sys.exit(0)

Fixed submission:
import sys
n=0
m=0

n, m  = map(int, input().split())
_min, _max  = map(int, input().split())
for i in range(1, m):
  gate_min, gate_max = map(int, input().split())
  if (_max > gate_max):
    _max = gate_max
   
  if _min < gate_min:
    _min = gate_min
 
result_list = list(filter(lambda x : (_min <= x) and (x <= _max), range(1, n+1)))
result = len(result_list)

print(result)
sys.exit(0)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
 
n=0
m=0
id_list=[]
 
def calculate(x):
  _x = x + 1
  for id_list_index in range(0, m):
    if not((_x >= id_list[id_list_index][0]) and (_x <= id_list[id_list_index][1])) :
      return False
 
  return True
  
  
is_arg_ok = False
try:
  n, m  = map(int, input().split())
  for i in range(0, m):
    gate_min, gate_max = map(int, input().split())
    id_list.append([gate_min, gate_max])
  is_arg_ok = True
  
except:
  print('arg error')
  sys.exit(1)
 
 
result = len(list(filter(lambda n: calculate(n), range(0, n))))
print(result)
sys.exit(0)

Fixed submission:
import sys
n=0
m=0

n, m  = map(int, input().split())
_min, _max  = map(int, input().split())
for i in range(1, m):
  gate_min, gate_max = map(int, input().split())
  if (_max > gate_max):
    _max = gate_max
   
  if _min < gate_min:
    _min = gate_min
 
result_list = list(filter(lambda x : (_min <= x) and (x <= _max), range(1, n+1)))
result = len(result_list)

print(result)
sys.exit(0)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

n=0
m=0
id_list=[]

def calculate(x):
  c = len(list(filter(lambda id_list_index: (x >= id_list[id_list_index][0]) and (x <= id_list[id_list_index][1]) , range(0, m))))
  if m == c:
    return True
  return False

is_arg_ok = False
try:
  n, m  = map(int, input().split())
  for i in range(0, m):
    gate_min, gate_max = map(int, input().split())
    id_list.append([gate_min, gate_max])
  is_arg_ok = True
  
except:
  print('arg error')
  sys.exit(1)


result = len(list(filter(lambda x: calculate(x), range(1, n + 1))))
print(result)
sys.exit(0)


Fixed submission:
import sys
n=0
m=0

n, m  = map(int, input().split())
_min, _max  = map(int, input().split())
for i in range(1, m):
  gate_min, gate_max = map(int, input().split())
  if (_max > gate_max):
    _max = gate_max
   
  if _min < gate_min:
    _min = gate_min
 
result_list = list(filter(lambda x : (_min <= x) and (x <= _max), range(1, n+1)))
result = len(result_list)

print(result)
sys.exit(0)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

n=0
m=0
id_list=[]

def calculate(x):
  _x = x +1
  is_passed = True
  for id_list_index in range(0, m):
    if not((_x >= id_list[id_list_index][0]) and (_x <= id_list[id_list_index][1])) :
      is_passed = False

  return is_passed
  
  
is_arg_ok = False
try:
  n, m  = map(int, input().split())
  for i in range(0, m):
    gate_min, gate_max = map(int, input().split())
    id_list.append([gate_min, gate_max])
  is_arg_ok = True
  
except:
  print('arg error')
  sys.exit(1)


result = len(list(filter(lambda n: calculate(n), range(0, n))))
print(result)
sys.exit(0)



Fixed submission:
import sys
n=0
m=0

n, m  = map(int, input().split())
_min, _max  = map(int, input().split())
for i in range(1, m):
  gate_min, gate_max = map(int, input().split())
  if (_max > gate_max):
    _max = gate_max
   
  if _min < gate_min:
    _min = gate_min
 
result_list = list(filter(lambda x : (_min <= x) and (x <= _max), range(1, n+1)))
result = len(result_list)

print(result)
sys.exit(0)

Buggy python submission (verdict: Time Limit Exceeded):
def calculate(n, m, id_list):
  result = 0
  for i in range(1, n+1):
    is_passed = True
    for id_list_index in range(0, m):
      if not((i >= id_list[id_list_index][0]) and (i <= id_list[id_list_index][1])) :
        is_passed = False
        
    if is_passed:
      result = result + 1
    
  return result
  
  
import sys

n=0
m=0
id_list=[]
is_arg_ok = False
try:
  n, m  = map(int, input().split())
  for i in range(0, m):
    gate_min, gate_max = map(int, input().split())
    id_list.append([gate_min, gate_max])
  is_arg_ok = True
  
except:
  print('arg error')
  sys.exit(1)

calculated_num = calculate(n, m, id_list)
print(calculated_num)
sys.exit(0)



Fixed submission:
import sys
n=0
m=0

n, m  = map(int, input().split())
_min, _max  = map(int, input().split())
for i in range(1, m):
  gate_min, gate_max = map(int, input().split())
  if (_max > gate_max):
    _max = gate_max
   
  if _min < gate_min:
    _min = gate_min
 
result_list = list(filter(lambda x : (_min <= x) and (x <= _max), range(1, n+1)))
result = len(result_list)

print(result)
sys.exit(0)