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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9 + 7;
typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

ll gcd(ll A, ll B) {
  if (A % B == 0)
    return (B);
  else
    return (gcd(B, A % B));
}

ll keta(ll N) {
  int tmp{};
  while (N > 0) {
    tmp += (N % 10);
    N /= 10;
  }
  N = tmp;
  return N;
}

vector<vector<ll>> combination(ll n, ll r) {
  vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
  for (ll i = 0; i < v.size(); ++i) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (ll i = 1; i < v.size(); ++i) {
    for (ll j = 0; j < i; ++j) {
      v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
    }
  }
  return v;
}

bool kai(string S) {
  bool flag = true;
  for (ll i = 0; i < S.size() / 2; ++i) {
    if (S[i] != S[S.size() - i - 1]) {
      flag = false;
      break;
    }
  }
  return flag;
}
// ---------------------------------------------

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

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9 + 7;
typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

ll gcd(ll A, ll B) {
  if (A % B == 0)
    return (B);
  else
    return (gcd(B, A % B));
}

ll keta(ll N) {
  int tmp{};
  while (N > 0) {
    tmp += (N % 10);
    N /= 10;
  }
  N = tmp;
  return N;
}

vector<vector<ll>> combination(ll n, ll r) {
  vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
  for (ll i = 0; i < v.size(); ++i) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (ll i = 1; i < v.size(); ++i) {
    for (ll j = 0; j < i; ++j) {
      v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
    }
  }
  return v;
}

bool kai(string S) {
  bool flag = true;
  for (ll i = 0; i < S.size() / 2; ++i) {
    if (S[i] != S[S.size() - i - 1]) {
      flag = false;
      break;
    }
  }
  return flag;
}
// ---------------------------------------------

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

  return 0;
}
Problem p03048 (C++)

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

#define froop1(a, n) for (int i = a; i < n; i++)
#define froop2(a, n) for (int i = a; i > n; i--)
int main() {
  int N, r, g, b, count;
  cin >> r >> g >> b >> N;
  froop1(0, N / r + 1) {
    for (int j = 0; j < (N - i * r) / g + 1; j++) {
      for (int k = 0; k < (N - i * r - j * g) / b + 1; k++) {
        if (r * i + g * j + b * k == N) {
          count++;
        }
      }
    }
  }
  cout << count << endl;

  return 0;
}

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

#define froop1(a, n) for (int i = a; i < n; i++)
#define froop2(a, n) for (int i = a; i > n; i--)
int main() {
  int N, r, g, b, count;
  cin >> r >> g >> b >> N;
  froop1(0, N / r + 1) {
    for (int j = 0; j < (N - i * r) / g + 1; j++) {
      if ((N - r * i - g * j) % b == 0) {
        count++;
      }
    }
  }
  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, a = 0;
  cin >> r >> g >> b >> n;
  for (int i = 0; i <= n / r; i++) {
    for (int j = 0; j <= (n - i * r) / g; j++) {
      int p = n - i * r - j * g;
      for (int k = 0; k <= p / b; k++) {
        if (n == i * r + j * g + k * b)
          a++;
      }
    }
  }
  cout << a << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, g, b, n, a = 0;
  cin >> r >> g >> b >> n;
  for (int i = 0; i <= n / r; i++) {
    for (int j = 0; j <= (n - i * r) / g; j++) {
      if ((n - i * r - j * g) % b == 0)
        a++;
    }
  }
  cout << a << endl;
}
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 i = 0; i <= 3000; i++) {
    for (int j = 0; j <= 3000 - i; j++) {
      for (int k = 0; k <= 3000 - i - j; k++) {
        int A = R * i + G * j + B * k;
        if (A == N)
          ans++;
      }
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      int A = R * i + G * j;
      int n = N - A;
      // cout << n << endl;
      if (n >= 0 && n % B == 0)
        ans++;
    }
  }
  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;
  cin >> R >> G >> B >> N;

  int ans = 0;

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

  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;

  int ans = 0;

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

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

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

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

  int result = 0;

  for (int r = 0, r_limit = N / R; r <= r_limit; ++r) {
    int r_buy = r * R;
    for (int g = 0, g_limit = (N - r_buy) / G; g <= g_limit; ++g) {
      int g_buy = g * G;
      for (int b = 0, b_limit = (N - g_buy) / B; b <= b_limit; ++b) {
        int b_buy = b * B;
        if (r_buy + g_buy + b_buy == N) {
          ++result;
        }
      }
    }
  }
  std::cout << result;
  return 0;
}

Fixed submission:
#include <iostream>

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

  int result = 0;

  for (int r = 0, r_limit = N / R; r <= r_limit; ++r) {
    int r_buy = r * R;
    for (int g = 0, g_limit = (N - r_buy) / G; g <= g_limit; ++g) {
      int g_buy = g * G;
      if (((N - r_buy - g_buy) % B) == 0) {
        ++result;
      }
    }
  }
  std::cout << result;
  return 0;
}
Problem p03048 (C++)

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

using ll = long long;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

const ll INF = (ll)1e11;

using namespace std;

int main() {
  ios::sync_with_stdio(false);

  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 - r * R) / G + 1; ++g) {
      for (int b = 0; b <= (N - r * R - g * G) / B + 1; ++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 <bits/stdc++.h>

using ll = long long;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

const ll INF = (ll)1e11;

using namespace std;

int main() {
  ios::sync_with_stdio(false);

  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 - r * R) / G + 1; ++g) {
      if (r * R + g * G > N)
        break;
      if ((N - r * R - g * 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 rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v), greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll, ll> pal;

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


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v), greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll, ll> pal;

int main() {
  ll R, G, B, N, cnt = 0;
  cin >> R >> G >> B >> N;
  for (ll r = 0; r * R <= N; r++) {
    for (ll g = 0; g * G <= N; g++) {
      ll bB = N - (r * R + g * G);
      if (bB % B == 0 && bB >= 0) {
        cnt++;
      }
    }
  }
  cout << cnt << 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 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) {
        int n = R * i + G * j + B * k;
        if (n == N)
          ++ans;
        else if (n > N)
          break;
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Fixed submission:
#include <iostream>

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

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;

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

  int count = 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) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}


Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;

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

  int count = 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) {
        // for (int b = 0; B * b <= N - R * r - G * g; b++) {
        // if (r * R + g * G + b * B == N) {
        count++;
        // }
      }
    }
  }
  cout << count << endl;
}
Problem p03048 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pr pair<ll, ll>
#define loop(i, n) for (ll i = 0; i < n; ++i)
#define rep(i, x, n) for (ll i = x; i <= n; ++i)
#define iteloop(type, data, name, it)                                          \
  for (type<data>::iterator it = name.begin(); it != name.end(); ++it)
using namespace std;
const ll N = 2e2 + 5;
int a, b, c, n;
int main() {
  cin.sync_with_stdio(false), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("in.txt", "rt", stdin);
  // freopen("out.txt", "wt" , stdout);
#endif // ONLINE_JUDGE
  cin >> a >> b >> c >> n;
  int ans = 0;
  loop(i, n + 1) {
    loop(j, n + 1) {
      int total = i * a + j * b;
      if (total > n)
        continue;
      if ((n - total) % c == 0)
        ans++;
    }
  }
  cout << ans << endl;
}

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

#define ll long long
#define ld long double
#define pr pair<ll, ll>
#define loop(i, n) for (ll i = 0; i < n; ++i)
#define rep(i, x, n) for (ll i = x; i <= n; ++i)
#define iteloop(type, data, name, it)                                          \
  for (type<data>::iterator it = name.begin(); it != name.end(); ++it)
using namespace std;
const ll N = 2e2 + 5;
int a, b, c, n;
int main() {
  cin.sync_with_stdio(false), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
  //  freopen("in.txt", "rt" , stdin);
  // freopen("out.txt", "wt" , stdout);
#endif // ONLINE_JUDGE
  cin >> a >> b >> c >> n;
  int ans = 0;
  loop(i, n + 1) {
    loop(j, n + 1) {
      int total = i * a + j * b;
      if (total > n)
        continue;
      if ((n - total) % c == 0)
        ans++;
    }
  }
  cout << ans << endl;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define ll long long
#define mod 1000000007

using namespace std;

// ll cnt;

int main() {
  IOS;
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int cnt = 0;
  for (int y = 0; y <= n / r; y++) {
    for (int x = 0; x <= n / g; x++) {
      for (int h = 0; h <= n / b; h++) {
        if (y * r + x * g + h * b == n)
          cnt++;
      }
    }
  }
  cout << cnt << "\n";
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define ll long long
#define mod 1000000007

using namespace std;

// ll cnt;

int main() {
  IOS;
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int cnt = 0;
  for (int y = 0; y <= n / r; y++) {
    for (int x = 0; x <= n / g; x++) {
      if (y * r + x * g == n)
        cnt++;
      else if ((n - y * r - x * g) % b == 0 && n - y * r - x * g > 0)
        cnt++;
    }
  }
  cout << cnt << "\n";
  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main(void) {
  int R, G, B, N, tmp, count = 0;
  cin >> R >> G >> B >> N;

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

  cout << count << "\n";
}

Fixed submission:
#include <iostream>
using namespace std;
int main(void) {
  int R, G, B, N, tmp, count = 0;
  cin >> R >> G >> B >> N;

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

  cout << count << "\n";
}
Problem p03048 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>
#include <iostream>
using namespace std;
int x, n;
int f[5000];
int main() {
  f[0] = 1;
  for (register int i = 1; i <= 3; i++) {
    scanf("%d", &x);
    for (register int j = 0; j <= 5000; j++) {
      if (f[j])
        f[j + x] += f[j];
    }
  }
  scanf("%d", &n);
  printf("%d\n", f[n]);
  return 0;
}

Fixed submission:
#include <cstdio>
#include <iostream>
using namespace std;
int x, n;
int f[10000];
int main() {
  f[0] = 1;
  for (register int i = 1; i <= 3; i++) {
    scanf("%d", &x);
    for (register int j = 0; j <= 5000; j++) {
      if (f[j])
        f[j + x] += f[j];
    }
  }
  scanf("%d", &n);
  printf("%d\n", f[n]);
  return 0;
}
Problem p03048 (C++)

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

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;
  return 0;
}


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

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

  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 count = 0;
  int rmax = n / r;
  int gmax = n / g;
  int bmax = n / b;
  for (int i = 0; i <= rmax; i++) {
    for (int j = 0; j <= (n - r * i) / g; j++) {
      if ((n - r * i - g * j) % b == 0)
        count++;
    }
  }

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

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

#define INF INT_MAX

using namespace std;

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

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

  return 0;
}

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

#define INF INT_MAX

using namespace std;

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

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int i = 0; i <= N; i += R) {
    for (int j = 0; j + i <= N; j += B) {
      if ((N - (i + j)) % G == 0) {
        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++)
typedef long long ll;
int main() {

  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int count = 0;
  rep(i, (N - 1) / R + 2) {
    rep(j, (N - 1) / G + 2) {
      rep(k, (N - 1) / B + 2) {
        if (R * i + G * j + B * k == N)
          count++;
      }
    }
  }
  cout << count << endl;
}

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

  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int count = 0;
  rep(i, 3001) {
    rep(j, 3001) {
      if ((N - R * i - G * j) % B == 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>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

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


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main() {
  int r, g, b, n;
  int ans = 0;
  cin >> r >> g >> b >> n;
  for (int R = 0; R <= n; R += r) {
    for (int G = 0; G < n + 1 - R; G += g) {
      if ((n - R - G) % b == 0)
        ans++;
    }
  }
  cout << ans << endl;
}
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 i = 0; i <= n / r; ++i) {
    for (int j = 0; j <= (n - i * r) / g; ++j) {
      for (int k = 0; k <= (n - i * r - j * g) / b; ++k) {
        if (i * r + j * g + k * b == n)
          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 i = 0; i <= n / r; ++i) {
    for (int j = 0; j <= (n - i * r) / g; ++j) {
      if ((n - (i * r + j * 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;

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


Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
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 i = 0; i <= n / r; ++i) {
    for (int j = 0; j <= n / g; ++j) {
      int temp = n - r * i - g * j;
      // cout << temp << endl;
      if (temp % b == 0 && temp / 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;

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

  int r = N / R + 1;
  int g = N / G + 1;
  int b = N / B + 1;
  for (int i = 0; i < r; i++) {
    int sum = i * R;
    for (int j = 0; j < g; j++) {
      int sum_sub = sum;
      sum_sub += j * G;
      for (int k = 0; k < b; k++) {
        int sum_sub_sub = sum_sub;
        sum_sub_sub += k * B;
        if (sum_sub_sub == N) {
          count += 1;
        }
      }
    }
  }
  cout << count << endl;
}

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

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

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;

  int r = N / R;
  int g = N / G;
  int b = N / B;

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

Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;

  int r = N / R;
  int g = N / G;
  int b = N / B;

  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= g; j++) {
      if ((N - (R * i + G * j)) % B == 0 && N - (R * i + G * j) >= 0)
        ans++;
    }
  }
  cout << ans;
}
Problem p03048 (C++)

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

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

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

int main() {
  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 / g; j++) {
      if ((n - r * i - g * j) % b == 0 && (n - r * i - g * j) >= 0)
        ans++;
    }
  }
  cout << ans << endl;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
// to format a document: ctrl + K -> ctrl + D

#include <algorithm>
#include <cmath>
#include <iostream>
#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 i = 0; i <= N; i += R) {
    for (int j = 0; j <= N - i; j += G) {
      for (int k = 0; k <= N - i - j; k += B) {
        if (i + j + k == N)
          ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Fixed submission:
// to format a document: ctrl + K -> ctrl + D

#include <algorithm>
#include <cmath>
#include <iostream>
#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 i = 0; i <= N; i += R) {
    for (int j = 0; j <= N - i; j += G) {
      if ((N - i - 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;
  vector<int> input(3);
  cin >> input[0] >> input[1] >> input[2] >> n;
  sort(input.begin(), input.end());
  r = input[2];
  g = input[1];
  b = input[0];
  int ans = 0;

  int r_n = n / r;
  int g_n = n / g;
  int b_n = n / b;

  for (int i = 0; i <= r_n; i++) {
    for (int j = 0; j <= g_n; j++) {
      if (r * i + g * j > n)
        break;
      for (int k = 0; k <= b_n; k++) {
        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;
  vector<int> input(3);
  cin >> input[0] >> input[1] >> input[2] >> n;
  sort(input.begin(), input.end());
  r = input[2];
  g = input[1];
  b = input[0];
  int ans = 0;

  int r_n = n / r;
  int g_n = n / g;
  int b_n = n / b;

  for (int i = 0; i <= r_n; i++) {
    for (int j = 0; j <= g_n; j++) {
      if ((n - r * i - g * j) % b == 0 && (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(void) {
  int R, G, B, N, a, ans = 0;
  cin >> R >> B >> G >> N;

  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++) {
        a = R * i + B * k + G * j;
        if (N == a) {
          ans++;
        }
      }
    }
  }

  cout << ans << "\n";
  return 0;
}

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

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

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

  cout << ans << "\n";
  return 0;
}
Problem p03048 (C++)

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

typedef long long ll;
using namespace std;

ll Mod = 1e9 + 7;
int main() {
  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 / G; j++) {
      for (int k = 0; k <= N / B; k++) {
        // cout << i << " " << j << " " << k << endl;
        if (i * R + j * G + k * B == N)
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

ll Mod = 1e9 + 7;
int main() {
  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 / G; j++) {
      if (i * R + j * G > N)
        continue;
      if ((N - i * R - j * G) % B == 0) {
        ans++;
        // cout << i << " " << j << endl;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <climits>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define MAX 1000000007

using namespace std;
#define ll long long
#define dbg if (1)
#define ISRANGE(val, lo, hi) ((lo <= val) && (val < hi))

int main() {
  ll ans, 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; k * b + j * g + i * r <= n; k++) {
        if (k * b + j * g + i * r == n)
          ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <climits>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define MAX 1000000007

using namespace std;
#define ll long long
#define dbg if (1)
#define ISRANGE(val, lo, hi) ((lo <= val) && (val < hi))

int main() {
  ll ans, 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 - (j * g + i * r)) % b == 0)
        ans++;
    }
  }

  cout << ans << 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;

  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;

  return 0;
}

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

int main() {
  int 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++;
              }
          }
      }
  }
  */

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

  cout << count << 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;
  cin >> R >> G >> B >> N;
  int count = 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 + g + b == N)
          count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}

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

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int count = 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)
        count++;
    }
  }
  cout << count << 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 all(v) v.begin(), v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll INFS = 1e18;
const int MOD = INF + 7;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int 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 (r * i + g * j + b * k == n)
          ans++;
      }
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll INFS = 1e18;
const int MOD = INF + 7;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

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

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

using namespace std;
int main(void) {
  int N, A;
  int T[3];
  cin >> T[0] >> T[1] >> T[2] >> N;
  A = 0;
  sort(T, T + 3);
  reverse(T, T + 3);

  for (int i = 0; i <= N / T[0]; i++) {
    for (int j = 0; j <= (N - i * T[0]) / T[1]; j++) {
      for (int t = 0; t <= (N - i * T[0] - j * T[1]) / T[2]; t++) {
        if (T[0] * i + T[1] * j + T[2] * t == N) {
          A = A + 1;
        }
      }
    }
  }

  cout << A << endl;
  return 0;
}

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

using namespace std;
int main(void) {
  int N, A;
  int T[3];
  cin >> T[0] >> T[1] >> T[2] >> N;
  A = 0;
  sort(T, T + 3);
  reverse(T, T + 3);

  for (int i = 0; i <= N / T[0]; i++) {
    for (int j = 0; j <= (N - i * T[0]) / T[1]; j++) {

      if ((N - T[0] * i - T[1] * j) % T[2] == 0) {
        A = A + 1;
      }
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#define _USE_MATH_DEFINES // M_PI
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
using ll = long long;
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define rREP(i, a, n) for (int(i) = (n)-1; (i) >= (a); --(i))
#define all(x) (x).begin(), (x).end()
#define out(y, x, h, w) (y) < 0 || (x) < 0 || (y) >= (h) || (x) >= (w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
inline void init() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  int r, g, b, N;
  cin >> r >> g >> b >> N;
  int ans = 0;
  for (int i = 0; i < N + 1; i += r) {
    for (int j = 0; j < N + 1; j += g) {
      for (int k = 0; k < N + 1; k += b) {
        if (i + j + k == N)
          ++ans;
      }
    }
  }
  cout << ans << "\n";

  return 0;
}

Fixed submission:
#define _USE_MATH_DEFINES // M_PI
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
using ll = long long;
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define rREP(i, a, n) for (int(i) = (n)-1; (i) >= (a); --(i))
#define all(x) (x).begin(), (x).end()
#define out(y, x, h, w) (y) < 0 || (x) < 0 || (y) >= (h) || (x) >= (w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
inline void init() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  int r, g, b, N;
  cin >> r >> g >> b >> N;
  int ans = 0;
  for (int i = 0; i < N + 1; i += r) {
    for (int j = 0; j < N + 1; j += g) {
      if (N - i - j < 0)
        continue;
      if ((N - i - j) % b == 0)
        ++ans;
    }
  }
  cout << ans << "\n";

  return 0;
}
Problem p03048 (C++)

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

int main(void) {
  int r, g, b, k;

  cin >> r >> g >> b >> k;
  int temp1, temp2;
  int num = 0;
  for (int x = 0; x < k + 1; x++) {
    if (x * r > k)
      continue;
    temp1 = k - r * x;
    for (int y = 0; y < temp1 + 1; y++) {
      if (y * g > temp1)
        continue;
      temp2 = temp1 - g * y;
      for (int z = 0; z < temp2 + 1; z++) {
        if (z * b > temp2)
          continue;
        if (temp2 == z * b) {
          // cout << "x:"<<x<< " y:" << y << " z:" << z << endl;
          // cout << '\n';
          num++;
        }
      }
    }
  }
  cout << num << endl;
}


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

int main(void) {
  int r, g, b, k;

  cin >> r >> g >> b >> k;
  int temp1, temp2;
  int num = 0;
  for (int x = 0; x < k + 1; x++) {
    if (x * r > k)
      continue;
    temp1 = k - r * x;
    for (int y = 0; y < temp1 + 1; y++) {
      if (y * g > temp1)
        continue;
      temp2 = temp1 - g * y;
      if (temp2 % b == 0) {
        // cout << "x:"<<x<< " y:" << y << " z:" << z << endl;
        // cout << '\n';
        num++;
      }
    }
  }
  cout << num << endl;
}
Problem p03048 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define inf 10000000000000007
#define all(vec) vec.begin(), vec.end()
#define ggr                                                                    \
  getchar();                                                                   \
  getchar();                                                                   \
  return 0;
#define ll long long
int gcd(int x, int y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}
int lcm(int x, int y) { return x / gcd(x, y) * y; }
bool prime(int x) {
  for (int i = 2; i <= sqrt(x); i++) {
    if (x % i == 0)
      return false;
  }
  return true;
}

int kai(int x) {
  if (x == 1)
    return 1;
  return kai(x - 1) * x;
}

int mod_pow(int x, int y, int moder) {
  int res = 1;
  while (y > 0) {
    if (y & 1)
      res = res * x % moder;
    x = x * x % moder;
    y >>= 1;
  }
  return res;
}

int r, g, b, n;
int ans;

signed main() {
  cin >> r >> g >> b >> n;
  for (int i = 0; i <= min(g, n); i++) {
    for (int j = 0; j <= min(b, n); i++) {
      if (n - i - j <= r)
        ans++;
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define inf 10000000000000007
#define all(vec) vec.begin(), vec.end()
#define ggr                                                                    \
  getchar();                                                                   \
  getchar();                                                                   \
  return 0;
#define ll long long
int gcd(int x, int y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}
int lcm(int x, int y) { return x / gcd(x, y) * y; }
bool prime(int x) {
  for (int i = 2; i <= sqrt(x); i++) {
    if (x % i == 0)
      return false;
  }
  return true;
}

int kai(int x) {
  if (x == 1)
    return 1;
  return kai(x - 1) * x;
}

int mod_pow(int x, int y, int moder) {
  int res = 1;
  while (y > 0) {
    if (y & 1)
      res = res * x % moder;
    x = x * x % moder;
    y >>= 1;
  }
  return res;
}

int r, g, b, n;
int ans;

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <vector>

using namespace std;
int main(void) {
  long long int R, G, B, N;
  long long int ans = 0;

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

  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 + j * G + k * B == N)
          ans++;

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

Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <vector>

using namespace std;
int main(void) {
  long long int R, G, B, N;
  long long int ans = 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) >= 0 && (N - i * R - j * G) % B == 0)
        ans++;

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

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

int main() {

  int R, G, B, N;
  std::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)
        if (r * R + g * G + b * B == N)
          ++ans;
  std::cout << ans << std::endl;
}

Fixed submission:
#ifdef __GNUC__
#include <bits/stdc++.h>
#endif // __GNUC_

int main() {

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

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
#define intll int long long
const intll INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int a, b, c, n;
  cin >> a >> b >> c >> n;
  int ans = 0;

  rep(i, (n / a) + 1) {
    rep(j, (n / b) + 1) {
      rep(k, (n / c) + 1) {
        int now = a * i + b * j + c * k;
        if (n == now)
          ans++;
      }
    }
  }

  cout << ans;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
#define intll int long long
const intll INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int a, b, c, n;
  cin >> a >> b >> c >> n;
  int ans = 0;

  rep(i, 3000) {
    rep(j, 3000) {
      int now = n - (a * i + b * j);
      if (now % c == 0 && now >= 0)
        ans++;
    }
  }

  cout << ans;
}
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 count = 0;
  for (int r = 0; r < N / R + 1; r++) {
    for (int g = 0; g < (N - r * R) / G + 1; g++) {
      for (int b = 0; b < (N - r * R - g * G) / B + 1; b++) {
        int ord = N - r * R - g * G;
        if (ord % B != 0) {
          break;
        } else if (N == r * R + g * G + b * B) {
          count++;
        }
        ord /= B;
      }
    }
  }
  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 count = 0;
  for (int r = 0; r < N / R + 1; r++) {
    for (int g = 0; g < (N - r * R) / G + 1; g++) {
      int ord = N - r * R - g * G;
      if (ord % B == 0) {
        count++;
      }
    }
  }
  cout << count << endl;
}
Problem p03048 (C++)

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

typedef long long ll;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  ll 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 <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  ll 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 && (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;
  cin >> R >> G >> B >> N;

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