output_description: Print the price of the bowl of ramen corresponding to S.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      S
attempt: n, c = map(int, input().split())
  x = [tuple(map(int, input().split())) for _ in range(n)]
  
  S_cw = [0]
  S_ccw = [0]
  S_cw_return = [0]
  S_ccw_return = [0]
  
  for i in range(n):
      S_cw.append(S_cw[-1] + x[i][1])
      S_ccw.append(S_ccw[-1] + x[n - 1 - i][1])
  
  for i in range(n):
      S_cw[i + 1] -= x[i][0]
      S_ccw[i + 1] -= c - x[n - 1 - i][0]
      S_cw_return.append(S_cw[i + 1] - x[i][0])
      S_ccw_return.append(S_ccw[i + 1] - (c - x[n - 1 - i][0]))
  
  S_cw_return_max = [0]
  S_ccw_return_max = [0]
  for i in range(n):
      if S_cw_return[i + 1] > S_cw_return_max[-1]:
          S_cw_return_max.append(S_cw_return[i + 1])
      else:
          S_cw_return_max.append(S_cw_return_max[-1])
  
      if S_ccw_return[i + 1] > S_ccw_return_max[-1]:
          S_ccw_return_max.append(S_ccw_return[i + 1])
      else:
          S_ccw_return_max.append(S_ccw_return_max[-1])
  
  ans = 0
  for i in range(n + 1):
      idx = n - i
      ans = max(ans, S_cw[i] + S_ccw_return_max[idx], S_ccw[i] + S_cw_return_max[idx])
  print(ans)
  
problem_description: Statement
  
  In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the
  currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced
  pork, green onions).
  
  A customer ordered a bowl of ramen and told which toppings to put on his ramen
  to a clerk. The clerk took a memo of the order as a string S. S is three
  characters long, and if the first character in S is `o`, it means the ramen
  should be topped with boiled egg; if that character is `x`, it means the ramen
  should not be topped with boiled egg. Similarly, the second and third
  characters in S mean the presence or absence of sliced pork and green onions
  on top of the ramen.
  
  Write a program that, when S is given, prints the price of the corresponding
  bowl of ramen.
samples: [{"input": "oxo", "output": "900\n    \n\nThe price of a ramen topped with two kinds of toppings, boiled egg and green\nonions, is 700 + 100 \\times 2 = 900 yen.\n\n* * *"}, {"input": "ooo", "output": "1000\n    \n\nThe price of a ramen topped with all three kinds of toppings is 700 + 100\n\\times 3 = 1000 yen.\n\n* * *"}, {"input": "xxx", "output": "700\n    \n\nThe price of a ramen without any toppings is 700 yen."}]