Language: C++

#include <iostream>
#include <string>
using namespace std;
int a_list[200000];
int main(){
  int n, q, a, b;
  cin >> n;
  cin >> q >> a >> b;
  a_list[0] = a
  int min_x = a;
  int max_x = a;
  int min = b;
  
  for( int i=1; i< n; i++){
    cin >> q;
    int _a, _b;
    if (q == 1){
      cin >> _a >> _b;
      a_list[i] = _a;
      b += _b;
	  int min_a_sub = abs(min_x - _a);
      int max_a_sub = abs(max_x - _a);
      int a_cand, min_cand1;
      int min_cand2 = b;
           
	  if( min_a_sub < max_a_sub ){
      	min_cand_1 = min + _b + min_a_sub;
        a_cand = min_x;
      }
      else{
        min_cand_1 = min + _b + max_a_sub;
        a_cand = max_x;
      }
 
      for (int j=0; j < i; j++){
	      min_cand_2 += abs(a_list[j] - a_list[i]);
      }
      
      if (min_cand_1 < min_cand_2){
          min = min_cand_1;
          min_x = a_cand;
          max_x = a_cand;
      }
      
      else if (min_cand_1 == min_cand_2){
      	  min = min_cand_1;
      	  if (_a < a_cand){
            min_x = _a;
            max_x = a_cand;
          }
          else if (_a > a_cand) {
          	min_x = a_cand;
            max_x = _a;
          }
          else {
			min_x = _a;
            max_x = _a;
          }
      }
      
      else ( min_cand_2 < min_cand_1){
          min = min_cand_2;
          min_x = _a;
          max_x = _a;
     }
     
     else{
	     if (min_x == max_x){
    	 	cout << min << endl;
	     }
         else{
         	cout << min_x << endl;
         }
     }
   }  
}
 


Compiler output:
a.cc: In function 'int main()':
a.cc:9:16: error: expected ';' before 'int'
    9 |   a_list[0] = a
      |                ^
      |                ;
   10 |   int min_x = a;
      |   ~~~           
a.cc:21:31: error: 'min_x' was not declared in this scope; did you mean 'min'?
   21 |           int min_a_sub = abs(min_x - _a);
      |                               ^~~~~
      |                               min
a.cc:27:9: error: 'min_cand_1' was not declared in this scope; did you mean 'min_cand1'?
   27 |         min_cand_1 = min + _b + min_a_sub;
      |         ^~~~~~~~~~
      |         min_cand1
a.cc:31:9: error: 'min_cand_1' was not declared in this scope; did you mean 'min_cand1'?
   31 |         min_cand_1 = min + _b + max_a_sub;
      |         ^~~~~~~~~~
      |         min_cand1
a.cc:36:15: error: 'min_cand_2' was not declared in this scope; did you mean 'min_cand2'?
   36 |               min_cand_2 += abs(a_list[j] - a_list[i]);
      |               ^~~~~~~~~~
      |               min_cand2
a.cc:39:11: error: 'min_cand_1' was not declared in this scope; did you mean 'min_cand1'?
   39 |       if (min_cand_1 < min_cand_2){
      |           ^~~~~~~~~~
      |           min_cand1
a.cc:39:24: error: 'min_cand_2' was not declared in this scope; did you mean 'min_cand2'?
   39 |       if (min_cand_1 < min_cand_2){
      |                        ^~~~~~~~~~
      |                        min_cand2
a.cc:67:6: error: expected '}' before 'else'
   67 |      else{
      |      ^~~~
a.cc:17:16: note: to match this '{'
   17 |     if (q == 1){
      |                ^
a.cc:68:18: error: 'min_x' was not declared in this scope; did you mean 'min'?
   68 |              if (min_x == max_x){
      |                  ^~~~~
      |                  min