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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h> // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repto(i, n) for (int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

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

Fixed submission:
#include <bits/stdc++.h> // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repto(i, n) for (int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int K, S;
  int result = 0;
  cin >> K >> S;
  repto(x, K) {
    repto(y, K) {
      int z = S - (x + y);
      if (0 <= z && z <= K)
        result++;
    }
  }
  cout << result << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _USE_NATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define REP(i, m, n) for (int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)
using namespace std;

int main() {
  int k, s;
  int cnt = 0;

  cin >> k >> s;
  rep(i, k + 1) {
    rep(j, k + 1) {
      rep(l, k + 1) {
        if (i + j + l == s)
          cnt++;
        if (i + j + l > s)
          break;
      }
    }
  }
  cout << cnt << endl;
}

Fixed submission:
#define _USE_NATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define REP(i, m, n) for (int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)
using namespace std;

int main() {
  int k, s;
  int cnt = 0;

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

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

const int INF = 1012345678;

int main() {
  int k, s = 0;
  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 << "\n";
  return 0;
}

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

const int INF = 1012345678;

int main() {
  int k, s = 0;
  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) {
        if ((x + y + z) == s) {
          ans++;
        }
      }
    }
  }

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

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

int main() {
  int k, s, 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 <bits/stdc++.h>

int main() {
  int k, s, count = 0;
  std::cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (0 <= s - i - j && k >= s - i - j)
        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;
  rep(x, k + 1) {
    rep(y, k + 1) {
      rep(z, k + 1) {
        if (x + y + z == 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;
  rep(x, k + 1) {
    rep(y, k + 1) {
      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 <bits/stdc++.h>
#include <math.h>
using namespace std;

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

  int ans = 0;

  for (int i = 0; i < k + 1; i++) {
    // cout << "test" << endl;
    for (int j = 0; j < k + 1; j++) {
      for (int l = 0; l < k + 1; l++) {
        // cout << "test" << endl;
        if (i + j + l == s) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

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

  int ans = 0;

  for (int i = 0; i < k + 1; i++) {
    // cout << "test" << endl;
    for (int j = 0; j < k + 1; j++) {
      int l = s - (i + j);
      if (0 <= l && l <= k) {
        ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

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 <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

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 && k >= z)
        ++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;
typedef long long ll;

int main() {
  int k, s, ans = 0;
  cin >> k >> s;

  rep(x, k + 1) rep(y, k + 1) {
    if (x + y > s)
      break;
    rep(z, k + 1) {
      if (x + y + z > s)
        break;
      if (x + y + z == 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;
typedef long long ll;

int main() {
  int k, s, ans = 0;
  cin >> k >> s;

  rep(x, k + 1) rep(y, k + 1) {
    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 sz(s) (int)s.size()
using namespace std;
int main() {
  int k, s;
  cin >> k >> s;
  int c = 0;
  for (int i = 0; i <= k; ++i) {

    for (int j = 0; j <= k; ++j) {
      for (int a = 0; a <= k; ++a) {
        if (i + j + a == s) {
          // cout << i << " " << j << " " << a << endl;
          c++;
        }
      }
    }
  }
  cout << c;
}

Fixed submission:

#include <bits/stdc++.h>

#define sz(s) (int)s.size()
using namespace std;
int main() {
  int k, s;
  cin >> k >> s;
  int c = 0;
  for (int i = 0; i <= k; ++i) {

    for (int j = 0; j <= k; ++j) {

      int z = s - (i + j);
      if (z >= 0 && z <= k && (i + j + z == s)) {
        // cout << i << " " << j << " " << a << endl;
        c++;
      }
    }
  }
  cout << c;
}
Problem p03835 (C++)

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

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  rep(i, k) {
    rep(j, k) {
      rep(l, k) {
        if (i + j + l == s)
          ans++;
      }
    }
  }

  cout << ans << endl;
}

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

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  rep(i, k) {
    rep(j, k) {
      if (s - (i + j) >= 0 && s - (i + j) <= k)
        ans++;
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
// Sum of Three Integers
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  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) {
        int su = X + Y + Z;
        if (su == S)
          ++count;
      }
    }
  }
  cout << count << endl;
}

Fixed submission:
// Sum of Three Integers
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  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;
      // cout << X << ' ' << Y << ' ' << Z << endl;
      if (0 <= Z && Z <= K && (S == X + Y + Z)) {
        ++count;
      }
    }
  }
  cout << count << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, n) for (int i = 1; i <= (n); i++)
#define mod (ll)(1e9 + 7)
#define inf (ll)(3e18 + 7)
#define pi (double)acos(-1)
#define P pair<int, int>
#define PiP pair<int, pair<int, int>>
#define all(x) x.begin(), x.end()
using namespace std;

int main() {
  int k, s, ans = 0;
  cin >> k >> s;
  rep(i, k + 1) {
    rep(j, k + 1) { rep(n, k + 1) if (i + j + n == s) ans++; }
  }
  cout << ans;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, n) for (int i = 1; i <= (n); i++)
#define mod (ll)(1e9 + 7)
#define inf (ll)(3e18 + 7)
#define pi (double)acos(-1)
#define P pair<int, int>
#define PiP pair<int, pair<int, int>>
#define all(x) x.begin(), x.end()
using namespace std;

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

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

using namespace std;

int main() {
  int k, s, x, y, z;
  int cnt = 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 (s == x + y + z) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

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

using namespace std;

int main() {
  int k, s, x, y, z;
  int cnt = 0;
  cin >> k >> s;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      if (s - x - y <= k && s - x - y >= 0) {
        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, cnt = 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)
          cnt++;
      }
    }
  }
  cout << cnt << endl;
}

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

int main() {
  int k, s, cnt = 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)
        cnt++;
    }
  }
  cout << cnt << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll << 61;
double pi = 3.141592653589793238;

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

  ll ans = 0;

  rep(x, k + 1) {
    rep(y, k + 1) {
      rep(z, k + 1) {
        if (x + y + z == s)
          ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll << 61;
double pi = 3.141592653589793238;

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

  ll ans = 0;

  rep(x, k + 1) {
    rep(y, k + 1) {
      if (s - x - y >= 0 && s - x - y <= 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 count = 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) {
          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 a = 0; a <= k; a++) {
    for (int b = 0; b <= k; b++) {
      int x = s - a - b;
      if (x >= 0 && x <= k) {
        count++;
      }
    }
  }
  cout << count << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main(void) {
  int K, S, X, Y, Z, cnt;
  cin >> K >> S;
  for (X = 0; X <= K; X++) {
    for (Y = 0; Y <= K; Y++) {
      for (Z = 0; Z <= K; Z++) {
        int total = X + Y + Z;
        if (total == S)
          cnt += 1;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main(void) {
  int K, S, X, Y, Z, cnt;
  cin >> K >> S;
  for (X = 0; X <= K; X++) {
    for (Y = 0; Y <= K; Y++) {
      int Z = S - Y - X;
      if (0 <= Z && Z <= K)
        cnt += 1;
    }
  }
  cout << cnt << 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)
using ll = long long;
using P = pair<int, int>;

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

  int count = 0;
  rep(i, k) {
    rep(j, k) {
      rep(l, k) {
        if ((i + j + l) == s) {
          ++count;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}

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

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

  int count = 0;
  rep(i, k) {
    rep(j, k) {
      int l = s - (i + j);
      if (l >= 0 && l <= k) {
        ++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 count = 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 (i + j + l == 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 i = 0; i < k + 1; i++) {
    for (int j = 0; j < k + 1; j++) {
      if (s - k <= i + j && i + j <= s) {
        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, count;
  cin >> K >> S;
  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) {
          count++;
        }
      }
    }
  }
  cout << count;
}

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

int main() {
  int K, S, count;
  cin >> K >> S;
  for (int i = 0; i < K + 1; i++) {
    for (int j = 0; j < K + 1; j++) {
      if (0 <= S - i - j && S - i - j <= K) {
        count++;
      }
    }
  }
  cout << count;
}
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 res = 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)
          res++;
      }
    }
  }
  cout << res << endl;
}

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

int main() {
  int K, S;
  cin >> K >> S;
  int res = 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)
        res++;
    }
  }
  cout << res << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod = 1000000007;
// const ll inf=LONG_LONG_MAX;
ll dx4[4] = {1, 0, -1, 0};
ll dy4[4] = {0, -1, 0, 1};
ll dx8[8] = {1, 0, -1, 1, -1, 1, 0, -1};
ll dy8[8] = {1, 1, 1, 0, 0, -1, -1, -1};

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

Fixed submission:
#include <bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod = 1000000007;
// const ll inf=LONG_LONG_MAX;
ll dx4[4] = {1, 0, -1, 0};
ll dy4[4] = {0, -1, 0, 1};
ll dx8[8] = {1, 0, -1, 1, -1, 1, 0, -1};
ll dy8[8] = {1, 1, 1, 0, 0, -1, -1, -1};

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

  for (ll i = K; i >= 0; i--) {
    if (S - i < 0)
      continue;
    if (S - i > 2 * K)
      break;

    for (ll j = i; j >= 0; j--) {
      ll x = S - i - j;
      if (x > j)
        break;
      if (x < 0)
        continue;

      if (i == j && i == x)
        cnt++;
      else if (i != j && i != x && j != x)
        cnt += 6;
      else
        cnt += 3;
    }
  }
  cout << cnt << endl;
}
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;
typedef long long ll;

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

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

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  rep(x, k + 1) rep(y, k + 1) {
    int z = s - x - y;
    if (0 <= z && z <= k)
      ans++;
  }
  cout << ans;
  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 x, y, z, n = 0;
  for (x = 0; x <= K; x++) {
    for (y = 0; y <= K; y++) {
      if (x + y > S) {
        break;
      }
      for (z = 0; z <= K; z++) {
        int sum = x + y + z;
        if (sum > S) {
          break;
        } else if (sum == S) {
          n++;
        }
      }
    }
  }
  cout << n << endl;

  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

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

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

Fixed submission:
#include <iostream>
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 (0 <= S - i - j) {
        if (S - i - j <= K)
          count += 1;
      }
    }
  }
  cout << count << endl;
}
Problem p03835 (C++)

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

int main() {
  int k, s;
  cin >> k >> s;
  int sum = 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)
          sum++;
      }
    }
  }
  cout << sum << endl;
}

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

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

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

using namespace std;

int main() {
  int K, S, 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++;
          break;
        }
      }
    }
  }
  cout << count << endl;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int K, S, 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 && 0 <= Z) {
        count++;
      }
    }
  }
  cout << count << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int, int> P;
#define INF 1000000000

struct edge {
  int from, to, cap, rev;
  edge(int from, int to, int cap, int rev) {
    this->from = from;
    this->to = to;
    this->cap = cap;
    this->rev = rev;
  }
};

int V, E;
typedef vector<edge> edges;
vector<edges> G;

int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  FORI(0, k + 1) {
    FORJ(0, k + 1) {
      FORL(0, k + 1) {
        if (i + j + l == s)
          cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Fixed submission:
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int, int> P;
#define INF 1000000000

struct edge {
  int from, to, cap, rev;
  edge(int from, int to, int cap, int rev) {
    this->from = from;
    this->to = to;
    this->cap = cap;
    this->rev = rev;
  }
};

int V, E;
typedef vector<edge> edges;
vector<edges> G;

int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  FORI(0, k + 1) {
    FORJ(0, k + 1) {
      if (i + j <= s && s - (i + j) <= k)
        cnt++;
    }
  }
  cout << cnt << 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 < (int)(n) + 1; i++)
using namespace std;

int main() {
  int k, s, ans = 0;
  cin >> k >> s;
  for (int a = 0; a <= k; a++) {
    for (int b = 0; b <= k; a++) {
      int c = s - a - b;
      if (0 <= c && c <= k) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int k, s, ans = 0;
  cin >> k >> s;
  for (int a = 0; a <= k; a++) {
    for (int b = 0; b <= k; b++) {
      int c = s - a - b;
      if (0 <= c && c <= 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 count = 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) {
          count++;
        }
      }
    }
  }
  cout << count;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, S;
  cin >> K >> S;
  int count = 0;
  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;
}
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 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;
  cin >> k >> s;

  int count = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0 + i; j <= k; j++) {
      for (int l = 0 + j; l <= k; l++) {
        if (i + j + l == s) {
          if (i == j && j == l)
            count++;
          else if (i == j || j == l || i == l)
            count += 3;
          else
            count += 6;
        }
      }
    }
  }
  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 ans = 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++) {
        int sum = i + j + l;
        if (sum == 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 + 1; i++) {
    for (int j = 0; j < k + 1; 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>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;

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

  int ans = 0;
  rep(x, k + 1) {
    rep(y, k + 1) {
      rep(z, k + 1) { ans += (x + y + z == s); }
    }
  }

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

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

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

  int ans = 0;
  rep(x, k + 1) {
    rep(y, k + 1) {
      int z = s - x - y;
      ans += (0 <= z && z <= k);
    }
  }

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

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

int main(int argc, char **argv) {
  int K, S;
  std::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) {
          // std::cout << x <<"+"<<y<<"+"<<z << "==" << S << std::endl;
          cnt++;
        }
      }
    }
  }

  std::cout << cnt << std::endl;
}


Fixed submission:
#include <iostream>

int main(int argc, char **argv) {
  int K, S;
  std::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++;
      }
    }
  }

  std::cout << cnt << std::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 < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)

typedef long long Int;

int main() {

  int K, S;
  cin >> K >> S;

  int cnt = 0;

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

  cout << cnt << endl;

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)

typedef long long Int;

int main() {

  int K, S;
  cin >> K >> S;

  int cnt = 0;

  rep(i, K + 1) rep(j, K + 1) {
    if (S - i - j >= 0 && S - i - j <= K)
      cnt++;
  }

  cout << cnt << 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)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define MAX 100005
using ll = long long;
using namespace std;

int main() {
  int k, s;
  cin >> k >> s;
  int c = 0;
  rep(i, k + 1) {
    rep(j, k + 1) {
      rep(l, k + 1) {
        if (i + j + l == s) {
          c++;
          break;
        }
      }
    }
  }
  cout << c << endl;

  return 0;
}

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

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

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
typedef long long LL;
typedef unsigned long long ULL;
using namespace std;

int main() {
  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 (S == i + j + k) {
          count++;
        }
      }
    }
  }
  cout << count << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
typedef long long LL;
typedef unsigned long long ULL;
using namespace std;

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

  return 0;
}
Problem p03835 (C++)

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

#define fio                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
#define time_passed 1.0 * clock() / CLOCKS_PER_SEC
ll MOD = 1e9 + 7;
ll MOD1 = 1e9 + 123;
ll MOD2 = 1e9 + 321;

int main() {
  fio;
  ll t, a, n, q, k, i, l, m, c, u, f, j, p, r, x, y, s, b, d;
  cin >> k >> s;
  c = 0;
  for (i = 0; i <= k; i++)
    for (j = 0; j <= k; j++)
      for (p = 0; p <= k; p++)
        if (i + j + p == s)
          c++;
  cout << c << endl;

  return 0;
}


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

#define fio                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
#define time_passed 1.0 * clock() / CLOCKS_PER_SEC
ll MOD = 1e9 + 7;
ll MOD1 = 1e9 + 123;
ll MOD2 = 1e9 + 321;

int main() {
  fio;
  ll t, a, n, q, k, i, l, m, c, u, f, j, p, r, x, y, s, b, d;
  cin >> k >> s;
  c = 0;
  for (i = 0; i <= k; i++)
    for (j = 0; j <= k; j++)
      if (s - i - j >= 0 && s - i - j <= k)
        c++;
  cout << c << 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;
  int ans = 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)
          ans++;
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int k, s;
  int 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 (0 <= z && z <= k)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03835 (C++)

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

using namespace std;

int main(void) {
  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 << endl;

  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int main(void) {
  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 (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 cnt = 0;
  for (int i1 = 0; i1 <= k; i1++) {
    for (int i2 = 0; i2 <= k; i2++) {
      for (int i3 = 0; i3 <= k; i3++) {
        if (i1 + i2 + i3 == s) {
          cnt++;
          break;
        }
      }
    }
  }
  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++) {
      int x = s - i - j;
      if (x >= 0 && x <= k) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}
Problem p03835 (C++)

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

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++;
        if ((i + j + l) > s)
          break;
      }
    }
  }
  cout << cnt;
}

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

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 sum = i + j;
      if (s - sum <= k && s - sum >= 0)
        cnt++;
    }
  }
  cout << cnt;
}
Problem p03835 (C++)

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

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

  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 <bits/stdc++.h>
using namespace std;

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

  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>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define snuke srand((unsigned)clock() + (unsigned)time(NULL));
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int k, s;
  cin >> k >> s;
  int count = 0;

  rep(i, k + 1) {
    rep(j, k + 1) {
      rep(l, k + 1) {
        int a = i + j + l;
        if (s == a) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define snuke srand((unsigned)clock() + (unsigned)time(NULL));
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

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

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

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

  return 0;
}


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

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

  return 0;
}
Problem p03835 (C++)

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

int a, b, c, K, S, ans;

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

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

  cout << ans << endl;

  return 0;
}

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

int a, b, c, K, S, ans;

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

  for (a = 0; a <= K; a++) {
    for (b = 0; b <= K; b++) {
      if ((S - a - b) <= K && (S - a - b) >= 0)
        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 res = 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)
          ++res;
      }
    }
  }
  cout << res << endl;
}

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

int main() {
  int K, S;

  cin >> K >> S;
  int res = 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)
        ++res;
    }
  }
  cout << res << endl;
}
Problem p03835 (C++)

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

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


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

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)

#define each(it, c)                                                            \
  for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x) cerr << #x << " = " << (x) << endl;

#define endl "\n"

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long lint;

using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  lint K, S, count = 0;
  cin >> K >> S;
  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>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)

#define each(it, c)                                                            \
  for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x) cerr << #x << " = " << (x) << endl;

#define endl "\n"

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long lint;

using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  lint k, s, count = 0;
  cin >> k >> s;
  rep(i, k + 1) rep(j, k + 1) if (s - (i + j) <= k && 0 <= s - (i + j)) 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, 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, count = 0;
  cin >> K >> S;

  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      if ((S - X - Y >= 0) && (S - X - Y <= K))
        count++;
    }
  }
  cout << count << endl;
}