prithivMLmods/Coder-Stat huggingface dataset:
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 int match = 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)
          match++;
      }
    }
  }
  cout << match << endl;
}

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

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

typedef long long ll;

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

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>
using namespace std;
int main(void) {
  int max, sum, count = 0;
  cin >> max >> sum;
  for (int i = 0; i <= max; i++) {
    for (int j = 0; j <= max; j++) {
      for (int k = 0; k <= max; k++) {
        if (i + j + k == sum) {
          count++;
          break;
        }
      }
    }
  }

  std::cout << count << std::endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;
int main(void) {
  int max, sum, count = 0;
  cin >> max >> sum;
  for (int i = 0; i <= max; i++) {
    for (int j = 0; j <= max; j++) {
      if (sum - i - j <= max && 0 <= sum - i - j)
        count++;
    }
  }

  std::cout << count << std::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 res = 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)
          ++res;
      }
    }
  }
  cout << res << endl;
  return 0;
}


Fixed submission:
#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 (Z >= 0 && Z <= K) {
        ++res;
      }
    }
  }
  cout << res << endl;
  return 0;
}
Problem p03835 (C++)

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

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

  cin >> k >> s;

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

  cout << ans << endl;
}

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

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

  cin >> k >> s;

  for (int a = 0; a <= k; a++) {
    for (int b = 0; b <= k; b++) {
      int c = s - a - b;
      if (c >= 0 && c <= k) {
        ans++;
      }
    }
  }

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

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

using namespace std;

int main(int argc, char *argv[]) {
  int K, S, ans = 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)
          ans++;
      }
    }
  }

  printf("%d\n", ans);
}


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

using namespace std;

int main(int argc, char *argv[]) {
  int K, S, ans = 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))
        ans++;
    }
  }

  printf("%d\n", ans);
}
Problem p03835 (C++)

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

int main() {
  int K, S;
  cin >> K >> S;
  int count = 0;
  // 0 < x,y,z < 2を満たす
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      for (int d = 0; d <= K; d++) {
        int sum = i + j + d;
        if (sum == S) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

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

int main() {
  int K, S;
  cin >> K >> S;
  int count = 0;
  // 0 < x,y,z < 2を満たす
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      int d = S - i - j; // dの値
      if (d >= 0 && d <= K) {
        count++;
      }
    }
  }
  cout << count << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):

#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i, a, b) for (ll i = (a), __last_##i = (b); i < __last_##i; i++)
#define RFOR(i, a, b) for (ll i = (b)-1, __last_##i = (a); i >= __last_##i; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, v.size()) {
    if (i)
      os << " ";
    os << v[i];
  }
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<vector<T>> &v) {
  REP(i, v.size()) {
    if (i)
      os << endl;
    os << v[i];
  }
  return os;
}

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

  cin >> k >> s;

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

  cout << ans << endl;
}

Fixed submission:

#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i, a, b) for (ll i = (a), __last_##i = (b); i < __last_##i; i++)
#define RFOR(i, a, b) for (ll i = (b)-1, __last_##i = (a); i >= __last_##i; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, v.size()) {
    if (i)
      os << " ";
    os << v[i];
  }
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<vector<T>> &v) {
  REP(i, v.size()) {
    if (i)
      os << endl;
    os << v[i];
  }
  return os;
}

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

  cin >> k >> s;

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

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

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


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, s;
  cin >> k >> s;
  int df = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k && x + y <= s; y++) {
      if (x + y + k >= s) {
        df++;
      }
    }
  }
  cout << df << 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 (X + Y + Z == 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 X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      if (S - X - Y <= K && S - X - Y >= 0) {
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}
Problem p03835 (C++)

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

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

  cout << count << endl;
}


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

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

  cin >> K >> S;

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

  cout << count << 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;
  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++;
        } else if (i + j + l > s) {
          continue;
        }
      }
    }
  }
  cout << count << endl;
}


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;
}
Problem p03835 (C++)

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

int main() {

  int s, k;
  cin >> k >> s;

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

  cout << cnt << endl;

  return 0;
}

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

int main() {

  int s, k;
  cin >> k >> s;

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

  cout << cnt << endl;

  return 0;
}
Problem p03835 (C++)

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

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

int main() {

  int k, s;
  cin >> k >> s;
  int cnt = 0;

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

  cout << cnt << endl;

  return 0;
};


Fixed submission:
#include <iostream>

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

int main() {

  int k, s;
  cin >> k >> s;
  int cnt = 0;

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

  cout << cnt << endl;

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

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

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

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

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

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

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

  int count = 0;
  rep(i, K + 1) {
    rep(j, K + 1) {
      rep(l, K + 1) {
        if (i + j + l == S) {
          count++;
        }
      }
    }
  }
  cout << count;
}


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

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

  int count = 0;
  rep(i, K + 1) {
    rep(j, K + 1) {
      if ((S - i - j) >= 0 && (S - i - j) <= K)
        count++;
    }
  }
  cout << count;
}
Problem p03835 (C++)

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

int main() {
  long long k, s;
  long long count = 0;
  bool flag = false;

  cin >> k >> s;

  for (int i = 0; i < k + 1; i++) {
    for (int j = 0; j < k + 1; j++) {
      for (int l = 0; l < k + 1; l++) {
        if ((i + j + l) == s && !flag) {
          if (i == j && j == l && j == i)
            flag = true;
          count++;
          //					cout << i << " "<< j << " " << l << " " << count
          //<<endl;
        }
      }
    }
  }

  cout << count << endl;
}

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

int main() {
  long long k, s;
  long long count = 0;
  bool flag = false;

  cin >> k >> s;

  for (int i = 0; i < k + 1; i++) {
    for (int j = 0; j < k + 1; j++) {
      long long l = s - (i + j);
      if (0 <= l && l <= 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 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;
  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 + 1; i++) {
    for (int j = 0; j < K + 1; j++) {
      if (s - (i + j) <= K && s >= i + j)
        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;
using P = pair<int, int>;

vector<int> to[100005];
const int INF = 1001001001;

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  k++;
  rep(i, k) {
    rep(j, k) {
      rep(l, k) {
        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)
using namespace std;

using ll = long long;
using P = pair<int, int>;

vector<int> to[100005];
const int INF = 1001001001;

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define INF (1 << 30)
#define INFLL (1ll << 60)
#define EPS (1e-10)
using namespace std;
map<int, int> mp;
typedef pair<int, int> P;
typedef long long ll;
static const int MAX = 100000;
static const int NMAX = 100;
int cunt;
int main() {
  int K, S;
  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)
          cunt++;
      }
    }
  }
  cout << cunt << "\n";
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define INF (1 << 30)
#define INFLL (1ll << 60)
#define EPS (1e-10)
using namespace std;
map<int, int> mp;
typedef pair<int, int> P;
typedef long long ll;
static const int MAX = 100000;
static const int NMAX = 100;
int cunt;
int main() {
  int K, S;
  cin >> K >> S;

  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      if ((x + y) <= S && (x + y) >= S - K)
        cunt++;
    }
  }
  cout << cunt << "\n";
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for (ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
const int MOD = 1000000007;

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

Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for (ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
const int MOD = 1000000007;

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

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>
int main() {
  int K, S;
  int br = 0;
  scanf("%d%d", &K, &S);

  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      for (int z = 0; z <= K; z++) {
        if (z == S - x - y) {
          br++;
        }
      }
    }
  }
  printf("%d", br);
  return 0;
}


Fixed submission:
#include <stdio.h>
int main() {
  int K, S;
  int br = 0;
  scanf("%d%d", &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) {
        br++;
      }
    }
  }
  printf("%d", br);
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
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++;
          break;
        }
      }
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
int main() {
  int K, S, ans = 0;
  cin >> K >> S;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      if (i + j <= S && 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, sum = 0;
  cin >> K >> S;
  for (int i = 0; i < K + 1; i++) {
    for (int j = 0; j < K + 1; j++) {
      for (int t = 0; t < K + 1; t++) {
        if (i + j + t == S) {
          sum++;
        }
      }
    }
  }
  cout << sum << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, S, sum = 0;
  cin >> K >> S;
  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 + 1) {
        sum++;
      }
    }
  }
  cout << sum << endl;
}
Problem p03835 (C++)

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

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

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

int main() {
  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 z = s - x - y;
      if (0 <= z && z <= k) {
        ++count;
      }
    }
  }
  std::cout << count << std::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 x, y, z;
  int count = 0;
  cin >> k >> s;
  for (x = 0; x < k + 1; x++) {
    for (y = 0; y < k + 1; y++) {
      for (z = 0; z < k + 1; z++) {
        if (x + y + z == s) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

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

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

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

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

using namespace std;

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

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

  cout << total_ways << endl;
  return 0;
}

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

using namespace std;

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

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

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

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

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

Fixed submission:
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int main() {
  int k, s;
  int x, y, z;
  int c = 0;
  scanf("%d %d", &k, &s);
  for (x = 0; x <= k; ++x)
    for (y = 0; y <= k; ++y)
      if (s - x - y >= 0 && s - x - y <= k)
        c++;
  printf("%d\n", c);
}
Problem p03835 (C++)

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

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

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

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cctype>
#include <cmath>
#include <ctype.h>
#include <iostream>
#include <map>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define REP1(j, n) for (int j = 0; j < (int)n; ++j)
#define REPD(i, n) for (int i = n; i >= 0; --i)
#define REPD1(j, n) for (int j = n; j = > 0; --j)
#define REPS(i, n) for (int i = 1; i <= (int)n; ++i)
#define REPS1(j, n) for (int j = 1; j <= (int)n; ++j)
#define rep(i, a, n) for (int i = a; i <= (int)n; ++i)
#define SZ(x) ((int)(x).size()) // size() unsigned -> int
#define DescSort(a) sort(a.begin(), a.end(), std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
  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 z = 0; z <= k; ++z) {
        if (s == i + j + z)
          cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cctype>
#include <cmath>
#include <ctype.h>
#include <iostream>
#include <map>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define REP1(j, n) for (int j = 0; j < (int)n; ++j)
#define REPD(i, n) for (int i = n; i >= 0; --i)
#define REPD1(j, n) for (int j = n; j = > 0; --j)
#define REPS(i, n) for (int i = 1; i <= (int)n; ++i)
#define REPS1(j, n) for (int j = 1; j <= (int)n; ++j)
#define rep(i, a, n) for (int i = a; i <= (int)n; ++i)
#define SZ(x) ((int)(x).size()) // size() unsigned -> int
#define DescSort(a) sort(a.begin(), a.end(), std::greater<int>())

using namespace std;
typedef long long ll;

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
// deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
// #include<bits/stdc++.h>
#define ll long long
using namespace std;

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


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
// deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
// #include<bits/stdc++.h>
#define ll long long
using namespace std;

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

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

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

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

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

  int ans = 0;
  rep(x, k) {
    rep(y, k) {
      rep(z, k) {
        int xyz = x + y + z;
        if (xyz == s) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;
}

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

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

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

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

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

typedef long long ll;
using namespace std;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;

const double EPS = 1e-8;

int main() {
  long K, S;
  long 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 <algorithm>
#include <cstdio>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;

const double EPS = 1e-8;

int main() {
  long K, S;
  long 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 (z >= 0 && z <= K)
        ans++;
    }
  }

  cout << ans;

  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) < (N); ++(i))
#define SORT(i) sort((i).begin(), (i).end())
constexpr ll INF = 2000000000;
constexpr ll mod = 1000000007;

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

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, N) for (int(i) = 0; (i) < (N); ++(i))
#define SORT(i) sort((i).begin(), (i).end())
constexpr ll INF = 2000000000;
constexpr ll mod = 1000000007;

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 (0 <= z && z <= k)
        ++ans;
    }
  }
  cout << ans << "\n";

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

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  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 z = 0; z <= k; z++)
        if (i + j + z == s)
          ans++;

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  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;

  return 0;
}
Problem p03835 (C++)

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

int main() {
  int s, k;
  cin >> k >> s;
  int h = 2500;
  int ans = 0;
  for (int i = 2; i <= h; i++)
    for (int j = 2; j <= h; j++)
      for (int l = 2; l <= h; l++)
        if (i + j + l == s)
          ans++;

  cout << ans << "\n";
  return 0;
}

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

int main() {
  int s, k;
  cin >> k >> s;
  int h = 2500;
  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 << "\n";
  return 0;
}
Problem p03835 (C++)

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

typedef long long ll;

int main(int argc, char *argv[]) {
  ll K, S;
  std::cin >> K >> S;

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

  std::cout << ans << std::endl;
  return 0;
}


Fixed submission:
#include <iostream>

typedef long long ll;

int main(int argc, char *argv[]) {
  ll K, S;
  std::cin >> K >> S;

  ll ans = 0;
  for (ll x = 0; x <= K; x++) {
    for (ll y = 0; y <= K; y++) {
      if (S - x - y <= K && S - x - y >= 0) {
        ans++;
      }
    }
  }

  std::cout << ans << std::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 count = 0;
  rep(x, K) {
    rep(y, K) {
      rep(z, K) {
        if (x + y + z == S) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

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 count = 0;
  rep(x, K) {
    rep(y, K) {
      if (S - x - y <= K && S - x - y >= 0) {
        count++;
      }
    }
  }
  cout << count << endl;
}
Problem p03835 (C++)

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

using namespace std;

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

  cin >> k >> s;
  for (int x = 0; x < k + 1; x++) {
    for (int y = 0; y < k + 1; y++) {
      for (int z = 0; z < k + 1; z++) {
        if (x + y + z == s) {
          count++;
        }
      }
    }
  }
  printf("%d\n", count);
  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 + 1; x++) {
    for (int y = 0; y < k + 1; y++) {
      if (k >= (s - (x + y)) && (s - (x + y)) >= 0) {
        count++;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}
Problem p03835 (C++)

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

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T> T gcd(T a, T b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

template <typename T> T lcm(T a, T b) {
  T g = gcd(a, b);
  return a / g * b;
}

bool check(vector<int> a, int index, int key) {
  if (a[index] >= key)
    return true;
  else
    return false;
}

int lower_bound(vector<int> a, int key) {
  int left = -1, right = a.size();
  while (right - left > 1) {
    int mid = left + (left + right) / 2;
    if (check(a, mid, key))
      right = mid;
    else
      left = mid;
  }
  return right;
}

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 <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T> T gcd(T a, T b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

template <typename T> T lcm(T a, T b) {
  T g = gcd(a, b);
  return a / g * b;
}

bool check(vector<int> a, int index, int key) {
  if (a[index] >= key)
    return true;
  else
    return false;
}

int lower_bound(vector<int> a, int key) {
  int left = -1, right = a.size();
  while (right - left > 1) {
    int mid = left + (left + right) / 2;
    if (check(a, mid, key))
      right = mid;
    else
      left = mid;
  }
  return right;
}

int main() {

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

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

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, a, op1, n, op2) for (int i = a; i op1(int)(n); op2##op2 i)
#define cout(val) cout << (val) << endl

using namespace std;

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


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, a, op1, n, op2) for (int i = a; i op1(int)(n); op2##op2 i)
#define cout(val) cout << (val) << endl

using namespace std;

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

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

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
typedef pair<int, int> P;

const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9 + 7;

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

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

  cout << endl;
  return 0;
}


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

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
typedef pair<int, int> P;

const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9 + 7;

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

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

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

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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y)-1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

int main() {
  int K, S;
  scanf("%d%d", &K, &S);

  int num{0};
  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 k{0}; k <= K; ++k) {
        if (i + j + k > S)
          break;
        if (i + j + k == S)
          ++num;
      }
    }
  }

  printf("%d\n", num);
  return 0;
}


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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y)-1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

int main() {
  int K, S;
  scanf("%d%d", &K, &S);

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

  printf("%d\n", num);
  return 0;
}
Problem p03835 (C++)

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

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


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

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
#define vec vector<int>
#define vecst vector<string>
#define vecch vector<char>
#define vecf vector<float>
#define vecvec vector<vector<int>>
#define vecHvec vector<vector<char>>
using ll = int long long;
const int INF = 1e9;
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

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


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
#define vec vector<int>
#define vecst vector<string>
#define vecch vector<char>
#define vecf vector<float>
#define vecvec vector<vector<int>>
#define vecHvec vector<vector<char>>
using ll = int long long;
const int INF = 1e9;
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

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

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

int main() {
  int64_t K, S, ans;
  cin >> K >> S;
  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 = ans + 1;
        }
      }
    }
  }
  cout << ans << endl;
}

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

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

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

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

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

void solve(long long K, long long 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 (S == i + j + k)
          ans++;
      }
    }
  }
  cout << ans << endl;
}

int main() {
  long long K;
  scanf("%lld", &K);
  long long S;
  scanf("%lld", &S);
  solve(K, S);
  return 0;
}


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

void solve(long long K, long long S) {
  int ans = 0;
  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;
}

int main() {
  long long K;
  scanf("%lld", &K);
  long long S;
  scanf("%lld", &S);
  solve(K, S);
  return 0;
}
Problem p03835 (C++)

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

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


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

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

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

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

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

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