prithivMLmods/Coder-Stat huggingface dataset:
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using namespace std;
using P = pair<int, int>;
typedef long long ll;

int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  long ans = 0;
  for (int i = 0; i <= n / r; i++) {
    for (int j = 0; j <= n / g; j++) {
      for (int k = 0; k <= n / b; k++) {
        if ((i * r) + (j * g) + (k * b) == n)
          ans++;
      }
    }
  }
  cout << ans << endl;
  return (0);
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using namespace std;
using P = pair<int, int>;
typedef long long ll;

int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  long ans = 0;
  for (int i = 0; i <= n / r; i++) {
    for (int j = 0; j <= n / g; j++) {
      if (n - ((i * r) + (j * g)) == 0)
        ans++;
      else if (n - ((i * r) + (j * g)) > 0) {
        if ((n - ((i * r) + (j * g))) % b == 0)
          ans++;
      }
    }
  }
  cout << ans << endl;
  return (0);
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) A.begin(), A.end()
const long long mod = 1000000007;
int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int sum = 0, ans = 0;
  for (int i = 0; i * r <= n; i++) {
    for (int j = 0; j * g + i * r <= n; j++) {
      for (int k = 0; k * b + i * r + j * g <= n; k++) {
        if (i * r + j * g + k * b == n)
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) A.begin(), A.end()
const long long mod = 1000000007;
int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int sum = 0, ans = 0;
  for (int i = 0; i * r <= n; i++) {
    for (int j = 0; i * r + j * g <= n; j++) {
      if ((n - i * r - j * g) % b == 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int INF = 1 << 29;

int main() {
  ios::sync_with_stdio(false);
  int R, G, B, N, ans = 0;
  cin >> R >> G >> B >> N;
  for (int i = 0; i <= N / R; i++) {
    for (int j = 0; j <= (N - R * i) / G; j++) {
      for (int k = 0; k <= (N - R * i - G * j) / B; k++) {
        if (R * i + G * j + B * k == N)
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int INF = 1 << 29;

int main() {
  ios::sync_with_stdio(false);
  int R, G, B, N, ans = 0;
  cin >> R >> G >> B >> N;
  for (int i = 0; i <= N / R; i++) {
    for (int j = 0; j <= (N - R * i) / G; j++) {
      if ((N - (R * i + G * j)) % B == 0)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>

using namespace std;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int count = 0;
  int max_r, max_g, max_b;
  max_r = N / R;
  max_g = N / G;
  max_b = N / B;

  for (int i = 0; i < max_r + 1; i++) {
    for (int j = 0; j < max_g + 1; j++) {
      for (int k = 0; k < max_b + 1; k++) {
        if (R * i + G * j + B * k == N)
          count++;
      }
    }
  }

  cout << count << endl;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int count = 0;
  int max_r, max_g, max_b;
  max_r = N / R;
  max_g = N / G;
  max_b = N / B;

  for (int i = 0; i < max_r + 1; i++) {
    for (int j = 0; j < max_g + 1; j++) {
      if ((N - (R * i + G * j)) % B == 0 and N - (R * i + G * j) >= 0) {
        count++;
      }
    }
  }

  cout << count << endl;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int r, g, b, n, cnt = 0;

  cin >> r >> g >> b >> n;

  for (int i = 0; i * r <= n; i++) {
    for (int j = 0; j * g + i * r <= n; j++) {
      for (int k = 0; k * b + j * g + i * r <= n; k++) {
        if (i * r + j * g + k * b == n) {
          cnt++;
        }
      }
    }
  }

  cout << cnt;

  return 0;
}

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

int main() {
  int r, g, b, n, cnt = 0;

  cin >> r >> g >> b >> n;

  for (int i = 0; i * r <= n; i++) {
    for (int j = 0; j * g + i * r <= n; j++) {
      if (i * r + j * g == n) {
        cnt++;
      } else if (i * r + j * g < n) {
        if ((n - (i * r + j * g)) % b == 0) {
          cnt++;
        }
      }
    }
  }

  cout << cnt;

  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <vector>
// #include <string>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
using namespace std;

int main() {
  int r, g, b, n, ans = 0, tmp;

  cin >> r >> g >> b >> n;

  if (r < g) {
    tmp = r;
    r = g;
    g = tmp;
  }
  if (r < b) {
    tmp = r;
    r = b;
    b = tmp;
  }

  if (g < b) {
    tmp = g;
    g = b;
    b = tmp;
  }

  for (int i = 0; i <= n / r; i++) {
    for (int j = 0; j <= (n - r * i) / g; j++) {
      for (int k = 0; k <= (n - r * i - g * j) / b; k++) {
        if (i * r + j * g + k * b == n)
          ans++;
      }
    }
  }

  cout << ans << endl;
}


Fixed submission:
#include <iostream>
#include <vector>
// #include <string>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
using namespace std;

int main() {
  int r, g, b, n, ans = 0, tmp;

  cin >> r >> g >> b >> n;

  if (r < g) {
    tmp = r;
    r = g;
    g = tmp;
  }
  if (r < b) {
    tmp = r;
    r = b;
    b = tmp;
  }

  if (g < b) {
    tmp = g;
    g = b;
    b = tmp;
  }

  for (int i = 0; i <= n / r; i++) {
    for (int j = 0; j <= (n - r * i) / g; j++) {
      if ((n - r * i - g * j) % b == 0)
        ans++;
    }
  }

  cout << ans << endl;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }

int main() {
  ll R, G, B, N, ans = 0;
  cin >> R >> G >> B >> N;

  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N - i * R; j++) {
      for (int k = 0; k <= N - i * R - j * G; k++) {
        if (k * B + i * R + j * G == N) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }

int main() {
  ll R, G, B, N, ans = 0;
  cin >> R >> G >> B >> N;

  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N - i * R; j++) {
      if ((N - (i * R + j * G)) / B >= 0 && (N - (i * R + j * G)) % B == 0) {
        ans++;
      }
    }
  }

  cout << ans << endl;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (int i = (a), i##Len_ = (b); i < i##Len_; i++)

int main() {

  vector<int> X(4);
  vector<int> Y(4);

  REP(i, 4) { cin >> X[i]; }

  int a, b, res, cnt;

  REP(i, 4) { Y[i] = X[3] / X[i]; }

  vector<int> tes(3000 * 3000);

  for (int j = 0; j <= Y[0]; j++) {
    if (X[3] < X[0] * j)
      break;
    for (int k = 0; k <= Y[1]; k++) {
      if (X[3] < X[0] * j + X[1] * k)
        break;
      tes[cnt] = X[0] * j + X[1] * k;
      cnt++;
    }
  }

  for (int m = 0; m < cnt; m++) {
    b = X[3] - tes[m];
    for (int l = 0; l <= Y[2]; l++) {
      if (b < X[2] * l)
        break;
      if (b == X[2] * l) {
        res++;
        break;
      }
    }
  }
  cout << res << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (int i = (a), i##Len_ = (b); i < i##Len_; i++)

int main() {

  vector<int> X(4);
  vector<int> Y(4);

  REP(i, 4) { cin >> X[i]; }

  int a, b, res, cnt;

  REP(i, 4) { Y[i] = X[3] / X[i]; }

  vector<int> tes(3000 * 3000);

  for (int j = 0; j <= Y[0]; j++) {
    if (X[3] < X[0] * j)
      break;
    for (int k = 0; k <= Y[1]; k++) {
      if (X[3] < X[0] * j + X[1] * k)
        break;
      tes[cnt] = X[0] * j + X[1] * k;
      cnt++;
    }
  }

  for (int m = 0; m < cnt; m++) {
    b = X[3] - tes[m];
    // ここはあまりを求めるだけよい
    if (b % X[2] == 0)
      res++;
  }
  cout << res << endl;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>

using namespace std;

constexpr int MAX_N = 3000;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int count = 0;
  for (auto r = 0u; r <= MAX_N / R; ++r) {
    for (auto g = 0u; g <= (MAX_N - R * r) / G; ++g) {
      for (auto b = 0u; b <= (MAX_N - R * r - G * g) / B; ++b) {
        if (R * r + G * g + B * b == N) {
          ++count;
        }
      }
    }
  }
  cout << count;
}

Fixed submission:
#include <iostream>

using namespace std;

constexpr int MAX_N = 3000;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int count = 0;
  for (auto r = 0u; r <= MAX_N / R; ++r) {
    auto rc = R * r;
    for (auto g = 0u; g <= (MAX_N - rc) / G; ++g) {
      auto rest = N - rc - G * g;
      if (rest / B <= MAX_N && rest % B == 0) {
        ++count;
      }
    }
  }
  cout << count;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

signed main() {
  long long R, G, B, N;
  cin >> R >> G >> B >> N;

  int count = 0;
  for (int i = 0; i <= N / R; i++) {
    for (int j = 0; j <= N / G; j++) {
      for (int k = 0; k <= N / B; k++) {
        if (R * i + G * j + B * k == N) {
          count++;
        }
      }
    }
  }

  cout << count << endl;
}

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

signed main() {
  long long R, G, B, N;
  cin >> R >> G >> B >> N;

  int count = 0;
  for (int i = 0; i <= N / R; i++) {
    for (int j = 0; j <= N / G; j++) {
      if (N - R * i - G * j >= 0 && (N - R * i - G * j) % B == 0) {
        count++;
      }
    }
  }

  cout << count << endl;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <queue>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int ans = 0;
  for (int r = 0; r <= (N / R); r++) {
    for (int g = 0; g <= ((N - r * R) / G); g++) {
      for (int b = 0; b <= ((N - r * R - g * G) / B); b++) {
        int count = r * R + g * G + b * B;
        if (count == N) {
          ans += 1;
        }
      }
    }
  }

  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <queue>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int ans = 0;
  for (int r = 0; r <= (N / R); r++) {
    for (int g = 0; g <= ((N - r * R) / G); g++) {
      int count = r * R + g * G;
      if ((N - count) % B != 0) {
        continue;
      }
      int b = (N - count) / B;
      if (b >= 0) {
        ans += 1;
      }
    }
  }

  cout << ans << endl;
  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend()) // vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int> vec;
typedef vector<vec> mat;
// typedef tuple<ll, ll, ll> T;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  ll ans = 0;
  for (int r = 0; r <= N / R; r++) {
    for (int g = 0; g <= N / G; g++) {
      for (int b = 0; b <= N / B; b++) {
        if (r * R + g * G + b * B == N)
          ans++;
      }
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend()) // vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int> vec;
typedef vector<vec> mat;
// typedef tuple<ll, ll, ll> T;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  ll ans = 0;
  for (int r = 0; r <= N; r++) {
    for (int g = 0; g <= N; g++) {
      int Bb = N - R * r - G * g;
      if (Bb >= 0 && Bb % B == 0) {
        // cout<<r<<":"<<g<<":"<<B*b<<endl;
        ans++;
      }
    }
  }
  cout << ans << endl;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  ll ans = 0;
  int r_max = (N + R - 1) / R;
  int g_max = (N + G - 1) / G;
  int b_max = (N + B - 1) / B;
  rep(i, r_max + 1) rep(j, g_max + 1) rep(k, b_max + 1) {
    if (i * R + j * G + k * B == N)
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  ll ans = 0;
  int r_max = (N + R - 1) / R;
  int g_max = (N + G - 1) / G;
  rep(i, r_max + 1) rep(j, g_max + 1) {
    int k = (N - i * R - j * G) / B;
    if (k < 0)
      break;
    if (i * R + j * G + k * B == N)
      ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string.h>
using namespace std;

int main(void) {
  int R, G, B, N, answer = 0, num1, num2;
  cin >> R >> G >> B >> N;
  for (int i = 0; i <= N / R; i++) {
    num1 = N - R * i;
    for (int j = 0; j <= num1 / G; j++) {
      num2 = num1 - G * j;
      for (int k = 0; k <= num2 / B; k++) {
        if (R * i + G * j + B * k == N) {
          answer++;
        }
      }
    }
  }
  cout << answer << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string.h>
using namespace std;

int main(void) {
  int R, G, B, N, answer = 0, num1, num2;
  cin >> R >> G >> B >> N;
  for (int i = 0; i <= N / R; i++) {
    num1 = N - R * i;
    for (int j = 0; j <= num1 / G; j++) {
      num2 = num1 - G * j;
      if (num2 % B == 0) {
        answer++;
      }
    }
  }
  cout << answer << endl;
  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, a, b) for (int i = (int)(a); (i) < (int)(b); i++)

typedef unsigned long long ull;
typedef long long ll;

const int INF = 1001001001;
const ll MOD = 1e9 + 7;

using namespace std;
using P = pair<int, int>;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
  ll r, g, b, n;
  cin >> r >> g >> b >> n;

  ll sum = 0;
  ll count = 0;
  rep(i, n / r + 1) {
    rep(j, n / g + 1) {
      rep(k, n / b + 1) {
        if (i + j > n)
          continue;
        sum = r * i + g * j + b * k;
        if (sum == n)
          count++;
        //   cout << sum << " " << count << endl;
        //   cout << i << " " << j << " " << n-i-j << " " << endl;
      }
    }
  }

  cout << count << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, a, b) for (int i = (int)(a); (i) < (int)(b); i++)

typedef unsigned long long ull;
typedef long long ll;

const int INF = 1001001001;
const ll MOD = 1e9 + 7;

using namespace std;
using P = pair<int, int>;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
  ll r, g, b, n;
  cin >> r >> g >> b >> n;

  ll sum = 0;
  ll count = 0;
  rep(i, 3001) {
    rep(j, 3001) {
      ll rem = r * i + g * j;
      if (n >= rem && (n - rem) % b == 0)
        count++;
      //   cout << i << " " << j << " " << n-i-j << " " << endl;
    }
  }

  cout << count << endl;
  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int ans = 0;

  for (int r = 0; R * r <= N; r++)
    for (int g = 0; G * g <= N; g++)
      for (int b = 0; B * b <= N; b++) {
        if (R * r + G * g + B * b == N)
          ans++;
      }

  cout << ans << endl;
}

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

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int ans = 0;

  for (int r = 0; R * r <= N; r++)
    for (int g = 0; G * g + R * r <= N; g++) {
      if ((N - R * r - G * g) % B == 0)
        ans++;
    }

  cout << ans << endl;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <ciso646>
#include <cmath>
#include <complex>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop                                                                   \
  char nyaa;                                                                   \
  cin >> nyaa;
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i >= 0; i--)
#define Rep(i, sta, n) for (int i = sta; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define per1(i, n) for (int i = n; i >= 1; i--)
#define Rep1(i, sta, n) for (int i = sta; i <= n; i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  rep(i, N / R + 1) {
    rep(j, (N - i * R) / G + 1) {
      rep(k, (N - i * R - j * G) / B + 1) {
        if (N - i * R - j * G - k * B == 0) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <ciso646>
#include <cmath>
#include <complex>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop                                                                   \
  char nyaa;                                                                   \
  cin >> nyaa;
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i >= 0; i--)
#define Rep(i, sta, n) for (int i = sta; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define per1(i, n) for (int i = n; i >= 1; i--)
#define Rep1(i, sta, n) for (int i = sta; i <= n; i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  rep(i, N / R + 1) {
    rep(j, (N - i * R) / G + 1) {
      int k;
      if ((N - i * R - j * G) % B == 0) {
        k = (N - i * R - j * G) / B;
        ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int cnt = 0;
  for (int r = 0; R * r <= N; r++) {
    for (int g = 0; G * g <= N; g++) {
      for (int b = 0; B * b <= N; b++) {
        if (N == R * r + G * g + B * b)
          cnt++;
      }
    }
  }

  cout << cnt << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int cnt = 0;
  for (int r = 0; R * r <= N; r++) {
    for (int g = 0; G * g <= N; g++) {
      if (N < R * r + G * g)
        continue;
      if ((N - R * r - G * g) % B == 0)
        cnt++;
    }
  }

  cout << cnt << endl;
  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int k = 0;
  for (int x = 0; x < N + 1; x++) {
    if (R * x > N)
      break;
    for (int y = 0; y < N + 1; y++) {
      if (R * x + G * y > N)
        break;
      for (int z = 0; z < N + 1; z++) {
        if (R * x + G * y + B * z > N)
          break;
        if (R * x + G * y + B * z == N) {
          k++;
        }
      }
    }
  }
  cout << k;
  cin >> k;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int k = 0;
  for (int x = 0; x < N + 1; x++) {
    if (R * x > N)
      break;
    for (int y = 0; y < N + 1; y++) {
      if (R * x + G * y > N)
        break;
      if ((N - R * x - G * y) % B == 0) {
        int z = (N - R * x - G * y) / B;
        if (R * x + G * y + B * z == N) {
          k++;
        }
      }
    }
  }
  cout << k;
  cin >> k;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int res = 0;
  for (int r = 0; r * R <= N; r++) {
    for (int g = 0; g * G <= N - (r * R); g++) {
      for (int b = 0; b * B <= N - (r * R) - (g * G); b++) {
        if (r * R + g * G + b * B == N)
          res++;
      }
    }
  }
  cout << res << endl;
}


Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int res = 0;
  for (int r = 0; r * R <= N; r++) {
    for (int g = 0; g * G <= N - (r * R); g++) {

      if ((N - (r * R + g * G)) % B == 0)
        res++;
    }
  }
  cout << res << endl;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int answer = 0;
  for (int i = 0; i <= (N / R); i++) {
    for (int j = 0; j <= (N - R * i) / G; j++) {
      for (int k = 0; k <= (N - R * i - G * j) / B; k++) {
        if (R * i + G * j + B * k == N)
          answer++;
      }
    }
  }
  cout << answer;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int answer = 0;
  for (int i = 0; i <= (N / R); i++) {
    for (int j = 0; j <= (N - R * i) / G; j++) {
      if ((N - R * i - G * j) % B == 0)
        answer++;
    }
  }
  cout << answer;
  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int r = R;
  int g = G;
  int b = B;
  int count = 0;
  for (int i = 0; i <= N; i += r) {
    for (int x = 0; x + i <= N; x += g) {
      for (int y = 0; y + x + i <= N; y += b) {
        if (y + x + i == N) {
          count += 1;
        }
      }
    }
  }
  cout << count << endl;
}

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

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int r = R;
  int g = G;
  int b = B;
  int count = 0;
  if (R == G == B) {
    if (N % G == 0) {
      int xxx = N / R;
      int yyy = xxx + 2;
      int yyyy = xxx + 1;
      int yyyyy = yyy * yyyy;
      count = yyyyy / 2;
    } else {
      count = 0;
    }
  } else {
    for (int i = 0; i <= N; i += r) {
      for (int x = 0; x + i <= N; x += g) {
        for (int y = 0; y + x + i <= N; y += b) {
          if (y + x + i == N) {
            count += 1;
          }
        }
      }
    }
  }
  cout << count << endl;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int a, b, c, ans, n, k, r, g;

int main() {
  cin >> r >> g >> b >> n;
  for (int i = 0; i < (n / r) + 1; i++) {
    for (int u = 0; u < (n / g) + 1; u++) {
      for (int o = 0; o < (n / b) + 1; o++) {
        if ((i * r) + (u * g) + (o * b) == n)
          ans++;
      }
    }
  }
  cout << ans << endl;
}


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

int a, b, c, ans, n, k, r, g;

int main() {
  cin >> r >> g >> b >> n;
  for (int i = 0; i < n + 1; i += r) {
    if (i > n)
      break;
    for (int u = 0; u < n + 1; u += g) {
      if (u > n)
        break;
      int ll = n - i - u;
      if (ll < b && ll != 0)
        continue;
      if (ll == 0) {
        ans++;
        continue;
      }
      if (ll % b == 0 && ll / b != 0) {
        // cout<<i<<" "<<u<<" "<<ll/b<<endl;
        ans++;
      }
    }
  }
  cout << ans << endl;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(), (a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
#define INF 1e18
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
template <class T> bool contain(const std::string &s, const T &v) {
  return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

unsigned long long gcd(unsigned long long a, unsigned long long b) {
  while (1) {
    if (a < b)
      swap(a, b);
    if (!b)
      break;
    a %= b;
  }
  return a;
}

int main() {
  int R, G, B, N, ans = 0;
  cin >> R >> G >> B >> N;
  for (int r = 0; r <= N / R; r++) {
    for (int g = 0; g <= N / G; g++) {
      for (int b = 0; b <= N / B; b++) {
        if (r * R + g * G + b * B == N) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(), (a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
#define INF 1e18
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
template <class T> bool contain(const std::string &s, const T &v) {
  return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

unsigned long long gcd(unsigned long long a, unsigned long long b) {
  while (1) {
    if (a < b)
      swap(a, b);
    if (!b)
      break;
    a %= b;
  }
  return a;
}

int main() {
  int R, G, B, N, ans = 0;
  cin >> R >> G >> B >> N;
  for (int r = 0; r <= N / R; r++) {
    for (int g = 0; g <= N / G; g++) {
      if ((N - (r * R + g * G)) >= 0 && ((N - (r * R + g * G)) <= N) &&
          ((N - (r * R + g * G)) % B == 0)) {
        // cout << "r: " << r << " g: " << g << " b: " << (N - (r * R + g * G))
        // / B << endl;
        ans++;
      }
    }
  }
  cout << ans << endl;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int R, B, G, N;
  cin >> R >> B >> G >> N;
  int r = N / R;
  int b = N / B;
  int g = N / G;
  int ans = 0;
  rep(i, r + 1) {
    rep(j, b + 1) {
      rep(k, g + 1) {
        if (N == i * R + j * B + k * G)
          ans++;
        if (N < i * R + j * B + k * G)
          break;
      }
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int R, B, G, N;
  cin >> R >> B >> G >> N;
  int r = N / R;
  int b = N / B;
  int g = N / G;
  int ans = 0;
  rep(i, r + 1) {
    rep(j, (N - R * i) / B + 1) {
      if ((N - i * R - j * B) % G == 0)
        ans++;
    }
  }
  cout << ans << endl;
}
Problem p03048 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>
#include <iostream>
using namespace std;

int a, b, c, n, ans;

int main() {
  freopen("input.txt", "r", stdin);
  int i, j, t;
  cin >> a >> b >> c >> n;
  for (i = 0; i <= 3000; i++)
    for (j = 0; j <= 3000; j++) {
      t = n - a * i - b * j;
      if (t < 0)
        break;
      if (t % c == 0)
        ans++;
    }
  cout << ans;
  return 0;
}

Fixed submission:
#include <cstdio>
#include <iostream>
using namespace std;

int a, b, c, n, ans;

int main() {
  int i, j, t;
  cin >> a >> b >> c >> n;
  for (i = 0; i <= 3000; i++)
    for (j = 0; j <= 3000; j++) {
      t = n - a * i - b * j;
      if (t < 0)
        break;
      if (t % c == 0)
        ans++;
    }
  cout << ans;
  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <stdio.h>
using namespace std;

int R, G, B, N;
int main() {
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int r = 0; r <= N; r += R) {
    for (int g = 0; g <= N - r; g += G) {
      for (int b = 0; b <= N - (r + g); b += B) {
        // int b =  N - (r + g);
        if ((r + g + b) == N)
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <iostream>
#include <stdio.h>
using namespace std;

int R, G, B, N;
int main() {
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int r = 0; r <= N; r += R) {
    for (int g = 0; g <= N - r; g += G) {
      if ((N - (r + g)) % B == 0)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  ll cnt = 0;
  int rm = n / r, gm = n / g, bm = n / b;
  for (int i = 0; i <= rm; i++) {
    for (int j = 0; j <= gm; j++) {
      for (int k = 0; k <= bm; k++) {
        if ((i * r + j * g + k * b) == n) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  ll cnt = 0;
  int rm = n / r, gm = n / g;
  for (int i = 0; i <= rm; ++i) {
    // G,Bが0個
    if ((i * r) == n) {
      cnt++;
      continue;
    }
    for (int j = 0; j <= gm; ++j) {
      // Bが0個
      if ((i * r + j * g) == n) {
        cnt++;
        continue;
      }
      // Bを取る場合
      else if (((n - (i * r + j * g)) % b) == 0 && (n - (i * r + j * g) > 0)) {
        cnt++;
        continue;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Runtime Error):
/*
author: Apoorv Singh
*/

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

typedef vector<long long> vi;
typedef pair<long long, long long> pii;
#define pb push_back
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"

int modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n) {
  for (int i = 0; i < n; ++i)
    cout << arr[i] << " ";
  cout << endl;
}

int fpow(int a, int n) {
  int ans = 1;
  while (n) {
    if (n & 1)
      ans = (ans * a) % modulo;
    a = (a * a) % modulo;
    n = n >> 1;
  }
  return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int ans = 0;
  FOR(i, 0, n + 1) {
    FOR(j, 0, n + 1) {
      if (r * i + g * j > n)
        continue;
      int x = r * i + g * j;
      if ((n - x) % b)
        continue;
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
/*
author: Apoorv Singh
*/

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

typedef vector<long long> vi;
typedef pair<long long, long long> pii;
#define pb push_back
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"

int modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n) {
  for (int i = 0; i < n; ++i)
    cout << arr[i] << " ";
  cout << endl;
}

int fpow(int a, int n) {
  int ans = 1;
  while (n) {
    if (n & 1)
      ans = (ans * a) % modulo;
    a = (a * a) % modulo;
    n = n >> 1;
  }
  return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int ans = 0;
  FOR(i, 0, n + 1) {
    FOR(j, 0, n + 1) {
      if (r * i + g * j > n)
        continue;
      int x = r * i + g * j;
      if ((n - x) % b)
        continue;
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

typedef long long int ll;

ll mod = 1e9 + 7;
ll power(ll a, ll b) {
  if (b == 0)
    return 1;
  else if (b % 2 == 0) {
    return power(a * a, b / 2);
  } else
    return (a * power(a * a, b / 2));
}

int main() {
  IOS
#ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int count = 0;
  for (int i = 0; i <= 3000; ++i) {
    for (int j = 0; j <= 3000; ++j) {
      int temp = n - i * r - j * g;
      if (temp < 0)
        continue;
      if (temp % b == 0)
        count++;
    }
  }
  cout << count << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

typedef long long int ll;

ll mod = 1e9 + 7;
ll power(ll a, ll b) {
  if (b == 0)
    return 1;
  else if (b % 2 == 0) {
    return power(a * a, b / 2);
  } else
    return (a * power(a * a, b / 2));
}

int main() {
  IOS

      int r,
      g, b, n;
  cin >> r >> g >> b >> n;
  int count = 0;
  for (int i = 0; i <= 3000; ++i) {
    for (int j = 0; j <= 3000; ++j) {
      int temp = n - i * r - j * g;
      if (temp < 0)
        continue;
      if (temp % b == 0)
        count++;
    }
  }
  cout << count << endl;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
signed main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int r = 0; R * r <= N; r++) {
    for (int g = 0; R * r + G * g <= N; g++) {
      for (int b = 0; R * r + G * g + B * b <= N; b++) {
        if (R * r + G * g + B * b == N)
          ans++;
      }
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
signed main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int r = 0; R * r <= N; r++) {
    for (int g = 0; R * r + G * g <= N; g++) {
      if (N > R * r + G * g && (N - R * r - G * g) % B == 0) {
        ans++;
      } else if (N == R * r + G * g) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main() {
  int R, G, B, n;
  cin >> R >> G >> B >> n;
  int64_t ans = 0;
  for (int i = n / R; i >= 0; i--) {
    for (int j = (n - i) / G; j >= 0; j--) {
      for (int k = (n - i - j) / B; k >= 0; k--) {
        if (R * i + G * j + B * k == n)
          ans++;
      }
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main() {
  int R, G, B, n;
  cin >> R >> G >> B >> n;
  int64_t ans = 0;
  for (int i = n / R; i >= 0; i--) {
    for (int j = (n - i) / G; j >= 0; j--) {
      if ((n - R * i - G * j) >= 0 && (n - R * i - G * j) % B == 0)
        ans++;
    }
  }
  cout << ans << endl;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <regex>
#include <set>
#include <string>
#include <vector>
using namespace std;
int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int r = 0, g = 0, b = 0, ans = 0;
  for (r = 0; r <= N; r++) {
    for (g = 0; g <= N; g++) {
      for (b = 0; b <= N; b++) {
        int tmp = (R * r) + (G * g) + (B * b);
        if (tmp == N) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <regex>
#include <set>
#include <string>
#include <vector>
using namespace std;
int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int r = 0, g = 0, b = 0, ans = 0;
  for (r = 0; r <= N; r++) {
    for (g = 0; g <= N; g++) {
      int tmp = (R * r) + (G * g);
      if (tmp <= N && (N - tmp) % B == 0) {
        ans++;
      }
    }
  }

  cout << ans << endl;
  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <typename T> ll gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> ll lcm(T a, T b) { return a * b / gcd(a, b); };
template <typename T> inline void chmin(T &a, const T &b) {
  if (a > b)
    a = b;
}
template <typename T> inline void chmax(T &a, const T &b) {
  if (a < b)
    a = b;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  ll ans = 0;
  for (int i = 0; r * i <= n; ++i) {
    for (int j = 0; r * i + g * j <= n; ++j) {
      for (int k = 0; r * i + g * j + b * k <= n; ++k) {
        if (r * i + g * j + b * k == n) {
          ++ans;
        }
      }
    }
  }
  cout << ans << '\n';
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <typename T> ll gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> ll lcm(T a, T b) { return a * b / gcd(a, b); };
template <typename T> inline void chmin(T &a, const T &b) {
  if (a > b)
    a = b;
}
template <typename T> inline void chmax(T &a, const T &b) {
  if (a < b)
    a = b;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  ll ans = 0;
  for (int i = 0; r * i <= n; ++i) {
    for (int j = 0; r * i + g * j <= n; ++j) {
      if (!((n - r * i - g * j) % b))
        ++ans;
    }
  }
  cout << ans << '\n';
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

using namespace std;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  vector<int> rgb(3, 0);
  rgb[0] = R;
  rgb[1] = G;
  rgb[2] = B;

  int rmax = N / R;
  int gmax = N / G;
  int bmax = N / B;

  int count = 0;
  for (int i = 0; i <= rmax; i++) {
    for (int j = 0; j <= gmax; j++) {
      for (int k = 0; k <= bmax; k++) {
        int sum = i * R + j * G + k * B;
        if (sum == N) {
          count += 1;
        }
      }
    }
  }
  cout << count << endl;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  vector<int> rgb(3, 0);
  rgb[0] = R;
  rgb[1] = G;
  rgb[2] = B;

  int rmax = N / R;
  int gmax = N / G;
  int bmax = N / B;

  int count = 0;
  for (int i = 0; i <= rmax; i++) {
    for (int j = 0; j <= gmax; j++) {
      int left = N - i * R - j * G;
      if (left >= 0 && left % B == 0) {
        count += 1;
      }
    }
  }
  cout << count << endl;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int cnt = 0;
  for (int r = 0; r <= (3000 / R) + 1; r++) {
    for (int g = 0; g <= (3000 / G) + 1; g++) {
      if (r * R + g * G > N)
        break;
      for (int b = 0; b <= (3000 / B) + 1; b++) {
        if (r * R + g * G + b * B == N) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


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

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int cnt = 0;
  for (int r = 0; r <= (3000 / R) + 1; r++) {
    for (int g = 0; g <= (3000 / G) + 1; g++) {
      if ((N - r * R - g * G) % B == 0 && r * R + g * G <= N)
        cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int sum = 0;
  for (int r = 0; r <= N / R; r++) {
    for (int g = 0; g <= (N - R * r) / G; g++) {
      for (int b = 0; b <= (N - R * r - g * G) / B; b++) {
        if (R * r + g * G + b * B == N) {
          sum++;
        }
      }
    }
  }
  cout << sum << endl;
  return 0;
}

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

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int sum = 0;
  for (int r = 0; r <= N / R; r++) {
    for (int g = 0; g <= (N - R * r) / G; g++) {
      if ((N - R * r - g * G) % B == 0) {
        sum++;
      }
    }
  }
  cout << sum << endl;
  return 0;
}