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

#include <iostream>
using namespace std;

int main() {
  int n[100] = {0};
  int a, b;
  int f = 0;
  while (cin >> a >> b) {
    n[a - 1]++;
    n[b - 1]++;
    if (a == 0) {
      f = 0;
      for (int i = 0; i < 100; i++) {
        if ((i < 2 && n[i] % 2 == 0) || (i >= 2 && n[i] % 2 == 1))
          f = 1;
        n[i] = 0;
      }
      if (f == 0)
        cout << "OK" << endl;
      else
        cout << "NG" << endl;
      n[100] = {0};
    }
  }
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {

  int a[101][101] = {{0}};

  int b[101] = {0};
  int u, v, f;

  //	for ( int k = 0; k < 50; k++ ) {

  while (cin >> u >> v) {
    while (1) {

      //			cin >> u >> v;

      if (u == v == 0)
        break;

      a[u][v] = 1;

      a[v][u] = 1;

      cin >> u >> v;
    }

    for (int i = 0; i < 101; i++)
      for (int j = 0; j < 101; j++)
        b[i] += a[i][j];
    f = 0;

    for (int i = 1; i < 101; i++) {

      if (i <= 2 && b[i] % 2 == 0)
        f = 1;

      if (i > 2 && b[i] % 2 == 1)
        f = 1;
    }

    if (f == 0)
      cout << "OK" << endl;

    else
      cout << "NG" << endl;
  }
}
Problem p00086 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int list[100];

int main(void) {
  int a, b;
  bool flag = false;
  while (scanf("%d %d", &a, &b) != EOF) {
    memset(list, 0, 100);
    list[a - 1]++;
    list[b - 1]++;
    while (true) {
      scanf("%d %d", &a, &b);
      if (!a && !b)
        break;
      list[a - 1]++;
      list[b - 1]++;
    }
    flag = false;
    if (!(list[0] & 1) || !(list[1] & 1))
      flag = true;
    for (int i = 2; i < 100; i++) {
      if (list[i] & 1)
        flag = true;
    }
    if (!flag)
      printf("OK\\n");
    else
      printf("NG\\n");
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int list[100];

int main(void) {
  int a, b;
  bool flag = false;
  while (scanf("%d %d", &a, &b)) {
    memset(list, 0, 100);
    list[a - 1]++;
    list[b - 1]++;
    while (true) {
      scanf("%d %d", &a, &b);
      if (!a && !b)
        break;
      list[a - 1]++;
      list[b - 1]++;
    }
    flag = false;
    if (!(list[0] & 1) || !(list[1] & 1))
      flag = true;
    for (int i = 2; i < 100; i++) {
      if (list[i] & 1)
        flag = true;
    }
    if (!flag)
      printf("OK\\n");
    else
      printf("NG\\n");
  }
  return 0;
}
Problem p00086 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int n, m;
  while (cin >> n >> m, n || m) {
    int f[101] = {0}, x = 0;
    for (int i = 0;; i++) {
      if (i != 0)
        cin >> n >> m;
      if (n == 0 && m == 0)
        break;
      f[n]++;
      f[m]++;
    }
    for (int i = 1; i < 101; i++)
      x += f[i] % 2;
    if (x == 2)
      cout << "OK" << endl;
    else
      cout << "NG" << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    vector<pair<double, double>> dot;
    bool f[100] = {false};
    for (double i = 0, a, b; i < n; i++) {
      scanf("%lf,%lf", &a, &b);
      dot.push_back(make_pair(a, b));
    }
    sort(dot.begin(), dot.end());
    int now = 0, next;
    for (;;) {
      for (int i = 0; i < n; i++) {
        if (i != now && !f[i]) {
          next = i;
          double ax = dot[i].first - dot[now].first;
          double ay = dot[i].second - dot[now].second;
          for (int j = 0; j < n; j++) {
            if (!f[j]) {
              double bx = dot[j].first - dot[now].first;
              double by = dot[j].second - dot[now].second;
              if (ax * by - ay * bx < 0) {
                next = -1;
                break;
              }
            }
          }
          if (next == i)
            break;
        }
      }
      f[next] = true;
      now = next;
      if (f[0])
        break;
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
      if (!f[i])
        ans++;
    cout << ans << endl;
  }
  return 0;
}
Problem p00086 (C++) — buggy submission, verdict: Memory Limit Exceeded

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

int dim[100000];

void init() { fill(dim, dim + 100000, 0); }

bool hitofude() {
  if ((dim[1] * dim[2] + 1) % 2) {
    return false;
  }
  for (int i = 3; i < 100000; i++) {
    if (dim[i] % 2) {
      return false;
    }
  }
  return true;
}

int main() {
  int a, b;
  init();
  while (scanf("%d%d", &a, &b) != EOF) {
    dim[a]++;
    dim[b]++;
    if (a == 0 && b == 0) {
      if (hitofude()) {
        printf("OK\\n");
      } else {
        printf("NG\\n");
      }
      init();
    }
  }
}

Error: MLE

Fixed submission:

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

int dim[100000000];

void init() { fill(dim, dim + 110, 0); }

bool hitofude() {
  if ((dim[1] + dim[2]) % 2) {
    return false;
  }
  for (int i = 3; i < 100000000; i++) {
    if (dim[i] % 2) {
      return false;
    }
  }
  return true;
}

int main() {
  int a, b;
  init();
  while (scanf("%d%d", &a, &b) != EOF) {
    dim[a]++;
    dim[b]++;
    if (a == 0 && b == 0) {
      if (hitofude()) {
        printf("OK\\n");
      } else {
        printf("NG\\n");
      }
      init();
    }
  }
}
Problem p00086 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <time.h>
using namespace std;
#define INF 10000000
typedef long long ll;
int n[101];
int main() {
  int a, b, flg;
  while (1) {
    flg = 0;
    for (int i = 0; i < 101; i++)
      n[i] = 0;
    while (1) {
      if (!(cin >> a >> b))
        return 0;
      if (a + b == 0)
        break;
      n[a]++;
      n[b]++;
    }
    if (n[1] % 2 != 1 || n[2] % 2 != 1)
      flg = 1;
    for (int i = 3; i <= 100 && flg != 1; i++) {
      if (n[i] % 2 == 1)
        flg = 1;
    }
    if (flg == 1) {
      cout << "NG" << endl;
    } else {
      cout << "OK" << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int n[101];
int main() {
  int a, b, flg;
  while (1) {
    flg = 0;
    for (int i = 0; i < 101; i++)
      n[i] = 0;
    while (1) {
      cin >> a >> b;
      if (a + b == 0)
        break;
      n[a]++;
      n[b]++;
    }
    for (int i = 3; i <= 100 && flg != 1; i++) {
      if (n[i] % 2 == 1)
        flg = 1;
    }
    if (flg == 1) {
      cout << "NG" << endl;
    } else {
      cout << "OK" << endl;
    }
  }
  return 0;
}
Problem p00086 (C++) — buggy submission, verdict: Runtime Error

// coding on smartphone
#include <iostream>
using namespace std;

int main() {
  int a, b;
  while (cin >> a >> b) {
    int deg[101] = {};
    deg[a]++, deg[b]++;
    while (cin >> a >> b, a + b)
      deg[a]++, deg[b]++;
    bool judge = deg[1] % 2 == 1 && deg[2] % 2 == 1;
    for (int i = 3; i < 51; i++)
      if (deg[i] % 2)
        judge = false;
    if (judge)
      cout << "OK" << endl;
    else
      cout << "NG" << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

// coding on smartphone
#include <iostream>
using namespace std;

int main() {
  int a, b;
  while (cin >> a >> b) {
    int deg[51] = {};
    deg[a]++, deg[b]++;
    while (cin >> a >> b, a + b)
      deg[a]++, deg[b]++;
    bool judge = deg[1] % 2 == 1 && deg[2] % 2 == 1;
    for (int i = 3; i < 51; i++)
      if (deg[i] % 2)
        judge = false;
    if (judge)
      cout << "OK" << endl;
    else
      cout << "NG" << endl;
  }
  return 0;
}
Problem p00087 (C++) — buggy submission, verdict: Runtime Error

#include <iomanip>
#include <iostream>
#include <stack>
#include <string>
using namespace std;
string S, U[1000];
stack<double> T;
int cnt;
double a, b;
int main() {
  while (getline(cin, S)) {
    for (int i = 0; i < 1000; i++) {
      U[i] = "";
    }
    cnt = 0;
    for (int i = 0; i < S.size(); i++) {
      if (S[i] == ' ') {
        cnt++;
      } else {
        U[cnt] += S[i];
      }
    }
    cnt++;
    for (int i = 0; i < cnt; i++) {
      if (U[i] == "+") {
        a = T.top();
        T.pop();
        b = T.top();
        T.pop();
        T.push(a + b);
      } else if (U[i] == "-") {
        a = T.top();
        T.pop();
        b = T.top();
        T.pop();
        T.push(b - a);
      } else if (U[i] == "*") {
        a = T.top();
        T.pop();
        b = T.top();
        T.pop();
        T.push(a * b);
      } else if (U[i] == "/") {
        a = T.top();
        T.pop();
        b = T.top();
        T.pop();
        T.push(b / a);
      } else {
        T.push(stoi(U[i]));
      }
    }
    cout << fixed << setprecision(20) << T.top() << endl;
    T.pop();
  }
}

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


Fixed submission:

#include <iomanip>
#include <iostream>
#include <stack>
#include <string>
using namespace std;
string S, U[1000];
stack<double> T;
int cnt;
double a, b;
int main() {
  while (getline(cin, S)) {
    cnt = 0;
    for (int i = 0; i < S.size(); i++) {
      if (S[i] == ' ') {
        cnt++;
      } else {
        U[cnt] += S[i];
      }
    }
    cnt++;
    for (int i = 0; i < cnt; i++) {
      if (U[i] == "+") {
        a = T.top();
        T.pop();
        b = T.top();
        T.pop();
        T.push(a + b);
      } else if (U[i] == "-") {
        a = T.top();
        T.pop();
        b = T.top();
        T.pop();
        T.push(b - a);
      } else if (U[i] == "*") {
        a = T.top();
        T.pop();
        b = T.top();
        T.pop();
        T.push(a * b);
      } else if (U[i] == "/") {
        a = T.top();
        T.pop();
        b = T.top();
        T.pop();
        T.push(b / a);
      } else {
        T.push(stoi(U[i]));
      }
    }
    cout << fixed << setprecision(20) << T.top() << endl;
    T.pop();
  }
}
Problem p00087 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int cur;
string s;
stack<double> st;

int digit() { return s[cur++] - '0'; }

double number() {
  double n = digit();
  while (isdigit(s[cur]))
    n = n * 10 + digit();
  return n;
}

int main() {
  while (getline(cin, s)) {
    cur = 0;
    while (cur < s.size()) {
      if (isdigit(s[cur])) {
        // double n=digit();
        // while(isdigit(s[cur]))n=n*10+digit();
        st.push(number());
      } else {
        char op = s[cur++];
        if (cur == s.size() || s[cur] == ' ') {
          double v2 = st.top();
          st.pop();
          double v1 = st.top();
          st.pop();
          if (op == '+')
            st.push(v1 + v2);
          if (op == '-')
            st.push(v1 - v2);
          if (op == '*')
            st.push(v1 * v2);
          if (op == '/')
            st.push(v1 / v2);
        } else
          st.push(-number());
      }
      cur++;
    }
    printf("%.6f\\n", st.top());
    st.pop();
  }
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int cur;
string s;
stack<double> st;

int digit() { return s[cur++] - '0'; }

int main() {
  while (getline(cin, s)) {
    cur = 0;
    while (cur < s.size()) {
      if (isdigit(s[cur])) {
        double n = digit();
        while (isdigit(s[cur]))
          n = n * 10 + digit();
        st.push(n);
      } else {
        char op = s[cur++];
        double v2 = st.top();
        st.pop();
        double v1 = st.top();
        st.pop();
        if (op == '+')
          st.push(v1 + v2);
        if (op == '-')
          st.push(v1 - v2);
        if (op == '*')
          st.push(v1 * v2);
        if (op == '/')
          st.push(v1 / v2);
      }
      cur++;
    }
    cout << st.top() << endl;
    st.pop();
  }
}
Problem p00087 (C++) — buggy submission, verdict: Runtime Error

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

int calculate(std::string str);
double arithmetic(double, double, char);

int main() {
  std::string str;

  while (std::getline(std::cin, str))
    calculate(str);

  return 0;
}

int calculate(std::string str) {
  std::stringstream ss(str);
  std::stack<double> st;
  std::string s;

  while (ss >> s) {
    if (s.size() == 1) {
      switch (s.at(0)) {
      case '+':
      case '-':
      case '*':
      case '/': {
        double a = st.top();
        st.pop();
        double b = st.top();
        st.pop();
        st.push(arithmetic(b, a, s.at(0)));
        break;
      }
      default:
        st.push(s.at(0) - '0');
      }
    } else {
      std::stringstream stod(s);
      double temp;
      stod >> temp;
      st.push(temp);
    }
  }

  std::cout << std::setprecision(6) << std::setiosflags(std::ios::fixed)
            << st.top() << std::endl;

  return 0;
}

double arithmetic(double a, double b, char op) {
  switch (op) {
  case '+':
    return a + b;
  case '-':
    return a - b;
  case '*':
    return a * b;
  case '/':
    if (b == 0.0)
      throw "0 devide";
    return a / b;
  default:
    throw "operator error";
  }
}

Error: -11

Fixed submission:

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

int calculate(std::string str);
double arithmetic(double, double, char);

int main() {
  std::string str;

  while (std::getline(std::cin, str))
    calculate(str);

  return 0;
}

int calculate(std::string str) {
  std::stringstream ss(str);
  std::stack<double> st;
  std::string s;

  while (ss >> s) {
    switch (s.at(0)) {
    case '+':
    case '-':
    case '*':
    case '/': {
      double a = st.top();
      st.pop();
      double b = st.top();
      st.pop();
      st.push(arithmetic(b, a, s.at(0)));
      break;
    }
    default: {
      std::stringstream stod(s);
      double temp;
      stod >> temp;
      st.push(temp);
      break;
    }
    }
  }

  std::cout << std::setprecision(6) << std::setiosflags(std::ios::fixed)
            << st.top() << std::endl;

  return 0;
}

double arithmetic(double a, double b, char op) {
  switch (op) {
  case '+':
    return a + b;
  case '-':
    return a - b;
  case '*':
    return a * b;
  case '/':
    if (b == 0.0)
      throw "0 devide";
    return a / b;
  default:
    throw "operator error";
  }
}
Problem p00087 (C++) — buggy submission, verdict: Runtime Error

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

using namespace std;

void solve() {
  string str;
  while (getline(cin, str)) {
    stack<double> digits;
    stringstream ss(str);
    string temp;
    while (ss >> temp) {
      if (temp == "+" || temp == "-" || temp == "*" || temp == "/") {
        double n1, n2;
        n2 = digits.top();
        digits.pop();
        n1 = digits.top();
        digits.pop();
        if (temp == "+") {
          digits.push(n1 + n2);
        } else if (temp == "-") {
          digits.push(n1 - n2);
        } else if (temp == "*") {
          digits.push(n1 * n2);
        } else if (temp == "/") {
          digits.push(n1 / n2);
        }
      } else {
        digits.push(atof(temp.c_str()));
      }
    }
    printf("%.6f\\n", digits.top());
  }
}

int main() {
  solve();
  return (0);
}

Error: -11

Fixed submission:

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

using namespace std;

void solve() {
  string str;
  while (getline(cin, str)) {
    stack<double> digits;
    int digit = 0;
    bool flag = false;
    for (int i = 0; i < str.size(); ++i) {
      if (str[i] == ' ') {
        flag = false;
        digits.push(digit);
        digit = 0;
      } else if (str[i] == '+' || str[i] == '-' || str[i] == '*' ||
                 str[i] == '/') {
        double a = digits.top();
        digits.pop();
        double b = digits.top();
        digits.pop();
        if (str[i] == '+') {
          digits.push(b + a);
        } else if (str[i] == '-') {
          digits.push(b - a);
        } else if (str[i] == '*') {
          digits.push(b * a);
        } else if (str[i] == '/') {
          digits.push(b / a);
        }
        ++i;
      } else {
        if (flag) {
          digit *= 10;
        }
        digit += str[i] - '0';
        flag = true;
      }
    }
    printf("%.6f\\n", digits.top());
  }
}

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

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

using namespace std;

int main() {
  char s[500];
  stack<double> S;
  while (scanf("%s", s) != EOF) {
    if ((s[0] < '0' || s[0] > '9') && (!s[1])) {
      double r = S.top();
      S.pop();
      double l = S.top();
      S.pop();
      switch (s[0]) {
      case '+':
        l += r;
        break;
      case '-':
        l -= r;
        break;
      case '*':
        l *= r;
        break;
      case '/':
        l /= r;
        break;
      }
      S.push(l);
    } else {
      S.push((double)atoi(s));
    }

    char c;
    if (scanf("%c", &c) == EOF || c != ' ') {
      printf("%.10f\\n", S.top());
      S.pop();
    }
  }
}

Error: -11

Fixed submission:

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

using namespace std;

int main() {
  char s[500];
  stack<double> S;
  while (scanf("%s", s) != EOF) {
    if (s[0] < '0' || s[0] > '9') {
      if (!S.empty()) {
        double r = S.top();
        S.pop();
        double l = S.top();
        S.pop();
        switch (s[0]) {
        case '+':
          l += r;
          break;
        case '-':
          l -= r;
          break;
        case '*':
          l *= r;
          break;
        case '/':
          l /= r;
          break;
        }
        S.push(l);
      }
    } else {
      S.push((double)atoi(s));
    }

    char c;
    if (scanf("%c", &c) == EOF || c != ' ') {
      if (!S.empty()) {
        printf("%.10f\\n", S.top());
        S.pop();
      }
    }
  }
}
Problem p00087 (C++) — buggy submission, verdict: Runtime Error

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

pair<double, string> ds(string s) {
  stringstream ss(s);
  double res1 = 0;
  string res2 = "";
  ss >> res1;
  ss.ignore(100, ' ');
  getline(ss, res2);
  return make_pair(res1, res2);
}

pair<char, string> cs(string s) {
  stringstream ss(s);
  char res1 = 0;
  string res2 = "";
  ss >> res1;
  ss.ignore(100, ' ');
  getline(ss, res2);
  return make_pair(res1, res2);
}

double solve(string s) {
  stack<double> st;
  double res = 0;
  while (s.size() != 0) {
    while (s[0] == ' ')
      s = s.substr(1);
    if ((s[0] == '+' || s[0] == '-' || s[0] == '/' || s[0] == '*') &&
        (s.size() == 1 || s[1] == ' ')) {
      auto tmp = cs(s);
      char c = tmp.first;
      s = tmp.second;
      double b = st.top();
      st.pop();
      double a = st.top();
      st.pop();
      switch (c) {
      case '+':
        a += b;
        break;
      case '/':
        a /= b;
        break;
      case '*':
        a *= b;
        break;
      case '-':
        a -= b;
        break;
      }
      st.push(a);
    } else {
      auto tmp = ds(s);
      st.push(tmp.first);
      s = tmp.second;
    }
  }
  return st.top();
}

int main() {
  string s;
  while (!cin.eof()) {
    getline(cin, s);
    if (s.size() == 0)
      return 0;
    cout << setprecision(100) << solve(s) << endl;
  }
}

Error: -11

Fixed submission:

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

pair<double, string> ds(string s) {
  stringstream ss(s);
  double res1 = 0;
  string res2 = "";
  ss >> res1;
  ss.ignore(100, ' ');
  getline(ss, res2);
  return make_pair(res1, res2);
}

pair<char, string> cs(string s) {
  stringstream ss(s);
  char res1 = 0;
  string res2 = "";
  ss >> res1;
  ss.ignore(100, ' ');
  getline(ss, res2);
  return make_pair(res1, res2);
}

double solve(string s) {
  stack<double> st;
  double res = 0;
  while (s.size() != 0) {
    while (s[0] == ' ')
      s = s.substr(1);
    if (s[0] == '+' || s[0] == '-' || s[0] == '/' || s[0] == '*') {
      auto tmp = cs(s);
      char c = tmp.first;
      s = tmp.second;
      double b = st.top();
      st.pop();
      double a = st.top();
      st.pop();
      switch (c) {
      case '+':
        a += b;
        break;
      case '/':
        a /= b;
        break;
      case '*':
        a *= b;
        break;
      case '-':
        a -= b;
        break;
      }
      st.push(a);
    } else {
      auto tmp = ds(s);
      st.push(tmp.first);
      s = tmp.second;
    }
  }
  return st.top();
}

int main() {
  string s;
  while (!cin.eof()) {
    getline(cin, s);
    if (s.size() == 0)
      return 0;
    cout << solve(s) << endl;
  }
}
Problem p00087 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  string s;
  while (getline(cin, s)) {
    int n = s.size();

    stack<double> sd;
    for (int i = 0; i < n; i++) {
      if (s[i] == ' ')
        continue;
      if (s[i] == '-' && isdigit(s[i + 1])) {
        double res = 0;
        i++;
        while (isdigit(s[i]))
          res = res * 10 + s[i] - '0', i++;
        sd.push(-res);
      } else if (isdigit(s[i])) {
        double res = 0;
        while (isdigit(s[i]))
          res = res * 10 + s[i] - '0', i++;
        sd.push(res);
      } else {

        double a, b;
        b = sd.top();
        sd.pop();
        a = sd.top();
        sd.pop();

        if (s[i] == '+')
          sd.push(a + b);
        if (s[i] == '-')
          sd.push(a - b);
        if (s[i] == '*')
          sd.push(a * b);
        if (s[i] == '/')
          sd.push(a / b);
      }
    }

    double ans = sd.top();
    printf("%.12lf\\n", ans);
  }
  return 0;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  string s;
  while (getline(cin, s)) {
    int n = s.size();

    stack<double> sd;
    for (int i = 0; i < n; i++) {
      if (s[i] == ' ')
        continue;
      if (isdigit(s[i])) {
        double res = 0;
        while (isdigit(s[i]))
          res = res * 10 + s[i] - '0', i++;
        sd.push(res);
      } else {

        double a, b;
        b = sd.top(); // sd.pop();
        a = sd.top(); // sd.pop();

        // if(s[i]=='+') sd.push(a+b);
        // if(s[i]=='-') sd.push(a-b);
        if (s[i] == '*')
          sd.push(a * b);
        // if(s[i]=='/') sd.push(a/b);
      }
    }

    double ans = sd.top();
    printf("%.12lf\\n", ans);
  }
  return 0;
}