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

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

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  ++k;
  for (int i = 0; k > i; ++i) {
    for (int j = 0; k > j; ++j) {
      for (int l = 0; k > l; ++l) {
        if ((i + j + l) == s)
          ++ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int i = 0; k >= i; ++i) {
    for (int j = 0; k >= j; ++j) {
      int z = s - i - j;
      if (z > k || z < 0)
        continue;
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
  int k, s;
  cin >> k >> s;
  int count = 0;

  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      for (int z = 0; z <= k; z++) {
        int sum = x + y + z;
        if (s == sum)
          count++;
      }
    }
  }
  cout << count << endl;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
  int k, s;
  cin >> k >> s;
  int count = 0;

  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = s - x - y;
      if (z >= 0 && z <= k)
        count++;
    }
  }
  cout << count << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
  int K, S;
  cin >> K >> S;

  int ans = 0;

  for (int i = 0; i < K + 1; ++i) {
    for (int j = 0; j < K + 1; ++j) {
      for (int k = 0; k < K + 1; ++k) {
        if (i + j + k == S) {
          ans++;
        }
      }
    }
  }

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

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
  int K, S;
  cin >> K >> S;

  int ans = 0;

  for (int x = 0; x < K + 1; ++x) {
    for (int y = 0; y < K + 1; ++y) {
      int z = S - x - y;
      if (0 <= z && z <= K) {
        ans++;
      }
    }
  }

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

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

int main() {
  int k, s;
  cin >> k >> s;

  int cnt = 0;
  for (int a = 0; a <= k; ++a) {
    for (int b = 0; b <= k; ++b) {
      for (int c = 0; c <= k; ++c) {
        if (a + b + c > s)
          break;
        if (a + b + c == s) {
          cnt++;
          break;
        }
      }
    }
  }

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

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

int main() {
  int k, s;
  cin >> k >> s;

  int cnt = 0;
  for (int a = 0; a <= k; ++a) {
    for (int b = 0; b <= k; ++b) {
      int c = s - (a + b);
      if (0 <= c && c <= k)
        cnt++;
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int l = 0; l <= k; l++) {
        if (i + j + l == s)
          ans++;
      }
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (s - i - j <= k && s - i - j >= 0)
        ans++;
    }
  }
  cout << ans << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios {
  fast_ios() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  };
} fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end)                                                     \
  for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end)                                                    \
  for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
const lint mod = 1e9 + 7;

int main() {
  lint k, s;
  cin >> k >> s;

  lint cnt = 0;
  REP(i, k + 1) {
    REP(j, k + 1) {
      REP(t, k + 1) {
        if (i + j + t == s) {
          cnt++;
          break;
        }
      }
    }
  }

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


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios {
  fast_ios() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  };
} fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end)                                                     \
  for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end)                                                    \
  for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
const lint mod = 1e9 + 7;

int main() {
  lint k, s;
  cin >> k >> s;

  lint cnt = 0;
  REP(i, k + 1) {
    REP(j, k + 1) {
      if (i + j + k >= s && i + j <= s)
        cnt++;
    }
  }

  cout << cnt << "\n";
  return 0;
}
Problem p03835 (C++)

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

int main() {
  int K, S;
  cin >> K >> S;
  int count = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      for (int z = 0; z <= K; z++) {
        if (x + y + z == S) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

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

int main() {
  int K, S;
  cin >> K >> S;
  int count = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      int z = S - x - y;
      if (z >= 0 && z <= K) {
        count++;
      }
    }
  }
  cout << count << endl;
}
Problem p03835 (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)

int main() {
  int K, S, r = 0;
  cin >> K >> S;

  rep(i, K + 1) rep(j, K + 1) rep(k, K + 1) if (i + j + k == S) r++;

  cout << r << endl;
}

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

int main() {
  int K, S, r = 0;
  cin >> K >> S;

  rep(i, min(K + 1, S + 1)) rep(j, min(K + 1, S + 1 - i)) if (S - i - j <= K)
      r++;

  cout << r << endl;
}
Problem p03835 (C++)

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

int main() {
  int K, S;
  cin >> K >> S;
  int cnt = 0;
  for (int i = 0; i < K + 1; i++) {
    for (int j = 0; j < K + 1; j++) {
      for (int l = 0; l < K + 1; l++) {
        if (S == i + j + l) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}

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

int main() {
  int K, S;
  cin >> K >> S;
  int cnt = 0;
  for (int i = 0; i < K + 1; i++) {
    for (int j = 0; j < K + 1; j++) {
      if (S - (i + j) < K + 1 && S - (i + j) > -1) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}
Problem p03835 (C++)

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

int main() {
  int K, S;
  cin >> K >> S;
  int count = 0;
  rep(i, K + 1) {
    rep(j, K + 1) {
      rep(k, K + 1) {
        if (i + j + k == S)
          count++;
      }
    }
  }
  cout << count << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
const ll INF = 9223372036854775807;

int main() {
  int K, S;
  cin >> K >> S;
  int count = 0;
  rep(i, K + 1) {
    rep(j, K + 1) {
      if (S - i - j < 0)
        continue;
      if (S - i - j <= K)
        count++;
    }
  }
  cout << count << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s, cnt = 0;
  cin >> n >> s;
  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < n + 1; j++) {
      for (int k = 0; k < n + 1; k++) {
        if (i + j + k == s)
          cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s, cnt = 0;
  cin >> n >> s;
  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < n + 1; j++) {
      int k = s - i - j;
      if (k >= 0 && k <= n)
        cnt++;
    }
  }
  cout << cnt << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i, n) for (int i = 0; i < (n); i++)
/* 配列の初期化 fill(array, 0); すべて0に初期化 */
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T *)array, (T *)(array + N), val);
}
using namespace std;
int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      for (int z = 0; z <= k; z++) {
        if (x + y + z > s) {
          z = k + 1;
        } else if (x + y + z == s) {
          cnt++;
        }
      }
    }
  }

  cout << cnt << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i, n) for (int i = 0; i < (n); i++)
/* 配列の初期化 fill(array, 0); すべて0に初期化 */
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T *)array, (T *)(array + N), val);
}
using namespace std;
int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = s - x - y;
      if (0 <= z && z <= k) {
        cnt++;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}
Problem p03835 (C++)

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

using namespace std;

int main(void) {

  int k, s, num = 0, x, y, z;

  cin >> k >> s;

  for (x = 0; x <= k; x++) {
    for (y = 0; y <= k; y++) {
      for (z = 0; z <= k; z++) {
        if (s == x + y + z)
          num++;
      }
    }
  }

  cout << num << "\n";

  return 0;
}

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

using namespace std;

int main(void) {

  int k, s, num = 0, x, y, z;

  cin >> k >> s;

  for (x = 0; x <= k; x++) {
    for (y = 0; y <= k; y++) {
      if (s - x - y >= 0 && s - x - y <= k)
        num++;
    }
  }

  cout << num << "\n";

  return 0;
}
Problem p03835 (C++)

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

int main() {
  int K, S;
  cin >> K >> S;

  int num = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      for (int z = 0; z <= K; z++) {
        if (S - x - y == z)
          ++num;
      }
    }
  }
  cout << num << endl;
}


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

int main() {
  int K, S;
  cin >> K >> S;

  int num = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      if ((x + y <= S) and (K >= S - x - y))
        ++num;
    }
  }
  cout << num << endl;
}
Problem p03835 (C++)

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
  int k, s;
  cin >> k >> s;

  int cnt = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      for (int z = 0; z <= k; z++) {
        if (x + y + z == s) {
          cnt++;
        }
      }
    }
  }

  cout << cnt << endl;

  return 0;
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
  int k, s;
  cin >> k >> s;

  int cnt = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = -(x + y - s);
      if (z >= 0 && z <= k) {
        cnt++;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int k, s, ans = 0;
  cin >> k >> s;

  for (int i = 0; i <= k; ++i) {
    for (int j = 0; j <= k; ++i) {
      int z = s - i - j;
      if (z >= 0 && z <= k) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int k, s, ans = 0;
  cin >> k >> s;

  for (int i = 0; i <= k; ++i) {
    for (int j = 0; j <= k; ++j) {
      int z = s - i - j;
      if (z >= 0 && z <= k) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03835 (C++)

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

// 入力
int K, S;

int main() {
  scanf("%d %d", &K, &S);

  int ans = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      for (int z = 0; z <= K; z++) {
        if (x + y + z == S)
          ans++;
      }
    }
  }

  printf("%d\n", ans);

  return 0;
}

Fixed submission:
#include <cstdio>

// 入力
int K, S;

int main() {
  scanf("%d %d", &K, &S);

  int ans = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      int z = S - x - y;
      if (0 <= z && z <= K)
        ans++;
    }
  }

  printf("%d\n", ans);

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define vi vector<int>
#define ll long long
#define pb push_back
#define ii pair<int, int>
#define qi queue<int>
#define si stack<int>
#define mii map<int, int>
#define msi map<string, int>
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
using namespace std;

const int MAX = 1e5 + 5;
const int mod = 1e9 + 7;

int k, s, ctr = 0;

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

#ifndef ONLINE_JUDGE
  freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
#endif

  cin >> k >> s;

  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = s - (x + y);
      if (z >= 0 && z <= k) {
        // cout << x << ' ' << y << ' ' << z << endl;
        ctr++;
      }
    }
  }

  cout << ctr << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define vi vector<int>
#define ll long long
#define pb push_back
#define ii pair<int, int>
#define qi queue<int>
#define si stack<int>
#define mii map<int, int>
#define msi map<string, int>
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
using namespace std;

const int MAX = 1e5 + 5;
const int mod = 1e9 + 7;

int k, s, ctr = 0;

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  // #ifndef ONLINE_JUDGE
  // freopen(".in", "r", stdin);
  // freopen(".out", "w", stdout);
  // #endif

  cin >> k >> s;

  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = s - (x + y);
      if (z >= 0 && z <= k) {
        // cout << x << ' ' << y << ' ' << z << endl;
        ctr++;
      }
    }
  }

  cout << ctr << endl;

  return 0;
}
Problem p03835 (C++)

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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= a; j++) {
      for (int k = 0; k <= a; k++) {
        if (i + j + k == b)
          ans++;
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= a; j++) {
      if (0 <= b - (i + j) && b - (i + j) <= a)
        ans++;
    }
  }
  cout << ans << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
  int k, s, cnt = 0;
  cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int l = 0; l <= k; l++) {
        if (i + j + l == s)
          cnt++;
      }
    }
  }

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


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
  int k, s, cnt = 0;
  cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      int l = s - i - j;
      if (0 <= l && l <= k)
        cnt++;
    }
  }

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

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

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int p = 0; p <= k; p++) {
        if ((i + j + p) == s)
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      int temp = s - (i + j);
      if (temp <= k && 0 <= temp)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, S;
  cin >> K >> S;
  int answer = 0;
  ;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      for (int k = 0; k <= K; k++) {
        if (i + j + k == S)
          answer++;
      }
    }
  }
  cout << answer << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, S;
  cin >> K >> S;
  int answer = 0;
  ;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      int k = S - i - j;
      if (k >= 0 && k <= K)
        answer += 1;
    }
  }
  cout << answer << endl;
}
Problem p03835 (C++)

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

int main() {
  int K, S;
  cin >> K >> S;

  int count = 0;

  for (int x = 0; x <= K && x <= S; x++) {
    for (int y = 0; y <= K && y <= (S - x); y++) {
      for (int z = 0; z <= K && z <= (S - x - y); z++) {
        if (x + y + z == S) {
          count++;
          break;
        }
      }
    }
  }

  cout << count << endl;

  return 0;
}

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

int main() {
  int K, S;
  cin >> K >> S;

  int count = 0;

  for (int x = 0; x <= K && x <= S; x++) {
    for (int y = 0; y <= K && y <= (S - x); y++) {
      if ((S - (x + y)) <= K)
        count++;
    }
  }

  cout << count << endl;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  int k, s, ans = 0;
  cin >> k >> s;
  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <= k; ++y) {
      for (int z = 0; z <= k; ++z) {
        if (x + y + z == s) {
          ans++;
        }
      }
    }
  }
  cout << ans;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  int k, s, ans = 0;
  cin >> k >> s;
  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <= k; ++y) {
      int z = s - x - y;
      if (0 <= z and z <= k) {
        ans++;
      }
    }
  }
  cout << ans;
  return 0;
}
Problem p03835 (C++)

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

int K, S;

int main() {
  cin >> K >> S;

  int ans = 0;

  for (int i = 0; i <= K; ++i) {
    for (int j = 0; j <= K; ++j) {
      for (int k = 0; k <= K; ++k) {
        if (i + j + k == S)
          ++ans;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

int K, S;

int main() {
  cin >> K >> S;

  int ans = 0;

  for (int x = 0; x <= K; ++x) {
    for (int y = 0; y <= K; ++y) {
      int z = S - x - y;
      if (0 <= z and z <= K)
        ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

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

using namespace std;

#define MAX 2500

int main() {
  int K, S;
  int ans = 0;

  cin >> K >> S;

  for (int l = 0; l <= K; ++l) {
    for (int m = 0; m <= K; ++m) {
      for (int n = 0; n <= K; ++n) {
        if ((l + m + n) == S) {
          ++ans;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>

using namespace std;

#define MAX 2500

int main() {
  int K, S;
  int ans = 0;

  cin >> K >> S;

  for (int X = 0; X <= K; ++X) {
    for (int Y = 0; Y <= K; ++Y) {
      int Z = S - X - Y;
      if (Z <= K && Z >= 0) {
        ans += 1;
      }
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

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

int main(void) {
  int k, s, count = 0;
  cin >> k >> s;
  for (int i = 0; i < k + 1; i++) {
    for (int j = 0; j < k + 1; j++) {
      for (int l = 0; l < k + 1; l++) {
        if (i + j + l == s) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}

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

int main(void) {
  int k, s, count = 0;
  cin >> k >> s;
  for (int i = 0; i < k + 1; i++) {
    for (int j = 0; j < k + 1; j++) {
      if (s - i - j >= 0 && s - i - j <= k)
        count++;
    }
  }
  cout << count << endl;
  return 0;
}
Problem p03835 (C++)

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

int main() {
  int k, s;
  cin >> k >> s;
  int count = 0;
  rep(x, k + 1) {
    rep(y, k + 1) {
      rep(z, k + 1) {
        if (x + y + z == s)
          ++count;
      }
    }
  }
  cout << count << endl;
  return 0;
}

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

int main() {
  int k, s;
  cin >> k >> s;
  int count = 0;
  rep(x, k + 1) {
    rep(y, k + 1) {
      int z = s - x - y;
      if (0 <= z && z <= k)
        ++count;
    }
  }
  cout << count << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <sstream>
#include <string.h>
#include <string>
using namespace std;
// char
// moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int m = 0; m <= k; m++) {
        if ((i + j + m) == s)
          ans++;
      }
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <sstream>
#include <string.h>
#include <string>
using namespace std;
// char
// moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      int m = s - (i + j);
      if ((i + j + m) == s && m >= 0 && m <= k)
        ans++;
    }
  }
  cout << ans << endl;
}
Problem p03835 (C++)

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

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      for (int z = 0; z <= k; z++) {
        if (x + y + z == s)
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = s - x - y;
      if (z >= 0 && z <= k)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03835 (C++)

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

int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <= k; ++y) {
      for (int z = 0; z <= k; ++z) {
        if (x + y + z == s)
          ++cnt;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

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

int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <= x; ++y) {
      for (int z = 0; z <= y; ++z) {
        if (x + y + z == s) {
          if (x == y && y == z) {
            cnt += 1;
          } else if (x == y || y == z) {
            cnt += 3;
          } else {
            cnt += 6;
          }
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p03835 (C++)

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

using namespace std;

int main() {
  int k, s;
  cin >> k;
  cin >> s;

  int result = 0;
  for (int x = 0; x <= k; x++) {
    if (s < x) {
      break;
    }

    for (int y = 0; y <= k; y++) {
      if (s < x + y) {
        continue;
      }

      for (int z = 0; z <= k; z++) {
        if (x + y + z == s) {
          result++;
          break;
        }
      }
    }
  }

  cout << result << endl;
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int k, s;
  cin >> k;
  cin >> s;

  int result = 0;
  for (int x = 0; x <= k; x++) {
    if (s < x) {
      break;
    }

    for (int y = 0; y <= k; y++) {
      if (s < x + y) {
        continue;
      }

      if (s - (x + y) <= k)
        result++;
    }
  }

  cout << result << endl;
}
Problem p03835 (C++)

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

int main(int argc, const char *argv[]) {
  int K, S;
  int count = 0;

  cin >> K >> S;

  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      for (int z = 0; z <= K; z++) {
        if (x + y + z == S) {
          count++;
        }
      }
    }
  }

  cout << count << endl;

  return 0;
}

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

int main(int argc, const char *argv[]) {
  int K, S;
  int count = 0;

  cin >> K >> S;

  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      int z = S - x - y;
      if (z <= K && z >= 0) {
        if (x + y + z == S) {
          count++;
        }
      }
    }
  }

  cout << count << endl;

  return 0;
}
Problem p03835 (C++)

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

int main() {
  int k, s;
  cin >> k >> s;

  int ans = 0;
  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <= k; ++y) {
      for (int z = 0; z <= k; ++z) {
        if (x + y + z == s)
          ++ans;
      }
    }
  }

  cout << ans << endl;
}


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

int main() {
  int k, s;
  cin >> k >> s;

  int ans = 0;
  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <= k; ++y) {
      int t = s - x - y;
      if (t >= 0 && t <= k)
        ++ans;
    }
  }

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

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

#include <cmath>
#include <functional>
#include <limits>
#include <vector>
using namespace std;

int main() {
  int K, S, length, max;
  cin >> K >> S;
  int x, y, z;
  int ans = 0;

  for (int a = 0; a <= K; a++) {
    for (int b = 0; b <= K; b++) {
      for (int c = 0; c <= K; c++) {
        if (a + b + c == S)
          ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

#include <cmath>
#include <functional>
#include <limits>
#include <vector>
using namespace std;

int main() {
  int K, S, length, max;
  cin >> K >> S;
  int x, y, z;
  int ans = 0;

  for (int a = 0; a <= K; a++) {
    for (int b = 0; b <= K; b++) {
      z = S - a - b;
      if (z >= 0 && z <= K)
        ans++;
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

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

int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      for (int k = 0; k <= K; k++) {
        if (S == i + j + k) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      if (S - i - j <= K && S - i - j >= 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
Problem p03835 (C++)

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

int main() {
  int k, s;
  int count = 0;
  cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int l = 0; l <= k; l++) {
        if (i + j + l == s) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

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

int main() {
  int k, s;
  int count = 0;
  cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      int l;
      l = s - i - j;
      if (l >= 0 && l <= k) {
        count++;
      }
    }
  }
  cout << count << endl;
}
Problem p03835 (C++)

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

int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int l = 0; l <= k; l++) {
        if (i + j + l == s) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}

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

int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (0 <= s - i - j && s - i - j <= k) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9 + 7;

int main() {
  int k, s;
  cin >> k >> s;
  ll ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int m = 0; m <= k; m++) {
        if (i + j + m > s)
          break;
        if (i + j + m == s) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
  int k, s;
  cin >> k >> s;
  ll ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (s - i - j >= 0 && s - i - j <= k)
        ans++;
    }
  }
  cout << ans << endl;
}
Problem p03835 (C++)

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

int main() {
  int k, s, count = 0;
  cin >> k >> s;
  if (k * 3 < s)
    cout << 0 << endl;
  else {
    r(i, k + 1) {
      r(j, k + 1) {
        r(l, k + 1) {
          if ((i + j + l) == s)
            count++;
        }
      }
    }
    cout << count << endl;
  }
}

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

int main() {
  int k, s, count = 0;
  cin >> k >> s;
  if (k * 3 < s)
    cout << 0 << endl;
  else {
    r(i, k + 1) {
      r(j, k + 1) {
        if ((s - i - j) >= 0 && (s - i - j) <= k)
          count++;
      }
    }
    cout << count << endl;
  }
}
Problem p03835 (C++)

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

using namespace std;

int main() {
  int K, S;
  cin >> K >> S;

  int cnt = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      for (int l = 0; l <= K; l++) {
        if (i + j + l == S) {
          cnt++;
        }
      }
    }
  }

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


Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int K, S;
  cin >> K >> S;

  int cnt = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      if ((S - i - j) <= K && (S - i - j) >= 0) {
        cnt++;
      }
    }
  }

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

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

int main() {
  int ans, n, s;
  ans = 0;

  cin >> n >> s;

  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        if (i + j + k == s)
          ans++;
      }
    }
  }

  cout << (ans) << endl;
}

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

int main() {
  int ans, n, s;
  ans = 0;

  cin >> n >> s;

  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {

      if (0 <= s - (i + j) && s - (i + j) <= n)
        ans++;
    }
  }

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(), greater<int>())
#define SORT(v, n) sort(v, v + n)
#define DSORT(v, n) sort(v, v + n, greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int, int>

template <class T> void chmin(T &a, const T &b) { a = min(a, b); }
template <class T> void chmax(T &a, const T &b) { a = max(a, b); }

const double EPS = 1e-9;
const long INF = 999999999;
const long MOD = 1000000007; // 10^9+7
#define PI 3.14159265258979

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

int main(void) {
  int K, S, result = 0;
  cin >> K >> S;

  REP(x, K + 1)
  REP(y, K + 1)
  REP(z, K + 1)
  if (x + y + z == S)
    result++;

  cout << result << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(), greater<int>())
#define SORT(v, n) sort(v, v + n)
#define DSORT(v, n) sort(v, v + n, greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int, int>

template <class T> void chmin(T &a, const T &b) { a = min(a, b); }
template <class T> void chmax(T &a, const T &b) { a = max(a, b); }

const double EPS = 1e-9;
const long INF = 999999999;
const long MOD = 1000000007; // 10^9+7
#define PI 3.14159265258979

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

int main(void) {
  int K, S, result = 0;
  cin >> K >> S;

  REP(x, K + 1)
  REP(y, K + 1)
  if (0 <= (S - x - y) && (S - x - y) <= K)
    result++;

  cout << result << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>

#define rep(i, m, n) for (int i = (m); i < (n); ++i)
#define rem(i, m, n) for (int i = (m); i > (n); --i)
#define MOD 1000000007

using namespace std;

using ll = long long int;
using std::swap;

vector<int> v;
vector<long long int> vll;
vector<long long int> w;
vector<vector<int>> vec(50, vector<int>(4, 0));

int main() {
  int K, S;
  int ans = 0;
  cin >> K >> S;
  rep(i, 0, K + 1) rep(j, 0, K + 1) rep(k, 0, K + 1) if (i + j + k == S)++ ans;
  cout << ans << '\n';
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>

#define rep(i, m, n) for (int i = (m); i < (n); ++i)
#define rem(i, m, n) for (int i = (m); i > (n); --i)
#define MOD 1000000007

using namespace std;

using ll = long long int;
using std::swap;

vector<int> v;
vector<long long int> vll;
vector<long long int> w;
vector<vector<int>> vec(50, vector<int>(4, 0));

int main() {
  int K, S;
  int ans = 0;
  cin >> K >> S;
  rep(i, 0, K + 1) {
    if (i == S) {
      ++ans;
    } else if (i < S) {
      rep(j, 0, K + 1) {
        if (i + j <= S && S - (i + j) <= K)
          ans++;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;
using llong = long long;
const int MOD = 1000000007;

int main(int argc, char **argv) {
  int k, s;
  cin >> k >> s;
  int counter = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int x = 0; x <= k; x++) {
        if (i + j + x == s)
          counter++;
      }
    }
  }
  cout << counter << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;
using llong = long long;
const int MOD = 1000000007;

int main(int argc, char **argv) {
  int k, s;
  cin >> k >> s;
  int counter = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      // for (int x = 0; x <= k; x++){
      //     if (i + j + x == s) counter++;
      // }
      if (0 <= s - i - j && s - i - j <= k) {
        counter++;
        // cout << i << " " << j << " " << s - i - j << endl;
      }
    }
  }
  cout << counter << endl;

  return 0;
}
Problem p03835 (C++)

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
  ll K, S;
  ll count = 0;
  cin >> K >> S;
  for (ll x = 0; x <= K; x++) {
    for (ll y = 0; y <= K; y++) {
      for (ll z = 0; z <= K; z++) {
        if (x + y + z == S)
          count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
  ll K, S;
  ll count = 0;
  cin >> K >> S;
  for (ll x = 0; x <= K; x++) {
    for (ll y = 0; y <= K; y++) {
      ll temp = S - (x + y);
      if (0 <= temp && temp <= K)
        count++;
    }
  }
  cout << count << endl;
  return 0;
}
Problem p03835 (C++)

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

using namespace std;

int main(void) {
  int K, S;
  cin >> K >> S;

  int ans = 0;
  for (int x = 0; x <= K; ++x) {
    for (int y = 0; y <= K; ++y) {
      for (int z = 0; z <= K; ++z) {
        if (x + y + z == S) {
          ans++;
          // break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int main(void) {
  int K, S;
  cin >> K >> S;

  int ans = 0;
  for (int x = 0; x <= K; ++x) {
    for (int y = 0; y <= K; ++y) {
      int z = S - x - y;
      if ((0 <= z) && (z <= K))
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <ctype.h>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

#define N_MAX (100000)
#define LL_MAX_NUM (1LL << 60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
  int K, S, res;
  res = 0;
  cin >> K >> S;
  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      for (int Z = 0; Z <= K; Z++) {
        if (X + Y + Z == S) {
          res++;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <ctype.h>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

#define N_MAX (100000)
#define LL_MAX_NUM (1LL << 60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
  int K, S, res;
  res = 0;
  cin >> K >> S;
  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      int Z = S - X - Y;
      if (Z >= 0 && Z <= K) {
        res++;
      }
    }
  }
  cout << res << endl;
  return 0;
}
Problem p03835 (C++)

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

int main(void) {
  int K, S;
  cin >> K >> S;
  int count = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      for (int k = 0; k <= K; k++) {
        if (i + j + k == S)
          count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

int main(void) {
  int K, S;
  cin >> K >> S;
  int count = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      if (i + j + K >= S && i + j <= S)
        count++;
    }
  }
  cout << count << endl;
  return 0;
}
Problem p03835 (C++)

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

using namespace std;

int main() {
  int k, s;
  cin >> k >> s;
  int answer = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      for (int z = 0; z <= k; z++) {
        if (x + y + z == s) {
          answer++;
        }
      }
    }
  }
  cout << answer << '\n';
  return 0;
}


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

using namespace std;

int main() {
  int k, s;
  cin >> k >> s;
  int answer = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = s - x - y;
      if (z >= 0 && z <= k) {
        answer++;
      }
    }
  }
  cout << answer << '\n';
  return 0;
}
Problem p03835 (C++)

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

int main() {
  int K, S;
  int count = 0;

  std::cin >> K >> S;

  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      for (int l = 0; l <= K; l++) {
        if (i + j + l == S)
          count++;
      }
    }
  }
  std::cout << count << std::endl;

  return 0;
}

Fixed submission:
#include <iostream>
#include <math.h>

int main() {
  int K, S;
  int count = 0;

  std::cin >> K >> S;

  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      int z = S - i - j;
      if (0 <= z and z <= K)
        count++;
    }
  }
  std::cout << count << std::endl;

  return 0;
}
Problem p03835 (C++)

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

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <= k; ++y) {
      for (int z = 0; z <= k; ++z) {
        int total = x + y + z;
        if (total == s)
          ++ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <= k; ++y) {
      int z = s - x - y;
      if (0 <= z && z <= k)
        ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03835 (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 rep2(i, s, n) for (int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll, ll>
#define all(v) v.begin(), v.end()

const ll mod = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void) {
  ll k, s, ans = 0;
  cin >> k >> s;
  rep(i, k + 1) rep(j, k + 1) rep(p, k + 1) {
    if (i + j + p == s)
      ++ans;
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll, ll>
#define all(v) v.begin(), v.end()

const ll mod = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void) {
  ll k, s, ans = 0;
  cin >> k >> s;
  rep(i, k + 1) rep(j, k + 1) {
    ll z = s - i - j;
    if (0 <= z && z <= k)
      ++ans;
  }
  cout << ans << endl;
  return 0;
}