output_description: Print the minimum possible number of subarrays after division of A.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 A_2 ... A_N
attempt: import numpy as np
  
  N, L, T = map(int, input().split())
  xw_list = []
  for n in range(N):
      xw_list.append(list(map(int, input().split())))
  
  dic = {k: v for k, v in enumerate(xw_list)}
  sort_dic = sorted(dic.items(), key=lambda x: x[1])
  
  # 1 : 時計回り、2 : 反時計回り
  for t in range(T):
      for n in range(N):
          t_xw = sort_dic[n][1]  # 対象アリ
          # 移動
          if t_xw[1] == 1:
              t_xw[0] += 1
          else:
              t_xw[0] -= 1
          # 周回した時の変換
          if t_xw[0] < 0:
              t_xw[0] = L + t_xw[0]
          elif t_xw[0] > L:
              t_xw[0] = t_xw[0] - L
  
      # 衝突
      for n in range(N):
          # 座標前後のみで検索
          t_xw = sort_dic[n][1]  # 対象アリ
          if n == 0:
              next_xw = sort_dic[-1][1]  # 前のアリ
          #             ato_xw = sort_dic[n+1][1]    # 後のアリ
          elif n == N - 1:
              next_xw = sort_dic[n - 1][1]  # 前のアリ
          #             ato_xw = sort_dic[0][1]    # 後のアリ
          else:
              next_xw = sort_dic[n - 1][1]  # 前のアリ
          #             ato_xw = sort_dic[n+1][1]    # 後のアリ
  
          #         for next_xw in [mae_xw]:
          #                         , ato_xw]:
          # １秒後に同じ場所　→　方向転換
          if t_xw[0] == next_xw[0]:
              t_xw[1] = next_xw[1]
              next_xw[1] = t_xw[1]
          # 0.5秒後にすれ違う
          if np.abs(t_xw[0] - next_xw[0]) == 1 and t_xw[1] != next_xw[1]:
              if (
                  t_xw[0] > next_xw[0] or (t_xw[0] == 0 and next_xw[0] == L - 1)
              ) and t_xw[1] == 1:
                  t_xw[0] -= 1
                  t_xw[1] = 2
                  next_xw[0] += 1
                  next_xw[1] = 1
              elif (
                  next_xw[0] > t_xw[0] or (next_xw[0] == 0 and t_xw[0] == L - 1)
              ) and next_xw[1] == 1:
                  t_xw[0] += 1
                  t_xw[1] = 1
                  next_xw[0] -= 1
                  next_xw[1] = 2
  
  for tup in sorted(sort_dic):
      print(tup[1][0])
  
problem_description: Statement
  
  You are given an array A of length N. Your task is to divide it into several
  contiguous subarrays. Here, all subarrays obtained must be sorted in either
  non-decreasing or non-increasing order. At least how many subarrays do you
  need to divide A into?
samples: [{"input": "6\n    1 2 3 2 2 1", "output": "2\n    \n\nOne optimal solution is to divide the array into [1,2,3] and [2,2,1].\n\n* * *"}, {"input": "9\n    1 2 1 2 1 2 1 2 1", "output": "5\n    \n\n* * *"}, {"input": "7\n    1 2 3 2 1 999999999 1000000000", "output": "3"}]