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

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

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

int k;
int s;

void input() { cin >> k >> s; }

void solve() {
  int ans = 0;

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

  cout << ans << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  _times = 2;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


Fixed submission:
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

int k;
int s;

void input() { cin >> k >> s; }

void solve() {
  int ans = 0;

  for (int i = 0; i < k + 1; ++i) {
    for (int j = 0; j < k + 1; ++j) {
      int val = s - (i + j);

      if (val > -1 && val < k + 1)
        ++ans;
    }
  }

  cout << ans << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  _times = 2;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}
Problem p03835 (C++)

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (s - i - j >= 0 && s - i - j <= 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 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 += 1;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

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

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <stdio.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++;
      }
    }
  }
  printf("%d", ans);

  return 0;
}

Fixed submission:
#include <iostream>
#include <stdio.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++) {
      int z = s - x - y;
      if (0 <= z and z <= k) {
        ans++;
      }
    }
  }
  printf("%d", ans);

  return 0;
}
Problem p03835 (C++)

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef pair<int, int> PII;
int a, b;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define MAX(a, b) a > b ? a : b
#define MIN(a, b) a > b ? b : a

int main() {
  int k, s, cnt = 0;
  cin >> k >> s;
  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 <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef pair<int, int> PII;
int a, b;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define MAX(a, b) a > b ? a : b
#define MIN(a, b) a > b ? b : a

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

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

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

  int ans = 0;

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

  int ans = 0;

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

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

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

int main() {
  int K, S;
  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 <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace std;
int main(void) {
  int i, j, k, k1, s, ans = 0;
  cin >> k1 >> s;
  for (i = 0; i <= k1; i++) {
    for (j = 0; j <= k1; j++) {
      for (k = 0; k <= k1; k++) {
        if (i + j + k == s)
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

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


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

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


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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, j, n) for (int i = (int)(j); i < (int)(n); i++)
#define REP(i, j, n) for (int i = (int)(j); i <= (int)(n); i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(), (a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int, int>
#define priq priority_queue<int>
#define disup(A, key) distance(A.begin(), upper_bound(ALL(A), (int)(key)))
#define dislow(A, key) distance(A.begin(), lower_bound(ALL(A), (int)(key)))
signed main() {
  int K, S, ans = 0;
  cin >> K >> S;
  REP(i, 0, K) {
    REP(j, 0, K) {
      REP(k, 0, K) {
        if (i + j + k == S)
          ans++;
        else if (i + j + k > S)
          break;
      }
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, j, n) for (int i = (int)(j); i < (int)(n); i++)
#define REP(i, j, n) for (int i = (int)(j); i <= (int)(n); i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(), (a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int, int>
#define priq priority_queue<int>
#define disup(A, key) distance(A.begin(), upper_bound(ALL(A), (int)(key)))
#define dislow(A, key) distance(A.begin(), lower_bound(ALL(A), (int)(key)))
signed main() {
  int K, S, ans = 0;
  cin >> K >> S;
  REP(i, 0, K) {
    REP(j, 0, K) {
      if (i + j <= S && S <= i + j + 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 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)
          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 + 1; x++) {
    for (int y = 0; y < K + 1; y++) {
      if ((0 <= S - x - y) && (S - x - y <= K)) {
        cnt++;
      }
    }
  }

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

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

int main(void) {

  int max, num;
  cin >> max >> num;

  int count = 0;
  for (int i = 0; i <= max; i++) {
    for (int j = 0; j <= max; j++) {
      for (int k = 0; k <= max; k++) {
        if (i + j + k == num)
          count++;
      }
    }
  }

  cout << count << endl;
}


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

int main(void) {

  int max, num;
  cin >> max >> num;

  int count = 0;
  for (int i = 0; i <= max; i++) {
    for (int j = 0; j <= max; j++) {
      if (0 <= (num - (i + j)) && (num - (i + j)) <= max) {
        count++;
      }
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
typedef long long LL;
int main() {
  int k = 0, s = 0, ans = 0;
  std::cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int l = 0; l <= k; l++) {
        if (i + j + l == s) {
          ans++;
        }
      }
    }
  }
  std::cout << ans << std::endl;
}

Fixed submission:
#include <iostream>
typedef long long LL;
int main() {
  int k = 0, s = 0, ans = 0;
  std::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) {
        ans++;
      }
    }
  }
  std::cout << ans << std::endl;
}
Problem p03835 (C++)

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

int main() {
  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 <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int k, s;

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

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

using namespace std;

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

  cout << cnt << endl;
}


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

using namespace std;

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


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

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

  int answer = 0;

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

Buggy submission (status: Runtime Error):
#include <iostream>

using namespace std;

int main() {

  int K;
  int S;

  cin >> K >> S;

  int count = 0;

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

Fixed submission:
#include <iostream>

using namespace std;

int main() {

  int K;
  int S;

  cin >> K >> S;

  int count = 0;

  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;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

  int count = 0;

  int min = 0;
  if (s - 2 * k > 0)
    min = s - 2 * k;

  for (int x = min; x <= k; x++) {
    for (int y = min; y <= k; y++) {
      for (int z = min; z <= k; z++) {
        if (x + y + z == s)
          count++;
      }
    }
  }
  cout << count << 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, s;
  cin >> k >> s;

  int count = 0;

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

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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

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;

        if (i + j + l > s)
          break;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

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

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

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

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

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


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

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

Buggy submission (status: Time Limit Exceeded):
/*#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<cstdio>
#include<deque>
#include<fstream>
#include<iomanip>
#include<map>
#include <numeric>*/
#include <queue>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, s, n) for (int i = (s); i < (n); i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define REPR(i, s, n) for (int i = (s); i >= (n); (i)--)
#define all(a) (a).begin(), (a).end()
#define reall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define pf push_front
#define MIN(a, b) a = min((a), (b))
#define MAX(a, b) a = max((a), (b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

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


Fixed submission:
/*#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<cstdio>
#include<deque>
#include<fstream>
#include<iomanip>
#include<map>
#include <numeric>*/
#include <queue>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, s, n) for (int i = (s); i < (n); i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define REPR(i, s, n) for (int i = (s); i >= (n); (i)--)
#define all(a) (a).begin(), (a).end()
#define reall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define pf push_front
#define MIN(a, b) a = min((a), (b))
#define MAX(a, b) a = max((a), (b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

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

Buggy submission (status: Time Limit Exceeded):
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, b) FOR(i, 0, b)
#define INF 1e9

using ll = long long;
const ll mod = 100000000 + 7;
const ll MAX_N = 1000;

ll k, s, ans;
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)
          ans++;
      }
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, b) FOR(i, 0, b)
#define INF 1e9

using ll = long long;
const ll mod = 100000000 + 7;
const ll MAX_N = 1000;

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

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

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

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

  cout << count << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

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

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

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

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 << fixed << setprecision(6) << ans << endl;
  cout << ans << endl;

  return (0);
}


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

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

  cin >> k >> s;

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

  //    cout << fixed << setprecision(6) << ans << endl;
  cout << ans << endl;

  return (0);
}
Problem p03835 (C++)

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

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


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

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

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

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

  cout << cnt << endl;
}

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

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

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

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++) {
      int C = S - A - B;
      if (C >= 0 && C <= K)
        ans++;
    }
  }

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

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

int main(int argc, char const *argv[]) {
  int k, s;
  cin >> k >> s;
  int num = 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) {
          num++;
          break;
        }
      }
    }
  }
  cout << num << endl;
  return 0;
}


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

int main(int argc, char const *argv[]) {
  int k, s;
  cin >> k >> s;
  int num = 0;

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

    if (s - x > 2 * k)
      ;
    else if (s - x > k) {
      num += 2 * k - (s - x) + 1;
    } else
      num += s - x + 1;
  }
  cout << num << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define MOD 1000000007
int main() {
  fast;
  int s, k, 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++;
        else if (i + j + l > s)
          break;
  cout << cnt;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define MOD 1000000007
int main() {
  fast;
  int s, k, cnt = 0;
  cin >> k >> s;
  for (int i = 0; i <= k; i++)
    for (int j = 0; j <= k; j++)
      if (s - i - j <= k && s - i - j >= 0)
        cnt++;
  cout << cnt;
  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() {
  int k, s;
  cin >> k >> s;

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

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

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

  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      for (int k = 0; k <= K; k++) {
        if (i + j + k == S)
          count += 1;
      }
    }
  }
  cout << count << endl;
  return 0;
}

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

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

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

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

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

  return 0;
}

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

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

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

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

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

  int cnt = 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) {
          cnt++;
          break;
        } else if (x + y + z > s) {
          break;
        }
      }
    }
  }

  cout << cnt << endl;
}

Fixed submission:
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

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

  int cnt = 0;
  for (int x = 0; x <= k; x++) {
    if (x > s) {
      break;
    }
    for (int y = 0; y <= k; y++) {
      if (x + y > s) {
        break;
      } else if (s - (x + y) <= 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 res = 0;
  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      for (int Z = 0; Z <= K; Z++) {
        if (X + Y + Z == S) {
          res++;
        }
      }
    }
  }

  cout << res << endl;
}

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

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

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

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

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

using namespace std;

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

  cin >> k >> s;

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

  cout << count << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

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

  cin >> k >> s;

  for (int a = 0; a <= k; a++) {
    for (int b = 0; b <= k; b++) {
      if (s - a - b < 0) {
        break;
      } else if (s - a - b <= k) {
        count++;
      }
    }
  }

  cout << count << endl;

  return 0;
}
Problem p03835 (C++)

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

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

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


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

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

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

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

int main() {
  int a, b, i, j, k, ans = 0;
  cin >> a >> b;

  for (i = 0; i <= a; i++) {
    for (j = 0; j <= a; j++) {
      for (k = 0; k <= a; k++) {
        if (i + k + j == b)
          ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

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

int main() {
  int a, b, i, j, k, ans = 0;
  cin >> a >> b;

  for (i = 0; i <= a; i++) {
    for (j = 0; j <= a; j++) {
      if (b - i - j >= 0 && b - i - j <= a)
        ans++;
    }
  }
  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

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

using namespace std;

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

  int count = 0;

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

  cout << count << endl;

  return 0;
}

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

using namespace std;

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

  int count = 0;

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

  cout << count << endl;

  return 0;
}
Problem p03835 (C++)

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

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>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int, int>;

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) {

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

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

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

int main() {
  int K, S;
  cin >> K >> S;
  int count = 0;
  for (int i = 0; i <= K; 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(void) {
  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;
  return 0;
}


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

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

  int count = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= x; y++) {
      for (int z = 0; z <= y; z++) {
        if (x + y + z == s) {
          if (x == y && y == z) {
            count++;
          } else if ((x == y && y != z) || (y == z && x != y) ||
                     (z == x && z != x)) {
            count += 3;
          } else {
            count += 6;
          }
        }
      }
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <array>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <set>
#include <vector>

using namespace std;

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


Fixed submission:
#include <algorithm>
#include <array>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <set>
#include <vector>

using namespace std;

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

Buggy submission (status: Time Limit Exceeded):
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
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;

  return 0;
}

Fixed submission:
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
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++) {
      if (i + j >= S - K && i + j <= S)
        ans++;
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

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

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

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

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int k, s, ans = 0;
  cin >> k >> s;
  for (int i = 0; i <= min(k, s); i++) {
    for (int j = 0; j <= min(k, s - i); j++) {
      if (s - i - j >= 0 && s - i - j <= k)
        ans++;
    }
  }
  cout << ans;
  return 0;
}
Problem p03835 (C++)

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

int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      for (int Z = 0; Z <= S - X - Y && Z <= K; Z++) {
        if (X + Y + Z == S) {
          ans++;
        }
      }
    }
  }
  cout << ans;
  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 m = S - X - Y;
      if (0 <= m && m <= K) {
        ans++;
      }
    }
  }
  cout << ans;
  return 0;
}
Problem p03835 (C++)

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


Fixed submission:
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
int main(void) {
  int K, S;
  cin >> K >> S;
  int count = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= i; j++) {
      for (int k = 0; k <= j; k++) {
        if (i + j + k == S) {
          if (i == j && j == k) {
            count++;
          } else if (i != j && j != k) {
            count += 6;
          } else
            count += 3;
        }
      }
    }
  }
  cout << count;
  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++)
typedef long long ll;
using namespace std;

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

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

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