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

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

using namespace std;

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

  int count = 0;
  for (int p = 0; p <= k; p++) {
    for (int q = 0; q <= k; q++) {
      for (int r = 0; r <= k; r++) {
        if (p + q + r == 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 p = 0; p <= k; p++) {
    for (int q = 0; q <= k; q++) {
      if (s - p - q <= k && s - p - q >= 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, cnt = 0;
  cin >> k >> s;
  for (int i = 0; i <= k; ++i) {
    for (int j = 0; j <= k; ++j) {
      for (int x = 0; x <= k; ++x) {
        if (i + j + x == s)
          cnt++;
      }
    }
  }
  cout << cnt;
  return 0;
}


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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; // 1e18
const double EPS = 1e-10;            //

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

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

Fixed submission:
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; // 1e18
const double EPS = 1e-10;            //

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

  int X, Y, Z;
  int ans = 0;
  for (X = 0; X <= K; X++) {
    for (Y = 0; Y <= K; Y++) {
      Z = S - X - Y;
      if (Z >= 0 && Z <= K && X + Y + Z == S) {
        // printf("%d %d %d\n", X, Y, Z);
        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, z;
  cin >> k >> s;
  int count = 0;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; k++) {
      z = s - i - j;
      if (z <= k && z >= 0)
        count++;
    }
  }
  cout << count << endl;

  return 0;
}


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

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

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<pint> vpint;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)
#define each(it, v)                                                            \
  for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a) < (b)) ? (b) : (a))
#define chmin(a, b) a = (((a) > (b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<pint> vpint;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)
#define each(it, v)                                                            \
  for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a) < (b)) ? (b) : (a))
#define chmin(a, b) a = (((a) > (b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(void) {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  /*
  TLE
  rep(i, k + 1)rep(j, k + 1)rep(l, k + 1){
          if(i + j + l == s) cnt++;
  }
  */
  rep(i, k + 1) rep(j, k + 1) {
    // i + j = s - z
    if (i + j <= s && s - i - j <= k)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}
Problem p03835 (C++)

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

int main() {
  int K, S;
  cin >> K >> S;
  int res = 0;
  rep(x, K) {
    rep(y, K) {
      rep(z, K) {
        if (x + y + z == S)
          res++;
      }
    }
  }
  cout << res << 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 res = 0;
  rep(x, K) {
    rep(y, K) {
      int z = S - (x + y);
      if (z <= K && z >= 0)
        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 < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

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

Buggy submission (status: Time Limit Exceeded):
/*
      author  : nishi5451
      created : 12.08.2020 22:05:46
*/

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

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

Fixed submission:
/*
      author  : nishi5451
      created : 12.08.2020 22:05:46
*/

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

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

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

int main() {
  // srandom((unsigned long)time(NULL));

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

  int cnt = 0;

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

  cout << cnt << endl;

  return 0;
}

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

int main() {
  // srandom((unsigned long)time(NULL));

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

  int cnt = 0;

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

  cout << cnt << endl;

  return 0;
}
Problem p03835 (C++)

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

using namespace std;
typedef long long ll;

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


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

using namespace std;
typedef long long ll;

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>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
int main() {
  int k, s;
  cin >> k >> s;
  ll ans = 0;
  for (int i = 0; i <= k && i <= s; i++) {
    for (int j = 0; j + i <= s && j <= k; j++) {
      for (int l = 0; i + j + l <= s && l <= k; l++) {
        if (i + j + l == s)
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
int main() {
  int k, s;
  cin >> k >> s;
  ll ans = 0;
  for (int i = 0; i <= k && i <= s; i++) {
    for (int j = 0; j + i <= s && 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;

/* {{{ */
#define PI(N) ((M_PI * (N)) / 180) // 角度をラジアンに変換する
#define CL(N) (cout << (N) << endl)
#define DCT(N) (cout << "debug " << (N) << endl)
#define REP(i, N) for (int i = 0; i < (N); i++)
/* }}} */

int main() {
  int k, s;

  cin >> k >> s;

  int c = 0;
  for (int i = 0; i <= k; i++) {
    if (i == s)
      c++;
    else {
      for (int j = 0; j <= k; j++) {
        if (i + j == s)
          c++;
        else {
          for (int l = 0; l <= k; l++) {
            if (i + j + l == s)
              c++;
          }
        }
      }
    }
  }

  CL(c);

  return (0);
}


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

/* {{{ */
#define PI(N) ((M_PI * (N)) / 180) // 角度をラジアンに変換する
#define CL(N) (cout << (N) << endl)
#define DCT(N) (cout << "debug " << (N) << endl)
#define REP(i, N) for (int i = 0; i < (N); i++)
/* }}} */

int main() {
  int k, s;

  cin >> k >> s;

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

  CL(c);

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

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

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

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

  cout << counter << endl;
  return 0;
}

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

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

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

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

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


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

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

using namespace std;

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

Fixed submission:
#include <iostream>

using namespace std;

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

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pi;
typedef pair<pair<ll, ll>, ll> pii;
vector<ll> vec;
vector<vector<ll>> vec2;
ll MOD = 1000000007;

int main() {

  ll K, S;
  cin >> K >> S;

  ll ans = 0;
  for (ll i = 0; i <= min(K, S); i++) {
    if (i > K) {
      break;
    }
    for (ll j = 0; j <= min(K, S); j++) {
      if (i + j > S) {
        break;
      }
      for (ll k = 0; k <= min(K, S); k++) {
        if (i + j + k == S) {
          ans++;
        }
        if (i + j + k >= S) {
          break;
        }
      }
    }
  }

  cout << ans << endl;
}

Fixed submission:
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pi;
typedef pair<pair<ll, ll>, ll> pii;
vector<ll> vec;
vector<vector<ll>> vec2;
ll MOD = 1000000007;

int main() {

  ll K, S;
  cin >> K >> S;

  ll ans = 0;
  for (ll i = 0; i <= min(K, S); i++) {
    if (i > K) {
      break;
    }
    for (ll j = 0; j <= min(K, S); j++) {
      if (i + j > S) {
        break;
      }
      if (S - (i + j) <= K) {
        ans++;
      }
    }
  }

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

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

using namespace std;
int abs(int x) {
  if (x < 0)
    return -x;
  else
    return x;
}
int main() {
  int k, s;
  cin >> k >> s;
  int cou = 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)
          cou++;
      }
    }
  }
  cout << cou << endl;
}

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

using namespace std;
int abs(int x) {
  if (x < 0)
    return -x;
  else
    return x;
}
int main() {
  int k, s;
  cin >> k >> s;
  int cou = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = s - x - y;
      if (z >= 0 and z <= k)
        cou++;
    }
  }
  cout << cou << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

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>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

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

  int count = 0;
  int j = S - 1;
  int k = S - 2;

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

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

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

  int count = 0;
  int j = S - 1;
  int k = S - 2;

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9 + 7)
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPS(i, n) for (int i = n; i > 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)(b); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0, sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI = acos(-1.0L);
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a, b) a = (((a) < (b)) ? (b) : (a))
#define chmin(a, b) a = (((a) > (b)) ? (b) : (a))

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed 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;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9 + 7)
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPS(i, n) for (int i = n; i > 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)(b); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0, sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI = acos(-1.0L);
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a, b) a = (((a) < (b)) ? (b) : (a))
#define chmin(a, b) a = (((a) > (b)) ? (b) : (a))

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  rep(a, k + 1) rep(b, k + 1) {
    if (s - a - b >= 0 && s - a - b <= k)
      ans++;
  }

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

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

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

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

  cout << num;

  return 0;
}

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

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

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

  cout << num;

  return 0;
}
Problem p03835 (C++)

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

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


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

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

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

using namespace std;

int main() {
  int k, s;
  cin >> k >> s;
  int result = 0;
  rep(i, k + 1) {
    rep(j, k + 1) {
      rep(h, k + 1) {
        if (i + j + h == s)
          result++;
      }
    }
  }

  cout << result;
  return 0;
}

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

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

using namespace std;

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

  cout << result;
  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 c = 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)
          c++;
      }
    }
  }
  cout << c << 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 c = 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)
        continue;
      c++;
    }
  }
  cout << c << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool bo[100];
#define ll long long
int main() {
  int k, s;
  cin >> k >> s;
  int c = 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) {
          c++;
        }
      }
    }
  }
  cout << c << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool bo[100];
#define ll long long
int main() {
  int k, s;
  cin >> k >> s;
  int c = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if ((s - (i + j)) <= k && (s - (i + j)) >= 0) {
        c++;
        // cout<<i<<" "<<j<<" "<<s-(i+j)<<endl;
      }
    }
  }
  cout << c << endl;
}
Problem p03835 (C++)

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

using namespace std;
int main() {
  int x, y, z;
  int k, s;
  int count{0};

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

Fixed submission:
#include <iostream>
#include <string>

using namespace std;
int main() {
  int x, y, z;
  int k, s;
  int count{0};

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

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

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

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

  cout << num << endl;
}

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

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

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

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

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

int main() {
  int K, S, X, Y, Z, answer;
  cin >> K >> S;

  for (X = K; X >= 0; X--) {
    if (S - X >= 0) {
      if (S - X <= K * 2) {
        for (Y = K; Y >= 0; Y--) {
          if (S - X - Y >= 0) {
            if (S - X - Y <= K) {
              for (Z = K; Z >= 0; Z--) {
                if (X + Y + Z == S) {
                  answer++;
                }
              }
            }
          }
        }
      }
    }
  }

  cout << answer;

  return 0;
}


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

int main() {
  int K, S, X, Y, Z, answer;
  cin >> K >> S;

  for (X = K; X >= 0; X--) {
    if (S - X >= 0) {
      if (S - X <= K * 2) {
        for (Y = K; Y >= 0; Y--) {
          if (S - X - Y >= 0) {
            if (S - X - Y <= K) {
              answer++;
            }
          }
        }
      }
    }
  }

  cout << answer;

  return 0;
}
Problem p03835 (C++)

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

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

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

  std::cout << counter << std::endl;
}

Fixed submission:
#include <cmath>
#include <iostream>

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

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

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define INF 1e9
typedef long long ll;
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 m = 0; m <= k; m++) {
        if ((i + j + m) == s) {
          count += 1;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define check(v)                                                               \
  rep(i, v.size()) cout << v[i] << " ";                                        \
  cout << endl
#define INF 1e9
typedef long long ll;
using namespace std;
// �I�[�o�[�t���[�ɋC������您����������
// �m�F�Y���Ȃ您����������

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

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define check(v)                                                               \
  rep(i, v.size()) cout << v[i] << " ";                                        \
  cout << endl
#define INF 1e9
typedef long long ll;
using namespace std;
// �I�[�o�[�t���[�ɋC������您����������
// �m�F�Y���Ȃ您����������

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

  return 0;
}
Problem p03835 (C++)

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

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


Fixed submission:
#include <iostream>

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

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"
// #include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define print(x) cout << x << endl;
typedef long long ll;

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

Fixed submission:
#include "bits/stdc++.h"
// #include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define print(x) cout << x << endl;
typedef long long ll;

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

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

using namespace std;

int main(void) {
  int k, s, ans;
  while (scanf("%d %d", &k, &s) != EOF) {
    ans = 0;
    for (int i = 0; i <= k; i++) {
      for (int j = 0; j <= k; j++) {
        for (int ii = 0; ii <= k; ii++) {
          if (i + j + ii == s)
            ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>

using namespace std;

int main(void) {
  int k, s, ans;
  while (scanf("%d %d", &k, &s) != EOF) {
    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;
#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) {
      rep(z, k + 1) {
        if (x + y + z == s)
          ans += 1;
      }
    }
  }
  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 += 1;
    }
  }
  cout << ans << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x, ll y) {
  if (y == 0)
    return x;
  else
    return GCD(y, x % y);
}

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


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x, ll y) {
  if (y == 0)
    return x;
  else
    return GCD(y, x % y);
}

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

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

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

  rep(i, k + 1) {
    rep(j, k + 1) {
      rep(h, k + 1) {
        if (i + j + h == s) {
          a++;
        }
      }
    }
  }
  cout << a << 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, x, y, z, a = 0;
  cin >> k >> s;

  rep(i, k + 1) {
    rep(j, k + 1) {

      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;
#define pi acos(-1)
#define IOS                                                                    \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie();                                                                   \
  cout.tie();
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define debug(val) cerr << "The Value Of " << #val << " is : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
ll k, s, ret = 0;

int main(void) {
  IOS cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int z = 0; z <= k; z++) {
        if (i + j + z == s)
          ret++;
      }
    }
  }
  cout << ret << '\n';
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS                                                                    \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie();                                                                   \
  cout.tie();
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define debug(val) cerr << "The Value Of " << #val << " is : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
ll k, s, ret = 0;

int main(void) {
  IOS cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      ll z = s - (i + j);
      if (z < 0 || z > k)
        continue;
      if (i + j + z == s) {
        ret++;
      }
    }
  }
  cout << ret << '\n';
}
Problem p03835 (C++)

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

int main() {

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

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

int main() {

  int k, s;
  cin >> k >> s;
  int x, y, z;
  int count = 0;
  rep(x, k + 1) {
    rep(y, k + 1) {
      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>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using LL = long long;
using P = pair<int, int>;

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;
  return 0;
}


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

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

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

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

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

using namespace std;

typedef long long ll;

int k, s;

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

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

  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

int k, s;

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

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

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

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

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

  long long ret = 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)
          ret++;

  cout << ret << endl;

  return 0;
}


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

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

  long long ret = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      int d = S - (i + j);

      if (d >= 0 && d <= K)
        ret++;
    }
  }

  cout << ret << 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 ct = 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) {
          ct++;
        }
      }
    }
  }
  cout << ct << endl;
}

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

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

  int ct = 0;
  for (int a = 0; a <= K; a++) {
    for (int b = 0; b <= K; b++) {
      int c = S - b - a;
      if (c <= K && 0 <= c) {
        ct++;
      }
    }
  }
  cout << ct << endl;
}
Problem p03835 (C++)

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

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++;
        }
      }
    }
  }
  OP(cnt);
  return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

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++) {
      if (0 <= s - i - j && s - i - j <= k) {
        cnt++;
      }
    }
  }
  OP(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 count = 0;
  for (int x = 0; x < k + 1; x++) {
    for (int y = 0; y < k + 1; y++) {
      for (int z = 0; z < k + 1; z++) {
        if (x + y + z == s) {
          count++;
        }
      }
    }
  }

  cout << count << endl;
}


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

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

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

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

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

int main(void) {
  int K, S;
  int X, Y, Z;
  int 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;
  return 0;
}

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

int main(void) {
  int K, S;
  int X, Y, Z;
  int cnt = 0;

  cin >> K >> S;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      Z = S - i - j;
      if (Z >= 0 && Z <= K)
        cnt++;
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
// sum 3 int
#include <bits/stdc++.h>
using namespace std;
long long n, m, k, s, tmp, sum = 0;
char r1, r2, op;
int main() {
  cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int l = 0; l <= k; l++) {
        if (i + j + l == s)
          sum++;
      }
    }
  }
  cout << sum << endl;
  return 0;
}

Fixed submission:
// sum 3 int
#include <bits/stdc++.h>
using namespace std;
long long n, m, k, s, tmp, sum = 0;
char r1, r2, op;
int main() {
  cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      long long tar = s - i - j;
      if (tar >= 0 && tar <= k)
        sum++;
    }
  }
  cout << sum << endl;
  return 0;
}
Problem p03835 (C++)

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

int main() {
  int k, s, c = 0;
  cin >> k >> s;
  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)
          continue;
        if (i + j + l == s)
          c++;
      }
    }
  }
  cout << c << "\n";
}

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

int main() {
  int k, s, c = 0;
  cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (i + j > s)
        continue;
      int d = s - i - j;
      if (d >= 0 && k >= d) {
        c++;
      }
    }
  }
  cout << c << "\n";
}