alexjercan/bugnet huggingface dataset:
Problem p02289 (C++) — buggy submission, verdict: Time Limit Exceeded

#if debug
#include <iostream>

using namespace std;
int H = 0;
int A[2000000 + 2];

void maxHeapify(int i) {
  int l = 2 * i;
  int r = 2 * i + 1;
  int largest;
  if (l <= H && A[l] > A[i]) {
    largest = l;
  } else
    largest = i;
  if (r <= H && A[r] > A[i])
    largest = i;
  if (largest != i) {
    swap(A[largest], A[i]);
    maxHeapify(largest);
  }
}

int extract() {
  int maxv;
  if (H < 1)
    return -1e9;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key) {
  if (key < A[i])
    return;
  A[i] = key;
  while (i > 1 && A[i / 2] < A[i]) {
    swap(A[i / 2], A[i]);
    i /= 2;
  }
}

void insert(int key) {
  H++;
  A[H] = -1e9;
  increaseKey(H, key);
}
#include <string>
int main() {
  int key;
  string s;
  while (cin >> s) {
    if (s == "insert") {
      cin >> key;
      insert(key);
    } else if (s == "extract") {
      cout << extract() << endl;
    } else
      break;
  }
  return 0;
}
#endif

#include <iostream>
#include <queue>
using namespace std;

int main() {
  char s[20];
  priority_queue<int> que;
  while (1) {
    cin >> s;
    if (s[0] == 'e' && s[1] == 'n')
      break;
    if (s[0] == 'i') {
      int key;
      cin >> key;
      que.push(key);
    } else if (s[0] == 'e') {
      cout << que.top() << endl;
      que.pop();
    }
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstring>

using namespace std;
#define MAX 2000000
#define INFTY (1 << 30)

int H, A[MAX + 1];

void maxHeapify(int i) {
  int l, r, largest;
  l = 2 * i;
  r = 2 * i + 1;

  if (l <= H && A[l] > A[i])
    largest = l;
  else
    largest = i;
  if (r <= H && A[r] > A[largest])
    largest = r;

  if (largest != i) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

void increaseKey(int i, int key) {
  if (key < A[i])
    return;
  A[i] = key;
  while (i > 1 && A[i / 2] < A[i]) {
    swap(A[i], A[i / 2]);
    i = i / 2;
  }
}

void insert(int key) {
  H++;
  A[H] = -INFTY;
  increaseKey(H, key);
}

int extract() {
  int maxv;
  if (H < 1)
    return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}

int main() {
  int key;
  int com[10];
  while (1) {
    scanf("%s", com);
    if (com[0] == 'e' && com[1] == 'n')
      break;
    if (com[0] == 'i') {
      scanf("%d", &key);
      insert(key);
    } else {
      printf("%d\\n", extract());
    }
  }

  return 0;
}
Problem p02289 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i, a, b) for (i = a; i < b; i++)
#define rloop(i, a, b) for (i = a; i >= b; i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define vs vector<string>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846

int main() {
  int key;
  string order;
  priority_queue<int> pq;
  while (1) {
    cin >> order;
    if (order == "insert") {
      cin >> key;
      pq.push(key);
    } else if (order == "extract") {
      cout << pq.top() << endl;
      pq.pop();
    } else {
      break;
    }
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i, a, b) for (i = a; i < b; i++)
#define rloop(i, a, b) for (i = a; i >= b; i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define vs vector<string>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846

int main() {
  int key;
  string order;
  vi a;
  while (1) {
    cin >> order;
    if (order == "insert") {
      cin >> key;
      a.push_back(key);
    } else if (order == "extract") {
      sort(a.begin(), a.end());
      cout << a.back() << endl;
      a.pop_back();
    } else {
      break;
    }
  }
}
Problem p02289 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;
int N;
int H[2000001];

int left(int i) { return i * 2; }
int right(int i) { return i * 2 + 1; }
int parent(int i) { return i / 2; }

void Maximize(int i) {
  int l = left(i);
  int r = right(i);

  int largest = i;
  if (l <= N && H[l] > H[largest])
    largest = l;
  if (r <= N && H[r] > H[largest])
    largest = r;

  if (largest != i) {
    swap(H[largest], H[i]);
    Maximize(largest);
  }
}

void Minimize(int i) {
  int p = parent(i);

  if (p > 0 && H[p] < H[i]) {
    swap(H[p], H[i]);
    Minimize(p);
  }
}

void extract() {
  if (N == 0)
    return;

  cout << H[1] << endl;
  H[1] = H[N];
  N--;
  Maximize(1);
}

void insert(int x) {
  N++;
  H[N] = x;
  Minimize(N);
}

int main() {
  int command;
  N = 0;

  while (true) {
    char com[16];
    scanf("%s", com);
    if (com[2] == 'd')
      break;

    if (com[0] == 'i') {
      int num;
      cin >> num;
      insert(num);
    } else {
      extract();
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;
int N;
int H[2000001];

int left(int i) { return i * 2; }
int right(int i) { return i * 2 + 1; }
int parent(int i) { return i / 2; }

void Maximize(int i) {
  int l = left(i);
  int r = right(i);

  int largest = i;
  if (l <= N && H[l] > H[largest])
    largest = l;
  if (r <= N && H[r] > H[largest])
    largest = r;

  if (largest != i) {
    swap(H[largest], H[i]);
    Maximize(largest);
  }
}

void Minimize(int i) {
  int p = parent(i);

  if (p > 0 && H[p] < H[i]) {
    swap(H[p], H[i]);
    Minimize(p);
  }
}

void extract() {
  if (N == 0)
    return;

  cout << H[1] << endl;
  H[1] = H[N];
  N--;
  Maximize(1);
}

void insert(int x) {
  N++;
  H[N] = x;
  Minimize(N);
}

int main() {
  int command;
  N = 0;

  while (true) {
    char com[16];
    scanf("%d", com);
    if (com[2] == 'd')
      break;

    if (com[0] == 'i') {
      int num;
      cin >> num;
      insert(num);
    } else {
      extract();
    }
  }

  return 0;
}
Problem p02289 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

struct Node {
  int key, lazy;
  Node *l, *r;
} *root = nullptr;

Node pool[2000001];

template <typename T> struct SkewHeap {
  bool rev;

  int ptr;

  SkewHeap(bool rev = false) : rev(rev) {}

  Node *propagate(Node *t) {
    if (t->lazy != 0) {
      if (t->l)
        t->l->lazy += t->lazy;
      if (t->r)
        t->r->lazy += t->lazy;
      t->key += t->lazy;
      t->lazy = 0;
    }
    return t;
  }

  Node *merge(Node *x, Node *y) {
    if (!x || !y)
      return x ? x : y;
    propagate(x), propagate(y);
    if ((x->key > y->key) ^ rev)
      swap(x, y);
    x->r = merge(y, x->r);
    swap(x->l, x->r);
    return x;
  }

  Node *push(const T &key) {
    pool[ptr].key = key;
    root = merge(root, &pool[ptr++]);
  }

  T top() { return propagate(root)->key; }

  void pop() {
    propagate(root);
    auto *temp = root;
    root = merge(root->l, root->r);
    //  delete temp;
  }

  bool empty() const { return !root; }

  void add(const T &lazy) {
    if (root) {
      root->lazy += lazy;
      propagate(root);
    }
  }
};

int main() {
  char buff[100];
  int key;

  SkewHeap<int> que(true);
  for (;;) {
    scanf("%s", buff);
    if (buff[0] == 'e' && buff[1] == 'n')
      break;
    if (buff[0] == 'i') {
      scanf("%d", &key);
      que.push(key);
    } else {
      printf("%d\\n", que.top());
      que.pop();
    }
  }
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

template <typename T> struct SkewHeap {
  struct Node {
    T key, lazy;
    Node *l, *r;
  } *root = nullptr;
  bool rev;

  Node pool[2000001];
  int ptr;

  SkewHeap(bool rev = false) : rev(rev) {}

  Node *propagate(Node *t) {
    if (t->lazy != 0) {
      if (t->l)
        t->l->lazy += t->lazy;
      if (t->r)
        t->r->lazy += t->lazy;
      t->key += t->lazy;
      t->lazy = 0;
    }
    return t;
  }

  Node *merge(Node *x, Node *y) {
    if (!x || !y)
      return x ? x : y;
    propagate(x), propagate(y);
    if ((x->key > y->key) ^ rev)
      swap(x, y);
    x->r = merge(y, x->r);
    swap(x->l, x->r);
    return x;
  }

  Node *push(const T &key) {
    pool[ptr].key = key;
    root = merge(root, &pool[ptr++]);
  }

  T top() { return propagate(root)->key; }

  void pop() {
    propagate(root);
    auto *temp = root;
    root = merge(root->l, root->r);
    //  delete temp;
  }

  bool empty() const { return !root; }

  void add(const T &lazy) {
    if (root) {
      root->lazy += lazy;
      propagate(root);
    }
  }

  void merge(SkewHeap<T> &p) { root = merge(root, p.root); }
};

int main() {
  char buff[100];
  int key;

  SkewHeap<int> que(true);
  for (;;) {
    scanf("%s", buff);
    if (buff[0] == 'e' && buff[1] == 'n')
      break;
    if (buff[0] == 'i') {
      scanf("%d", &key);
      que.push(key);
    } else {
      printf("%d\\n", que.top());
      que.pop();
    }
  }
}
Problem p02289 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

vector<int> A;
int H = 0;

void maxHeapify(int idx) {
  int left = 2 * idx, right = 2 * idx + 1;
  int largest;
  if (left <= H && A[left] > A[idx]) {
    largest = left;
  } else {
    largest = idx;
  }
  if (right <= H && A[right] > A[largest]) {
    largest = right;
  }
  if (largest != idx) {
    swap(A[largest], A[idx]);
    maxHeapify(largest);
  }
}

void insert() {
  int idx = H;
  int parent = idx / 2;
  while (parent && A[idx] > A[parent]) {
    swap(A[idx], A[parent]);
    idx = parent;
    parent /= 2;
  }
}

int main() {
  A.push_back(-1); // dummy
  while (true) {
    char buf[8];
    scanf("%s", buf);
    if (*buf == 'i') {
      int k;
      scanf("%d", &k);
      A.push_back(k);
      H++;
      insert();
    } else if (buf[1] == 'x') {
      printf("%d\\n", A[1]);
      A[1] = A[H];
      H--;
      A.pop_back();
      maxHeapify(1);
    } else {
      break;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

vector<int> A;
int H = 0;

void maxHeapify(int idx) {
  int left = 2 * idx, right = 2 * idx + 1;
  int largest;
  if (left <= H && A[left] > A[idx]) {
    largest = left;
  } else {
    largest = idx;
  }
  if (right <= H && A[right] > A[largest]) {
    largest = right;
  }
  if (largest != idx) {
    swap(A[largest], A[idx]);
    maxHeapify(largest);
  }
}

void buildMaxHeap() {
  for (int i = H / 2; i; i--) {
    maxHeapify(i);
  }
}

int main() {
  A.push_back(-1); // dummy
  while (true) {
    char buf[8];
    scanf("%s", buf);
    if (*buf == 'i') {
      int k;
      scanf("%d", &k);
      A.push_back(k);
      H++;
      buildMaxHeap();
    } else if (buf[1] == 'x') {
      printf("%d\\n", A[1]);
      A[1] = A[H];
      H--;
      A.pop_back();
      maxHeapify(1);
    } else {
      break;
    }
  }
  return 0;
}
Problem p02289 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
  priority_queue<int> PQ;
  while (true) {
    char command[10];
    cin >> command;
    if (command[0] == 'i') {
      int key;
      scanf("%d", &key);
      PQ.push(key);
    } else if (command[1] == 'x') {
      printf("%d\\n", PQ.top());
      PQ.pop();
    } else {
      break;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
  priority_queue<int> PQ;
  while (true) {
    string command;
    cin >> command;
    if (command[0] == 'i') {
      int key;
      scanf("%d", &key);
      PQ.push(key);
    } else if (command[1] == 'x') {
      printf("%d\\n", PQ.top());
      PQ.pop();
    } else {
      break;
    }
  }
  return 0;
}
Problem p02289 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

template <class T> struct LeftistHeap {

private:
  struct node {
    node *lch, *rch;
    int s;
    T val;
    node(T val) : val(val) { lch = rch = NULL; }
  } *root;

public:
  LeftistHeap() { root = NULL; }

  node *meld(node *a, node *b) {
    if (!a || !b)
      return a ? a : b;
    if (a->val < b->val)
      swap(a, b);
    a->rch = meld(a->rch, b);
    if (!a->lch || a->lch->s < a->rch->s)
      swap(a->lch, a->rch);
    a->s = (!a->rch ? 0 : a->rch->s) + 1;
    return a;
  }

  void push(T x) { root = meld(root, new node(x)); }

  void pop() {
    node *tmp = root;
    root = meld(root->rch, root->lch);
    delete tmp;
  }

  T top() { return root->val; }
  bool empty() { return !root; }
  void clear() {
    while (!empty())
      pop();
  }
};

int main(void) {

  LeftistHeap<int> que;
  // string com;
  char ch[10];
  int k;

  // while(cin >> com,com!="end"){
  while (true) {
    scanf(" %s", ch);
    if (ch[2] == 'd')
      break;
    if (ch[0] == 'i') {
      scanf("%d", &k);
      que.push(k);
    } else {
      printf("%d\\n", que.top());
      que.pop();
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

template <class T> struct LeftistHeap {

private:
  struct node {
    node *lch, *rch;
    int s;
    T val;
    node(T val) : val(val) { lch = rch = NULL; }
  } *root;

public:
  LeftistHeap() { root = NULL; }

  node *meld(node *a, node *b) {
    if (!a || !b)
      return a ? a : b;
    if (a->val < b->val)
      swap(a, b);
    a->rch = meld(a->rch, b);
    if (!a->lch || a->lch->s < a->rch->s)
      swap(a->lch, a->rch);
    a->s = (!a->rch ? 0 : a->rch->s) + 1;
    return a;
  }

  void push(T x) { root = meld(root, new node(x)); }

  void pop() {
    // node *tmp=root;
    root = meld(root->rch, root->lch);
    // delete tmp;
  }

  T top() { return root->val; }
  bool empty() { return !root; }
  void clear() {
    while (!empty())
      pop();
  }
};

int main(void) {

  LeftistHeap<int> que;
  string com;
  int k;

  while (cin >> com, com != "end") {
    if (com == "insert") {
      cin >> k;
      que.push(k);
    } else {
      printf("%d\\n", que.top());
      que.pop();
    }
  }

  return 0;
}
Problem p02289 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int main() {
  priority_queue<int> num;
  string command;

  int n;

  while (1) {
    cin >> command;
    if (command.compare("insert") == 0) {
      cin >> n;
      num.push(n);
    }
    if (command.compare("extract") == 0) {
      cout << num.top() << endl;
      num.pop();
    }
    if (command.compare("end") == 0) {
      break;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

// adiciona elementos a heap
vector<unsigned long int> addElement(vector<unsigned long int> &heap, int k) {
  int i = 0;
  while (i < heap.size()) {
    if (k > heap[i]) {
      int temp = k;
      k = heap[i];
      heap[i] = temp;
    }
    i++;
  }

  heap.push_back(k);
  return heap;
}

// corrige a heap
vector<unsigned long int> heapify(vector<unsigned long int> &heap) {
  int i = 0;
  unsigned long int k = heap[0];
  while (i < heap.size()) {
    if (k < heap[i]) {
      int temp = k;
      k = heap[i];
      heap[i] = temp;
    }
    i++;
  }

  return heap;
}

void printHeap(vector<unsigned long int> &heap) {
  for (int i = 0; i < heap.size(); i++) {
    cout << heap[i] << ", ";
  }
  cout << endl;
}

int main() {
  vector<unsigned long int> heap;

  string str;

  while (cin >> str && str != "end") {
    if (str == "insert") {
      unsigned long int k;
      cin >> k;
      heap = addElement(heap, k);

    } else if (str == "extract") {
      cout << heap[0] << endl;
      heap.erase(heap.begin());
      // heap = heapify(heap);
    }

    // printHeap(heap);
  }

  return 0;
}
Problem p02289 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

struct Heap {
  int *set;
  int numberKeys;

  Heap() {
    this->set = new int[2000001];
    this->numberKeys = 0;
  }

  ~Heap() { delete[] this->set; }

  void insert(int key) {
    this->set[++this->numberKeys] = key;

    bool isHeap = false;
    for (int i = this->numberKeys; !isHeap && i > 1; i /= 2) {
      if (this->set[i] <= this->set[i / 2])
        isHeap = true;
      else {
        int aux = this->set[i];
        this->set[i] = this->set[i / 2];
        this->set[i / 2] = aux;
      }
    }
  }

  int extractMax() {
    int max = this->set[1];
    this->set[1] = this->set[this->numberKeys--];
    heapify(1);

    return max;
  }

  void heapify(int position) {
    if (position <= this->numberKeys / 2) {
      int sonPos = position * 2;

      if (sonPos + 1 <= this->numberKeys &&
          this->set[sonPos + 1] > this->set[sonPos])
        sonPos++;

      if (this->set[sonPos] > this->set[position]) {
        int aux = this->set[position];
        this->set[position] = this->set[sonPos];
        this->set[sonPos] = aux;

        heapify(sonPos);
      }
    }
  }
};

int main() {
  Heap heap;
  string input;

  while (cin >> input && input != "end") {
    if (input == "insert") {
      int key;
      cin >> key;
      heap.insert(key);
    } else {
      int max = heap.extractMax();
      cout << max << endl;
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

struct Heap {
  int *set;
  int numberKeys;

  Heap() {
    this->set = new int[2000001];
    this->numberKeys = 0;
  }

  ~Heap() { delete[] this->set; }

  void insert(int key) { this->set[++this->numberKeys] = key; }

  int extractMax() {
    heapify();
    int max = this->set[1];
    this->set[1] = this->set[this->numberKeys--];

    return max;
  }

  void heapify() {
    /*for (int i = this->numberKeys / 2; i > 0; i--) {
        int index = i;
        int key = this->set[i];
        bool isHeap = false;

        while (!isHeap && (2 * index) <= this->numberKeys) {
            int indexSon = 2 * index;

            if (indexSon + 1 <= this->numberKeys && this->set[indexSon + 1] >
    this->set[indexSon]) indexSon++;

            if (key >= this->set[indexSon])
                isHeap = true;
            else {
                this->set[index] = this->set[indexSon];
                index = indexSon;
            }
        }

        this->set[index] = key;
    }*/

    for (int i = this->numberKeys; i > 1; i--) {
      if (this->set[i] > this->set[i / 2]) {
        int aux = this->set[i];
        this->set[i] = this->set[i / 2];
        this->set[i / 2] = aux;
      }
    }
  }
};

int main() {
  Heap heap;
  string input;

  while (cin >> input && input != "end") {
    if (input == "insert") {
      int key;
      cin >> key;
      heap.insert(key);
    } else {
      int max = heap.extractMax();
      cout << max << endl;
    }
  }

  return 0;
}
Problem p02289 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <string>

using namespace std;

int main() {
  char letter[30], dump[30];
  int b;
  priority_queue<int> PQ;
  do {
    fgets(letter, 25, stdin);
    if (letter[0] == 'i') {
      sscanf(letter, "%*s %d", &b, sizeof(b));
      PQ.push(b);
    } else {
      if (letter[0] == 'e' && letter[1] == 'n' && letter[2] == 'd') {
        break;
      } else {
        cout << PQ.top() << endl;
        PQ.pop();
      }
    }
  } while (1);
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;

typedef struct node {
  int number;
  struct node *next;
  struct node *prev;
} data;

data *pqhead = NULL;
data *pqtail = NULL;

void pqpush(int input) {
  data *node = (data *)malloc(sizeof(data));

  node->number = input;
  node->prev = NULL;
  node->next = NULL;

  if (pqhead == NULL) {
    pqhead = node;
    pqtail = node;
  } else {

    if (node->number >= pqhead->number) {
      node->next = pqhead;
      pqhead->prev = node;
      pqhead = node;
    } else if (node->number <= pqtail->number) {
      node->prev = pqtail;
      pqtail->next = node;
      pqtail = node;
    } else {
      data *temp = pqhead;

      while (input < temp->number) {
        temp = temp->next;
      }

      node->next = temp;
      node->prev = temp->prev;
      temp->prev = node;
      node->prev->next = node;
    }
  }
}
void pqpop() {
  data *temp = pqhead;

  pqhead = pqhead->next;

  free(temp);
}

int pqtop() { return pqhead->number; }

int main() {
  string kata;
  int angka;
  while (1) {
    cin >> kata;
    if (kata == "insert") {
      cin >> angka;
      pqpush(angka);
    } else if (kata == "extract") {
      cout << pqtop() << endl;
      pqpop();
    } else {
      break;
    }
  }

  return 0;
}