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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<int, int> P;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = {0, 1, 0, -1};

int main() {

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

  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<int, int> P;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = {0, 1, 0, -1};

int main() {

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

  return 0;
}
Problem p03835 (C++)

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

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

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


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

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

  ll ans = 0;
  for (ll x = 0; x <= K; ++x) {
    for (ll y = 0; y <= K; ++y) {
      ll z = S - x - y;
      if (z >= 0 && z <= 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 counter = 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)
          counter++;
      }
    }
  }
  cout << counter << endl;
}

Fixed submission:
#include <bits/stdc++.h>
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 (i + j <= S && (S - i - j) <= K)
        counter++;
    }
  }
  cout << counter << endl;
}
Problem p03835 (C++)

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

int main(void) {
  int K, S, a = 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)
          a++;
      }
    }
  }
  cout << a << endl;
  return 0;
}


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

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

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

int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int 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;
}

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll = long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
  int k, s;
  int cnt = 0;
  cin >> k >> s;
  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 <cstdio>
#include <cstring>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll = long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

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

Buggy submission (status: Time Limit Exceeded):
#define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

const long long INF = 10000000000000000;

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:
#define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

const long long INF = 10000000000000000;

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 tmp = x + y;
      if (tmp <= S && S - tmp <= K) {
        ans++;
        // cout<<x<<" "<<y<<" "<<S-(x+y)<<endl;
      }
    }
  }
  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 < (int)(n); i++)

using namespace std;

int main(void) {

  /* Variable_Proclamation */
  int K, S; // input
  int ans;  // output

  int x, y, z; // subscript
  int comp;
  int count;

  /* Input, Array_Proclamation */
  cin >> K >> S;

  /* Initialize */
  ans = 0;
  count = 0;

  /* Calculation */
  for (x = 0; x <= K; x++) {
    for (y = 0; y <= K; y++) {
      for (z = 0; z <= K; z++) {
        comp = x + y + z;
        if (S == comp) {
          count++;
        }
      }
    }
  }

  /* Output */
  cout << count << endl;

  return 0;
}


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

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

using namespace std;

int main(void) {

  /* Variable_Proclamation */
  int K, S; // input
  int ans;  // output

  int x, y, z; // subscript
  int comp;
  int count;

  /* Input, Array_Proclamation */
  cin >> K >> S;

  /* Initialize */
  ans = 0;
  count = 0;

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

  /* Output */
  cout << count << endl;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, S;
  cin >> K >> S;

  int res = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      for (int k = 0; k <= K; k++) {
        int total = i + j + k;
        if (total == 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 <bits/stdc++.h>

using namespace std;

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

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

using namespace std;

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

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

using namespace std;

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

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

using namespace std;

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

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

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

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

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

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

using namespace std;

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

Fixed submission:
#include <iostream>

using namespace std;

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

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

using namespace std;

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

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

using namespace std;

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

Buggy submission (status: Time Limit Exceeded):
// https://atcoder.jp/contests/abc051/tasks/abc051_b

#include <iostream>

using namespace std;

int k, s;
int sum = 0;

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

  if (k * 3 == s) {
    cout << 1 << endl;
    return 0;
  } else if (k * 3 < s) {
    cout << 0 << endl;
    return 0;
  }

  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= min(k, s - x); y++) {
      for (int z = 0; z <= min(k, s - x - y); z++) {
        if (x + y + z == s) {
          sum += 1;
        }
      }
    }
  }

  cout << sum << endl;
  return 0;
}

Fixed submission:
// https://atcoder.jp/contests/abc051/tasks/abc051_b

#include <iostream>

using namespace std;

int k, s;
int sum = 0;

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

  if (k * 3 == s) {
    cout << 1 << endl;
    return 0;
  } else if (k * 3 < s) {
    cout << 0 << endl;
    return 0;
  }

  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= min(k, s - x); y++) {
      int z = s - x - y;
      if (0 <= z && z <= k) {
        sum++;
      }
    }
  }

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ii pair<int, int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fore(i, a, b) for (int i = a; i < b; i += 1)
#define forr(i, a) for (int i = a; i >= 0; i--)
#define fori(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define sz(s) int(s.size())
#define cls(a, car) memset(a, car, sizeof(a))
using namespace std;
typedef long long ll;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD = ll(INT_MAX) * 2 + 1;
int main() {
  freopen("in", "r", stdin);
  freopen("out", "w", stdout);
  fast;
  int k, s;
  cin >> k >> s;
  ll ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      int c = s - i - j;
      if (i + j + c == s && c <= k && c >= 0) {
        ans++;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ii pair<int, int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fore(i, a, b) for (int i = a; i < b; i += 1)
#define forr(i, a) for (int i = a; i >= 0; i--)
#define fori(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define sz(s) int(s.size())
#define cls(a, car) memset(a, car, sizeof(a))
using namespace std;
typedef long long ll;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD = ll(INT_MAX) * 2 + 1;
int main() { /*
      freopen("in","r",stdin);
      freopen("out","w",stdout);*/
  fast;
  int k, s;
  cin >> k >> s;
  ll ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      int c = s - i - j;
      if (i + j + c == s && c <= k && c >= 0) {
        ans++;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define ar array
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
const ll mod = 1000000007;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ar array
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
const ll mod = 1000000007;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
/// Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout << #var << " " << var << endl;
#define co(q) cout << q << endl;
#define all(q) (q).begin(), (q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9 + 7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead                                                               \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
int main() {
  FastRead
      // freopen("output.txt", "w", stdout);
      int n,
      m, cnt = 0;
  cin >> m >> n;
  for (int i = 0; i <= m; i++) {
    for (int j = 0; j <= m; j++) {
      for (int k = 0; k <= m; k++)
        if (i + j + k == n)
          cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
/// Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout << #var << " " << var << endl;
#define co(q) cout << q << endl;
#define all(q) (q).begin(), (q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9 + 7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead                                                               \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
int main() {
  FastRead
      // freopen("output.txt", "w", stdout);
      int n,
      m, cnt = 0;
  cin >> m >> n;
  for (int i = 0; i <= m; i++) {
    for (int j = 0; j <= m; j++) {
      int rem = (n - (i + j));
      if (i + j == n)
        cnt++;
      else if (rem <= m && rem >= 0) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;

  return 0;
}
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) {
      // if (x+y>=s) break;
      for (int z = 0; z <= k; ++z) {
        if (x + y + z == s) {
          ans++;
          // break;
        }
      }
    }
  cout << ans << endl;
}

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) {
      int z = s - x - y;
      if (z >= 0 && z <= 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 sum = 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) {
          sum += 1;
        }
      }
    }
  }
  cout << sum << endl;
}

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

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

  int sum = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      if (i + j > S) {
      } else {
        if (K >= S - i - j) {
          sum += 1;
        }
      }
    }
  }
  cout << sum << 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++)
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;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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)
        continue;
      count++;
    }
  }

  cout << count << endl;

  return 0;
}
Problem p03835 (C++)

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

using namespace std;

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

  cin >> K >> S;

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

  cout << count << endl;

  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

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

  cin >> K >> S;

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

  cout << count << endl;

  return 0;
}
Problem p03835 (C++)

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

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;
typedef long long LL;

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 <iostream>

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

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

  std::cout << ret << std::endl;
}


Fixed submission:
#include <iostream>

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

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

  std::cout << ret << std::endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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


Fixed submission:
#include <iostream>
#include <string>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

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

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

  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#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;
}
Problem p03835 (C++)

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

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

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

  return 0;
}

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

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

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

  return 0;
}
Problem p03835 (C++)

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

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

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

  return 0;
}

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

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

  int cnt = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      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 <algorithm>
#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
int main(void) {
  // Your code here!
  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 <algorithm>
#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
int main(void) {
  // Your code here!
  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;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

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

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

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
// https://atcoder.jp/contests/abc051/tasks/abc051_b
int main() {
  int k, s, count = 0;
  cin >> k >> s;

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

  cout << count << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
// https://atcoder.jp/contests/abc051/tasks/abc051_b
int main() {
  int k, s, count = 0;
  cin >> k >> s;

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

  cout << count << endl;

  return 0;
}
Problem p03835 (C++)

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

int main(void) {
  int K, S;
  scanf("%d", &K);
  scanf("%d", &S);
  int c = 0;
  for (int x = 0; x <= K; x++) {
    if (x > S)
      break;
    for (int y = 0; y <= K; y++) {
      if (x + y > S)
        break;
      for (int z = 0; z <= K; z++) {
        if (x + y + z > S)
          break;
        if (x + y + z == S)
          c++;
      }
    }
  }
  printf("%d\n", c);

  return 0;
}


Fixed submission:
#include <stdio.h>

int main(void) {
  int K, S;
  scanf("%d", &K);
  scanf("%d", &S);
  int c = 0;
  for (int x = 0; x <= K; x++) {
    if (x > S)
      break;
    for (int y = 0; y <= K; y++) {
      if (S - x - y >= 0 && S - x - y <= K)
        c++;
    }
  }
  printf("%d\n", c);

  return 0;
}
Problem p03835 (C++)

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

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

  rep(i, k + 1) {
    rep(j, k + 1) {
      rep(l, k + 1) {
        if (i + j + l == s)
          ++ans;
      }
    }
  }

  cout << ans << endl;
}

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

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

  rep(i, k + 1) {
    for (int j = i; j < k + 1; ++j) {
      for (int l = j; l < k + 1; ++l) {

        if (i + j + l == s) {
          if (i == j || j == l || i == l) {
            if (i == j && j == l)
              ++ans;
            else
              ans += 3;
          } else
            ans += 6;
        }
      }
    }
  }

  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 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++) {
      int k = S - i - j;
      if (0 <= k and k <= K) {
        count++;
      }
    }
  }
  cout << count << endl;
}
Problem p03835 (C++)

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

template <typename T> T get_value(std::istream &is);

int main() {
  cin.sync_with_stdio(false);
  cin.tie(nullptr);

  const auto K{get_value<int>(cin)}, S{get_value<int>(cin)};
  auto res{0u};
  for (auto X{0u}; X <= K; ++X)
    for (auto Y{0u}; Y <= K; ++Y)
      for (auto Z{0u}; Z <= K; ++Z)
        if (X + Y + Z == S)
          ++res;

  cout << res << '\n';
  return 0;
}

template <typename T> inline T get_value(std::istream &is) {
  T v;
  is >> v;
  return v;
}


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

template <typename T> T get_value(std::istream &is);

int main() {
  cin.sync_with_stdio(false);
  cin.tie(nullptr);

  const auto K{get_value<int>(cin)}, S{get_value<int>(cin)};
  auto res{0u};
  for (auto X{0u}; X <= K; ++X)
    for (auto Y{0u}; Y <= K; ++Y) {
      const auto Z = S - X - Y;
      if (0 <= Z && Z <= K)
        ++res;
    }

  cout << res << '\n';
  return 0;
}

template <typename T> inline T get_value(std::istream &is) {
  T v;
  is >> v;
  return v;
}
Problem p03835 (C++)

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

// #include <bits/stdc++.h>
using namespace std;
#define print(x) cout << (x) << endl
#define prints(x, y) cout << (x) << " " << (y) << endl
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define r_rep(i, n) for (int i = n; i >= 0; i--)
#define ll long long int
#define pb push_back

const long long INF = 1LL << 60;

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

  rep(i, k + 1) {
    for (int j = i; j <= k; j++) {
      for (int n = j; n <= k; n++) {
        if (i + j + n == s) {
          if (i != j && i != n && j != n) {
            ans += 6;
          } else if (i == j && i == n) {
            ans++;
          } else {
            ans += 3;
          }
        }
      }
    }
  }
  print(ans);
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>

// #include <bits/stdc++.h>
using namespace std;
#define print(x) cout << (x) << endl
#define prints(x, y) cout << (x) << " " << (y) << endl
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define r_rep(i, n) for (int i = n; i >= 0; i--)
#define ll long long int
#define pb push_back

const long long INF = 1LL << 60;

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

  rep(i, k + 1) {
    rep(j, k + 1) {
      int n = s - (i + j);
      if (n < 0 || n > k)
        continue;
      ans++;
    }
  }
  print(ans);
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int ka, s, ans = 0;
  cin >> ka >> s;
  for (int i = 0; i <= ka; ++i) {
    if ((i + 2 * ka) >= s) {
      for (int j = 0; j <= ka; ++j) {
        for (int k = 0; k <= ka; ++k) {
          if ((i + j + k) == s) {
            ans++;
          }
        }
      }
    }
  }
  cout << ans;
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int ka, s, ans = 0;
  cin >> ka >> s;
  for (int i = ka; 0 <= i; --i) {
    if (i + 2 * ka < s) {
      break;
    }
    for (int j = ka; 0 <= j; --j) {
      if (0 <= s - i - j && s - i - j <= ka) {
        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 ans = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      for (int z = 0; z <= K; z++) {
        if (x + y + z == S) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;
}

Fixed submission:
#include <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++) {
      if (S - (x + y) >= 0 && S - (x + y) <= 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 all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define sort(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int, int> p;
typedef pair<ll, ll> lp;
bool is_uruu(int y) { return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0); }
const ll MOD = 1e9 + 7;
//---------------------------------------------------------------------------//

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


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define sort(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int, int> p;
typedef pair<ll, ll> lp;
bool is_uruu(int y) { return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0); }
const ll MOD = 1e9 + 7;
//---------------------------------------------------------------------------//

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

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

using namespace std;

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


Fixed submission:
#include <iostream>

using namespace std;

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

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

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

  for (int 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;
  int count = 0;
  cin >> k >> s;

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, S;
  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++) {
      int k = S - i - j;
      if (0 <= k and k <= 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, x, y, z;
  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;

  return 0;
}

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

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

  cout << count << endl;

  return 0;
}
Problem p03835 (C++)

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

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

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

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#define popcount(x) __builtin_popcount(x)
#define oddparity(x) __builtin_parity(x)
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#define sf scanf
#define pf printf
#define ll long long int
using namespace std;

int k, s, x, y, z, c;

int main() {
  sf("%d%d", &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) {
          c++;
        }
      }
    }
  }
  pf("%d\n", c);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#define popcount(x) __builtin_popcount(x)
#define oddparity(x) __builtin_parity(x)
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#define sf scanf
#define pf printf
#define ll long long int
using namespace std;

int k, s, x, y, z, c;

int main() {
  sf("%d%d", &k, &s);
  for (x = 0; x <= k; x++) {
    for (y = 0; y <= k; y++) {
      z = s - x - y;
      if (z >= 0 && z <= k && x + y + z == s)
        c++;
    }
  }
  pf("%d\n", c);
  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 n = 0;
  for (int x = 0; x <= K && x <= S; x++) {
    for (int y = 0; y <= K && (x + y) <= S; y++) {
      for (int z = 0; z <= K && (x + y + z) <= S; z++) {
        if ((x + y + z) == S)
          n++;
      }
    }
  }

  cout << n << endl;
}


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

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

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

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

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

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <random>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)n; i++)

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

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <random>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)n; i++)

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

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

bool beki[1000];

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

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

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

bool beki[1000];

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

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

typedef long long int lli;
#define rep(i, s, N) for (int i = s; i < N; i++)
#define MOD 1000000007
using namespace std;

int main(void) {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  rep(x, 0, K + 1) {
    rep(y, 0, K + 1) {
      rep(z, 0, K + 1) {
        if (x + y + z == S) {
          ans++;
          break;
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

typedef long long int lli;
#define rep(i, s, N) for (int i = s; i < N; i++)
#define MOD 1000000007
using namespace std;

int main(void) {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  rep(x, 0, K + 1) {
    rep(y, 0, K + 1) {
      if ((S - x - y) >= 0 && (S - x - y) <= K) {
        ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}