prithivMLmods/Coder-Stat huggingface dataset:
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;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

using namespace std;

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

  int result = 0;
  rep(x, k + 1) {
    rep(y, k + 1) {
      rep(z, k + 1) {
        if (x + y + z == s) {
          // cout << x << y << z << endl;
          result++;
          break;
        }
      }
      if (x + y > s)
        break;
    }
    if (x > s)
      break;
  }

  cout << result << endl;

  return 0;
}

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

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

using namespace std;

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

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

  cout << result << endl;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
// 前置き
#pragma region

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

#pragma endregion

// 関数定義
#pragma region
// 偶数 ->　true :: 奇数　-> false
bool EVEN(ll a) { return a % 2 - 1; }

// 最大公約数
ll gcd(ll a, ll b) {
  if (!b)
    return a;
  return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

#pragma endregion

int dore(int a, int b, int c) {

  if (a == max(a, max(b, c)))
    return 1;
  if (b == max(a, max(b, c)))
    return 2;
  if (c == max(a, max(b, c)))
    return 3;
}
int main() {
  int k, s;
  cin >> k >> s;

  int ans = 0;

  REP(i, k + 1) {
    REP(j, k + 1) {
      REP(kk, k + 1) {
        if (i + j + kk == s)
          ans++;
      }
    }
  }

  cout << ans << endl;
}


Fixed submission:
// 前置き
#pragma region

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

#pragma endregion

// 関数定義
#pragma region
// 偶数 ->　true :: 奇数　-> false
bool EVEN(ll a) { return a % 2 - 1; }

// 最大公約数
ll gcd(ll a, ll b) {
  if (!b)
    return a;
  return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

#pragma endregion

int dore(int a, int b, int c) {

  if (a == max(a, max(b, c)))
    return 1;
  if (b == max(a, max(b, c)))
    return 2;
  if (c == max(a, max(b, c)))
    return 3;
}
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 (z >= 0 && k >= z)
        ans++;
    }
  }

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

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

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

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

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

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

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF = 1LL << 60;

vector<string> split(const string &input, char delimiter) {
  stringstream stream(input);

  string field;
  vector<string> result;
  while (getline(stream, field, delimiter)) {
    result.push_back(field);
  }
  return result;
}

// #define DEBUG

ll A, B, M, N, D, K, Q, W, H, T, X, Y, S;

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

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

  cout << cnt << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <vector>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF = 1LL << 60;

vector<string> split(const string &input, char delimiter) {
  stringstream stream(input);

  string field;
  vector<string> result;
  while (getline(stream, field, delimiter)) {
    result.push_back(field);
  }
  return result;
}

// #define DEBUG

ll A, B, M, N, D, K, Q, W, H, T, X, Y, S;

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

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

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 + 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;
typedef long long int ll;
const int MOD = (int)1e9 + 7;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()

int main(int argc, char const *argv[]) {
  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"
using namespace std;
typedef long long int ll;
const int MOD = (int)1e9 + 7;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()

int main(int argc, char const *argv[]) {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  REP(x, K + 1) {
    REP(y, K + 1) {
      if (x + y <= S && S - (x + y) <= K)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03835 (C++)

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

using namespace std;

#define rep(i, a, n) for (int i = (a); i < (n); ++i)

void Main() {
  int K, s;
  cin >> K >> s;
  int cnt = 0;
  rep(i, 0, K + 1) {
    rep(j, 0, K + 1) {
      rep(k, 0, K + 1) {
        if (i + j + k == s) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}

int main() {
  std::cin.tie(nullptr);                 // 標準入出力高速化
  std::ios_base::sync_with_stdio(false); // SとS++の入出力出力を非同期
  Main();
}

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

using namespace std;

#define rep(i, a, n) for (int i = (a); i < (n); ++i)

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

int main() {
  std::cin.tie(nullptr);                 // 標準入出力高速化
  std::ios_base::sync_with_stdio(false); // SとS++の入出力出力を非同期
  Main();
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define int long long
#define ull unsigned long long
#define mod 1000000007
#define vi vector<ll>
#define ppi pair<ll, pair<ll, ll>>
#define pb push_back
#define mp make_pair
#define str string
#define pi 2 * acos(0.0)
#define pr(a, n)                                                               \
  for (int i = 0; i < n; i++) {                                                \
    cout << a[i] << " ";                                                       \
  }
#define p(a) cout << a;
#define sp(x, y) fixed << setprecision(y) << x
#define w(x)                                                                   \
  ll x;                                                                        \
  cin >> x;                                                                    \
  while (x--)
#define e cout << '\n';
#define all(v) v.begin(), v.end()
#define test cout << "LOL_ABHISHEK" << endl;
void kehsihba() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
  // kehsihba();
  ll k, s;
  cin >> k >> s;
  ll ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int x = 0; x <= k; x++) {
        if (i + j + x == s) {
          ans += 1;
        }
      }
    }
  }
  cout << ans;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define int long long
#define ull unsigned long long
#define mod 1000000007
#define vi vector<ll>
#define ppi pair<ll, pair<ll, ll>>
#define pb push_back
#define mp make_pair
#define str string
#define pi 2 * acos(0.0)
#define pr(a, n)                                                               \
  for (int i = 0; i < n; i++) {                                                \
    cout << a[i] << " ";                                                       \
  }
#define p(a) cout << a;
#define sp(x, y) fixed << setprecision(y) << x
#define w(x)                                                                   \
  ll x;                                                                        \
  cin >> x;                                                                    \
  while (x--)
#define e cout << '\n';
#define all(v) v.begin(), v.end()
#define test cout << "LOL_ABHISHEK" << endl;
void kehsihba() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
  // kehsihba();
  ll k, s;
  cin >> k >> s;
  ll ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      ll x = i + j;
      if ((s - x) >= 0 and (s - x) <= k) {
        ans += 1;
      }
    }
  }
  cout << ans;
}
Problem p03835 (C++)

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

int k, s;
int ta = 0;

int main() {
  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) {
          ta++;
        }
      }
    }
  }
  cout << ta << endl;
  return 0;
}

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

int k, s;
int ta = 0;

int main() {
  cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (s - i - j >= 0 && s - i - j <= k) {
        ta++;
      }
    }
  }
  cout << ta << 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 + 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 <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++) {
      int k = S - i - j;
      if (k >= 0 && k <= K) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
Problem p03835 (C++)

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

using namespace std;

template <int base> int digit_sum(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % base;
    n /= base;
  }
  return sum;
}

using ivec = vector<int>;

ivec read_int_args() {
  int N;
  cin >> N;
  ivec v(N);
  for (auto &e : v) {
    cin >> e;
  }
  return v;
}

int compar(const void *b, const void *a) { return (*(int *)a - *(int *)b); }

template <typename T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

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

  return 0;
}


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

using namespace std;

template <int base> int digit_sum(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % base;
    n /= base;
  }
  return sum;
}

using ivec = vector<int>;

ivec read_int_args() {
  int N;
  cin >> N;
  ivec v(N);
  for (auto &e : v) {
    cin >> e;
  }
  return v;
}

int compar(const void *b, const void *a) { return (*(int *)a - *(int *)b); }

template <typename T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

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

  cout << sum << endl;

  return 0;
}
Problem p03835 (C++)

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define llint long long int
#define vvint vector<vector<int>>
#define vint vector<int>

using namespace std;

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

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define llint long long int
#define vvint vector<vector<int>>
#define vint vector<int>

using namespace std;

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
static const int INF = 1e9 + 7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define all(a) a.begin(), a.end()
#define PI 3.14159265359

int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  rep(i, k + 1) {
    rep(j, k + 1) {
      rep(h, k + 1) {
        if (i + j + h == s)
          cnt++;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
static const int INF = 1e9 + 7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define all(a) a.begin(), a.end()
#define PI 3.14159265359

int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  rep(i, k + 1) {
    rep(j, k + 1) {
      int h = s - (i + j);
      if (0 <= h and h <= k)
        cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
// cout <<  << endl;
typedef long long int ll;
typedef long double ld;

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

const long long INF = 1LL << 60;

#define MAX_N 1010
#define MAX_M 200000100

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


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
// cout <<  << endl;
typedef long long int ll;
typedef long double ld;

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

const long long INF = 1LL << 60;

#define MAX_N 1010
#define MAX_M 200000100

int main() {
  ll k, s, ans = 0;
  cin >> k >> s;
  for (ll i = 0; i <= k; ++i)
    for (ll j = i; j <= k; ++j)
      for (ll l = j; l <= k; ++l) {
        if (i + j + l == s) {
          if (i == j && j == l) {
            ans++;
          } else if (i == j || j == l || i == l) {
            ans += 3;
          } else {
            ans += 6;
          }
        }
      }
  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 lint = long int;
using llint = long long int;
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; 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 <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using lint = long int;
using llint = long long int;
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; i++) {
    for (int j = 0; j <= k; j++) {
      int l = s - i - j;
      if (0 <= l && l <= k) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p03835 (C++)

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

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

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

int main() {
  int k, z, cnt = 0;
  cin >> k >> z;
  for (int a = 0; a <= k; a++) {
    for (int b = 0; b <= k; b++) {
      int c = z - a - b;
      if (0 <= c && c <= k) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p03835 (C++)

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  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 h = 0; h <= k; h++)
        if (i + j + h == s)
          c++;
  cout << c;
  return 0;
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int k, s;
  cin >> k >> s;
  int c = 0;
  for (int i = 0; i <= k; i++)
    for (int j = 0; j <= k; j++)
      if (s - (i + j) <= k && s - (i + j) > -1)
        c++;
  cout << c;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define full(c) c.begin(), c.end()
#define vector2d(name, type, h, w, init)                                       \
  vector<vector<type>> name(h, vector<type>(w, init))
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main() {
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  int k, s, 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 (x + y + z == s)
          cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Fixed submission:
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define full(c) c.begin(), c.end()
#define vector2d(name, type, h, w, init)                                       \
  vector<vector<type>> name(h, vector<type>(w, init))
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main() {
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  int k, s, cnt = 0;
  cin >> k >> s;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = s - x - y;
      if (0 <= z && z <= 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; n > i; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using VI = vector<ll>;
using vis = vector<string>;
using vvi = vector<vi>;
int gcd(int a, int b) {
  if (a % b == 0)
    return b;
  return gcd(b, a % b);
}
int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int x = 0; k >= x; ++x) {
    for (int y = 0; k >= y; ++y) {
      for (int z = 0; k >= z; ++z) {
        if (x + y + z == s)
          ++ans;
      }
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; n > i; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using VI = vector<ll>;
using vis = vector<string>;
using vvi = vector<vi>;
int gcd(int a, int b) {
  if (a % b == 0)
    return b;
  return gcd(b, a % b);
}
int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int x = 0; k >= x; ++x) {
    for (int y = 0; k >= y; ++y) {
      int z = s - x - y;
      if (z >= 0 && z <= k)
        ++ans;
    }
  }
  cout << ans << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int S, K;
  cin >> K >> S;
  int count = 0;
  for (int i = 0; i <= K; i++) {
    for (int k = 0; k <= K; k++) {
      for (int j = 0; j <= K; j++) {
        if (i + j + k == S) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int S, K;
  cin >> K >> S;
  int count = 0;
  for (int i = 0; i <= K; i++) {
    for (int k = 0; k <= K; k++) {
      int z = S - i - k;
      if (0 <= z && z <= K) {
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}
Problem p03835 (C++)

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

long long k, s, cnt = 0;

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

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

long long k, s, cnt = 0;

int main() {
  cin >> k >> s;
  for (int i = 0; i <= k; ++i)
    for (int j = 0; j <= k; ++j)
      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 <iostream>
using namespace std;
int main(void) {
  // Your code here!
  int K, S;
  int X = 0, Y = 0, Z = 0;
  cin >> K >> S;

  int count = 0;

  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      for (int Z = 0; Z <= K; Z++) {
        int sum = X + Y + Z;
        if (sum == S)
          count++;
      }
    }
  }

  cout << count;
}


Fixed submission:
#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  int K, S;
  int X = 0, Y = 0, Z = 0;
  cin >> K >> S;

  int count = 0;

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

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

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


Fixed submission:
#include <algorithm>
#include <cstring>
#include <iostream>
#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 z = s - (i + j);
      if (z >= 0 && z <= k)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03835 (C++)

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

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

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 + 1; i++) {
    for (int j = 0; j < K + 1; j++) {
      if (0 <= S - i - j && S - i - j < K + 1) {
        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 cou = 0;
  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      for (int Z = 0; Z <= K; Z++) {
        if (S == X + Y + Z) {
          cou++;
        }
      }
    }
  }
  cout << cou++ << endl;
}


Fixed submission:
#include <iostream>

using namespace std;

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define All(v) (v).begin(), (v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  rep(x, k + 1) rep(y, k + 1) rep(z, k + 1) {
    if (x + y + z == s)
      cnt++;
  }
  cout << cnt << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define All(v) (v).begin(), (v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  rep(x, k + 1) rep(y, k + 1) {
    if (0 <= s - x - y && s - x - y <= 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 < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000;          // 10^9
const ll inff = 1000000000000000000; // 10^18

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

  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000;          // 10^9
const ll inff = 1000000000000000000; // 10^18

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

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

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

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 <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;

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

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

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


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

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

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

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

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define PI 3.14159265359
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 k = 0; k <= K; k++) {
        int sum = i + j + k;
        if (sum == S)
          cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define PI 3.14159265359
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 n = S - (i + j);
      if ((n >= 0) && (n <= K))
        cnt++;
    }
  }
  cout << cnt << 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 i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      if (S - i - j >= 0 && S - i - j <= K) {
        count++;
      }
    }
  }
  cout << count << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, s;
  int x, y, z;
  int cnt = 0;
  cin >> k >> s;
  for (x = 0; x <= k; x++) {
    for (y = 0; y <= k; y++) {
      for (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;
  int x, y, z;
  int cnt = 0;
  cin >> k >> s;
  for (x = 0; x <= k; x++) {
    for (y = 0; y <= k; y++) {
      z = s - x - y;
      if (z >= 0 && z <= k)
        cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p03835 (C++)

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

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

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

int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for (int x = 0; x <= K; x++) {
    int sum = S - x;
    if (sum <= 2 * K && sum >= 0) {
      ans += (sum + 1) - max(0, 2 * (sum - K));
    }
  }

  cout << ans;
  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 x, y, z, a;
  a = 0;
  for (x = 0; x <= K; x++) {
    for (y = 0; y <= K; y++) {
      for (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;
  cin >> K >> S;
  int x, y, z, a;
  a = 0;
  for (x = 0; x <= K; x++) {
    for (y = 0; y <= K; y++) {
      z = S - x - y;
      if (0 <= z && z <= K) {
        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, X, Y, Z, cnt = 0;
  cin >> K >> S;
  for (auto i = 0; i <= K; i++) {
    for (auto j = 0; j <= K; j++) {
      for (auto k = 0; k <= K; k++) {
        if (i + j + k == S)
          cnt++;
      }
    }
  }
  cout << cnt << endl;
}

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

using namespace std;

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

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

using namespace std;

#define pb push_back

typedef long long ll;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  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;
}


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

using namespace std;

#define pb push_back

typedef long long ll;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (s - i - j <= k && 0 <= s - i - j) {
        ans++;
      }
    }
  }
  cout << ans;
}
Problem p03835 (C++)

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

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

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

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

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

using namespace std;

#define MD 1000000007
typedef long long int ll;

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

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

using namespace std;

#define MD 1000000007
typedef long long int ll;

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int a = 0; a <= k; a++) {
    for (int 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 <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 k = S - i - j;
      if (0 <= k && k <= K)
        res++;
    }
  }
  cout << res << endl;
}
Problem p03835 (C++)

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

/* using */
using namespace std;

/* main constructor */
struct Fast {
  Fast() {
    std::cin.tie(0);
    ios::sync_with_stdio(0);
    // cout << fixed << setprecision(12);
  }
} fast;

/* template */
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;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) (x).erase(unique(all(x)), (x).end())
// #define int long long

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

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

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

/* using */
using namespace std;

/* main constructor */
struct Fast {
  Fast() {
    std::cin.tie(0);
    ios::sync_with_stdio(0);
    // cout << fixed << setprecision(12);
  }
} fast;

/* template */
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;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) (x).erase(unique(all(x)), (x).end())
// #define int long long

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

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

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

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

  for (i = 0; i < k + 1; i++) {
    for (j = 0; j < k + 1; j++) {
      for (l = 0; l < k + 1; l++) {
        if (i + j + l == s)
          count++;
      }
    }
  }
  cout << count << endl;
}


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

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

  for (i = 0; i < k + 1; i++) {
    for (j = 0; j < k + 1; j++) {
      if (s - i - j <= k and s - i - j >= 0)
        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 < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;

  REP(x, k + 1) {
    if (x == s) {
      ans++;
      break;
    }
    REP(y, k + 1) {
      if (x + y == s) {
        ans++;
        break;
      }
      REP(z, k + 1) {
        if (x + y + z == s) {
          ans++;
          break;
        }
      }
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;

  REP(x, k + 1) {
    if (x == s) {
      ans++;
      break;
    }
    REP(y, k + 1) {
      if (x + y == s) {
        ans++;
        break;
      }
      if (s - (x + y) <= k)
        ans++;
    }
  }
  cout << ans << endl;
}
Problem p03835 (C++)

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

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

  cout << count << endl;
}