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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#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++;
      }
    }
  }
  cout << count << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#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 <= S; x++) {
    for (int y = 0; y <= S - x; y++) {
      if (x <= K && y <= K && S - x - y <= K)
        count++;
    }
  }
  cout << count << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <map>
#include <math.h>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
// for (int i = 0; i < N; i++){}

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

Fixed submission:
#include <iostream>
#include <map>
#include <math.h>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
// for (int i = 0; i < N; i++){}

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++) {
      if (i + j <= S && (S - i - j) <= K) {
        res++;
      }
    }
  }
  cout << res << endl;
}
Problem p03835 (C++)

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

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

  cin >> K >> S;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      for (int m = 0; m <= K; m++) {
        if ((i + j + m) == S) {
          a++;
        }
      }
    }
  }

  cout << a << endl;
}

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

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

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

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

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

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

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

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

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

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

  for (i = 0; i <= K; i++) {
    for (j = 0; j <= K; j++) {
      if (i + j <= S) {
        if (S - j - i <= K)
          cnt++;
      }
    }
  }
  cout << cnt;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
int main(int argc, char *argv[]) {
  int K, S;
  std::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;
        }
  std::cout << count << std::endl;
}


Fixed submission:
#include <iostream>
int main(int argc, char *argv[]) {
  int K, S;
  std::cin >> K >> S;

  int count = 0;
  for (int x = 0; x <= K; ++x)
    for (int y = 0; y <= K; ++y) {
      int s = S - (x + y);
      if (0 <= s && s <= K)
        ++count;
    }
  std::cout << count << std::endl;
}
Problem p03835 (C++)

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

int K, S;
int main() {
  cin >> K >> S;
  int cnt = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      for (int l = 0; l <= K; l++) {
        if (i + j + l == S)
          cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


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

int K, S;
int main() {
  cin >> K >> S;
  int cnt = 0;
  for (int x = 0; x < K + 1; x++) {
    for (int y = 0; y < K + 1; y++) {
      int z = S - (x + y);
      if (x + y + z == S && (z >= 0 && z < K + 1))
        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;
  int S;
  cin >> K >> S;
  int X;
  int Y;
  int Z;
  int num = 0;

  for (X = K; X >= 0; --X) {
    for (Y = K; Y >= K; --Y) {
      for (Z = K; K >= 0; --Z) {
        if (X + Y + Z == S) {
          num++;
        }
      }
    }
  }

  cout << num << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {

  int K;
  int S;
  cin >> K >> S;
  int X;
  int Y;
  int Z;
  int num = 0;

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

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


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

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
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 ((s - x - y - z) == 0)
          ++res;
      }
    }
  }
  cout << res << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
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 (0 <= z && z <= k)
        ++res;
    }
  }
  cout << res << endl;
  return 0;
}
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
k, s = map(int, input().split())
r = range(0, k + 1)
cnt = 0
for x in r:
    for y in r:
        if x + y > s:
            continue
        for z in r:
            if x + y + z == s:
                cnt += 1

print(cnt)


Fixed submission:
k, s = map(int, input().split())
r = range(0, k + 1)
cnt = 0
for x in r:
    for y in r:
        if s - k <= x + y <= s:
            cnt += 1
print(cnt)
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

  REP(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++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

  REP(i, k + 1) {
    REP(j, k + 1) {
      int z = s - i - j;
      if (z <= k && z >= 0)
        ans++;
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>
#include <vector>
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 (S == i + j + k) {
          ++count;
        }
      }
    }
  }

  cout << count << endl;
}


Fixed submission:
#include <iostream>
#include <string>
#include <vector>
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 <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
using ll = long long;
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 <= s - x; y++) {
      for (int z = 0; z <= k && z <= s - x - y; z++) {
        if (x + y + z == s)
          ans++;
      }
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
using ll = long long;
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 <= s - x; y++) {
      if (s - x - y <= k)
        ans++;
    }
  }
  cout << ans << endl;
}
Problem p03835 (C++)

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

using namespace std;

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

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

  cout << ans;
}

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

using namespace std;

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

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

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define vi vector<int>
#define vvi vector<vector<int>>
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i, n) for (int i = 0; i < n; i++)
#define loop(i, s, n) for (int i = s; i < n; i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define int ll
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
signed main() {
  int k, s;
  cin >> k >> s;
  vi dp(10000, 0);
  vb check(10, true);
  rep(i, k + 1) rep(j, k + 1) {
    if (i == j && check[i]) {
      dp[i + j]++;
      check[i] = false;
    } else if (i != j)
      dp[i + j]++;
  }
  int ans = 0;
  rep(i, k + 1) if (s - i >= 0) ans += dp[s - i];
  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define vi vector<int>
#define vvi vector<vector<int>>
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i, n) for (int i = 0; i < n; i++)
#define loop(i, s, n) for (int i = s; i < n; i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define int ll
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
signed main() {
  int k, s;
  cin >> k >> s;
  vi dp(10000, 0);
  vb check(10000, true);
  rep(i, k + 1) rep(j, k + 1) {
    if (i == j && check[i]) {
      dp[i + j]++;
      check[i] = false;
    } else if (i != j)
      dp[i + j]++;
  }
  int ans = 0;
  rep(i, k + 1) if (s - i >= 0) ans += dp[s - i];
  cout << ans << endl;
}
Problem p03835 (C++)

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

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

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

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


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

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

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


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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (long long i = 0; i < (n); i++)
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (long long i = 0; i < (n); i++)
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

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


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

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

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

Fixed submission:
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

using namespace std;

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

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

  cout << cnt << endl;
}

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

using namespace std;

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

  for (int X = 0; X <= K; ++X) {
    for (int Y = 0; Y <= K; ++Y) {
      int Z = S - X - Y;
      if (Z >= 0 && Z <= 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 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 && 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() {
  int64_t K, S;
  cin >> K >> S;
  int64_t 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() {
  int64_t K, S;
  cin >> K >> S;
  int64_t 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 <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(a, k + 1) {
    rep(b, k + 1) {
      rep(c, k + 1) {
        if (a + b + c == s) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}


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

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

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

using namespace std;

int main() {
  int K, S;
  int count = 0; // 条件を満たす個数をカウント

  // 入力
  cin >> K >> S;

  // 0<=X,Y,Z<=K.X+Y+Z=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) {
          // cout << "(" << x << "," << y << "," << z << ")" << endl;
          count++;
        }
      }
    }
  }

  cout << count << endl;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int K, S;
  int count = 0; // 条件を満たす個数をカウント

  // 入力
  cin >> K >> S;

  // 0<=X,Y,Z<=K.X+Y+Z=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;
}
Problem p03835 (C++)

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

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

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

int main(void) {
  int i, j, k, K, S, X, Y, Z, ans = 0;
  cin >> K;
  cin >> S;
  for (i = 0; i <= K; i++) {
    for (j = i; j <= K; j++) {
      for (k = j; k <= K; k++) {
        if (i + j + k == S) {
          if (i == j && j != k)
            ans += 3;
          else if (j == k && i != k)
            ans += 3;
          else if (i == k && j != k)
            ans += 3;
          else if (i == k && j == k && k == i)
            ans += 1;
          else
            ans += 6;
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>
#include <iostream>
using namespace std;
int k, s;
long long res;
int ans[5010];
int main() {
  scanf("%d%d", &k, &s);
  for (int i = 0; i <= 2 * k; i++)
    ans[i] = min(i, k) + 1 - max(i - k, 0);
  for (int i = 0; i <= min(s, k); i++)
    res += ans[s - i];
  printf("%lld", res);
  return 0;
}

Fixed submission:
#include <cstdio>
#include <iostream>
using namespace std;
int k, s;
long long res;
int ans[5010];
int main() {
  scanf("%d%d", &k, &s);
  for (int i = 0; i <= 2 * k; i++)
    ans[i] = min(i, k) + 1 - max(i - k, 0);
  for (int i = max(0, s - 2 * k); i <= min(s, k); i++)
    res += ans[s - i];
  printf("%lld", res);
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int k, s;
  cin >> k >> s;
  int count = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int l = 0; l <= k; l++) {
        if ((i + j + l) == s)
          count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  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;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <tuple>
#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 += 1;
        }
      }
    }
  }

  cout << count << "\n";

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <tuple>
#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 - (x + y)) >= 0) and ((S - (x + y)) <= K)) {
        count += 1;
      }
    }
  }

  cout << count << "\n";

  return 0;
}
Problem p03835 (C++)

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

using namespace std;

int main() {

  int k, s;
  int count = 0;
  int x = 0, y = 0, z = 0;

  cin >> k >> s;

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

  cout << count << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

int main() {

  int k, s;
  int count = 0;
  int x = 0, y = 0, z = 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;

  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;
using ll = long long;

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 <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

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

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

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

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 = i; j <= k; j++) {
      for (int l = j; l <= k; l++) {
        if (i + j + l == s) {
          if (i != j && j != l && i != l)
            count += 6;
          else if (i == j && j == l)
            count += 1;
          else
            count += 3;
        }
      }
    }
  }
  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++) {
        int sum = x + y + z;
        if (sum == S)
          ans++;
      }
    }
  }

  cout << ans << endl;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {

  int K, S;
  cin >> K >> S;
  int ans = 0;
  for (int 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;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#define lowbit(x) ((x) & (-x))
#define sc scanf
#define debug1(x) cout << x << " "
#define debug2(x) cout << x << "\n"
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
const ll inf = 1e18;
const int N = 1e5 + 10;
ll mod = 1e9 + 7;
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int arr[N], brr[N];
ll quick_pow(ll a, ll b, ll m) {
  ll ret = 1;
  while (b) {
    if (b & 1) {
      ret *= a;
      ret %= m;
    }
    a *= a;
    a %= m;
    b >>= 1;
  }
  return ret;
}
int main() {
  int k, s;
  while (cin >> k >> s) {
    int ans = 0;
    for (int i = 0; i <= k; i++) {
      for (int j = 0; j <= k; j++) {
        for (int p = 0; p <= k; p++)
          if (i + j + p == s)
            ans++;
      }
    }
    cout << ans << "\n";
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#define lowbit(x) ((x) & (-x))
#define sc scanf
#define debug1(x) cout << x << " "
#define debug2(x) cout << x << "\n"
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
const ll inf = 1e18;
const int N = 1e5 + 10;
ll mod = 1e9 + 7;
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int arr[N], brr[N];
ll quick_pow(ll a, ll b, ll m) {
  ll ret = 1;
  while (b) {
    if (b & 1) {
      ret *= a;
      ret %= m;
    }
    a *= a;
    a %= m;
    b >>= 1;
  }
  return ret;
}
int main() {
  int k, s;
  while (cin >> k >> s) {
    int ans = 0;
    for (int i = 0; i <= k; i++) {
      for (int j = 0; j <= k; j++) {
        int p = s - i - j;
        if (p <= k && p >= 0)
          ans++;
      }
    }
    cout << ans << "\n";
  }
  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;
using ll = long long;
using P = pair<int, int>;
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 <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int K, S;
void func() {
  cin >> K >> S;
  int ans(0);
  rep(i, 0, K + 1) {
    rep(j, 0, K + 1) {
      rep(k, 0, K + 1) {
        if (i + j + k == S)
          ++ans;
      }
    }
  }
  cout << ans << endl;
}
int main() { func(); }

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int K, S;
void func() {
  cin >> K >> S;
  int ans(0);
  rep(i, 0, K + 1) {
    rep(j, 0, K + 1) {
      if (S - i - j >= 0 && S - i - j <= K)
        ++ans;
    }
  }
  cout << ans << endl;
}
int main() { func(); }
Problem p03835 (C++)

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

using namespace std;

#define int long long

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


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

using namespace std;

#define int long long

signed 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) <= K && S - (i + j) >= 0)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, S;
  cin >> K >> S;
  int X, Y, Z;
  int 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++;
        }
      }
    }
  }
  cout << count;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, S;
  cin >> K >> S;
  int X, Y, Z;
  int count = 0;
  for (X = 0; X <= K; X++) {
    for (Y = 0; Y <= K; Y++) {
      if (S - X - Y >= 0 && S - X - Y <= K) {
        count++;
      }
    }
  }
  cout << count;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):

// C++ program for implementation of Ford Fulkerson algorithm
#include <iostream>
#include <iterator>
#include <limits.h>
#include <queue>
#include <set>
#include <string.h>

using namespace std;
int count = 0;
int jum, s;
int totalsum = 3;

void dfs(int lvl, int k, int tot, int num) {
  if (lvl > 3 || num > tot)
    return;
  else if (tot == num) {
    count++;
  } else {
    for (int i = 0; i <= jum; i++) {
      dfs(lvl + 1, i, tot, num + i);
    }
  }
}

int main() {
  cin >> jum >> s;
  dfs(0, -1, s, 0);
  cout << count;
}

Fixed submission:

// C++ program for implementation of Ford Fulkerson algorithm
#include <iostream>
#include <iterator>
#include <limits.h>
#include <queue>
#include <set>
#include <string.h>

using namespace std;
int count = 0;
int jum, s;
int totalsum = 3;

void dfs(int lvl, int k, int tot, int num) {
  if (lvl > 3 || num > tot)
    return;
  else if (lvl == 2) {
    int sisa = tot - num;
    if (sisa >= 0 && sisa <= jum) {
      count++;
    }
  } else {
    for (int i = 0; i <= jum; i++) {
      dfs(lvl + 1, i, tot, num + i);
    }
  }
}

int main() {
  cin >> jum >> s;
  dfs(0, -1, s, 0);
  cout << count;
}
Problem p03835 (C++)

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

int main() {
  int x, y, z, k, s;

  while (scanf("%d %d", &k, &s) != EOF) {
    int cnt = 0;

    for (x = 0; x <= k; x++) {
      for (y = 0; y <= k; y++) {
        for (z = 0; z <= k; z++) {
          if (x + y + z == s)
            cnt++;
        }
      }
    }
    printf("%d\n", cnt);
  }

  return 0;
}


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

int main() {
  int x, y, z, k, s;

  while (scanf("%d %d", &k, &s) != EOF) {
    int cnt = 0;

    for (x = 0; x <= k; x++) {
      for (y = 0; y <= k; y++) {
        z = s - (x + y);

        if (z >= 0 && z <= k) {
          cnt++;
        }
      }
    }
    printf("%d\n", cnt);
  }

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):

// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>

#define MOD 1000000007

using namespace std;

int main(int argc, char *argv[]) {

  long long X, Y, Z, K, S;
  long long ans = 0;

  cin >> K;
  cin >> S;

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

  cout << ans << endl;

  return 0;
}


Fixed submission:

// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>

#define MOD 1000000007

using namespace std;

int main(int argc, char *argv[]) {

  long long X, Y, Z, K, S;
  long long ans = 0;

  cin >> K;
  cin >> S;

  for (X = 0; X <= K; X++) {
    for (Y = 0; Y <= K; Y++) {
      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 <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int k, s;
  cin >> k >> s;
  int count = 0;
  for (int a = 0; a <= s; a++) {
    for (int b = 0; b <= s; b++) {
      for (int c = 0; c <= s - a - b; c++) {
        if (a + b + c == s && a <= k && b <= k && c <= k)
          count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int k, s;
  cin >> k >> s;
  int count = 0;
  for (int a = 0; a <= k; a++) {
    for (int b = 0; b <= k; b++) {
      if (s - a - b >= 0 && s - a - b <= k) {
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string.h>
using namespace std;
int main() {
  int k, s;
  int x, y, z;
  int cnt = 0;

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

Fixed submission:
#include <iostream>
#include <string.h>
using namespace std;
int main() {
  int k, s;
  int x, y, z;
  int cnt = 0;

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

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

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

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

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

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

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18

priority_queue<int, vector<int>, greater<int>> que;

llint k, s;

void solve() {
  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;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18

priority_queue<int, vector<int>, greater<int>> que;

llint k, s;

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

int main(int argc, char *argv[]) {
  solve();
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <stack>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define out(s) cout << s << endl

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


Fixed submission:
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <stack>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define out(s) cout << s << endl

int main() {
  int s, k;
  cin >> k >> s;
  int cnt = 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)
        cnt++;
    }
  }
  out(cnt);
  return 0;
}
Problem p03835 (C++)

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

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

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

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

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

using namespace std;

ifstream fin("../data.txt");

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

int main() {

  cin >> k >> s;

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


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

using namespace std;

ifstream fin("../data.txt");

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

int main() {

  cin >> k >> s;

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <numeric>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define repd(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char *argv[]) {
  int k, s;
  cin >> k >> s;
  long 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 <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <numeric>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define repd(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char *argv[]) {
  int k, s;
  cin >> k >> s;
  long ans = 0;
  rep(i, k + 1) {
    rep(j, k + 1) {
      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;

#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(), a.end()

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

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

#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(), a.end()

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

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

Fixed submission:
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int k, s;
  cin >> k >> s;
  int x, y, z;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    x = i;
    for (int j = 0; j <= k; j++) {
      y = j;
      z = s - x - y;
      if (z >= 0 && z <= k)
        ans++;
      /*for(int l=0; l<=k;l++) {
          z=l;
          if (x+y+z==s) 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;
  int res = 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)
          ++res;
      }
    }
  }
  cout << res << endl;
  return 0;
}

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

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