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 < n; i++)
#define REP(i, n, k) for (int i = n; i < k; i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v)                                                              \
  for (int i = 0; i < v.size(); i++)                                           \
    P(v[i]);
#define printt(a, b) cout << a << " " << b << endl;
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int MOD = 1e9 + 7;

void solve() {
  int a, b, c, n;
  cin >> a >> b >> c >> n;
  int count = 0;
  rep(i, n / a + 1) {
    if (a * i < n) {
      rep(j, (n - (a * i)) / b + 1) {
        if (a * i + b * j < n) {
          rep(k, (n - a * i - b * j) / c + 1) {
            if (a * i + b * j + c * k == n)
              count++;
          }
        } else if (a * i + b * j == n) {
          count++;
        }
      }
    } else if (a * i == n) {
      count++;
    }
  }
  P(count);
}

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


Fixed submission:
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n, k) for (int i = n; i < k; i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v)                                                              \
  for (int i = 0; i < v.size(); i++)                                           \
    P(v[i]);
#define printt(a, b) cout << a << " " << b << endl;
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int MOD = 1e9 + 7;

void solve() {
  int a, b, c, n;
  cin >> a >> b >> c >> n;
  int count = 0;
  rep(i, n / a + 1) {
    if (a * i < n) {
      rep(j, (n - (a * i)) / b + 1) {
        if (a * i + b * j < n) {
          if ((n - a * i - b * j) % c == 0) {
            count++;
          }
        } else if (a * i + b * j == n) {
          count++;
        }
      }
    } else if (a * i == n) {
      count++;
    }
  }
  P(count);
}

int main() {
  solve();
  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define mod 1000000007
#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

using namespace std;
using ll = __int64_t;

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

void solve() {
  int r, g, b, n;
  int res = 0;
  cin >> r >> g >> b >> n;

  for (int i = 0; i < (n / r) + 1; i++) {
    for (int j = 0; j < (n / g) + 1; j++) {
      for (int k = 0; k < (n / b) + 1; k++) {
        if ((i * r) + (j * g) + (k * b) == n) {
          res++;
          break;
        }
      }
    }
  }
  cout << res << endl;
}

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

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define mod 1000000007
#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

using namespace std;
using ll = __int64_t;

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

void solve() {
  int r, g, b, n;
  int res = 0;
  cin >> r >> g >> b >> n;

  for (int i = 0; i < (n / r) + 1; i++) {
    for (int j = 0; j < (n / g) + 1; j++) {
      int x = n - ((i * r) + (j * g));
      if (x % b == 0 && x >= 0) {
        res++;
      }
    }
  }
  cout << res << endl;
}

int main() {
  solve();
  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;
  long long int counter = 0;
  for (int i = (int)n / r; i >= 0; i--) {
    if ((r * i + g * (int)n / g + b * (int)n / b) < n)
      continue;
    for (int j = (int)n / g; j >= 0; j--) {
      if ((r * i + g * j + b * (int)n / b) < n)
        continue;
      for (int s = (int)n / b; s >= 0; s--) {
        if ((r * i + j * g + s * b) == n) {
          counter++;
          break;
        }
      }
    }
  }
  cout << counter << endl;
}

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

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

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

using namespace std;

int r, g, b, n;
int res = 0;

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

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

  cout << res << endl;
}

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

using namespace std;

int r, g, b, n;
int res = 0;

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

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

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

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

int main() {
  int R, G, B, N;
  int r, g, b, cnt;
  r = g = b = cnt = 0;

  cin >> R >> G >> B >> N;

  for (r = N / R; r >= 0; r--) {
    for (g = (N - r * R) / G; g >= 0; g--) {
      for (b = (N - r * R - g * G) / B; b >= 0; b--) {
        if (r * R + g * G + b * B == N) {
          cnt++;
        }
      }
    }
  }

  cout << cnt << endl;

  return 0;
}

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

int main() {
  int R, G, B, N;
  int r, g, b, cnt;
  r = g = b = cnt = 0;

  cin >> R >> G >> B >> N;

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

  cout << cnt << endl;

  return 0;
}
Problem p03048 (C++)

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

#define INF 1LL << 60
#define MOD 1000000007;
#define pb push_back

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, b, e) for (int i = (b); i <= (e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a)                                                              \
  cout << #a << ": " << endl;                                                  \
  for (const auto &v : (a))                                                    \
  cout << v << endl

int R, G, B;
int N;

int main() {
  cin.tie(0);
  cin >> R >> G >> B >> N;

  int cnt = 0;
  REPR(i, 0, N / R + 1) {
    REPR(j, 0, N / G + 1) {
      REPR(k, 0, N / B + 1) {
        if (R * i + G * j + B * k == N) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;

  return 0;
}


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

#define INF 1LL << 60
#define MOD 1000000007;
#define pb push_back

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, b, e) for (int i = (b); i <= (e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a)                                                              \
  cout << #a << ": " << endl;                                                  \
  for (const auto &v : (a))                                                    \
  cout << v << endl

int R, G, B;
int N;

int main() {
  cin.tie(0);
  cin >> R >> G >> B >> N;

  int cnt = 0;
  int tmp = 0;
  REPR(r, 0, N / R + 1) {
    REPR(g, 0, N / G + 1) {
      tmp = N - r * R - g * G;
      if (tmp >= 0 && tmp % B == 0) {
        cnt++;
      }
    }
  }
  cout << cnt << 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 ans = 0;

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

        if ((R * r + g * G + B * b) == N) {
          ans += 1;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {

  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int ans = 0;

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

  cout << ans << endl;

  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
// RGB Boxes

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, x, y) for (int i = x; i < y; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) a / __gcd(a, b) * b
#define range(a) (a).begin(), (a).end()
const int inf = 2147483647;

int main() {
  int R, G, B, N, Ans = 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; (j * G + i * R + k * B) <= N; k++) {
        if (N == i * R + j * G + k * B)
          Ans++;
      }
    }
  }
  cout << Ans << endl;
  return 0;
}

Fixed submission:
// RGB Boxes

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, x, y) for (int i = x; i < y; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) a / __gcd(a, b) * b
#define range(a) (a).begin(), (a).end()
const int inf = 2147483647;

int main() {
  int R, G, B, N, Ans = 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 (N >= i * R + j * G && (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;
using Graph = vector<vector<int>>;
#define rep(i, a, b) for (int i = (a); i < (b); i++)

typedef pair<int, int> P;
typedef long long ll;

const int INF = 100000000;
const double PI = 3.14159265358979323846;

int main() {

  ll R, G, B, N;
  cin >> R >> G >> B >> N;

  ll a, b, c, ans;
  ans = 0;
  a = b = c = 0;
  while (a <= N) {
    b = 0;
    while (a + b <= N) {
      // cout << a+b+c << endl;
      c = 0;
      while (a + b + c <= N) {
        if (a + b + c == N) {
          ans++;
          // cout << ans << endl;
        }
        c += B;
      }
      b += G;
    }
    a += R;
  }
  cout << ans << endl;
}

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

typedef pair<int, int> P;
typedef long long ll;

const int INF = 100000000;
const double PI = 3.14159265358979323846;

int main() {

  ll R, G, B, N;
  cin >> R >> G >> B >> N;

  ll a, b, c, ans;
  ans = 0;
  a = b = c = 0;
  while (a <= N) {
    b = 0;
    while (a + b <= N) {
      if ((N - a - b) % B == 0) {
        ans++;
      }
      b += G;
    }
    a += R;
  }
  cout << ans << endl;
}
Problem p03048 (C++)

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

int main() {
  int r, g, b, n;
  int count = 0;
  cin >> r >> g >> b >> n;

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

  cout << count << endl;
}

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

int main() {
  int r, g, b, n;
  int count = 0;
  cin >> r >> g >> b >> n;

  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < n + 1 - i; j++) {
      if ((n - i * r - j * g) % b == 0) {
        if (n - i * r - j * g >= 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;
  cin >> R >> G >> B >> N;
  int cnt = 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) {
          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++) {
    for (int g = 0; g <= 3000; g++) {
      if (R * r + G * g <= N && (N - R * r - G * g) % B == 0) {
        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 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>
using namespace std;
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 / G; g++) {
      if (r * R + g * G <= N && (N - (r * R + g * G)) % B == 0)
        ans++;
    }
  }
  cout << ans << endl;
}
Problem p03048 (C++)

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

#define FOR(i, b, e) for (int i = b; i <= e; i++)
#define FORD(i, b, e) for (int i = b; i >= e; i--)
#define SIZE(x) ((int)x.size())
#define pb push_back
#define st first
#define nd second
#define sp ' '
#define ent '\n'
// END OF TEMPLATE

ll t[3], n;

ll ways(int pos, ll rem) {
  if (pos == 3)
    return rem == 0;
  ll ret = 0;
  for (ll i = 0; i * t[pos] <= rem; i++) {
    ret += ways(pos + 1, rem - i * t[pos]);
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  FOR(i, 0, 2) cin >> t[i];
  cin >> n;
  cout << ways(0, n) << ent;
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

#define FOR(i, b, e) for (int i = b; i <= e; i++)
#define FORD(i, b, e) for (int i = b; i >= e; i--)
#define SIZE(x) ((int)x.size())
#define pb push_back
#define st first
#define nd second
#define sp ' '
#define ent '\n'
// END OF TEMPLATE

ll t[3], n;

ll ways(int pos, ll rem) {
  if (pos == 2)
    return rem % t[pos] == 0;
  ll ret = 0;
  for (ll i = 0; i * t[pos] <= rem; i++) {
    ret += ways(pos + 1, rem - i * t[pos]);
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  FOR(i, 0, 2) cin >> t[i];
  cin >> n;
  cout << ways(0, n) << ent;
  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 ret = 0;

  for (int i = n / r; i >= 0; --i) {
    if (i * r == n) {
      ++ret;
    } else {
      for (int j = (n - i * r) / g; j >= 0; --j) {
        if ((i * r + j * g) == n) {
          ++ret;
        } else {
          for (int k = (n - i * r - j * g) / b; k >= 0; --k) {
            if ((i * r + j * g + k * b) == n) {
              ++ret;
            }
          }
        }
      }
    }
  }
  cout << ret << 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 ret = 0;

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

Buggy submission (status: Time Limit Exceeded):
/**
 *    author:  yuya1234
 *    created: 09.07.2020 09:28:00
 **/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(), (s).end())
#define SORTD(s) sort((s).rbegin(), (s).rend())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int r, g, b, n;
  cin >> r >> g >> b >> n;

  ll cnt = 0;
  REP(i, n / r + 1) REP(j, n / g + 1) REP(k, n / b + 1) {
    if (n == i * r + j * g + k * b) {
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}

Fixed submission:
/**
 *    author:  yuya1234
 *    created: 09.07.2020 09:28:00
 **/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(), (s).end())
#define SORTD(s) sort((s).rbegin(), (s).rend())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int r, g, b, n;
  cin >> r >> g >> b >> n;

  ll cnt = 0;
  REP(i, n / r + 1) REP(j, n / g + 1) {
    if ((n - i * r - j * g) % b == 0 && n - i * r - j * g >= 0) {
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for (int i = 0; i < n; i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(), n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli, lli>>
int main() {
  lli A, B = 0, C, D = 0, E, F = INF;
  cin >> A >> B >> C >> E;
  if (A == 1 && B == 1 && C == 1 && D == 3000)
    Out(4504501);
  else {
    rep(i, INF) {
      if (i * A > E)
        break;
      rep(j, INF) {
        if (i * A + j * B > E)
          break;
        rep(k, INF) {
          if (i * A + j * B + k * C > E)
            break;
          else if (i * A + j * B + k * C == E)
            D++;
        }
      }
    }
    Out(D);
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for (int i = 0; i < n; i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(), n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli, lli>>
int main() {
  lli A, B = 0, C, D = 0, E, F = INF;
  cin >> A >> B >> C >> E;
  if (A == 1 && B == 1 && C == 1 && E == 3000)
    Out(4504501);
  else {
    rep(i, INF) {
      if (i * A > E)
        break;
      rep(j, INF) {
        if (i * A + j * B > E)
          break;
        rep(k, INF) {
          if (i * A + j * B + k * C > E)
            break;
          else if (i * A + j * B + k * C == E)
            D++;
        }
      }
    }
    Out(D);
  }
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

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

  if (R == 1 && G == 1 && B == 1) {
    long abc = 0;
    for (int i = 1; i <= N + 1; i++) {
      abc += i;
    }
    cout << abc << endl;
  }

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

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

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

  if (R == 1 && G == 1 && B == 1) {
    long abc = 0;
    for (int i = 1; i <= N + 1; i++) {
      abc += i;
    }
    cout << abc << endl;
    return 0;
  }

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

  return 0;
}
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 erep(i, n) for (int i = 0; i <= n; i++)
#define rep1(i, n) for (int i = 1; i < n; i++)
#define erep1(i, n) for (int i = 1; i <= n; i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int, int>;
signed main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int rcount = n / r;
  int gcount = n / g;
  int bcount = n / b;
  int ans = 0;
  erep(i, rcount) erep(j, gcount) erep(s, bcount) {
    if (r * i + g * j + b * s == 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 erep(i, n) for (int i = 0; i <= n; i++)
#define rep1(i, n) for (int i = 1; i < n; i++)
#define erep1(i, n) for (int i = 1; i <= n; i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int, int>;
signed main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int rcount = n / r;
  int gcount = n / g;
  int bcount = n / b;
  int ans = 0;
  erep(i, rcount) erep(j, gcount) {
    if (r * i + g * j <= n)
      if ((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 <vector>

using namespace std;

int main(int argc, char **argv) {
  int n;
  std::vector<int> rgb(3);
  cin >> rgb[0] >> rgb[1] >> rgb[2] >> n;
  int ans{0};
  std::sort(rgb.begin(), rgb.end(), std::greater<int>());

  for (int i = 0; i <= n; i += rgb[0]) {
    for (int j = 0; (j + i) <= n; j += rgb[1]) {
      for (int k = 0; (k + j + i) <= n; k += rgb[2]) {
        if ((i + j + k) == n) {
          ++ans;
        }
      }
    }
  }

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

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char **argv) {
  int n;
  std::vector<int> rgb(3);
  cin >> rgb[0] >> rgb[1] >> rgb[2] >> n;
  int ans{0};
  std::sort(rgb.begin(), rgb.end(), std::greater<int>());

  for (int i = 0; i <= n; i += rgb[0]) {
    for (int j = 0; (j + i) <= n; j += rgb[1]) {
      if (((j + i) - n) % rgb[2] == 0) {
        ++ans;
      }
    }
  }

  cout << ans << 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;
  int64_t ans = 0;
  for (auto i = 0; i <= n; i++) {
    if (r * i > n)
      break;
    for (auto j = 0; j <= n; j++) {
      if (r * i + g * j > n)
        break;
      for (auto k = 0; k <= n; k++) {
        if (r * i + g * j + b * k > n)
          break;
        if (r * i + g * j + b * k == n)
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

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

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

int main() {
  int ans = 0;
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      if (i + j > n)
        continue;
      for (int k = 0; k <= (n - i * r - j * g) / b; k++)
        if (i * r + j * g == n - b * k) {
          // printf("%d %d %d\n", i, j, k);
          ans++;
        }
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

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

int main() {
  int a, b, c, n;

  cin >> a >> b >> c >> n;

  int ans = 0;

  for (int i = 0; a * i <= n; i++) {
    for (int j = 0; b * j <= n; j++) {
      for (int k = 0; c * k <= n; k++) {
        if (a * i + b * j + c * k == n)
          ans++;
      }
    }
  }

  cout << ans;

  return 0;
}

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

int main() {
  int a, b, c, n;

  cin >> a >> b >> c >> n;

  int ans = 0;

  for (int i = 0; a * i <= n; i++) {
    for (int j = 0; b * j <= n; j++) {
      if ((n - (a * i + b * j)) % c == 0 && (n - (a * i + b * j)) >= 0) {
        ans++;
        // cout << a*i << " " << b*j << " " << n-(a*i+b*j) << endl;
      }
    }
  }

  cout << ans;

  return 0;
}
Problem p03048 (C++)

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

int main(void) {
  int R, G, B, N;
  int count = 0;

  std::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 (k * B + j * G + i * R == N)
          count++;

  std::cout << count << std::endl;

  return 0;
}

Fixed submission:
#include <iostream>

int main(void) {
  int R, G, B, N;
  int count = 0;

  std::cin >> R >> G >> B >> N;
  for (int i = 0; i * R <= N; i++)
    for (int j = 0; j * G + i * R <= N; j++)
      if ((N - i * R - j * G) % B == 0)
        count++;

  std::cout << count << std::endl;

  return 0;
}
Problem p03048 (C++)

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

using namespace std;

int main() {
  int R, G, B, N, count = 0;
  scanf("%d %d %d %d", &R, &G, &B, &N);

  for (int i = 0; i <= N; i += R) {
    for (int j = 0; i + j <= N; j += G) {
      for (int k = 0; i + j + k <= N; k += B) {
        if (N == (i + j + k)) {
          count++;
        } else if (N < (i + j + k)) {
          break;
        }
      }
    }
  }
  cout << count << endl;
}

Fixed submission:
#include <iostream>
#include <string>

using namespace std;

int main() {
  int R, G, B, N, count = 0;
  scanf("%d %d %d %d", &R, &G, &B, &N);

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int R, G, B, N;
long long ans = 0;

int main(int argc, char *argv[]) {
  cin >> R >> G >> B >> N;

  for (int i = 0; R * i <= N; i++) {
    if (R * i > N)
      continue;
    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 << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int R, G, B, N;
long long ans = 0;

int main(int argc, char *argv[]) {
  cin >> R >> G >> B >> N;

  for (int i = 0; R * i <= N; i++) {
    if (R * i > N)
      continue;
    for (int j = 0; R * i + G * j <= N; 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 <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 <= N / R; i++) {
    for (int j = 0; j <= (N - R * i) / G; j++) {
      for (int k = 0; k <= N / B; k++) {
        if (R * i + G * j + B * k == N) {
          cnt++;
          break;
        }
      }
    }
  }

  cout << cnt << endl;
}

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 <= N / R; i++) {
    for (int j = 0; j <= (N - R * i) / G; j++) {
      int tmp = N - R * i - G * j;
      if (tmp >= 0 && tmp % B == 0) {
        cnt++;
      }
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int R, G, B, N;
  int ans = 0;
  cin >> R >> G >> B >> N;
  for (int i = 0; i <= N; i++) {
    if (i * R > N)
      break;
    for (int j = 0; j <= N; j++) {
      if (i * R + j * G > N)
        break;
      for (int k = 0; k <= N; k++) {
        if (i * R + j * G + k * B > N)
          break;
        if (i * R + j * G + k * B == N)
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int R, G, B, N;
  int ans = 0;
  cin >> R >> G >> B >> N;
  for (int i = 0; i <= N; i++) {
    if (i * R > N)
      break;
    for (int j = 0; j <= N; j++) {
      if (i * R + j * G > N)
        break;

      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;

int main() {

  int r, g, b, N, cnt = 0;
  cin >> r >> g >> b >> N;

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

  cout << cnt << endl;
  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 <= N / r; i++) {
    for (int j = 0; j <= N / g; j++) {
      if (((N - (i * r + j * g)) % b == 0) && (i * r + j * g <= N))
        cnt++;
    }
  }

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

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

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

  int cnt = 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)
        continue;
      for (int k = 0; i * R + j * G + k * B <= N; k++) {
        if (i * R + j * G + k * B == N)
          cnt++;
      }
    }
  }

  cout << cnt << endl;
}

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

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

  int cnt = 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)
        cnt++;
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ll = long long;

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

Fixed submission:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ll = long long;

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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


Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int r, g, b, n, c = 0;
  cin >> r >> g >> b >> n;
  for (size_t i = 0; r * i <= n; i++) {
    for (size_t j = 0; g * j <= n; j++) {
      int k = (n - (r * i + g * j));
      if (k >= 0 && k % b == 0) {
        // cout << "ijk" << i << j << (n - (r * i + g * j)) / b << endl;
        c++;
      }
    }
  }
  cout << c << endl;
}
Problem p03048 (C++)

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

signed main() {

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

  return 0;
}

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

signed main() {

  int ans = 0;
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  for (int i = 0; i * r <= n; i++) {
    for (int j = 0; j * g <= n; j++) {
      if (i * r + j * g > n)
        continue;
      int N = n - i * r - j * g;
      if (N % 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 ll long long
#define Fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);
#define pb push_back
#define mx *max_element
#define mi *min_element
#define fn for (long long int i = 0; i < n; i++)
#define fn1 for (long long int i = 1; i <= n; i++)
#define fm for (long long int j = 0; j < m; j++)
#define fm1 for (long long int j = 1; j <= m; j++)
#define fi first
#define se second
#define MOD 1000000007
const int N = 1e6;
int main() {
  Fast;
  ll n, p, q, s;
  ll ans = 0;
  cin >> p >> q >> s >> n;
  for (int i = 0; i <= n / p; i++) {
    for (int j = 0; j <= n / q; j++) {
      for (int k = 0; k <= n / s; k++) {
        /// cout<< i*p+j*q+k*s << " " << i <<" " << endl;
        if (n == (i * p + j * q + k * s)) {
          ans++;
        }
      }
    }
  }
  cout << ans;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define Fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);
#define pb push_back
#define mx *max_element
#define mi *min_element
#define fn for (long long int i = 0; i < n; i++)
#define fn1 for (long long int i = 1; i <= n; i++)
#define fm for (long long int j = 0; j < m; j++)
#define fm1 for (long long int j = 1; j <= m; j++)
#define fi first
#define se second
#define MOD 1000000007
const int N = 1e6;
int main() {
  Fast;
  ll n, p, q, s;
  ll ans = 0;
  cin >> p >> q >> s >> n;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      /// cout << n-p*i-q*j << endl;
      if ((n - p * i - s * j) % q == 0 && ((n - p * i - s * j) / q >= 0))
        ans++;
    }
  }
  cout << ans;
  return 0;
}
Problem p03048 (C++)

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

int main() {

  int R;
  int G;
  int B;
  int N;

  cin >> R >> G >> B >> N;

  int i = -1;
  int j = -1;
  int k = -1;
  int times = 0;

  while (true) {
    i += 1;
    if (i * R > N) {
      i = -1;
      break;
    }

    while (true) {
      j += 1;
      if ((i * R + j * G) > N) {
        j = -1;
        break;
      }

      while (true) {
        k += 1;
        if (i * R + j * G + k * B > N) {
          k = -1;
          break;
        }

        if (i * R + j * G + k * B == N) {
          times += 1;
        }
      }
    }
  }

  cout << times << endl;
}


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

int main() {

  int R;
  int G;
  int B;
  int N;

  cin >> R >> G >> B >> N;

  int i = -1;
  int j = -1;
  int k = -1;
  int times = 0;

  while (true) {
    i += 1;
    if (i * R > N) {
      i = -1;
      break;
    }

    while (true) {
      j += 1;
      if ((i * R + j * G) > N) {
        j = -1;
        break;
      }
      if ((N - i * R - j * G) % B == 0) {
        times++;
      }
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;

int main(int argc, char **argv) {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

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

  cout << res << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;

int main(int argc, char **argv) {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

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

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

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

int main() {
  int R, G, B, N;
  std::cin >> R >> G >> B >> N;
  int r = N / R, g = N / G, b = N / B;
  int count = 0;
  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= g; j++) {
      bool l = true;
      for (int k = 0; l; k++) {
        int a = B * k + G * j + R * i;
        if (a == N)
          count += 1;
        if (a >= N)
          l = false;
      }
    }
  }
  std::cout << count;
  return 0;
}

Fixed submission:
#include <iostream>

int main() {
  int R, G, B, N;
  std::cin >> R >> G >> B >> N;
  int r = N / R, g = N / G, b = N / B;
  int count = 0;
  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= g; j++) {
      int a = N - i * R - j * G;
      if (a % B == 0 && a >= 0) {
        count += 1;
      }
    }
  }
  std::cout << count;
  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 ans = 0;
  for (int r_num = 0; r_num <= n / r; r_num++) {
    for (int g_num = 0; g_num <= (n - r * r_num) / g; g_num++) {
      for (int b_num = 0; b_num <= (n - r * r_num - g * g_num) / b; b_num++) {
        if (r * r_num + g * g_num + b * b_num == n)
          ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int ans = 0;
  for (int r_num = 0; r_num <= n / r; r_num++) {
    for (int g_num = 0; g_num <= (n - r * r_num) / g; g_num++) {
      if ((n - r * r_num - g * g_num) % b == 0)
        ans++;
    }
  }
  cout << ans << endl;

  return 0;
}
Problem p03048 (C++)

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

using namespace std;

int main() {
  int R, G, B, N, ans;
  cin >> R >> G >> B >> N;
  ans = 0;
  for (int i = 0; i * R <= N; ++i) {
    for (int j = 0; j * G + i * R <= N; ++j) {
      for (int k = 0; i * R + k * B + j * G <= N; ++k) {
        int total = R * i + G * j + B * k;
        if (total == N)
          ans += 1;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int R, G, B, N, ans;
  cin >> R >> G >> B >> N;
  ans = 0;
  if (R == 1 && G == 1 && B == 1) {
    ans = (N + 1) * (N + 2) / 2;
  } else {
    for (int i = 0; i * R <= N; ++i) {
      for (int j = 0; j * G + i * R <= N; ++j) {
        for (int k = 0; i * R + k * B + j * G <= N; ++k) {
          int K = N - i * R - j * G - k * B;
          if (K == 0)
            ans++;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p03048 (C++)

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

int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int ans = 0;
  for (int i = 0; int r0 = r * i <= n; i++) {
    for (int j = 0; int b0 = j * b <= n - r0; b++) {
      int x = n - r0 - b0;
      if (x >= 0 && (x % g) == 0)
        ans++;
    }
  }
  cout << ans << endl;
}


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

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

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

int main(int argc, char const *argv[]) {
  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; 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)
          cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

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

int main(int argc, char const *argv[]) {
  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; r * R + g * G <= N; g++) {
      if ((N - r * R - g * G) % B == 0) {
        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 ans = 0;

  for (int i = 0; i * r <= n; i++) {
    for (int j = 0; i * r + j * g <= n; j++) {
      for (int k = 0; i * r + j * g + k * b <= n; k++) {
        if (i * r + j * g + k * 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 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;
}
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 ll long long
const long long INF = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
  int r, g, b, N;
  cin >> r >> g >> b >> N;
  int ans = 0;
  REP(i, N / r + 1) {
    REP(j, N / g + 1) {
      REP(k, N / b + 1) {
        if (r * i + g * j + b * k == 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 ll long long
const long long INF = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
  int r, g, b, N;
  cin >> r >> g >> b >> N;
  int ans = 0;
  REP(i, N / r + 1) {
    REP(j, N / g + 1) {
      int sum = i * r + j * g;
      int x = N - sum;
      if (x == 0)
        ans++;
      else if (x % b == 0 && x > 0)
        ans++;
    }
  }
  cout << ans << endl;
}