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

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

int main() {
  int K, S;
  cin >> K >> S;
  int res = 0;
  for (int a = 0; a <= K; ++a) {
    for (int b = 0; b <= K; ++b) {
      for (int c = 0; c <= K; ++c) {
        int total = a + b + c; // 総和
        if (total == S)
          ++res; // 合計金額が X に一致したら答えをインクリメント
      }
    }
  }
  cout << res << endl;
}

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

int main() {
  int K, S;
  cin >> K >> S;
  int res = 0;
  for (int a = 0; a <= K; ++a) {
    for (int b = 0; b <= K; ++b) {
      int c = S - a - b; // 総和
      if (0 <= c && c <= K)
        ++res; // 合計が k に一致したら答えをインクリメント
    }
  }
  cout << res << endl;
}
Problem p03835 (C++)

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

int main(void) {
  int s, k;
  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) {
          // cout << i << j << l << endl;
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(void) {
  int s, k;
  cin >> k >> s;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      int num = s - i - j;
      if (num < 0 || num > k)
        continue;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

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

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

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


Fixed submission:
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

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

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

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

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

using namespace std;

int main(void) {
  int K, S;
  int ans = 0;
  cin >> K >> S;
  for (int i = 0; i <= K; i++)
    for (int j = 0; j <= K; j++)
      for (int k = 0; k <= K; k++) {
        if ((i + j + k) == S)
          ans++;
      }
  cout << ans;
  return 0;
}

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

using namespace std;

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = int(a); i < int(b); ++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main() {
  int K, S;
  cin >> K >> S;
  int count = 0;
  rep(i, 0, K + 1) rep(j, 0, K + 1) rep(k, 0, K + 1) {
    if (i + j + k == S) {
      count++;
    }
  }
  cout << count << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = int(a); i < int(b); ++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main() {
  int K, S;
  cin >> K >> S;
  int count = 0;
  rep(i, 0, K + 1) rep(j, 0, K + 1) {
    if (S - i - j >= 0 && S - i - j <= K) {
      count++;
    }
  }
  cout << count << endl;

  return 0;
}
Problem p03835 (C++)

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

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

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

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

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

int main() {
  int k, s, x, y, z, count;
  cin >> k >> s;
  if (k < 2 || k > 2500 || s < 0 || s > 3 * k)
    return -1;

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

  cout << count << "\n";

  return 0;
}


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

int main() {
  int k, s, x, y, z, count;
  cin >> k >> s;
  if (k < 2 || k > 2500 || s < 0 || s > 3 * k)
    return -1;

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

  cout << count << "\n";

  return 0;
}
Problem p03835 (C++)

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

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

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

int main() {
  int S;
  int K;
  int count = 0;
  scanf("%d%d", &K, &S);
  for (int a = 0; a <= K; a++) {
    for (int b = 0; b <= K; b++) {
      if (S - a - b <= K && S - a - b >= 0)
        count++;
    }
  }
  printf("%d", count);
  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 l = 0; l <= K; l++) {
        if (i + j + l == S)
          res++;
      }
    }
  }

  cout << res << endl;
}

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

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

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

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
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 <algorithm>
#include <cmath>
#include <iostream>
#include <string>
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)
        break;
      if ((S - i - j) <= K)
        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;
  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>
using namespace std;

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(), x.end()
#define rep(i, j, n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(), v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
// name[i][j]-> vvl name(i,vl(j))
// map<int,int>mp
// 余りを切り上げる =>  (a + b - 1) / b

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(), x.end()
#define rep(i, j, n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(), v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
// name[i][j]-> vvl name(i,vl(j))
// map<int,int>mp
// 余りを切り上げる =>  (a + b - 1) / b

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#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;
  int a;
  cin >> a;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#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 (x + y <= s && x + y + k >= s) {
        count++;
      }
    }
  }
  cout << count << endl;
  int a;
  cin >> a;
  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;

  return 0;
}


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

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

  cout << count << endl;

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

  cout << c << endl;
}

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

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

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

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

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

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

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

int main() {
  int a, b;
  cin >> a >> b;
  int res;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= a; j++) {
      if (b >= i + j && i + j >= b - a) {
        res++;
      }
    }
  }
  cout << res << endl;
}
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;
  int ans = 0;
  cin >> K >> S;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      bool f = false;
      for (int k = 0; k <= K; k++) {
        if (i + j + k == S) {
          ans++;
          f = true;
          break;
        }
        if (f)
          break;
      }
    }
  }
  cout << ans << endl;
}

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

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
const int INF = 1e9;
using namespace std;

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


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
const int INF = 1e9;
using namespace std;

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

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

  return 0;
}

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

  return 0;
}
Problem p03835 (C++)

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

template <typename T> void drop(const T &x) {
  cout << x << '\n';
  exit(0);
}

void solve() {
  int n, x;
  cin >> n >> x;

  int count = 0;
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= n; ++j)
      for (int k = 0; k <= n; ++k)
        if (i + j + k == x)
          count++;
  cout << count << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt = 1;
  // cin >> T;
  while (tt--)
    solve();

  return 0;
}


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

template <typename T> void drop(const T &x) {
  cout << x << '\n';
  exit(0);
}

void solve() {
  int n, x;
  cin >> n >> x;

  int count = 0;
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= n; ++j) {
      int k = x - i - j;
      if (k >= 0 && k <= n)
        count++;
    }
  cout << count << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt = 1;
  // cin >> T;
  while (tt--)
    solve();

  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++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
  int k, s;
  cin >> k >> s;
  int count = 0;
  rep(i, k + 1) rep(j, k + 1) rep(l, k + 1) if (i + j + l == 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++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
  int k, s;
  cin >> k >> s;
  vector<int> sum_ij;
  rep(i, k + 1) rep(j, k + 1) sum_ij.push_back(i + j);
  sort(all(sum_ij));
  long count = 0;
  rep(i, sum_ij.size()) {
    if (0 <= s - sum_ij[i] && s - sum_ij[i] <= k)
      count++;
  }
  cout << count << endl;
}
Problem p03835 (C++)

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int x = 0; x <= k; x++) {
        if (i + j + x == s)
          cnt++;
      }
    }
  }
  cout << cnt << '\n';
  return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (!(s - i - j >= 0 && s - i - j <= k))
        continue;
      if (i + j + (s - i - j) == s)
        cnt++;
    }
  }
  cout << cnt << '\n';
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"
#define rep(i, a, n) for (int i = (a); i < (n); i++)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

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

Fixed submission:
#include "bits/stdc++.h"
#define rep(i, a, n) for (int i = (a); i < (n); i++)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int a, b, cnt = 0;
  cin >> a >> b;
  rep(i, 0, a + 1) {
    rep(j, 0, a + 1) {
      if ((b - i - j) <= a && (b - i - j) >= 0) {
        cnt++;
      }
    }
  }

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

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

using namespace std;

int K, S, ans;

int main() {
  scanf("%d%d", &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++;
        }
      }
    }
  }
  printf("%d\n", ans);
}


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

using namespace std;

int K, S, ans;

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

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

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

  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>
#include <string>
using namespace std;

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

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

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

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;
ll mod = pow(10, 9) + 7;
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
char upper(char c) { return c - 0x20; }
char lower(char c) { return c + 0x20; }
int main() {
  int k, s;
  cin >> k >> s;
  int count = 0;
  rep(i, k + 1) {
    rep(j, k + 1) {
      if (i + j > s)
        break;
      rep(l, k + 1) {
        if (i + j + l > s)
          break;
        if (i + j + l == s) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;
ll mod = pow(10, 9) + 7;
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
char upper(char c) { return c - 0x20; }
char lower(char c) { return c + 0x20; }
int main() {
  int k, s;
  cin >> k >> s;
  int count = 0;
  rep(i, k + 1) {
    rep(j, k + 1) {
      if (i + j <= s && 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 < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define sort(A) sort(A.begin(), A.end())
#define reverse(A) reverse(A.begin(), A.end());

typedef long long ll;

int main() {

  int k, s;
  cin >> k >> s;
  int ans = 0;
  rep(p, k + 1) rep(q, k + 1) rep(r, k + 1) if (p + q + r == s) ans++;
  cout << ans << endl;
}

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

typedef long long ll;

int main() {

  int k, s;
  cin >> k >> s;
  int ans = 0;
  rep(p, k + 1) {
    rep(q, k + 1) {
      int r = s - p - q;
      if (r >= 0 && r <= k)
        ans++;
    }
  }
  cout << ans << endl;
}
Problem p03835 (C++)

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

using namespace std;

int main() {
  int K, S, ans = 0;

  cin >> K >> S;

  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      for (int k = 0; k <= K; k++) {
        if (i + j + k == S)
          ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <iostream>

using namespace std;

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

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

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

  int count;

  for (int x = 0; x <= K; ++x) {
    for (int y = 0; y <= K; ++y) {
      if ((x + y) > S || (x + y) < (S - K)) {
        continue;
      } else if ((x + y) >= (S - K)) {
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  string s;
  int K, S;
  cin >> K >> S;
  // cout << K <<" ks " << S <<endl;

  long 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 <iostream>
using namespace std;
int main() {
  string s;
  int K, S;
  cin >> K >> S;
  // cout << K <<" ks " << S <<endl;

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

Buggy submission (status: Time Limit Exceeded):
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

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

  return 0;
}

Fixed submission:
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

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

  return 0;
}
Problem p03835 (C++)

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n - 1; i >= 0; i--)
#define repone(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for (auto i : mp)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

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

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n - 1; i >= 0; i--)
#define repone(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for (auto i : mp)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  rep(i, k + 1) {
    rep(j, k + 1) {
      if (s - i - j >= 0 && s - i - j <= k)
        ans++;
    }
  }
  cout << ans << 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++)
const int MOD = 1000000007;
// long long a;
int main() {
  int K, S;
  cin >> K >> S;
  int tmp;
  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;
#define REP(i, n) for (int i = 0; i < (int)n; i++)
const int MOD = 1000000007;
// long long a;
int main() {
  int K, S;
  cin >> K >> S;
  int tmp;
  int count = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      tmp = S - (i + j);
      if (0 <= tmp && tmp <= K)
        count++;
    }
  }
  cout << count << endl;
}
Problem p03835 (C++)

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

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:
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < n; i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod = 1e+9 + 7;

int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = x; y <= K; y++) {
      for (int z = y; z <= K; z++) {
        if (x + y + z == S) {
          if (x == y && x == z)
            ans += 1;
          else if (x != z && x != y && z != y)
            ans += 6;
          else
            ans += 3;
        }
      }
    }
  }
  cout << ans << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, m, n) for (int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define LL long long
template <class T> inline void chmax(T &a, T b) {
  if (a < b) {
    a = b;
  }
}
template <class T> inline void chmin(T &a, T b) {
  if (a > b) {
    a = b;
  }
}
template <class T> void print_vector(vector<T> vec) {
  cout << "[ ";
  for (int i = 0; i < vec.size(); i++) {
    cout << vec[i] << " ";
  }
  cout << "]" << endl;
}
template <class T> void print_pair_vector(vector<pair<T, T>> vec) {
  cout << "[ ";
  for (int i = 0; i < vec.size(); i++) {
    cout << "(" << vec[i].first << "," << vec[i].second << ") ";
  }
  cout << "]" << endl;
}

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

  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, m, n) for (int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define LL long long
template <class T> inline void chmax(T &a, T b) {
  if (a < b) {
    a = b;
  }
}
template <class T> inline void chmin(T &a, T b) {
  if (a > b) {
    a = b;
  }
}
template <class T> void print_vector(vector<T> vec) {
  cout << "[ ";
  for (int i = 0; i < vec.size(); i++) {
    cout << vec[i] << " ";
  }
  cout << "]" << endl;
}
template <class T> void print_pair_vector(vector<pair<T, T>> vec) {
  cout << "[ ";
  for (int i = 0; i < vec.size(); i++) {
    cout << "(" << vec[i].first << "," << vec[i].second << ") ";
  }
  cout << "]" << endl;
}

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

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

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

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

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

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

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 (S == x + y + z)
          cnt++;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}

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

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 && K + x + y >= S)
        cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define SORT(c) sort((c).begin(), (c).end())
#define MOD 1000000007
// S.size()
// 配列名.Length()
using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;

int main(void) {
  int K, S;
  cin >> K >> S;
  int cnt = 0;
  for (int i = 0; i <= K; i++) {
    if (i + K + K < S)
      continue;
    for (int j = 0; j <= K; j++) {
      if (K + j + K < S)
        continue;
      for (int t = 0; t <= K; t++) {
        if (i + j + t == S) {
          cnt++;
          break;
        }
      }
    }
  }
  cout << cnt;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define SORT(c) sort((c).begin(), (c).end())
#define MOD 1000000007
// S.size()
// 配列名.Length()
using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;

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

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

using namespace std;

#define PI 3.1415926535897932

int main() {
  int k, s, ans = 0;
  scanf("%d %d", &k, &s);
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; k++) {
      if (s - i - j >= 0 && s - i - j <= k)
        ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;

#define PI 3.1415926535897932

int main() {
  int k, s, ans = 0;
  scanf("%d %d", &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++;
    }
  }
  printf("%d\n", 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 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 <iostream>
using namespace std;

int main() {

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

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

  cout << count << endl;

  return 0;
}
Problem p03835 (C++)

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

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

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

  cout << count << endl;
}

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 + 1; x++) {
    for (int y = 0; y < k + 1; 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 <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

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

const ll mod = 1000000007ll;
const ll inf = 1000000000000000ll;

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

  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

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

const ll mod = 1000000007ll;
const ll inf = 1000000000000000ll;

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

  return 0;
}


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++) {
      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):
#include <iostream>
using namespace std;
int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0, count = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      for (int z = 0; z <= K; z++) {
        ans = x + y + z;
        if (ans == S) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int)x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template <class T> void print(const T &t) { cout << t << endl; }
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  ll k, s;
  cin >> k >> s;
  ll count = 0;
  rep(x, k + 1) {
    rep(y, k + 1) {
      rep(z, k + 1) {
        if (x + y + z == s) {
          count++;
        }
      }
    }
  }
  print(count);
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int)x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template <class T> void print(const T &t) { cout << t << endl; }
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <vector>
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;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <vector>
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 (x + y <= s && s - x - y <= k)
        res++;
    }
  }
  cout << res << endl;
  return 0;
}
Problem p03835 (C++)

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

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

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

int main() {
  int K, S;
  cin >> K >> S;
  int count = 0;
  for (int i = 0; i < K + 1; i++) {
    for (int j = 0; j < K + 1; j++) {
      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 k, s;
  cin >> k >> s;
  int ans = 0;

  if (k + k + k < s) {
    cout << ans << endl;
  } else {

    for (int i = k; i >= 0; i--) {
      if (i + k + k < s) {
        break;
      }

      for (int j = k; j >= 0; j--) {
        if (i + j + k < s) {
          break;
        }

        for (int r = k; r >= 0; r--) {
          if (i + j + r == s) {
            ans++;
          } else if (i + j + r < s) {
            break;
          }
        }
      }
    }
  }

  cout << ans << endl;
}

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

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

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

  cout << ans << endl;
}