prithivMLmods/Coder-Stat huggingface dataset:
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 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;
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++) {
      if (s - (x + y) >= 0 && s - (x + y) <= 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, A;
  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) {
          A++;
        }
      }
    }
  }
  cout << A << endl;
}

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

int main() {
  int k, s, A;
  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) {
        A++;
      }
    }
  }
  cout << A << 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 k = 0; k <= K; k++) {
        int x = i + j + k;
        if (S == x)
          count++;
      }
    }
  }

  cout << count << endl;

  return 0;
}

Fixed submission:
#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++) {
      int x = S - (i + j);
      if ((K >= x) && (x >= 0))
        count++;
    }
  }

  cout << count << endl;

  return 0;
}
Problem p03835 (C++)

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

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

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

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

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

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

Buggy submission (status: Time Limit Exceeded):
// #include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

#define FAST                                                                   \
  ios_base ::sync_with_stdio(false);                                           \
  cin.tie(NULL);
#define endl "\n"

typedef long long int ll;

int main() {
  FAST;
  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;
  return 0;
}

Fixed submission:
// #include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

#define FAST                                                                   \
  ios_base ::sync_with_stdio(false);                                           \
  cin.tie(NULL);
#define endl "\n"

typedef long long int ll;

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

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
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; i <= k; j++) {
      int aaa = i + j;
      int p = s - aaa;
      if (0 <= p && p <= k) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
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++) {

      int p = s - i - j;
      if (0 <= p && p <= 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 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++;
        } else
          continue;
      }
    }
  }

  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++;
      } else
        continue;
    }
  }

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

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int k, s, ans;
int main() {
  cin >> k >> s;
  for (register int i = 0; i <= k; i++)
    for (register 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 <iostream>

using namespace std;

int main() {

  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 k = 0; k <= K; ++k) {
        if (i + j + k == S)
          counter++;
      }
    }
  }

  cout << counter << endl;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {

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

  int counter = 0;

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

  cout << counter << 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;
}

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 <= k; y++) {
      int z = s - (x + y);
      if (z >= 0 && z <= k)
        cnt++;
    }
  }
  cout << cnt << endl;
}
Problem p03835 (C++)

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

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

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

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

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

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

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

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

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

  count = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      if (i + j <= S && 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 i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      for (int k = 0; k <= K; k++) {
        if (i + j + k == 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 i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      int z = S - i - j;
      if (z >= 0 && z <= K)
        res++;
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <cmath>
#include <float.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

using ULL = unsigned long long;

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

Fixed submission:
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <cmath>
#include <float.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

using ULL = unsigned long long;

int main() {
  int K, S;
  ULL num = 0;
  cin >> K >> S;
  // if (K == S)num += 3;
  for (int x = 0; x < K + 1; ++x) {
    for (int y = 0; y < K + 1; ++y) {
      auto z = S - x - y;
      if (z >= 0 && z <= K) {
        ++num;
      } else if (x != 0 && y != 0 && z == 0)
        ++num;
    }
  }
  cout << num << endl;
  return 0;
}
Problem p03835 (C++)

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

int main() {

  // 入力
  int K, S;
  std::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++;
      }

  // 出力
  std::cout << ans << '\n';

  return 0;
}

Fixed submission:
#include <iostream>

int main() {

  // 入力
  int K, S;
  std::cin >> K >> S;

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

  // 出力
  std::cout << ans << '\n';

  return 0;
}
Problem p03835 (C++)

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  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>
typedef long long ll;
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  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 + i + j == s && s - i - j >= 0 && (s - i - j) <= k &&
          i <= k && j <= k) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt", "r", stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(), c.end()
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1 << 29;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> void print(T t) {
  for (auto &it : t)
    cout << it << " ";
}
inline int powerexp(int a, int b, int m = MOD) {
  int res = 1;
  while (b) {
    if (b & 1)
      res = res * a % m;
    a = a * a % m, b >>= 1;
  }
  return res % m;
}
inline int modinv(int a) { return powerexp(a, MOD - 2, MOD); }
inline int lcm(int a, int b) {
  int g = __gcd(a, b);
  return a / g * b;
}

//-------------------< start here >-------------------------//
void solve() {
  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 z = 0; z <= k; z++) {
        cnt += (i + j + z == s);
      }
    }
  }
  cout << cnt << endl;
}
//-----------------------------
// comment from here for TOPCODER
int32_t main() {
  IOS;
  solve();
// find();
#ifdef LOCAL_DEFINE
  cerr << "time elapsed " << (double)clock() / CLOCKS_PER_SEC << endl;
#endif
}


Fixed submission:
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt", "r", stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(), c.end()
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1 << 29;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> void print(T t) {
  for (auto &it : t)
    cout << it << " ";
}
inline int powerexp(int a, int b, int m = MOD) {
  int res = 1;
  while (b) {
    if (b & 1)
      res = res * a % m;
    a = a * a % m, b >>= 1;
  }
  return res % m;
}
inline int modinv(int a) { return powerexp(a, MOD - 2, MOD); }
inline int lcm(int a, int b) {
  int g = __gcd(a, b);
  return a / g * b;
}

//-------------------< start here >-------------------------//
void solve() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      int ret = s - i - j;
      if (ret >= 0 && ret <= k)
        cnt++;
    }
  }
  cout << cnt << endl;
}
//-----------------------------
// comment from here for TOPCODER
int32_t main() {
  IOS;
  solve();
// find();
#ifdef LOCAL_DEFINE
  cerr << "time elapsed " << (double)clock() / CLOCKS_PER_SEC << endl;
#endif
}
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; i++) {
      int z = S - i - j;
      if (z >= 0 && z <= 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++) {
      int z = S - i - j;
      if (z >= 0 && z <= K) {
        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++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using llong = long long;

const int INF = 100100100;
const int MOD = 1e9 + 7;

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

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

  int X, Y, Z;

  int count = 0;
  REP(i, K + 1) {
    REP(j, K + 1) {
      REP(k, K + 1) {
        if ((i + j + k) == S) {
          count++;
        }
      }
    }
  }
  cout << count << "\n";

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using llong = long long;

const int INF = 100100100;
const int MOD = 1e9 + 7;

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

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

  int X, Y, Z;

  int count = 0;
  REP(i, K + 1) {
    REP(j, K + 1) {
      int k = S - i - j;
      if (k <= K && 0 <= k) {
        count++;
      }
    }
  }
  cout << count << "\n";

  return 0;
}
Problem p03835 (C++)

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

int K, S;

int main() {
  scanf("%d%d", &K, &S);
  int cnt = 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)
          cnt++;
      }
    }
  }
  printf("%d\n", cnt);
  return 0;
}


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

int K, S;

int main() {
  scanf("%d%d", &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++;
    }
  }
  printf("%d\n", cnt);
  return 0;
}
Problem p03835 (C++)

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

using namespace std;

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

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

using namespace std;

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

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int K, S;
  int ans = 0;
  cin >> K >> S;
  rep(i, K + 1) {
    rep(j, K + 1) {
      rep(k, K + 1) {
        if (i + j + k == S)
          ans++;
      }
    }
  }
  printf("%d\n", ans);
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int K, S;
  int ans = 0;
  cin >> K >> S;
  rep(i, K + 1) {
    rep(j, K + 1) {
      if (S - (i + j) <= K && S - (i + j) >= 0)
        ans++;
    }
  }
  printf("%d\n", ans);
}
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++) {
        int sum = i + j + l;
        if (sum == 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; j <= k; j++) {
      int z = s - (i + j);
      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, rep = 0;
  cin >> k >> s;
  rep(i, k + 1) rep(j, k + 1) rep(l, k + 1) {
    if (s == i + j + l)
      rep++;
  }
  cout << rep << 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, rep = 0;
  cin >> k >> s;
  rep(i, k + 1) rep(j, k + 1) {
    int z = s - i - j;
    if (z >= 0 && z <= k)
      rep++;
  }
  cout << rep << 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 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;
}


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;

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 <= X; Y++) {
      for (int Z = 0; Z <= Y; Z++) {
        if (X + Y + Z == S) {
          if (X == Y && Y == Z)
            count++;
          else if (X != Y && Y != Z)
            count += 6;
          else
            count += 3;
        }
      }
    }
  }
  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 < n; i++)
using namespace std;

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

  int counter = 0;
  rep(i, K + 1) {
    rep(j, K + 1) {
      rep(k, K + 1) {
        if (S == i + j + k) {
          counter++;
        }
      }
    }
  }

  cout << counter << 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 counter = 0;
  rep(i, K + 1) {
    rep(j, K + 1) {
      int tmp = S - i - j;
      if ((0 <= tmp) && (K >= tmp)) {
        counter++;
      }
    }
  }

  cout << counter << 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 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 <iostream>
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 (i + j <= s && i + j >= s - k)
        ans++;
    }
  }
  cout << ans << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define fore(i, a) for (auto &i : a)
#define all(x) (x).begin(), (x).end()
#pragma GCC optimize("-O3")
using namespace std;
void _main();
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  _main();
}
typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
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;
}
//---------------------------------------------------------------------------------------------------

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

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define fore(i, a) for (auto &i : a)
#define all(x) (x).begin(), (x).end()
#pragma GCC optimize("-O3")
using namespace std;
void _main();
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  _main();
}
typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
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;
}
//---------------------------------------------------------------------------------------------------

void _main() {
  int K, S;
  cin >> K >> S;
  int counter = 0;
  rep(x, 0, K + 1) {
    rep(y, 0, K + 1) {
      int z = S - x - y;
      // マイナスやｋ以上は入ってはならない
      if (0 <= z and z <= K) {
        counter++;
      }
    }
  }
  cout << counter << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  int kaito = 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) {
          kaito++;
        }
      }
    }
  }
  cout << kaito << endl;
}

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
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;
}
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;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
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;
}
int main() {
  int K, S;
  cin >> K >> S;

  int cnt = 0;
  REP(i, K + 1) {
    REP(j, K + 1) {
      if ((i + j) > S)
        continue;
      if (S <= (i + j + K)) {
        // cout << i <<" "<< j << endl;
        cnt++;
      }
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll int
#define ln cout << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;

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

  int a, b, c, d, m, n, maxi = 0, f = 0, mini = INF, sum = 0;
  string str;
  ll k;
  cin >> k >> n;
  a = n;
  ll v[k + 1];
  ll w[(k + 1) * (k + 1)];
  rep(i, k + 1) {
    v[i] = i;
    // cout<<i<<" ";
  }
  // ln;
  map<ll, ll> ma;

  rep(i, k + 1) {
    rep(j, k + 1) { ma[i + j]++; }
  }
  // ln;
  map<ll, ll> mp;

  rep(j, k + 1) {
    rep(i, n * 2 + 1) {
      mp[i + j] += ma[i];
      // cout<<w[i]+j<<" ";
    }
  }
  // cout<<n<<endl;

  cout << mp[a] << endl;

  return 0;
}


Fixed submission:
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll int
#define ln cout << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;

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

  int a, b, c, d, m, n, maxi = 0, f = 0, mini = INF, sum = 0;
  string str;
  ll k;
  cin >> k >> n;
  a = n;
  ll v[k + 1];
  ll w[(k + 1) * (k + 1)];
  rep(i, k + 1) {
    v[i] = i;
    // cout<<i<<" ";
  }
  // ln;
  map<ll, ll> ma;

  rep(i, k + 1) {
    rep(j, k + 1) { ma[i + j]++; }
  }
  // ln;
  map<ll, ll> mp;

  rep(j, k + 1) {
    rep(i, k * 2 + 1) {
      mp[i + j] += ma[i];
      // cout<<w[i]+j<<" ";
    }
  }
  // cout<<n<<endl;

  cout << mp[a] << endl;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl /*, greater<ll>*/> pql; // 降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for (ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for (ll i = 1; i <= ll(n); ++i)
// #define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
// #define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
bool chmax(ll &a, ll b) {
  if (b > a) {
    a = b;
    return 1;
  }
  return 0;
}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl /*, greater<ll>*/> pql; // 降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for (ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for (ll i = 1; i <= ll(n); ++i)
// #define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
// #define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
bool chmax(ll &a, ll b) {
  if (b > a) {
    a = b;
    return 1;
  }
  return 0;
}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll k, s, ans = 0;
  cin >> k >> s;
  rep(x, k + 1) rep(y, k + 1) if (s - x - y >= 0 && s - x - y <= k) ans++;
  cout << ans << newl;
  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 sum = 0;
  for (int X = 0; X < K + 1; X++) {
    for (int Y = 0; Y < K + 1; Y++) {
      for (int Z = 0; Z < K + 1; Z++) {
        if (X + Y + Z == S) {
          sum += 1;
        }
      }
    }
  }
  cout << sum << endl;
}

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

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

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

int main() {
  int K, S;
  cin >> K >> S;
  int Z;
  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;
}

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

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

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 (0 <= z && z <= K) {
        ans++;
      }
    }
  }

  cout << ans;
}
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 c = 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)
          c++;
      }
    }
  }
  cout << c << endl;
}


Fixed submission:
#include <bits/stdc++.h>
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 p = s - (i + j);
      if (p >= 0 && p <= k)
        c++;
    }
  }
  cout << c << 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++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
struct cww {
  cww() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
int main() {
  int K, S;
  cin >> K >> S;
  int count{};
  REP(i, K + 1) {
    REP(j, K + 1) {
      REP(k, K + 1) {
        if (i + j + k == 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++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
struct cww {
  cww() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
int main() {
  int K, S;
  cin >> K >> S;
  int count{};
  REP(i, K + 1) {
    REP(j, K + 1) {
      if (S - (j + i) <= K && S - (i + j) >= 0) {
        count++;
      }
    }
  }
  cout << count << 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 ans = 0;
  int limit = min(k, s);
  for (int x = 0; x <= limit; x++) {
    for (int y = 0; y <= limit; y++) {
      for (int z = 0; z <= limit; z++) {
        if (x + y + z == s) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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 ans = 0;
  int limit = min(k, s);
  for (int x = 0; x <= limit; x++) {
    for (int y = 0; y <= limit; y++) {
      if (s - (x + y) >= 0 && k >= s - (x + y)) {
        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 ans;

  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 <iostream>
using namespace std;

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

  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      if ((i + j <= S) && (i + j + K >= S))
        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 l = 0; l <= k; l++) {
        if (i + j + l == s) {
          ans++;
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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++) {
      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 <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define repe1(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(k, v) emplace_back(k, v)
using namespace std;
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 ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

ll pow_kai(ll a, ll n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1) {
      x = x * a;
    }
    a = a * a;
    n >>= 1;
  }
  return x;
}

int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  repe(i, k) {
    repe(j, k) {
      repe(l, k) {
        if (i + j + l == s) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << "\n";
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define repe1(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(k, v) emplace_back(k, v)
using namespace std;
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 ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

ll pow_kai(ll a, ll n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1) {
      x = x * a;
    }
    a = a * a;
    n >>= 1;
  }
  return x;
}

int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  repe(i, k) {
    repe(j, k) {
      if (s - i - j <= k && s - i - j >= 0) {
        cnt++;
      }
    }
  }
  cout << cnt << "\n";
}
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;
}

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 (0 <= z && z <= K) {
        count++;
      }
    }
  }
  cout << count;
}
Problem p03835 (C++)

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

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", ans);
}


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

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", ans);
}
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, n) for (int i = 1; i < n; i++)

int main() {
  int k, s, ans = 0;
  cin >> k >> s;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; x <= k; y++) {
      int z = s - x - y;
      if (z <= k && z >= 0)
        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, n) for (int i = 1; i < n; i++)

int main() {
  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 <= k && z >= 0)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <ctype.h>
#include <iostream>
#include <math.h>
#include <string.h>
#include <string>
#define pi 3.141592653589
#include <iomanip>
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 <ctype.h>
#include <iostream>
#include <math.h>
#include <string.h>
#include <string>
#define pi 3.141592653589
#include <iomanip>
using namespace std;

int main() {

  int k, s, cnt = 0;

  cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    for (int j = i; j <= k; j++) {
      for (int l = j; l <= k; l++) {
        if (i + j + l == s) {
          if (i == j && j == l)
            cnt += 1;
          else if ((i == j && j != l) || (j == l && i != j) ||
                   (i == l && i != j))
            cnt += 3;
          else
            cnt += 6;
        }
      }
    }
  }
  cout << cnt << endl;

  return 0;
}
Problem p03835 (C++)

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

int main() {
  int K, S;
  int variables = scanf("%d %d", &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++) {
        count += (x + y + z == S ? 1 : 0);
      }
    }
  }
  printf("%d", count);
}

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

int main() {
  int K, S;
  int variables = scanf("%d %d", &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 (0 <= z && z <= K)
        count++;
    }
  }
  printf("%d", count);
}
Problem p03835 (C++)

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

int main() {
  // your code goes here
  int K, S;
  cin >> K >> S;
  int cnt = 0;
  for (int x = K; x >= 0; x--) {
    for (int y = K; y >= 0; y--) {
      for (int z = K; z >= 0; z--) {
        if (x + y + z == S) {
          cnt++;
          break;
        }
      }
    }
  }
  cout << cnt;
  return 0;
}

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

int main() {
  // your code goes here
  int K, S;
  cin >> K >> S;
  int cnt = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      if (S - x - y >= 0 && S - x - y <= K)
        cnt++;
    }
  }
  cout << cnt;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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 h = 0; h <= k; h++) {
        if (i + j + h == s)
          ans++;
      }
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

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

using namespace std;

typedef long long ll;

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

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

using namespace std;

typedef long long ll;

int main() {
  ll K, S;
  cin >> K >> S;
  ll sum = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      if (S - x - y <= K && S - x - y >= 0) {
        sum++;
      }
    }
  }
  cout << sum << endl;
}