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

#include <cstdio>
#include <iostream>
#include <sstream>
#include <stack>
#include <string>

using namespace std;

bool debug = false;

double toint(string str) {
  istringstream iss(str);
  double ret;

  iss >> ret;
  return ret;
}

int main(void) {
  stack<double> st;
  string str;
  string tmp = "";
  while (getline(cin, str)) {
    for (int i = 0; i < str.size(); i++) {
      if (debug)
        cout << i << ":" << str[i] << endl;
      if (('0' <= str[i] && str[i] <= '9') || str[i] == '.' ||
          (str[i] == '-' && '0' <= str[i + 1] && str[i + 1] <= '9')) {
        tmp += str[i];
      } else if (str[i] == ' ') {
        if (!tmp.empty()) {
          st.push(toint(tmp));
          if (debug)
            cout << "pushed " << tmp << endl;
          tmp.clear();
        }
      } else {
        double arg1, arg2;
        arg2 = st.top();
        st.pop();
        arg1 = st.top();
        st.pop();
        if (str[i] == '+') {
          st.push(arg1 + arg2);
        } else if (str[i] == '-') {
          st.push(arg1 - arg2);
        } else if (str[i] == '*') {
          st.push(arg1 * arg2);
        } else {
          st.push(arg1 / arg2);
        }
      }
    }
    if (!st.empty()) {
      printf("%.7f\\n", st.top());
    }
    if (!tmp.empty()) {
      printf("%.7f\\n", toint(tmp));
      tmp.clear();
    }
    while (!st.empty())
      st.pop();
  }
}

Error: -11

Fixed submission:

#include <cstdio>
#include <iostream>
#include <sstream>
#include <stack>
#include <string>

using namespace std;

bool debug = false;

double toint(string str) {
  istringstream iss(str);
  double ret;

  iss >> ret;
  return ret;
}

int main(void) {
  stack<double> st;
  string str;

  while (getline(cin, str)) {
    string tmp = "";
    for (int i = 0; i < str.size(); i++) {
      if (debug)
        cout << i << ":" << str[i] << endl;
      if (('0' <= str[i] && str[i] <= '9') || str[i] == '.') {
        tmp += str[i];
      } else if (str[i] == ' ') {
        if (!tmp.empty()) {
          st.push(toint(tmp));
          if (debug)
            cout << "pushed " << tmp << endl;
          tmp.clear();
        }
      } else {
        double arg1, arg2;
        arg2 = st.top();
        st.pop();
        arg1 = st.top();
        st.pop();
        if (str[i] == '+') {
          st.push(arg1 + arg2);
        } else if (str[i] == '-') {
          st.push(arg1 - arg2);
        } else if (str[i] == '*') {
          st.push(arg1 * arg2);
        } else {
          st.push(arg1 / arg2);
        }
      }
    }
    if (!st.empty()) {
      printf("%.6f\\n", st.top());
    }
    while (!st.empty())
      st.pop();
  }
}
Problem p00087 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <stack>
#include <string>
using namespace std;

int main() {
  string str;

  while (getline(cin, str)) {
    stack<double> st;
    stringstream ss;

    ss << str;
    string item;
    while (ss >> item) {
      char c = item.at(0);

      if (c == '+' || (c == '-' && item.length() == 1) || c == '*' ||
          c == '/') {
        double a, b;

        b = st.top();
        st.pop();
        a = st.top();
        st.pop();
        if (c == '+')
          st.push(a + b);
        else if (c == '-')
          st.push(a - b);
        else if (c == '*')
          st.push(a * b);
        else
          st.push(a / b);
      } else {
        st.push(atof(item.c_str()));
      }
    }
    printf("%f\\n", st.top());
  }

  return 0;
}

Error: -11

Fixed submission:

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <stack>
#include <string>
using namespace std;

int main() {
  string str;

  while (getline(cin, str)) {
    stack<double> st;
    stringstream ss;

    ss << str;
    string item;
    while (ss >> item) {
      char c = item.at(0);

      if (c == '+' || c == '-' || c == '*' || c == '/') {
        double a, b;

        b = st.top();
        st.pop();
        a = st.top();
        st.pop();
        if (c == '+')
          st.push(a + b);
        else if (c == '-')
          st.push(a - b);
        else if (c == '*')
          st.push(a * b);
        else
          st.push(a / b);
      } else {
        st.push(atof(item.c_str()));
      }
    }
    printf("%f\\n", st.top());
  }

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

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <stack>
#include <string>
using namespace std;
int main() {
  double x, y;
  string s;
  while (getline(cin, s)) {
    stack<double> box;
    s = s + ' ';
    for (int i = 0; i < (int)s.size() - 1; i++) {
      if (s[i] == '-') {
        if (!isdigit(s[i + 1])) {
          x = box.top();
          box.pop();
          y = box.top();
          box.pop();
          box.push(y - x);
        } else {
          box.push(-atof(&s[i + 1]));
          for (i += 1; s[i] != ' '; i++)
            ;
        }
      } else if (s[i] == '+') {
        x = box.top();
        box.pop();
        y = box.top();
        box.pop();
        box.push(y + x);
      } else if (s[i] == '*') {
        x = box.top();
        box.pop();
        y = box.top();
        box.pop();
        box.push(y * x);
      } else if (s[i] == '/') {
        x = box.top();
        box.pop();
        y = box.top();
        box.pop();
        box.push(y / x);
      } else if (isdigit(s[i])) {
        box.push(atof(&s[i]));
        for (; s[i] != ' '; i++)
          ;
      }
    }
    if (!box.empty()) {
      printf("%.6lf\\n", box.top());
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <stack>
#include <string>
using namespace std;
int main() {
  double x, y;
  string s;
  while (getline(cin, s)) {
    stack<double> box;
    s = s + '\\0';
    for (int i = 0; i < (int)s.size() - 1; i++) {
      if (s[i] == '-') {
        if (!isdigit(s[i + 1])) {
          x = box.top();
          box.pop();
          y = box.top();
          box.pop();
          box.push(y - x);
        } else {
          box.push(-atof(&s[i + 1]));
          for (i += 1; s[i] != ' '; i++)
            ;
        }
      } else if (s[i] == '+') {
        x = box.top();
        box.pop();
        y = box.top();
        box.pop();
        box.push(y + x);
      } else if (s[i] == '*') {
        x = box.top();
        box.pop();
        y = box.top();
        box.pop();
        box.push(y * x);
      } else if (s[i] == '/') {
        x = box.top();
        box.pop();
        y = box.top();
        box.pop();
        box.push(y / x);
      } else if (isdigit(s[i])) {
        box.push(atof(&s[i]));
        for (; s[i] != ' '; i++)
          ;
      }
    }
    if (!box.empty()) {
      printf("%.6lf\\n", box.top());
    }
  }
  return 0;
}
Problem p00087 (C++) — buggy submission, verdict: Runtime Error

#define _USE_MATH_DEFINES
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  while (true) {
    stack<double> s;
    char In[81];
    double num = 0;
    bool is_pos = true;
    int r;
    for (int i = 0; r = scanf("%c", &In[i]); i++) {
      if (In[i] == '\\n')
        break;
      if (r == EOF)
        return 0;
    }
    for (int i = 0; In[i] != '\\n'; i++) {
      if (In[i] == ' ')
        continue;
      if ('0' <= In[i] && In[i] <= '9') {
        num = num * 10 + (In[i] - '0');
        if (In[i + 1] < '0' || '9' < In[i + 1]) {
          if (is_pos == false)
            num *= -1;
          s.push(num);
          num = 0;
          is_pos = true;
        }
      } else {
        if (In[i] == '-' && '0' <= In[i + 1] && In[i + 1] <= '9') {
          is_pos = false;
        } else {
          double a, b;
          b = s.top();
          s.pop();
          a = s.top();
          s.pop();
          if (In[i] == '+')
            s.push(a + b);
          else if (In[i] == '-')
            s.push(a - b);
          else if (In[i] == '*')
            s.push(a * b);
          else
            s.push(a / b);
        }
      }
    }
    printf("%lf\\n", s.top());
  }
  return 0;
}

Error: 0

Fixed submission:

#define _USE_MATH_DEFINES
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  while (true) {
    stack<double> s;
    char In[81];
    double num = 0;
    bool is_pos = true;
    int r;
    for (int i = 0; r = scanf("%c", &In[i]); i++) {
      if (In[i] == '\\n')
        break;
      if (r == EOF)
        return 0;
    }
    for (int i = 0; In[i] != '\\n'; i++) {
      if (In[i] == ' ')
        continue;
      if ('0' <= In[i] && In[i] <= '9') {
        num = num * 10 + (In[i] - '0');
        if (In[i + 1] == ' ') {
          if (is_pos == false)
            num *= -1;
          s.push(num);
          num = 0;
          is_pos = true;
        }
      } else {
        if (In[i] == '-' && '0' <= In[i + 1] && In[i + 1] <= '9') {
          is_pos = false;
        } else {
          double a, b;
          b = s.top();
          s.pop();
          a = s.top();
          s.pop();
          if (In[i] == '+')
            s.push(a + b);
          else if (In[i] == '-')
            s.push(a - b);
          else if (In[i] == '*')
            s.push(a * b);
          else
            s.push(a / b);
        }
      }
    }
    printf("%lf\\n", s.top());
  }
  return 0;
}
Problem p00087 (C++) — buggy submission, verdict: Runtime Error

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y)                                                            \\
  cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
#define BINARY(x) static_cast<bitset<16>>(x)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for (int i = m; i < (int)(n); i++)

#define in_range(x, y, w, h)                                                   \\
  (0 <= (int)(x) && (int)(x) < (int)(w) && 0 <= (int)(y) && (int)(y) < (int)(h))
#define ALL(a) (a).begin(), (a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4] = {0, -1, 1, 0}, dy[4] = {-1, 0, 0, 1};

int main() {
  string line;
  while (true) {
    getline(cin, line);
    if (cin.eof())
      break;

    stack<double> st;
    stringstream ss(line);
    while (!ss.eof()) {
      string S;
      ss >> S;

      if (isdigit(S[0]) || S.size() > 1) {
        int num = stoi(S);
        st.push(num);
      } else {
        double b = st.top();
        st.pop();
        double a = st.top();
        st.pop();
        if (S == "-")
          st.push(a - b);
        if (S == "+")
          st.push(a + b);
        if (S == "*")
          st.push(a * b);
        if (S == "/")
          st.push(a / b);
      }
    }

    cout << fixed << setprecision(10) << st.top() << endl;
  }
}

Error: -11

Fixed submission:

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y)                                                            \\
  cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
#define BINARY(x) static_cast<bitset<16>>(x)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for (int i = m; i < (int)(n); i++)

#define in_range(x, y, w, h)                                                   \\
  (0 <= (int)(x) && (int)(x) < (int)(w) && 0 <= (int)(y) && (int)(y) < (int)(h))
#define ALL(a) (a).begin(), (a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4] = {0, -1, 1, 0}, dy[4] = {-1, 0, 0, 1};

int main() {
  string line;
  while (true) {
    getline(cin, line);
    if (cin.eof())
      break;

    stack<double> st;
    stringstream ss(line);
    while (!ss.eof()) {
      string S;
      ss >> S;

      if (isdigit(S[0])) {
        int num = stoi(S);
        st.push(num);
      } else {
        double b = st.top();
        st.pop();
        double a = st.top();
        st.pop();
        if (S == "-")
          st.push(a - b);
        if (S == "+")
          st.push(a + b);
        if (S == "*")
          st.push(a * b);
        if (S == "/")
          st.push(a / b);
      }
    }

    cout << fixed << setprecision(10) << st.top() << endl;
  }
}
Problem p00087 (C++) — buggy submission, verdict: Runtime Error

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

int main() {

  string in, l;

  while (true) {
    if (cin.eof())
      break;

    getline(cin, l);
    if (l.size() == 0)
      break;

    stack<double> s;
    stringstream st(l);

    while (st >> in) {

      if (in == "+" || in == "-" || in == "*" || in == "/") {
        double a, b;
        a = s.top();
        s.pop();
        b = s.top();
        s.pop();
        if (in == "+") {
          // cout << b << " + " << a << endl;
          b += a;
        } else if (in == "-") {
          // cout << b << " - " << a << endl;
          b -= a;
        } else if (in == "*") {
          // cout << b << " * " << a << endl;
          b *= a;
        } else if (in == "/") {
          // cout << b << " / " << a << endl;
          b /= a;
        }
        s.push(b);
      } else {
        double s_in;
        stringstream ss(in);
        ss >> s_in;
        s.push(s_in);
      }
    }

    cout << fixed << setprecision(10) << s.top() << endl;
  }

  return 0;
}

Error: -11

Fixed submission:

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

int main() {

  string in;

  while (true) {
    if (cin.eof())
      break;

    getline(cin, in);
    if (in.size() == 0)
      break;

    stack<double> s;

    long long int k = 0;
    long long int d = 0;

    for (int i = 0; i < in.size(); i++) {
      if (in[i] >= '0' && in[i] <= '9') {
        k *= 10;
        k += in[i] - '0';
        d *= 10;
      } else if (in[i] == ' ') {
        if (d == 0) {
          s.push(1.00 * k);
        } else {
          s.push(1.00 * k / d);
        }
        k = 0;
        d = 0;
      } else if (in[i] == '.') {
        d = 1;
      } else {
        double a, b;
        a = s.top();
        s.pop();
        b = s.top();
        s.pop();
        if (in[i] == '+') {
          //	  cout << a << " + " << b << endl;
          b += a;
        } else if (in[i] == '-') {
          // cout << a << " - " << b << endl;
          b -= a;
        } else if (in[i] == '*') {
          // cout << a << " * " << b << endl;
          b *= a;
        } else if (in[i] == '/') {
          // cout << a << " / " << b << endl;
          b /= a;
        }
        s.push(b);
        i++;
      }
    }

    cout << fixed << setprecision(10) << s.top() << endl;
  }

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

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <stack>
using namespace std;

string str;

int main() {
  while (getline(cin, str)) {
    stack<double> st;
    stringstream ss(str);
    while (ss >> str) {
      if (str == "+") {
        double p = st.top();
        st.pop();
        double q = st.top();
        st.pop();
        st.push(p + q);
      } else if (str == "-") {
        double p = st.top();
        st.pop();
        double q = st.top();
        st.pop();
        st.push(q - p);
      } else if (str == "*") {
        double p = st.top();
        st.pop();
        double q = st.top();
        st.pop();
        st.push(p * q);
      } else if (str == "/") {
        double p = st.top();
        st.pop();
        double q = st.top();
        st.pop();
        st.push(q / p);
      } else {
        st.push((double)(atoi(str.c_str())));
      }
    }
    printf("%.7f\\n", st.top());
  }
}

Error: -11

Fixed submission:

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

string str;

int main() {
  while (getline(cin, str)) {
    stack<double> st;
    for (int i = 0; i < str.size(); i++) {
      if (str[i] == ' ')
        continue;
      if (str[i] - '0' >= 0 && str[i] - '0' <= 9) {
        if (i != 0 && str[i - 1] - '0' >= 0 && str[i - 1] - '0' <= 9) {
          double p = st.top();
          st.pop();
          p *= 10.0;
          p += (double)(str[i] - '0');
          st.push(p);
        } else {
          st.push((double)(str[i] - '0'));
        }
      } else if (str[i] == '+') {
        double p = st.top();
        st.pop();
        double q = st.top();
        st.pop();
        st.push(p + q);
      } else if (str[i] == '-') {
        double p = st.top();
        st.pop();
        double q = st.top();
        st.pop();
        st.push(q - p);
      } else if (str[i] == '*') {
        double p = st.top();
        st.pop();
        double q = st.top();
        st.pop();
        st.push(p * q);
      } else if (str[i] == '/') {
        double p = st.top();
        st.pop();
        double q = st.top();
        st.pop();
        st.push(q / p);
      }
    }
    printf("%.6f\\n", st.top());
  }
}
Problem p00087 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  char str[2048];

  double stack[2048];

  while (fgets(str, 2048, stdin) != NULL) {
    int len = strlen(str);

    int p = 0;
    int m = 10;

    while (p < len) {
      if ((str[p] >= '0' && str[p] <= '9') ||
          (str[p] == '-' && str[p + 1] >= '0' && str[p + 1] <= '9')) {
        sscanf(&str[p], "%lf", &stack[m++]);

        char w[128];
        sscanf(&str[p], "%s", w);

        p += strlen(w) + 1;
      }

      else {
        switch (str[p]) {
        case '+':
          stack[m - 2] += stack[m - 1];
          break;

        case '-':
          stack[m - 2] -= stack[m - 1];
          break;

        case '*':
          stack[m - 2] *= stack[m - 1];
          break;

        case '/':
          stack[m - 2] /= stack[m - 1];
          //					break;
        }

        m--;
        p += 2;

        //				printf("%lf\\n", stack[m - 1]);
      }
    }

    printf("%lf\\n", stack[10]);
  }

  return 0;
}

Error: -11

Fixed submission:

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

int main() {
  char str[2048];

  double stack[2048];

  while (fgets(str, 2048, stdin) != NULL) {
    int len = strlen(str);

    int p = 0;
    int m = 0;

    while (p < len) {
      if (str[p] >= '0' && str[p] <= '9') {
        sscanf(&str[p], "%lf", &stack[m++]);

        char w[128];
        sscanf(&str[p], "%s", w);

        p += strlen(w) + 1;
      }

      else {
        switch (str[p]) {
        case '+':
          stack[m - 2] += stack[m - 1];
          break;

        case '-':
          stack[m - 2] -= stack[m - 1];
          break;

        case '*':
          stack[m - 2] *= stack[m - 1];
          break;

        case '/':
          stack[m - 2] /= stack[m - 1];
          break;
        }

        m--;
        p += 2;

        //				printf("%lf\\n", stack[m - 1]);
      }
    }

    printf("%lf\\n", stack[0]);
  }

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

#include <iostream>
#include <stack>
#include <stdio.h>
#include <vector>

using namespace std;

typedef long double ldouble;
string in;

int main() {

  while (getline(cin, in)) {
    stack<ldouble> st;
    for (int i = 0; i < in.size(); i++) {

      if (i < in.size() - 1 && in[i] == '-' && in[i + 1] >= '0' &&
          in[i + 1] <= '9') {
        double s = 0;
        i++;
        while (1) {
          if (in[i] < '0' || in[i] > '9')
            break;
          s *= 10;
          s += in[i] - '0';
          i++;
        }
        st.push(-1 * s);
      }
      if (in[i] >= '0' && in[i] <= '9') {
        vector<char> V;
        while (1) {
          if (in[i] < '0' || in[i] > '9')
            break;
          V.push_back(in[i]);
          i++;
        }
        double kake = 1, sum = 0;
        for (int j = V.size() - 1; j >= 0; j--) {
          sum += (V[j] - '0') * kake;
          kake *= 10;
        }
        st.push(sum);
        // st.push(in[i]-'0');
        // cout << "push " << sum << endl;
      } else if (in[i] == '+' || in[i] == '/' || in[i] == '*' || in[i] == '-') {
        double num[2];
        num[0] = st.top();
        st.pop();
        num[1] = st.top();
        st.pop();
        if (in[i] == '+')
          st.push(num[1] + num[0]);
        if (in[i] == '-')
          st.push(num[1] - num[0]);
        if (in[i] == '/')
          st.push(num[1] / num[0]);
        if (in[i] == '*')
          st.push(num[1] * num[0]);
      }
    }
    printf("%.6Lf\\n", st.top());
    // cout << st.top() << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <stack>
#include <stdio.h>
#include <vector>

using namespace std;

typedef long double ldouble;

string in;

int main() {

  while (getline(cin, in)) {
    stack<ldouble> st;
    for (int i = 0; i < in.size(); i++) {
      if (in[i] >= '0' && in[i] <= '9') {
        vector<char> V;
        while (1) {
          if (in[i] < '0' || in[i] > '9')
            break;
          V.push_back(in[i]);
          i++;
        }
        int kake = 1, sum = 0;
        for (int j = V.size() - 1; j >= 0; j--) {
          sum += (V[j] - '0') * kake;
          kake *= 10;
        }
        st.push(sum);
        // st.push(in[i]-'0');
        // cout << "push " << sum << endl;
      } else if (in[i] == '+' || in[i] == '-' || in[i] == '/' || in[i] == '*') {
        int num[2];
        num[0] = st.top();
        st.pop();
        num[1] = st.top();
        st.pop();
        if (in[i] == '+')
          st.push(num[1] + num[0]);
        if (in[i] == '-')
          st.push(num[1] - num[0]);
        if (in[i] == '/')
          st.push(num[1] / num[0]);
        if (in[i] == '*')
          st.push(num[1] * num[0]);
      }
    }
    printf("%.6Lf\\n", st.top());
    // cout << st.top() << endl;
  }
  return 0;
}
Problem p00087 (C++) — buggy submission, verdict: Runtime Error

#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, j) for (int i = 0; i < j; i++)

double cal(vector<double> &v, string op) {
  double right = v[v.size() - 1];
  double left = v[v.size() - 2];
  v.pop_back();
  v.pop_back();
  if (op == "+")
    return left + right;
  if (op == "-")
    return left - right;
  if (op == "*")
    return left * right;
  if (op == "/")
    return left / right;
}

int main() {
  string str;
  while (getline(cin, str)) {
    stringstream ss(str);
    vector<double> v;
    while (ss >> str) {
      if (str.length() != 1 && str[0] == '-')
        v.push_back(-1.0 * atoi(str.substr(1).c_str()));
      else if (isdigit(str[0]))
        v.push_back((double)(atoi(str.c_str())));
      else
        v.push_back(cal(v, str));
    }
    printf("%.7lf\\n", v[0]);
  }
  return 0;
}

Error: WA

Fixed submission:

#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, j) for (int i = 0; i < j; i++)

int cal(vector<double> &v, string op) {
  int right = v[v.size() - 1];
  int left = v[v.size() - 2];
  v.pop_back();
  v.pop_back();
  if (op == "+")
    return left + right;
  if (op == "-")
    return left - right;
  if (op == "*")
    return left * right;
  if (op == "/")
    return left / right;
}

int main() {
  string str;
  while (getline(cin, str))
    cerr << str << endl;
  // while(getline(cin, str)){
  //     stringstream ss(str);
  //     vector<double> v;
  //     while(ss >>str){
  //         if(isdigit(str[0])) v.push_back( (double)(atoi(str.c_str())) );
  //         else v.push_back( cal(v, str) );
  //     }
  //     printf("%.7lf\\n", v[0]);
  // }
  return 0;
}