Problem p02630 (C++) — buggy submission, verdict: Runtime Error

// #include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;
#define PI 3.14159265359;

class Hoge {
public:
  long int i0;
  long int isum0;
  int i1, N0, Q;
  string s0;
  int *iarray0;
  int *iarrayb;
  int *iarrayc;
  int *iarrayn;
  Hoge(int);
  void func0();
  ~Hoge();
  void array0();
  void array1();
  void printarray0();
  void count0();
  void printarrayn();
  void convert0();
};

Hoge::Hoge(int itemp) {

  i0 = itemp;
  isum0 = 0;
  // cout<<"i0="<<i0<<endl;
}

void Hoge::func0() {

  i0 += 1;
  // cout<<"i0="<<i0<<endl;
}

void Hoge::array0() {

  // cout<<"N0?";
  cin >> N0;
  iarray0 = new int[N0];

  for (int i0 = 0; i0 < N0; i0++) {
    // cout<<"i0="<<i0<<endl;
    cin >> iarray0[i0];
  }
}

void Hoge::array1() {

  // cout<<"Q?";
  cin >> Q;
  iarrayb = new int[Q];
  iarrayc = new int[Q];
  for (int i0 = 0; i0 < Q; i0++) {
    // cout<<"i0="<<i0<<endl;
    cin >> iarrayb[i0];
    cin >> iarrayc[i0];
  }
}

void Hoge::count0() {
  int i00 = pow(10, 5) + 1;
  // cout<<"i00="<<i00<<endl;

  iarrayn = new int[i00];
  for (int i0 = 0; i0 < N0; i0++) {
    iarrayn[iarray0[i0]]++;
  }
  for (int i0 = 0; i0 < (i00); i0++) {
    isum0 += i0 * iarrayn[i0];
  }
}

void Hoge::convert0() {

  int inc0;
  // cout<<"isum0="<<isum0<<endl;
  for (int i0 = 0; i0 < Q; i0++) {
    inc0 = (iarrayc[i0] - iarrayb[i0]) * iarrayn[iarrayb[i0]];
    // cout<<"inc0="<<inc0<<endl;
    // cout<<"iarrayn["<<iarrayb[i0]<<"]="<<iarrayn[iarrayb[i0]]<<endl;
    // cout<<"iarrayn["<<iarrayc[i0]<<"]="<<iarrayn[iarrayc[i0]]<<endl;
    isum0 += inc0;
    cout << isum0 << endl;

    iarrayn[iarrayc[i0]] += iarrayn[iarrayb[i0]];
    iarrayn[iarrayb[i0]] = 0;
    // cout<<"iarrayn["<<iarrayb[i0]<<"]="<<iarrayn[iarrayb[i0]]<<endl;
    // cout<<"iarrayn["<<iarrayc[i0]<<"]="<<iarrayn[iarrayc[i0]]<<endl;
  }
}

Hoge::~Hoge() {
  delete[] iarray0;
  delete[] iarrayb;
  delete[] iarrayc;
  delete[] iarrayn;
}
void Hoge::printarray0() {

  for (int i0 = 0; i0 < N0; i0++) {
    cout << "iarray0[" << i0 << "]=" << iarray0[i0] << endl;
  }

  cout << "---------" << endl;
}
void Hoge::printarrayn() {

  for (int i0 = 0; i0 < 20; i0++) {
    cout << "iarrayn[" << i0 << "]=" << iarrayn[i0] << endl;
  }
  cout << "---------" << endl;
}

int main() {
  int N;
  //	cin>>N;
  Hoge *hoge = new Hoge(0);
  // hoge->func0();
  hoge->array0();
  hoge->array1();
  // hoge->printarray0();
  hoge->count0();
  hoge->convert0();
  // hoge->printarrayn();

  return 0;
  delete hoge;
} // end of main

Error: 0

Fixed submission:

// #include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;
#define PI 3.14159265359;

class Hoge {
public:
  long int i0;
  long int isum0;
  int i1, N0, Q;
  string s0;
  int *iarray0;
  int *iarrayb;
  int *iarrayc;
  int *iarrayn;
  Hoge(int);
  void func0();
  ~Hoge();
  void array0();
  void array1();
  void printarray0();
  void count0();
  void printarrayn();
  void convert0();
};

Hoge::Hoge(int itemp) {

  i0 = itemp;
  isum0 = 0;
  // cout<<"i0="<<i0<<endl;
}

void Hoge::func0() {

  i0 += 1;
  // cout<<"i0="<<i0<<endl;
}

void Hoge::array0() {

  // cout<<"N0?";
  cin >> N0;
  iarray0 = new int[N0];

  for (int i0 = 0; i0 < N0; i0++) {
    // cout<<"i0="<<i0<<endl;
    cin >> iarray0[i0];
  }
}

void Hoge::array1() {

  // cout<<"Q?";
  cin >> Q;
  iarrayb = new int[Q];
  iarrayc = new int[Q];
  for (int i0 = 0; i0 < Q; i0++) {
    // cout<<"i0="<<i0<<endl;
    cin >> iarrayb[i0];
    cin >> iarrayc[i0];
  }
}

void Hoge::count0() {
  iarrayn = new int[10 ^ 5 + 1];
  for (int i0 = 0; i0 < N0; i0++) {
    iarrayn[iarray0[i0]]++;
  }
  for (int i0 = 0; i0 < (10 ^ 5 + 1); i0++) {
    isum0 += i0 * iarrayn[i0];
  }
}

void Hoge::convert0() {

  int inc0;
  // cout<<"isum0="<<isum0<<endl;
  for (int i0 = 0; i0 < Q; i0++) {
    inc0 = (iarrayc[i0] - iarrayb[i0]) * iarrayn[iarrayb[i0]];
    // cout<<"inc0="<<inc0<<endl;
    // cout<<"iarrayn["<<iarrayb[i0]<<"]="<<iarrayn[iarrayb[i0]]<<endl;
    // cout<<"iarrayn["<<iarrayc[i0]<<"]="<<iarrayn[iarrayc[i0]]<<endl;
    isum0 += inc0;
    cout << isum0 << endl;

    iarrayn[iarrayc[i0]] += iarrayn[iarrayb[i0]];
    iarrayn[iarrayb[i0]] = 0;
    // cout<<"iarrayn["<<iarrayb[i0]<<"]="<<iarrayn[iarrayb[i0]]<<endl;
    // cout<<"iarrayn["<<iarrayc[i0]<<"]="<<iarrayn[iarrayc[i0]]<<endl;
  }
}

Hoge::~Hoge() {
  delete[] iarray0;
  delete[] iarrayb;
  delete[] iarrayc;
  delete[] iarrayn;
}
void Hoge::printarray0() {

  for (int i0 = 0; i0 < N0; i0++) {
    cout << "iarray0[" << i0 << "]=" << iarray0[i0] << endl;
  }

  cout << "---------" << endl;
}
void Hoge::printarrayn() {

  for (int i0 = 0; i0 < 20; i0++) {
    cout << "iarrayn[" << i0 << "]=" << iarrayn[i0] << endl;
  }
  cout << "---------" << endl;
}

int main() {
  int N;
  //	cin>>N;
  Hoge *hoge = new Hoge(0);
  // hoge->func0();
  hoge->array0();
  hoge->array1();
  // hoge->printarray0();
  hoge->count0();
  hoge->convert0();
  // hoge->printarrayn();

  return 0;
  delete hoge;
} // end of main