alexjercan/bugnet huggingface dataset:
Problem p02263 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <cstdlib>
#include <iostream>

int num[1000] = {0};
int id = 0;

void push(int x) { num[id++] = x; }

int pop() { return num[--id]; }

int main() {
  char ch[15];
  int a, b;

  while (scanf("%s", ch) != EOF) {
    if (ch[0] == '+') {
      //
      a = pop();
      b = pop();
      push(a + b);
    } else if (ch[0] == '-') {
      a = pop();
      b = pop();
      push(b - a);
    } else if (ch[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(ch));
    }
  }
  printf("%d\\n", pop());
}


Error: -11

Fixed submission:

#include <cstdio>
#include <cstring>
#include <iostream>
#include <stack>
#include <stdlib.h>

using namespace std;

int main() {
  int a, b;
  char s[100];

  stack<int> ans;

  while (cin >> s) {
    for (int i = 0; i < strlen(s); i++) {
      if (s[i] == '+') {
        a = ans.top();
        ans.pop();
        b = ans.top();
        ans.pop();
        ans.push(a + b);
      } else if (s[i] == '-') {
        a = ans.top();
        ans.pop();
        b = ans.top();
        ans.pop();
        ans.push(b - a);
      } else if (s[i] == '*') {
        a = ans.top();
        ans.pop();
        b = ans.top();
        ans.pop();
        ans.push(a * b);
      } else {
        ans.push(s[i] - '0');
      }
    }
    printf("%d\\n", ans.top());
    ans.pop();
  }
}
Problem p02263 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <sstream>
#include <stack>
#include <stdlib.h>
#include <string.h>

using namespace std;

int main() {
  stack<float> stack;
  int i;
  float num, result, first, second;
  char op, ch;
  string str, str1;

  while (getline(cin, str)) {
    istringstream is(str);
    for (; is >> str1;) {
      if (str1.compare("+") == 0) {

        first = stack.top();
        stack.pop();
        second = stack.top();
        stack.pop();
        stack.push(first + second);

      } else if (str1.compare("-") == 0) {

        first = stack.top();
        stack.pop();
        second = stack.top();
        stack.pop();
        stack.push(second - first);

      } else if (str1.compare("*") == 0) {

        first = stack.top();
        stack.pop();
        second = stack.top();
        stack.pop();
        stack.push(first * second);

      } else {
        stack.push(strtof(str1.c_str(), NULL));
      }
    }
    cout << stack.top() << '\\n';
  }
}


Error: 0

Fixed submission:

#include <iostream>
#include <stack>
#include <string>
using namespace std;

int main() {
  string str;
  getline(cin, str);
  stack<char> op;
  stack<int> num;
  bool pding = false;

  for (int i = str.size() - 1; i >= 0; --i) {
    char ch = str[i];
    if (ch == '+' || ch == '-' || ch == '*') {
      op.push(ch);
      pding = false;
    } else if (ch >= '0' && ch <= '9') {
      int a = ch - '0';
      if (pding) {
        while (!num.empty()) {
          int b = num.top();
          num.pop();
          char opd = op.top();
          op.pop();
          if (opd == '+')
            a += b;
          else if (opd == '-')
            a -= b;
          else if (opd == '*')
            a *= b;
        }
      }
      num.push(a);
      pding = true;
    }
  }

  cout << num.top() << endl;
}
Problem p02263 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int top, s[1000];
void push(int x) { s[++top] = x; }
int pop() {
  top--;
  return s[top + 1];
}
int main() {
  int a, b;
  top = 0;
  char h[100];
  while (scanf("%s", h) != EOF) {
    if (h[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if (h[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    } else if (h[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } else
      push(atoi(h));
  }
  printf("%d\\n", pop());
  return 0;
}

Error: -11

Fixed submission:

#include <cstdlib>
#include <iostream>
#include <stack>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
  stack<int> s;
  int a, b, x;
  char k[100000];
  while (scanf("%s", k) != EOF) {
    if (k[0] == '+') {
      int a = s.top();
      s.pop();
      int b = s.top();
      s.pop();
      s.push(a + b);
    } else if (k[0] == '-') {
      b = s.top();
      s.pop();
      a = s.top();
      s.pop();
      s.push(a - b);
    } else if (k[0] = '*') {
      a = s.top();
      s.pop();
      b = s.top();
      s.pop();
      s.push(a * b);
    } else {
      s.push(atoi(k));
    }
  }
  printf("%d", s.top());
  return 0;
}
Problem p02263 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
int s[1000], top = 0;
void push(int x) { s[++top] = x; }
int pop() {
  --top;
  return s[top + 1];
}

int main() {
  int c, b;

  char a[100];
  while (scanf("%s", a) != EOF) {
    if (a[0] == '+') {
      b = pop();
      c = pop();
      push(b + c);
    } else if (a[0] == '-') {
      b = pop();
      c = pop();
      push(c - b);
    } else if (a[0] == '*') {
      b = pop();
      c = pop();
      push(b * c);
    } else {
      push(atoi(a));
    }
  }
  printf("%d\\n", pop());
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
int s[1000], top = 0;
void push(int x) { s[++top] = x; }
int pop() {
  --top;
  return s[top + 1];
}

int main() {
  int c, b;

  char a[100];
  while (scanf("%s", a)) {
    if (a[0] == '+') {
      b = pop();
      c = pop();
      push(b + c);
    } else if (a[0] == '-') {
      b = pop();
      c = pop();
      push(c - b);
    } else if (a[0] == '*') {
      b = pop();
      c = pop();
      push(b * c);
    } else {
      push(atoi(a));
    }
  }
  printf("%d\\n", pop());
  return 0;
}
Problem p02263 (C++) — buggy submission, verdict: Runtime Error

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

int main() {

  string s;
  int stk[100];
  int indx = 0;
  int i = 0;

  getline(cin, s);

  while (i < (int)s.size()) {

    if (s[i] == ' ') {
    } else if (s[i] == '+') {
      stk[indx - 2] += stk[indx - 1];
      indx--;
    } else if (s[i] == '-') {
      stk[indx - 2] -= stk[indx - 1];
      indx--;
    } else if (s[i] == '*') {
      stk[indx - 2] *= stk[indx - 1];
      indx--;
    } else {
      stk[indx] = 0;
      while (s[i] != ' ') {
        stk[indx] *= 10;
        stk[indx] += s[i] - '0';
        i++;
      }
      i--;
      indx++;
    }

    i++;
  }

  cout << stk[0] << endl;

  return 0;
}

Error: 0

Fixed submission:

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

int main() {

  string s;
  long int stk[50];
  int indx = 0;
  int i = 0;

  getline(cin, s);

  while (i < (int)s.size()) {

    if (s[i] == ' ') {
    } else if (s[i] == '+') {
      stk[indx - 2] += stk[indx - 1];
      indx--;
    } else if (s[i] == '-') {
      stk[indx - 2] -= stk[indx - 1];
      indx--;
    } else if (s[i] == '*') {
      stk[indx - 2] *= stk[indx - 1];
      indx--;
    } else {
      stk[indx] = 0;
      while (s[i] != ' ') {
        stk[indx] *= 10;
        stk[indx] += s[i] - '0';
        i++;
      }
      i--;
      indx++;
    }

    i++;
  }

  cout << stk[0] << endl;

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

#include <cstdio>
#include <cstdlib>
#include <stack>

using namespace std;

int main(void) {
  stack<int> st;
  char mozsu[10] = {0};
  int hen = 0;
  int aa = 0;
  int bb = 0;
  while (scanf("%s", mozsu) != EOF) {
    switch (mozsu[0]) {
    case '+':
      aa = st.top();
      st.pop();
      bb = st.top();
      st.pop();
      aa = aa + bb;
      st.push(aa);
      break;
    case '-':
      aa = st.top();
      st.pop();
      bb = st.top();
      st.pop();
      aa = bb - aa;
      st.push(aa);
      break;
    case '*':
      aa = st.top();
      st.pop();
      bb = st.top();
      st.pop();
      aa = aa * bb;
      st.push(aa);
      break;
    default:
      hen = atoi(mozsu);
      st.push(hen);
      break;
    }
  }
  aa = st.top();
  printf("%d\\n", aa);
  return 0;
}

Error: 3

Fixed submission:

#include <cstdio>
#include <cstdlib>
#include <stack>

using namespace std;

int main(void) {
  stack<int> st;
  char mozsu[10] = {0};
  int hen = 0;
  int aa = 0;
  int bb = 0;
  while (scanf("%s", mozsu) != EOF) {
    switch (mozsu[0]) {
    case '+':
      aa = st.top();
      st.pop();
      bb = st.top();
      st.pop();
      aa = aa + bb;
      st.push(aa);
      break;
    case '-':
      aa = st.top();
      st.pop();
      bb = st.top();
      st.pop();
      aa = aa - bb;
      st.push(aa);
      break;
    case '*':
      aa = st.top();
      st.pop();
      bb = st.top();
      st.pop();
      aa = aa * bb;
      st.push(aa);
      break;
    default:
      hen = atoi(mozsu);
      st.push(hen);
      break;
    }
  }
  aa = st.top();
  return aa;
}
Problem p02263 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>

using namespace std;

long computeByOperator(long a, long b, char operatorInput) {
  long result = 0;
  if (operatorInput == '+') {
    result = a + b;
  }
  if (operatorInput == '-') {
    result = a - b;
  }
  if (operatorInput == '*') {
    result = a * b;
  }
  return result;
}

int main() {
  long numList[200];
  int index = 0;
  string input;

  while (cin >> input) {
    // cin >> input;
    // cout << input;
    if (!isdigit(input[0])) {
      numList[index - 2] =
          computeByOperator(numList[index - 2], numList[index - 1], input[0]);
      // cout << numList[index - 2] << endl;
      index -= 1;
    } else {
      long temp = stol(input, nullptr, 10);
      numList[index] = temp;
      index++;
    }
  }
  cin.get();
  cout << numList[0] << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

long computeByOperator(long a, long b, char operatorInput) {
  long result = 0;
  if (operatorInput == '+') {
    result = a + b;
  }
  if (operatorInput == '-') {
    result = a - b;
  }
  if (operatorInput == '*') {
    result = a * b;
  }
  return result;
}

int main() {
  long numList[4];
  int index = 0;
  string input;

  while (cin >> input && (!cin.eof())) {
    // cin >> input;
    // cout << input;
    if (!isdigit(input[0])) {
      numList[index - 2] =
          computeByOperator(numList[index - 2], numList[index - 1], input[0]);
      // cout << numList[index - 2] << endl;
      index -= 2;
    } else {
      long temp = stol(input, nullptr, 10);
      numList[index] = temp;
      index++;
    }
  }

  cout << numList[0] << endl;

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

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
int top, s[101];
int pop() {
  top--;
  return s[top + 1];
}
void push(int a) {
  s[++top] = a;
  // cout<<a<<endl;
}
int main() {
  char temp[100] = {};
  int a, b;
  while (cin >> temp) {
    if (temp[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if (temp[0] == '-') {
      a = pop();
      b = pop();
      push(b - a);
      // cout<<a<<"-"<<b<<endl;
    } else if (temp[0] == '*')
      push(pop() * pop());
    else {
      push(atoi(temp));
      // cout<<temp<<endl;
    }
  }
  cout << pop() << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
int top, s[100];
int pop() {
  top--;
  return s[top + 1];
}
void push(int a) {
  s[++top] = a;
  // cout<<a<<endl;
}
int main() {
  char temp[100] = {};
  int a, b;
  while (cin >> temp) {
    if (temp[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if (temp[0] == '-') {
      a = pop();
      b = pop();
      push(b - a);
      // cout<<a<<"-"<<b<<endl;
    } else if (temp[0] == '*')
      push(pop() * pop());
    else {
      push(atoi(temp));
      // cout<<temp<<endl;
    }
  }
  cout << pop() << endl;
  return 0;
}
Problem p02263 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
#include <stdlib.h>

#define MAX_LENGTH 200

long stack[MAX_LENGTH];
int top = 0;

int isFull() {
  if (top == 199) {
    // printf("満タンです。\\n");
    return 1;
  } else {
    // printf("満タンではありません。\\n");
    return 0;
  }
}

int isEmpty() {
  if (top == 0) {
    // printf("空です。\\n");
    return 1;
  } else {
    // printf("空ではありません。\\n");
    return 0;
  }
}

void push(long x) {
  if (!isFull()) {
    stack[top + 1] = x;
    top++;
    // printf("%ldをプッシュしました。\\n", x);
  } else {
    // printf("プッシュできません。\\n");
  }
}

long pop() {
  if (!isEmpty()) {
    top--;
    // printf("%ldをポップしました。\\n", stack[top + 1]);
    return stack[top + 1];
  } else {
    // printf("ポップできません。\\n");
  }
}

int main(void) {
  char temp[10];
  int i, a, b;

  while (scanf("%s", temp) != EOF) {

    if (temp[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
      // printf("+が入力されました。\\n");
    } else if (temp[0] == '-') {
      a = pop();
      b = pop();
      push(b - a);
      // printf("-が入力されました。\\n");
    } else if (temp[0] == '*') {
      a = pop();
      b = pop();
      // printf("*が入力されました。\\n");
      push(a * b);
    } else if (temp[0] == EOF) {
      // printf("終了です。\\n");
      break;
    } else {
      push(atol(temp));
      // printf("整数%ldが入力されました。\\n", atol(temp));
    }
  }

  printf("%ld\\n", pop());

  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
#include <stdlib.h>

#define MAX_LENGTH 200

long stack[MAX_LENGTH];
int top = 1;

int isFull() {
  if (top == 199) {
    // printf("満タンです。\\n");
    return 1;
  } else {
    // printf("満タンではありません。\\n");
    return 0;
  }
}

int isEmpty() {
  if (top == 0) {
    // printf("空です。\\n");
    return 1;
  } else {
    // printf("空ではありません。\\n");
    return 0;
  }
}

void push(long x) {
  if (!isFull()) {
    stack[top + 1] = x;
    top++;
    // printf("%ldをプッシュしました。\\n", x);
  } else {
    // printf("プッシュできません。\\n");
  }
}

long pop() {
  if (!isEmpty()) {
    top--;
    // printf("%ldをポップしました。\\n", stack[top + 1]);
    return stack[top + 1];
  } else {
    // printf("ポップできません。\\n");
  }
}

int main(void) {
  char temp[10];
  int i;

  while (scanf("%s", temp)) {
    // scanf("%s", temp);
    if (temp[0] == '+') {
      push(pop() + pop());
      // printf("+が入力されました。\\n");
    } else if (temp[0] == '-') {
      push(pop() - pop());
      // printf("-が入力されました。\\n");
    } else if (temp[0] == '*') {
      // printf("*が入力されました。\\n");
      push(pop() * pop());
    } else if (temp[0] == EOF) {
      // printf("終了です。\\n");
      break;
    } else if (temp[0] == '\\n') {
      // printf("改行されました。\\n");
      break;
    } else {
      push(atol(temp));
      // printf("整数%ldが入力されました。\\n", atol(temp));
    }
    for (i = 0; i < sizeof(temp) / sizeof(temp[0]); i++) {
      temp[i] = '\\0';
    }
  }

  printf("%ld\\n", pop());

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

#include <cstdint>
#include <string>

using namespace std;

#define ARRAY_SIZE 256
int32_t array[ARRAY_SIZE];
int32_t index = 0;

void stack_push(int32_t data) {
  array[index] = data;
  index++;
}

bool stack_pop(int32_t &data) {
  if (index > 0) {
    index--;
    data = array[index];
    return true;
  }

  return false;
}

#if !defined(TEST)
#include <cstdio>
#include <iostream>

int32_t main() {
  string str;

  while (cin >> str) {
    if (cin.eof())
      break;
    int32_t data1, data2;
    switch (str.front()) {
    case '+':
      stack_pop(data2);
      stack_pop(data1);
      stack_push(data1 + data2);
      break;
    case '-':
      stack_pop(data2);
      stack_pop(data1);
      stack_push(data1 - data2);
      break;
    case '*':
      stack_pop(data2);
      stack_pop(data1);
      stack_push(data1 * data2);
      break;
    default:
      stack_push(stoi(str));
      break;
    }
    str.clear();
  }

  int32_t data;
  stack_pop(data);
  cout << data << endl;

  return 0;
}
#endif

Error: -6
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoi


Fixed submission:

#include <cstdint>

using namespace std;

#define ARRAY_SIZE 256
int32_t array[ARRAY_SIZE];
int32_t index = 0;

void stack_push(int32_t data) {
  array[index] = data;
  index++;
}

bool stack_pop(int32_t &data) {
  if (index > 0) {
    index--;
    data = array[index];
    return true;
  }

  return false;
}

#if !defined(TEST)
#include <iostream>
int32_t main() {
  string str;
  while (!cin.eof()) {
    int32_t data1, data2;
    cin >> str;
    switch (str.front()) {
    case '+':
      stack_pop(data2);
      stack_pop(data1);
      stack_push(data1 + data2);
      break;
    case '-':
      stack_pop(data2);
      stack_pop(data1);
      stack_push(data1 - data2);
      break;
    case '*':
      stack_pop(data2);
      stack_pop(data1);
      stack_push(data1 * data2);
      break;
    default:
      stack_push(stoi(str));
      break;
    }
    str.clear();
  }

  int32_t data;
  stack_pop(data);
  cout << data << endl;

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

#include "bits/stdc++.h"
using namespace std;

void push(int A);
int pop(void);

int S[1000];
int Top = 0;

int main(void) {

  string str;
  int a, b;
  Top = 0;
  while (cin >> str) {

    if (str[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if (str[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    } else if (str[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(str.c_str()));
    }
  }
  printf("%d\\n", pop());

  return 0;
}

void push(int A) { S[++Top] = A; }

int pop(void) {
  Top--;
  return S[Top + 1];
}


Error: -6
terminate called after throwing an instance of 'std::__ios_failure'
  what():  basic_ios::clear: iostream error


Fixed submission:

#include "bits/stdc++.h"
using namespace std;

void push(int A);
int pop(void);

int S[1000];
int Top = 0;

int main(void) {

  string str;
  int a, b;
  Top = 0;
  while (str != "-1") {
    cin >> str;

    if (str[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if (str[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    } else if (str[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(str.c_str()));
    }
  }
  printf("%d\\n", pop());

  return 0;
}

void push(int A) { S[++Top] = A; }

int pop(void) {
  Top--;
  return S[Top + 1];
}
Problem p02263 (C++) — buggy submission, verdict: Runtime Error

#include "bits/stdc++.h"
using namespace std;

void push(int A);
int pop(void);

int S[1000];
int Top = 0;

int main(void) {

  char str[100];
  int a, b;
  Top = 0;
  while (scanf("%s", str) != EOF) {

    if (str[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if (str[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    } else if (str[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(str));
    }
  }
  printf("%d\\n", pop());

  return 0;
}

void push(int A) { S[++Top] = A; }

int pop(void) {
  Top--;
  return S[Top + 1];
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 18446744073709551615) >= this->size() (which is 1000)


Fixed submission:

#include "bits/stdc++.h"
using namespace std;

void push(int A);
int pop(void);

vector<int> S(1000);
int Top = 0;

int main(void) {

  string str = "0";
  int a, b;
  Top = 0;
  while (str.c_str() != "\\n") {
    cin >> str;

    if (str == "+") {
      a = pop();
      b = pop();
      push(a + b);
    } else if (str == "-") {
      b = pop();
      a = pop();
      push(a - b);
    } else if (str == "*") {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(str.c_str()));
    }
  }
  int x = pop();
  cout << x << endl;
}

void push(int A) {
  Top++;
  S.at(Top) = A;
}

int pop(void) {
  Top--;
  return S.at(Top + 1);
}
Problem p02263 (C++) — buggy submission, verdict: Runtime Error

/*
created at 29.6.2015 by charis
last edited at 2.9.2015 by charis
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A
*/

#include <cstdio>
#include <cstdlib>
using namespace std;

class stack {
public:
  int top;
  int S[1000];

  void initialize() { top = 0; }
  int isEmpty() { return top == 0; }
  int isFull() {
    return top >= 1000; // S[100]
  }
  void push(int x) {
    if (isFull())
      printf("Error\\n");
    else {
      top++;
      S[top] = x;
    }
  }
  int pop() {
    if (isEmpty())
      printf("Error\\n");
    top--;
    return S[top + 1];
  }
};

int main() {
  stack s;
  char C[100];
  s.initialize();
  while (scanf("%s", &C) != EOF) {
    if (C[0] == 'E')
      break;
    if (C[0] == '+') {
      int a = s.pop();
      int b = s.pop();
      s.push(a + b);
    } else if (C[0] == '-') {
      int a = s.pop();
      int b = s.pop();
      s.push(b - a);
    } else if (C[0] == '*') {
      int a = s.pop();
      int b = s.pop();
      s.push(a * b);
    } else {
      int x = atoi(C);
      s.push(x);
    }
  }
  printf("%d\\n", s.pop());

  return 0;
}

Error: 0

Fixed submission:

/*
created at 29.6.2015 by charis
last edited at 2.9.2015 by charis
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A
*/

#include <cstdio>
#include <cstdlib>
using namespace std;

class stack {
public:
  int top;
  int S[];

  void initialize() { top = 0; }
  int isEmpty() { return top == 0; }
  int isFull() {
    return top >= 100; // S[100]
  }
  void push(int x) {
    if (isFull())
      printf("Error\\n");
    else {
      top++;
      S[top] = x;
    }
  }
  int pop() {
    if (isEmpty())
      printf("Error\\n");
    top--;
    return S[top + 1];
  }
};

int main() {
  stack s;
  char C[100];
  s.initialize();
  while (scanf("%s", &C) != EOF) {
    if (C[0] == 'E')
      break;
    if (C[0] == '+') {
      int a = s.pop();
      int b = s.pop();
      s.push(a + b);
    } else if (C[0] == '-') {
      int a = s.pop();
      int b = s.pop();
      s.push(b - a);
    } else if (C[0] == '*') {
      int a = s.pop();
      int b = s.pop();
      s.push(a * b);
    } else {
      int x = atoi(C);
      s.push(x);
    }
  }
  printf("%d\\n", s.pop());

  return 0;
}