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

#define scanf_s scanf
// #define sscanf_s sscanf
// #define gets_s gets
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
using namespace std;
#define MAX 1001
#define _MAX 100
#define HO 6
int main(void) {
  char str[MAX];
  string word[_MAX];
  int pa[_MAX], rank[_MAX], cou, a;
  for (cou = 0; scanf_s("%s %d", str, &pa[cou]) != EOF; ++cou) {
    string wo(str);
    word[cou] = wo;
    rank[cou] = cou;
  }
  for (int i = 0; i < cou; ++i) {
    for (int j = cou - 1; j > i; --j) {
      if (word[rank[j]] <= word[rank[j - 1]]) {
        if (word[rank[j]] == word[rank[j - 1]]) {
          if (pa[rank[j]] < pa[rank[j - 1]]) {
            a = rank[j];
            rank[j] = rank[j - 1];
            rank[j - 1] = a;
          }
        } else {
          a = rank[j];
          rank[j] = rank[j - 1];
          rank[j - 1] = a;
        }
      }
    }
  }
  for (int i = 0; i < cou; ++i) {
    if (i == 0 || word[rank[i - 1]] != word[rank[i]])
      cout << word[rank[i]] << "\\n";
    if (i != 0 && word[rank[i - 1]] == word[rank[i]])
      printf(" ");
    printf("%d", pa[rank[i]]);
    if (i != cou - 1 && word[rank[i + 1]] != word[rank[i]])
      printf("\\n");
  }
  printf("\\n");
}

Error: -11

Fixed submission:

#define scanf_s scanf
// #define sscanf_s sscanf
// #define gets_s gets
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
using namespace std;
#define MAX 1001
#define _MAX 100
#define HO 6
int main(void) {
  char str[MAX];
  string word[_MAX];
  int pa[_MAX], rank[_MAX], cou, a;
  for (cou = 0; scanf_s("%s %d", str, MAX, &pa[cou]) != EOF; ++cou) {
    string wo(str);
    word[cou] = wo;
    rank[cou] = cou;
  }
  for (int i = 0; i < cou; ++i) {
    for (int j = cou - 1; j > i; --j) {
      if (word[rank[j]] <= word[rank[j - 1]]) {
        if (word[rank[j]] == word[rank[j - 1]]) {
          if (pa[rank[j]] < pa[rank[j - 1]]) {
            a = rank[j];
            rank[j] = rank[j - 1];
            rank[j - 1] = a;
          }
        } else {
          a = rank[j];
          rank[j] = rank[j - 1];
          rank[j - 1] = a;
        }
      }
    }
  }
  for (int i = 0; i < cou; ++i) {
    if (i == 0 || word[rank[i - 1]] != word[rank[i]])
      cout << word[rank[i]] << "\\n";
    if (i != 0 && word[rank[i - 1]] == word[rank[i]])
      printf(" ");
    printf("%d", pa[rank[i]]);
    if (i != cou - 1 && word[rank[i + 1]] != word[rank[i]])
      printf("\\n");
  }
  printf("\\n");
}
Problem p00106 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

int v, dp[5001];
const int m[] = {200, 300, 500, 1000, 1200, 1500};
const int p[] = {380, 550, 850, 1520, 1870, 2244};
const int INF = 10000000;

/*
  @ツ残ツづィツづ個重ツつウ
*/

int dfs(int w) {
  if (w <= 0)
    return 0;
  if (dp[w] >= 0)
    return dp[w];
  int res = INF;
  rep(i, 6) { res = min(res, dfs(w - m[i]) + p[i]); }
  return dp[w] = res;
}

void solve() { cout << dp[v] << endl; }

int main(int argc, char const *argv[]) {
  rep(i, 5001) dp[i] = INF;

  dp[0] = 0;
  rep(z, 6) for (int i = 0; i + m[z] < 5001; i++) {
    dp[i + m[z]] = min(dp[i + m[z]], dp[i] + p[z]);
  }

  while (cin >> v, v) {
    solve();
  }
  return 0;
}

Error: TLE

Fixed submission:

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

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

int v;
const int m[] = {200, 300, 500, 1000, 1200, 1500};
const int p[] = {380, 550, 850, 1520, 1870, 2244};
const int INF = 10000000;

/*
  @ツ残ツづィツづ個重ツつウ
*/
int dfs(int w) {
  if (w <= 0)
    return 0;
  int res = INF;
  rep(i, 6) { res = min(res, dfs(w - m[i]) + p[i]); }
  return res;
}

void solve() { cout << dfs(v) << endl; }

int main(int argc, char const *argv[]) {
  while (cin >> v, v) {
    solve();
  }
  return 0;
}
Problem p00106 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;
int c;
int d[52];
int item[] = {2, 3, 5, 10, 12, 15};
int price[] = {380, 550, 850, 380 * 5 * 0.8, 550 * 4 * 0.85, 850 * 3 * 0.88};

void dp(int i) {
  for (int j = 0; j < 6; j++) {
    if (i + item[j] < 51) {
      d[i + item[j]] = min(d[i + item[j]], d[i] + price[j]);
      dp(i + item[j]);
    }
  }
  return;
}

int main(void) {
  int n;
  for (int i = 0; i < 52; i++) {
    d[i] = 1000000;
  }
  d[0] = 0;
  dp(0);
  while (cin >> n, n != 0) {
    cout << d[n / 100] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;

int Max;

void solve(int n, int k) {
  if (n <= 0) {
    Max = min(k, Max);
    return;
  }
  solve(n - 200 * 5, k + 380 * 0.8 * 5);
  solve(n - 300 * 4, k + 550 * 0.85 * 4);
  solve(n - 500 * 3, k + 850 * 0.88 * 3);
  solve(n - 200, k + 380);
  solve(n - 300, k + 550);
  solve(n - 500, k + 850);
  return;
}

int main(void) {
  int n;
  while (cin >> n, n != 0) {
    Max = 9999999;
    solve(n, 0);
    cout << Max << endl;
  }
  return 0;
}
Problem p00106 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
#define gram_a 200
#define gram_b 300
#define gram_c 500
#define yen_a 380
#define yen_b 550
#define yen_c 850
#define set_a 5
#define set_b 4
#define set_c 3
#define dis_a 0.8
#define dis_b 0.85
#define dis_c 0.88
/*
int main() {
        int n,a, b, c;
        a = 0;
        b = 0;
        c = 0;
        while (1) {
                cout << "a = " << a << " b = " << b << " c = "<<c << endl;
                cout << "g = " << gram_a * a + gram_b * b + gram_c * c << endl;
                cout <<"y = "<< set_a * ((int)(a / set_a))*yen_a*dis_a +
(a%set_a)*yen_a + set_b * ((int)(b / set_b))*yen_b*dis_b + (b%set_b)*yen_b +
                        set_c * ((int)(c / set_c))*yen_c*dis_c + (c%set_c)*yen_c
                        << endl;
                cin >> n;
                if (n == 1)
                        c++;
                if (n == 2) {
                        b++;
                        c = 0;
                }
                if (n == 3) {
                        a++;
                        b = 0;
                        c = 0;
                }
        }

}
*/

int main() {
  int n;
  while (cin >> n) {
    if (n == 0)
      break;
    int i, a = 0, b = 0, c = 0, min = 0, y, g;
    bool f = true, brk = false;
    for (a = 0;; a++) {
      for (b = 0;; b++) {
        for (c = 0;; c++) {
          brk = false;
          g = gram_a * a + gram_b * b + gram_c * c;
          if (n == g) {
            y = set_a * ((int)(a / set_a)) * yen_a * dis_a +
                (a % set_a) * yen_a +
                set_b * ((int)(b / set_b)) * yen_b * dis_b +
                (b % set_b) * yen_b +
                set_c * ((int)(c / set_c)) * yen_c * dis_c +
                (c % set_c) * yen_c;
            if (min > y || f) {
              min = y;
              f = false;
            }
            break;
          }
          if (n < g) {
            if (c == 0)
              brk = true;
            break;
          }
        }
        if (brk) {
          if (b > 0)
            brk = false;
          break;
        }
      }
      if (brk)
        break;
    }
    cout << min << endl;
  }
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  long long int n, r, d, w, h, x;
  while (1) {
    cin >> d >> w >> h;
    if (d + w + h == 0)
      return 0;
    if (d <= h && w <= h)
      x = d * d + w * w;
    else if (d <= w && h <= w)
      x = d * d + h * h;
    else if (w <= d && h <= d)
      x = w * w + h * h;
    cout << x;
    cin >> n;
    for (int lop = 0; lop < n; lop++) {
      cin >> r;
      if (4 * r * r >= x)
        cout << "OK\\n";
      else
        cout << "NA\\n";
    }
  }
  return 0;
}
Problem p00106 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#define INF 1 << 28
using namespace std;

int memo[10000];

int solve(int n) {
  int res = INF;
  if (!n)
    return 0;
  if (n < 0)
    return INF;
  if (memo[n])
    return memo[n];
  return memo[n] = res =
             min(res, min(solve(n - 1000) + 1520,
                          min(solve(n - 1200) + 1870,
                              min(solve(n - 1500) + 2244,
                                  min(solve(n - 200) + 380,
                                      min(solve(n - 300) + 550,
                                          solve(n - 500) + 850))))));
}

int main() {
  int n;
  for (int i = 0; i < 5001; i++)
    solve(i);
  while (cin >> n, n)
    cout << memo[n] << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#define INF 1 << 28
using namespace std;

int solve(int n) {
  int res = INF;
  if (!n)
    return 0;
  if (n < 0)
    return INF;
  return res = min(res, min(solve(n - 1000) + 1520,
                            min(solve(n - 1200) + 1870,
                                min(solve(n - 1500) + 2244,
                                    min(solve(n - 200) + 380,
                                        min(solve(n - 300) + 550,
                                            solve(n - 500) + 850))))));
}

int main() {
  int n;
  while (cin >> n, n)
    cout << solve(n) << endl;
}
Problem p00106 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#define INF 1000000000

int price;
int weight;

int main() {
  while (scanf("%d", &weight), weight) {
    price = INF;
    for (int i = 0; i <= 25; i++) {
      for (int j = 0; j <= 16; j++) {
        for (int k = 0; k <= 10; k++) {
          int w = i * 200 + j * 300 + k * 500;
          if (weight == w) {
            int calc_price = ((i / 5) * 5) * 380 * 0.8 + (i % 5) * 380 +
                             ((j / 4) * 4) * 550 * 0.85 + (j % 4) * 550 +
                             ((k / 3) * 3) * 850 * 0.88 + (k % 3) * 850;
            if (price > calc_price) {
              price = calc_price;
            }
            break;
          } else if (weight < w) {
            break;
          }
        }
      }
    }

    printf("%d\\n", price);
  }
}

Error: TLE

Fixed submission:

#include <cstdio>
#define INF 1000000000

int price;
int dp[11][11][11]; // dp table
int weight;

void solve(int a, int b, int c) {
  if (dp[a][b][c] != INF)
    return;

  int w = a * 200 + b * 300 + c * 500;
  int calc_price = ((a / 5) * 5) * 380 * 0.8 + (a % 5) * 380 +
                   ((b / 4) * 4) * 550 * 0.85 + (b % 4) * 550 +
                   ((c / 3) * 3) * 850 * 0.88 + (c % 3) * 850;

  if (weight == w) {
    if (price >= calc_price) {
      price = calc_price;
      dp[a][b][c] = calc_price;
    }
    return;
  } else if (weight < w) {
    return;
  } else {
    solve(a + 1, b, c);
    solve(a, b + 1, c);
    solve(a, b, c + 1);
  }
}

int main() {
  while (scanf("%d", &weight), weight) {
    for (int i = 0; i < 11; i++)
      for (int j = 0; j < 11; j++)
        for (int k = 0; k < 11; k++)
          dp[i][j][k] = INF;

    price = INF;
    solve(0, 0, 0);

    printf("%d\\n", price);
  }
}
Problem p00106 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair<INT, INT> II;
typedef vector<II> VII;

template <class T> ostream &operator<<(ostream &os, vector<T> v) {
  for (typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i) {
    os << *it_i << ", ";
  }
  return os;
}

typedef long long LL;

double calc(int n, double value, int k, double p) {
  return value * (int)(n - n % k) * p + (n % k) * value;
}

LL solve(int n) {
  LL res = INT_MAX;
  int W[3] = {200, 300, 500};
  int V[3] = {380, 550, 850};
  int K[3] = {5, 4, 3};
  double P[3] = {0.8, 0.85, 0.88};
  for (int a = 0; a < 100; ++a) {
    for (int b = 0; b < 100; ++b) {
      for (int c = 0; c < 100; ++c) {
        int sumW = W[0] * a + W[1] * b + W[2] * c;
        if (sumW != n)
          continue;
        res = min(res,
                  (LL)(calc(a, V[0], K[0], P[0]) + calc(b, V[1], K[1], P[1]) +
                       calc(c, V[2], K[2], P[2])));
      }
    }
  }
  return res;
}

int main() {
  int n;
  while (cin >> n && n) {
    cout << solve(n) << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int na, nb, nc;
const int inf = INT_MAX;

int solve(int n) {
  if (n <= 0) {
    int ra = na % 5;
    int rb = nb % 4;
    int rc = nc % 3;
    int nna = na - ra;
    int nnb = nb - rb;
    int nnc = nc - rc;
    return (nna * 380) * 0.8 + 380 * ra + (550 * nnb) * 0.85 + 550 * rb +
           (850 * nnc) * 0.88 + 850 * rc;
  }
  int answer = inf;
  na++;
  answer = min(answer, solve(n - 200));
  na--;
  nb++;
  answer = min(answer, solve(n - 300));
  nb--;
  nc++;
  answer = min(answer, solve(n - 500));
  nc--;
  return answer;
}

int main() {
  int n;
  while (cin >> n && n != 0) {
    na = nb = nc = 0;
    cout << solve(n) << endl;
  }
  return 0;
}
Problem p00106 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
using namespace std;
const int INT_MAX = 1e+7;

int main() {
  int m[5001];
  for (int i = 0; i < 5001; i++) {
    m[i] = INT_MAX;
  }
  for (int a = 0; a < 20; a++) {
    for (int b = 0; b < 20; b++) {
      for (int c = 0; c < 20; c++) {
        int cost = (a * 380) - (a / 5 * 380) + (b * 550) - (b / 4 * 330) +
                   (c * 850) - (c / 3 * 306);
        int w = a * 200 + b * 300 + c * 500;
        if (w <= 5000) {
          m[w] = min(m[w], cost);
        }
      }
    }
  }
  int n;
  while (cin >> n, n) {
    cout << m[n] << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int n, ans;
int w[] = {200, 300, 500};
int p[] = {380, 550, 850};
int k[] = {5, 4, 3};
int d[] = {380, 330, 306};

void solve(int weight, int cost, vector<int> num) {
  if (weight >= n) {
    ans = min(ans, cost);
    return;
  }
  for (int i = 0; i < 3; i++) {
    num[i]++;
    int cost_ = cost;
    if (num[i] % k[i] == 0) {
      cost_ -= d[i];
    }
    solve(weight + w[i], cost_ + p[i], num);
    num[i]--;
  }
}

int main() {
  while (cin >> n, n) {
    vector<int> num;
    for (int i = 0; i < 3; i++)
      num.push_back(0);
    ans = 1000000;
    solve(0, 0, num);
    cout << ans << endl;
  }
}
Problem p00106 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef complex<double> Point;

int main() {
  int answers[64];
  int dp[64][8][4][4];

  rep(i, 51) {
    answers[i] = 1 << 29;
    rep(j, 5) rep(k, 4) rep(l, 3) {
      int ans = i + j + k + l ? 1 << 29 : 0;
      if (2 <= i && j)
        ans = min(ans, dp[i - 2][j - 1][k][l] + 380);
      if (10 <= i && !j)
        ans = min(ans, dp[i - 10][0][k][l] + 1520);
      if (3 <= i && k)
        ans = min(ans, dp[i - 3][j][k - 1][l] + 550);
      if (12 <= i && !k)
        ans = min(ans, dp[i - 12][j][0][l] + 1870);
      if (5 <= i && l)
        ans = min(ans, dp[i - 5][j][k][l - 1] + 850);
      if (15 <= i && !l)
        ans = min(ans, dp[i - 15][j][k][0] + 2244);
      dp[i][j][k][l] = ans;
      answers[i] = min(answers[i], ans);
    }
  }

  int weight;
  while (scanf("%d", &weight), weight) {
    printf("%d\\n", answers[weight / 100]);
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef complex<double> Point;

int solve(int weight, int a, int b, int c) {
  int sum = a * 200 + b * 300 + c * 500;

  if (sum == weight)
    return a / 5 * 1520 + a % 5 * 380 + b / 4 * 1870 + b % 4 * 550 +
           c / 3 * 2244 + c % 3 * 850;

  int best = 1 << 29;
  if (sum + 200 <= weight)
    best = min(best, solve(weight, a + 1, b, c));
  if (sum + 300 <= weight)
    best = min(best, solve(weight, a, b + 1, c));
  if (sum + 500 <= weight)
    best = min(best, solve(weight, a, b, c + 1));

  return best;
}

int main() {
  int weight;
  while (scanf("%d", &weight), weight) {
    printf("%d\\n", solve(weight, 0, 0, 0));
  }

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

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

int main() {
  int combi[100000][3] = {0}, m = 0;
  int input, price[100000] = {0}, weight;
  int a, b, c, a1, b1, c1;

  while (cin >> input) {
    if (input == 0)
      break;
    for (int i = 0; i < 26; i++) { // generate combination of weight over input
      for (int j = 0; j < 17; j++) {
        for (int k = 0; k < 11; k++) {
          weight = 200 * i + 300 * j + 500 * k;
          // cout << weight << " ";
          if (input == weight) {
            combi[m][0] = i;
            combi[m][1] = j;
            combi[m][2] = k;
            // cout << combi[m][0] << " " <<  combi[m][1] << " " << combi[m][2]
            // << endl;
            m++;
          }
        }
      }
    }

    for (int i = 0; i < m; i++) { // calculate price[i] from combi[i]
      a = combi[i][0] / 5;        // sale
      a1 = combi[i][0] - a * 5;   // not sale
      b = combi[i][1] / 4;        // sale
      b1 = combi[i][1] - b * 4;   // not sale
      c = combi[i][2] / 3;        // sale
      c1 = combi[i][2] - c * 3;   // not sale
      price[i] =
          1520 * a + 380 * a1 + 1870 * b + 550 * b1 + 2244 * c + 850 * c1;
      //      cout << price[i] << endl;
    }

    sort(price, price + m);

    cout << price[0] << endl;
    m = 0;
    int price[100000] = {0};
  }
}

Error: WA

Fixed submission:

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

int main() {
  int combi[100000][3] = {0}, m = 0;
  int input, price[100000] = {0};
  int a, b, c, a1, b1, c1;

  while (cin >> input) {
    if (input = 0)
      break;
    for (int i = 0; i < 26; i++) { // generate combination of weight over input
      for (int j = 0; j < 17; j++) {
        for (int k = 0; k < 11; k++) {
          if (input <= 200 * i + 300 * j + 500 * k) {
            combi[m][0] = i;
            combi[m][1] = j;
            combi[m][2] = k;
            m++;
          }
        }
      }
    }

    for (int i = 0; i < m; i++) { // calculate price[i] from combi[i]
      a = combi[i][0] / 5;        // sale
      a1 = combi[i][0] - a * 5;   // not sale
      b = combi[i][1] / 4;        // sale
      b1 = combi[i][1] - b * 4;   // not sale
      c = combi[i][2] / 3;        // sale
      c1 = combi[i][2] - c * 3;   // not sale
      price[i] =
          1520 * a + 380 * a1 + 1870 * b + 550 * b1 + 2244 * c + 850 * c1;
    }

    sort(price, price + m);

    cout << price[0] << endl;
  }
}
Problem p00106 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  for (int n; cin >> n && n;) {
    int r = 1e9;
    for (int c0 = 0; c0 <= 25; c0++)
      for (int c1 = 0; c1 <= 16; c1++)
        for (int c2 = 0; c2 <= 10; c2++)
          for (int c3 = 0; c3 <= 5; c3++)
            for (int c4 = 0; c4 <= 4; c4++)
              for (int c5 = 0; c5 <= 3; c5++)
                if (n == c0 * 200 + c1 * 300 + c2 * 500 + c3 * 1000 +
                             c4 * 1200 + c5 * 1500)
                  r = min(r, c0 * 380 + c1 * 550 + c2 * 850 + c3 * 1520 +
                                 c4 * 1870 + c5 * 2244);
    cout << r << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  while (1) {
    int n, sum = 0, a, b, c, sa = 0, min, a1 = 0, a2 = 0, a3 = 0;
    cin >> n;
    if (n >= 1000) {
      for (int i = 0; i <= 5; i++) {
        for (int j = 0; j <= 5; j++) {
          for (int q = 0; q <= 5; q++) {
            sa = n - i * 1500 - j * 1200 - q * 1000;
            if (i == 0 && j == 0 && q == 0)
              min = sa;
            if (sa >= 0 && sa != 100 && sa < min) {
              min = sa;
              a1 = i;
              a2 = j;
              a3 = q;
            }
          }
        }
      }
    }
    sum += 850 * 3 * a1 * 0.88;
    sum += 550 * 4 * a2 * 0.85;
    sum += 380 * 5 * a3 * 0.8;
    n -= 1500 * a1;
    n -= 1200 * a2;
    n -= 1000 * a3;
    a = n / 500;
    if (n % 500 == 100)
      a--;
    sum += 850 * a;
    n -= a * 500;
    c = n / 300;
    if (n % 300 == 100)
      c--;
    sum += 550 * c;
    n -= c * 300;
    b = n / 200;
    if (n % 200 == 100)
      b--;
    sum += 380 * b;
    cout << sum << endl;
  }
  return 0;
}