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

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

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

  cin >> K >> S;

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

  cout << ans << endl;
}


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

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

  cin >> K >> S;

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

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

int main() {
  int K = 0, S = 0, count = 0;
  cin >> K >> S;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      for (int z = 0; z <= K; z++) {
        if (x + y + z == S) {
          count++;
        }
      }
    }
  }

  cout << count << endl;
}

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

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

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

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

  int val;
  int counter = 0;
  for (int n = 0; n <= k; ++n) {
    for (int m = 0; m <= n; ++m) {
      for (int l = 0; l <= m; ++l) {
        val = n + m + l;

        if (s == val) {
          if (n != m && m != l && l != m) {
            counter += 6;
          } else if (n == m && m == l && l == m) {
            counter += 1;
          } else {
            counter += 3;
          }
        }
      }
    }
  }

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

  return 0;
}


Fixed submission:
#include <iostream>

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

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

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

  return 0;
}
Problem p03835 (C++)

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


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

Fixed submission:
#include <bits/stdc++.h>
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++) {
      if (S - i - j <= K && S - i - j >= 0)
        cnt++;
    }
  }
  cout << cnt << endl;
}
Problem p03835 (C++)

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

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

Fixed submission:
#include <stdio.h>

int main() {
  int k, s;
  int total = 0;
  scanf("%i %i", &k, &s);
  for (int x = 0; x <= k; x++) {
    if (x > s) {
      break;
    }
    for (int y = 0; y <= k; y++) {
      if ((x + y) > s) {
        break;
      }
      if ((0 <= (s - x - y)) and ((s - x - y) <= k)) {
        total++;
      }
    }
  }
  printf("%i\n", total);
  return 0;
}
Problem p03835 (C++)

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

int main() {
  // kは3変数の範囲、sは3変数の和
  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++) {
        int val = i + j + l;
        if (val == s)
          ans++;
      }
    }
  }

  cout << ans << endl;
}

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

int main() {
  // kは3変数の範囲、sは3変数の和
  int k, s;
  cin >> k >> s;

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

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

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

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

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

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

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

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

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


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

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

  for (int i = 0; i < K + 1; i++) {
    if (S - i <= 2 * K) {
      for (int j = 0; j < K + 1; j++) {
        if (S - i - j <= K && S - i - j >= 0) {
          ans++;
          // cout<<i<<" "<<j<<" "<<S-i-j<<endl;
        }
      }
    }
  }
  cout << ans << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int k, s, a, b, c, cnt = 0;
  cin >> k >> s;
  for (a = 0; a <= k; a++) {
    for (b = 0; b <= k; b++) {
      for (c = 0; c <= k; c++) {
        if (a + b + c == s)
          cnt++;
      }
    }
  }
  cout << cnt;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int k, s, a, b, c, cnt = 0;
  cin >> k >> s;
  for (a = 0; a <= k; a++) {
    for (b = 0; b <= k; b++) {
      if (s - a - b <= k && 0 <= s - a - b)
        cnt++;
    }
  }
  cout << cnt;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);

  int ans = 0;
  int k, s;
  cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    int sa = s - i;
    if ((sa / 2) > k)
      continue;
    for (int j = 0; j <= k; j++) {
      for (int h = 0; h <= k; h++) {
        if (j + h == sa)
          ans++;
      }
    }
  }

  cout << ans << endl;
}


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

  int ans = 0;
  int k, s;
  cin >> k >> s;
  for (int x = 0; x <= k; x++) {
    int sa = s - x;
    for (int y = 0; y <= k; y++) {
      int t = sa - y;
      if (t > k || t < 0)
        continue;
      // cout << x << " " << y << " " << t << endl;
      ans++;
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
void print() { cout << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) {
  cout << head;
  if (sizeof...(tail) != 0)
    cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T> void print(vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back())
      cout << " ";
  }
  cout << endl;
}
template <class T> void print(vector<vector<T>> &df) {
  for (auto &vec : df) {
    print(vec);
  }
}
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using ll = long long;
const int INF = 1001001001;

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
void print() { cout << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) {
  cout << head;
  if (sizeof...(tail) != 0)
    cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T> void print(vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back())
      cout << " ";
  }
  cout << endl;
}
template <class T> void print(vector<vector<T>> &df) {
  for (auto &vec : df) {
    print(vec);
  }
}
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using ll = long long;
const int INF = 1001001001;

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
void print() { cout << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) {
  cout << head;
  if (sizeof...(tail) != 0)
    cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T> void print(vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back())
      cout << " ";
  }
  cout << endl;
}
template <class T> void print(vector<vector<T>> &df) {
  for (auto &vec : df) {
    print(vec);
  }
}
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
using ll = long long;
const int INF = 1001001001;

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++;
          break;
        }
      }
    }
  }
  print(cnt);

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
void print() { cout << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) {
  cout << head;
  if (sizeof...(tail) != 0)
    cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T> void print(vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back())
      cout << " ";
  }
  cout << endl;
}
template <class T> void print(vector<vector<T>> &df) {
  for (auto &vec : df) {
    print(vec);
  }
}
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
using ll = long long;
const int INF = 1001001001;

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

  return 0;
}
Problem p03835 (C++)

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

using namespace std;

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

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

  cout << cnt << endl;
}

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

using namespace std;

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

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

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

Buggy submission (status: Time Limit Exceeded):

#include <bits/stdc++.h>
using namespace std;
#define N 1000000
#define REP(i, n) for (int i = 0; i < n; i++)
int x, y, z;
int k, s;
int main(void) {
  cin >> k >> s;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int l = 0; l <= k; l++) {
        if (i + j + l == s)
          ans++;
      }
    }
  }
  cout << ans << endl;
}


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define N 1000000
#define REP(i, n) for (int i = 0; i < n; i++)
int x, y, z;
int k, s;
int main(void) {
  cin >> k >> s;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      int t = s - i - j;
      if (0 <= t && t <= k)
        ans++;
    }
  }
  cout << ans << endl;
}
Problem p03835 (C++)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i, n) for (int i = 0; i < (int)n; ++i)

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;

template <typename T> void vprint(T &v) {
  REP(i, v.size()) { cout << v[i] << " "; }
  cout << endl;
}

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

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i, n) for (int i = 0; i < (int)n; ++i)

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;

template <typename T> void vprint(T &v) {
  REP(i, v.size()) { cout << v[i] << " "; }
  cout << endl;
}

int main() {
  ll K, S;
  cin >> K >> S;
  ll res = 0;
  REP(x, K + 1) REP(y, K + 1) {
    ll z = S - x - y;
    res += (z >= 0 && z <= K);
  }
  cout << res << endl;
  return 0;
}
Problem p03835 (C++)

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

int main() {
  int K, S;
  cin >> K >> S;
  int counter = 0;
  for (int A = 0; A <= K; A++) {
    for (int B = 0; B <= K; B++) {
      for (int C = 0; C <= K; C++) {
        if (A + B + C == S)
          counter++;
      }
    }
  }
  cout << counter << endl;
}

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

int main() {
  int K, S;
  cin >> K >> S;
  int counter = 0;
  for (int A = 0; A <= K; A++) {
    for (int B = 0; B <= K; B++) {
      if (S - A - B >= 0 && S - A - B <= K)
        counter++;
    }
  }
  cout << counter << endl;
}
Problem p03835 (C++)

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

using namespace std;

#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define vs vector<string>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(c) c.begin(), c.end()

const int INF = 1000000000;

int main() {
  int K, S;

  cin >> K >> S;

  int count = 0;

  rep(i, K + 1) {
    rep(j, K + 1) {
      rep(k, K + 1) {
        int sum = i + j + k;
        if (sum == S)
          count++;
      }
    }
  }

  cout << count << endl;
}


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

using namespace std;

#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define vs vector<string>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(c) c.begin(), c.end()

const int INF = 1000000000;

int main() {
  int K, S;

  cin >> K >> S;

  int count = 0;

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

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

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

using namespace std;

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

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>

using namespace std;

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

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

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

int main() {
  int K, S;

  cin >> K >> S;

  int ans = 0;
  rep(i, K + 1) {
    rep(j, K + 1) {
      rep(k, K + 1) {
        if (i + j + k == S) {
          ans += 1;
        }
      }
    }
  }
  cout << ans << endl;
}


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

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

int main() {
  int K, S;

  cin >> K >> S;

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

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
  int K, S;
  cin >> K >> S;
  int X = 0, Y = 0, Z = 0;
  int aw = 0;

  for (X = 0; X <= K; X++) {
    for (Y = 0; Y <= K; Y++) {
      if (X + Y > S) {
        break;
      }
      for (Z = 0; Z <= K; Z++) {
        if (X + Z > S || Y + Z > S) {
          break;
        }
        if (X + Y + Z == S) {
          aw++;
        }
      }
    }
  }
  cout << aw << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
  int K, S;
  cin >> K >> S;
  int X = 0, Y = 0, Z = 0;
  int aw = 0;

  for (X = 0; X <= K; X++) {
    for (Y = 0; Y <= K; Y++) {
      Z = S - X - Y;
      if (Z >= 0 && Z <= K) {
        aw++;
      }
    }
  }
  cout << aw << endl;
  return 0;
}
Problem p03835 (C++)

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int x = 0; x <= k; x++) {
    if (s == 3 * x)
      cnt++;
    for (int y = x + 1; y <= k; y++) {
      if (s == 2 * x + y or s == x + 2 * y)
        cnt += 3;
      for (int z = y + 1; z <= k; z++) {
        if (s == x + y + z)
          cnt += 6;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int x = 0; x <= k; x++) {
    if (s == 3 * x)
      cnt++;
    for (int y = x + 1; y <= k; y++) {
      if (s == 2 * x + y or s == x + 2 * y)
        cnt += 3;
      else if (s - x - y <= k && s - x - y > y)
        cnt += 6;
    }
  }
  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 count = 0;

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

  cout << count << endl;
}

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

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

  int count = 0;

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

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

int main() {
  int k, s;
  int cnt = 0;
  cin >> k >> s;
  for (int 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;
  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 cnt = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int l = 0; l <= k; l++) {
        if (s == i + j + l) {
          cnt++;
          break;
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

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

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

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

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

  int cnt = 0;
  for (int X = 0; X < K + 1; X++) {
    for (int Y = 0; Y < K + 1; Y++) {
      if (0 <= S - X - Y && S - X - Y <= K)
        cnt++;
    }
  }
  cout << cnt << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1E9 + 9;
const int INF = 1 << 29;

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

Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1E9 + 9;
const int INF = 1 << 29;

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for (int(i) = (n)-1; (i) >= 0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9 + 7;
ll const INF = 1e18;
using namespace std;

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  REP(a, k + 1) {
    REP(b, k + 1) {
      REP(c, k + 1) {
        if (a + b + c == s) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for (int(i) = (n)-1; (i) >= 0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9 + 7;
ll const INF = 1e18;
using namespace std;

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  REP(a, k + 1) {
    REP(b, k + 1) {
      int c = s - a - b;
      if (c >= 0 && c <= k) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03835 (C++)

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

using namespace std;

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

  for (int 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, ans = 0;
  cin >> K >> S;

  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {

      int z = S - x - y;

      if (0 <= z and z <= K) {
        ans = 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;
typedef unsigned long long ull;
int main() {
  int i, j, k, a, b, sum = 0;
  cin >> a >> b;
  for (i = 0; i <= a; i++) {
    for (j = 0; j <= a; j++) {
      for (k = 0; k <= a; k++) {
        if (i + j + k == b)
          sum++;
      }
    }
  }
  cout << sum;
  return 0;
}


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

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

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


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

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

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

int main() {
  int K, S, X, Y, Z, total, count = 0;

  cin >> K >> S;

  for (X = 0; X <= K; X++) {
    for (Y = 0; Y <= K; Y++) {
      for (Z = 0; X <= K; Z++) {
        total = X + Y + Z;
        if (total == S)
          count++;
      }
    }
  }

  cout << count << endl;
}

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

int main() {
  int K, S, X, Y, Z, total, count = 0;

  cin >> K >> S;

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

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

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

int main() {
  int 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++;
        }
        if (x + y + z > s) {
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  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++) {
      if (s - x - y >= 0 && s - x - y <= k) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int n, s;
  cin >> n >> s;
  long int cnt = 0;
  for (int i = 0; i <= n; i++) {
    int t1 = s - i;
    if (t1 > 2 * n || t1 < 0)
      continue;
    for (int j = 0; j <= n; j++) {
      int t2 = t1 - j;
      if (t2 > n || t2 < 0)
        continue;
      for (int k = 0; k <= n; k++) {
        if (i + j + k == s)
          cnt++;
      }
    }
  }
  cout << cnt;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int n, s;
  cin >> n >> s;
  long int cnt = 0;
  for (int i = 0; i <= n; i++) {
    int t1 = s - i;
    if (t1 > 2 * n || t1 < 0)
      continue;
    for (int j = 0; j <= n; j++) {
      int t2 = t1 - j;
      if (t2 > n || t2 < 0)
        continue;
      cnt++;
    }
  }
  cout << cnt;
}
Problem p03835 (C++)

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

using namespace std;

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

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

using namespace std;

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

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

using namespace std;

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

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

int main() {
  int K, S;

  cin >> K >> S;

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

  cout << ans << endl;

  return 0;
}


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

int main() {
  int K, S;

  cin >> K >> S;

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

  cout << ans << endl;

  return 0;
}
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
k, s = [int(i) for i in input().split()]
ans = 0
for x in range(k, -1, -1):
    for y in range(k, -1, -1):
        for z in range(k, -1, -1):
            if x + y + z is s:
                ans += 1
print(ans)


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

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

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

Fixed submission:
#include <iostream>
// #include <vector>
// #include <algorithm>
// #include <cmath>
// #include <math.h>
using namespace std;

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) && (0 <= S - i - j))
        c++;
    }
  }
  cout << c << endl;
}
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
k, s = map(int, input().split())

result = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                result += 1

                break

print(result)


Fixed submission:
k, s = map(int, input().split())

result = 0
for x in range(k + 1):
    for y in range(k + 1):
        z = s - x - y
        if 0 <= z <= k:
            result += 1

print(result)
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
K, S = list(map(int, input().rstrip().split()))

n = 0
for x in range(K + 1):
    for y in range(K + 1):
        if x + y > S:
            break

        for z in range(K + 1):
            if x + y + z > S:
                break

            if (x + y + z) == S:
                n += 1

print(n)


Fixed submission:
K, S = list(map(int, input().rstrip().split()))

n = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= z and z <= K:
            n += 1

print(n)
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
k, s = map(int, input().split())

ans = 0

for i in range(k + 1):
    for j in range(k + 1):
        for h in range(k + 1):
            if h + i + j == s:
                ans += 1

print(ans)


Fixed submission:
k, s = map(int, input().split())

ans = 0

for i in range(k + 1):
    for j in range(k + 1):
        z = s - i - j
        if 0 <= z <= k:
            ans += 1

print(ans)
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
K, S = map(int, input().split())
n = 0
for i in range(K + 1):
    for j in range(K + 1):
        if (i + j) > S:
            continue
        elif (S - i - j) > K:
            continue
        for k in range(K + 1):
            if (i + j + k) == S:
                n += 1
print(str(n))


Fixed submission:
K, S = map(int, input().split())
n = 0
for x in range(K + 1):
    for y in range(K + 1):
        if (x + y) > S:
            break
        elif (S - (x + y)) <= K:
            n += 1
print(str(n))
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
def solve():
    k, s = map(int, input().split())
    c = 0
    for x in range(k + 1):
        for y in range(k + 1):
            for z in range(k + 1):
                if x + y + z == s:
                    c += 1
    return c


if __name__ == "__main__":
    print(solve())


Fixed submission:
def solve():
    k, s = map(int, input().split())
    c = 0
    for x in range(k + 1):
        for y in range(k + 1):
            if 0 <= s - (x + y) <= k:
                c += 1
    return c


if __name__ == "__main__":
    print(solve())
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
K, S = map(int, input().split())
count = 0
for i in range(K + 1):
    for j in range(K + 1):
        for k in range(K + 1):
            if i + j + k == S:
                count = count + 1

print(count)


Fixed submission:
K, S = map(int, input().split())
count = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= z <= K:
            count = count + 1

print(count)
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
K, S = map(int, (input().split()))

ans = 0

for x in range(0, K + 1):
    for y in range(0, K + 1):
        for z in range(0, K + 1):
            if x + y + z == S:
                ans += 1

print(ans)


Fixed submission:
K, S = map(int, (input().split()))

ans = 0

for x in range(0, K + 1):
    for y in range(0, K + 1):
        z = S - x - y
        if z <= K and z >= 0:
            ans += 1

print(ans)
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
K, S = map(int, input().split())
count = 0
for i in range(S + 1):
    X = S - i
    for j in range(i + 1):
        Y = j
        Z = S - X - Y
        if K >= X >= 0 and K >= Y >= 0 and K >= Z >= 0:
            count += 1
print(count)


Fixed submission:
K, S = map(int, input().split())
count = 0
for i in range(K + 1):
    for j in range(K + 1):
        Z = S - i - j
        if K >= Z >= 0:
            count += 1
print(count)
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
k, s = map(int, input().split())

cnt = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if s == x + y + z:
                cnt += 1

print(cnt)


Fixed submission:
k, s = map(int, input().split())

cnt = 0
for x in range(k + 1):
    for y in range(k + 1):
        z = s - x - y
        if 0 <= z <= k:
            cnt += 1

print(cnt)
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
k, s = list(map(int, input().split()))

count = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                count += 1
                break

print(count)


Fixed submission:
k, s = list(map(int, input().split()))

count = 0
for x in range(k + 1):
    for y in range(k + 1):
        if x + y <= s <= x + y + k:
            count += 1

print(count)
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
k, s = map(int, input().split())

ans = 0
for x in range(0, k + 1):
    for y in range(0, k + 1):
        for z in range(0, k + 1):
            if x + y + z == s:
                ans += 1
print(ans)


Fixed submission:
k, s = map(int, input().split())

ans = 0
for x in range(0, k + 1):
    for y in range(0, k + 1):
        if 0 <= s - (x + y) <= k:
            ans += 1
print(ans)
Problem p03835 (Python)

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


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

Buggy submission (status: Time Limit Exceeded):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

K, S = map(int, input().split())

r = 0
for i in range(K + 1):
    for j in range(K + 1):
        for k in range(K + 1):
            if i + j + k == S:
                r += 1

print(r)


Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

K, S = map(int, input().split())

r = 0
for i in range(K + 1):
    for j in range(K + 1):
        k = S - i - j
        if k >= 0 and k <= K:
            r += 1

print(r)
Problem p03835 (Python)

Buggy submission (status: Runtime Error):
k, s = map(int, input().split(" "))
answer = 0

for i in range(k + 1):
    for j in range(k + 1):
        rem = 3 * k - i - j
        if 0 <= rem <= k:
            answer += 1
print(answer)


Fixed submission:
k, s = map(int, input().split(" "))
answer = 0

for i in range(k + 1):
    for j in range(k + 1):
        rem = s - i - j
        if 0 <= rem <= k:
            answer += 1
print(answer)
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
k, s = map(int, input().split())
count = 0

for i in range(k + 1):
    for j in range(k + 1):
        if s - i - j in range(k + 1):
            count += 1

print(count)


Fixed submission:
k, s = map(int, input().split())
count = 0

for i in range(k + 1):
    for j in range(k + 1):
        if 0 <= s - i - j <= k:
            count += 1

print(count)
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read

K, S = map(int, read().split())
count = 0

for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            if x + y + z == S:
                count += 1

print(count)


Fixed submission:
#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read

K, S = map(int, read().split())
count = 0

for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= z <= K:
            count += 1

print(count)
Problem p03835 (Python)

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

print(count)


Fixed submission:
k, s = map(int, input().split())
count = 0
for x in range(k + 1):
    for y in range(k + 1):
        if s - x - y <= k and s - x - y >= 0:
            # print(x, y)
            count += 1

print(count)
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
k, s = [int(x) for x in input().split()]
cnt = 0
for x in range(k + 1):
    if x > s:
        continue
    for y in range(x, k + 1):
        if y > s:
            break
        for z in range(y, k + 1):
            if z > s:
                break
            if x + y + z == s:
                if x == y == z:
                    cnt += 1
                elif x == y or y == z:
                    cnt += 3
                else:
                    cnt += 6
print(cnt)


Fixed submission:
k, s = [int(x) for x in input().split()]
cnt = 0
for x in range(k + 1):
    if x > s:
        continue
    for y in range(x, k + 1):
        if y > s:
            break
        z = s - x - y
        if y <= z and z <= k:
            if x + y + z == s:
                if x == y == z:
                    cnt += 1
                elif x == y or y == z:
                    cnt += 3
                else:
                    cnt += 6
print(cnt)
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
import sys

input = sys.stdin.readline


def ii():
    return int(input())


def il():
    return list(map(int, input().split()))


K, S = il()
c = 0
for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            if (x + y + z) == S:
                c += 1
print(c)


Fixed submission:
import sys

input = sys.stdin.readline


def ii():
    return int(input())


def il():
    return list(map(int, input().split()))


K, S = il()
c = 0
for x in range(K + 1):
    for y in range(K + 1):
        if 0 <= (S - (x + y)) <= K:
            c += 1
print(c)
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
k, s = map(int, input().split())
cnt = 0

for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                cnt += 1
print(cnt)


Fixed submission:
k, s = map(int, input().split())
cnt = 0

for i in range(k + 1):
    t = s - i
    if t >= 0:
        cnt += max(0, (t + 1) - 2 * (max(0, t - k)))
print(cnt)
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
k, s = map(int, input().split())

k += 1

ans = 0
for x in range(k):
    for y in range(k):
        for z in range(k):
            if x + y + z == s:
                ans += 1

print(ans)


Fixed submission:
k, s = map(int, input().split())

k += 1

ans = 0
for x in range(k):
    for y in range(k):
        if s - (x + y) >= 0 and s - (x + y) <= k - 1:
            ans += 1

print(ans)
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
typedef long long ll;
#define for_(i, a, b) for (ll i = a; i < ll(b); i++)
#define forr_(i, a, b) for (ll i = a; i >= ll(b); i--)
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repr(i, n) for (ll i = n - 1; i >= 0; i--)
using namespace std;

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


Fixed submission:
#include <iostream>
typedef long long ll;
#define for_(i, a, b) for (ll i = a; i < ll(b); i++)
#define forr_(i, a, b) for (ll i = a; i >= ll(b); i--)
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repr(i, n) for (ll i = n - 1; i >= 0; i--)
using namespace std;

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

Buggy submission (status: Time Limit Exceeded):
k, s = map(int, input().split())

ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                ans += 1
            if x + y + z > s:
                break

print(ans)


Fixed submission:
k, s = map(int, input().split())

ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        if 0 <= s - x - y <= k:
            ans += 1

print(ans)
Problem p03835 (Python)

Buggy submission (status: Time Limit Exceeded):
# -*- coding: utf-8 -*-

k, s = map(int, input().split())

cnt = 0

for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                cnt += 1

print(cnt)


Fixed submission:
# -*- coding: utf-8 -*-

k, s = map(int, input().split())

cnt = 0

for x in range(k + 1):
    for y in range(k + 1):
        z = s - x - y
        if 0 <= z <= k:
            cnt += 1

print(cnt)