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

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

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

  cout << ans << endl;

  return 0;
}


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

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, S;
  cin >> K >> S;

  int ans = 0;

  rep(i, K + 1) rep(j, K + 1) {
    int t = i + j;
    if (S - t >= 0 && S - t <= 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 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;
}


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

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

#define pb(s) push_back(s)
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PI 3.14159265358979323846264338327950L

typedef long long ll;

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

  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int i = 0; i <= k; ++i) {
    for (int j = 0; j <= k; ++j) {
      for (int x = 0; x <= k; ++x) {
        if (i + j + x == s)
          cnt++;
        else if (i + j + x > s)
          break;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


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

#define pb(s) push_back(s)
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PI 3.14159265358979323846264338327950L

typedef long long ll;

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

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

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

using namespace std;

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

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

  cout << c << endl;
}


Fixed submission:
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>

using namespace std;

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

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

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

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

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

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

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

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

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

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

  cout << count << endl;
}

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

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

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

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T> bool contain(const std::string &s, const T &v) {
  return s.find(v) != std::string::npos;
}

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


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T> bool contain(const std::string &s, const T &v) {
  return s.find(v) != std::string::npos;
}

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

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

Buggy submission (status: Time Limit Exceeded):
#define DBG 0 // submit 0
#define ll long long
#if DBG
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
#else
#include <bits/stdc++.h>
#endif

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

  // cout << (flag ? "Yes" : "No") << endl;
  cout << ans << endl;
  // printf("%.10f",ans_d);cout<<endl;
}


Fixed submission:
#define DBG 0 // submit 0
#define ll long long
#if DBG
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
#else
#include <bits/stdc++.h>
#endif

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 << (flag ? "Yes" : "No") << endl;
  cout << ans << endl;
  // printf("%.10f",ans_d);cout<<endl;
}
Problem p03835 (C++)

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

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 <algorithm>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <string>
#include <vector>

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 (z >= 0 && 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;
  cin >> k >> s;
  int icount = 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) {
          icount++;
        }
      }
    }
  }
  cout << icount << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int k, s;
  cin >> k >> s;
  int icount = 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)) {
        icount++;
      }
    }
  }
  cout << icount << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; i++) {
      if (0 <= S - i - j && S - i - j <= K)
        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 i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      if (0 <= S - i - j && S - i - j <= K)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03835 (C++)

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

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

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

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

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

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

  cout << count << endl;
}


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

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

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

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

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

int main() {
  int K, S;

  scanf("%d %d", &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; x++) {
        if (x + y + z == S) {
          ans = ans + 1;
        }
      }
    }
  }

  printf("%d", ans);
  return 0;
}

Fixed submission:
#include <cstdio>

int main() {
  int K, S;

  scanf("%d %d", &K, &S);
  int ans = 0;

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

  printf("%d", ans);
  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(i, K + 1) rep(j, K + 1) rep(k, K + 1) {
    if (i + j + k == S)
      ans++;
  }
  cout << ans << endl;
}

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

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

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

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

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

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

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

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

  cout << count << endl;
}


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

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

  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      int t = X + Y;
      if (t <= S && t + K >= S) {
        count++;
      }
    }
  }

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

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

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

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

int main() {
  int K, S, ans = 0;
  cin >> K >> S;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {

      if (S - i - j >= 0 && S - i - j <= 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;
  cin >> k >> s;
  int ans = 0;
  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <= k; ++y) {
      for (int z = 0; z <= k; ++z) {
        if (x + y + z == s)
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

Buggy submission (status: Time Limit Exceeded):
/*
 * Copyright (c) 2019 ... All rights reserved.
 * ...
 */
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <vector>

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

using namespace std;

int inputValue() {
  int a;
  cin >> a;
  return a;
};

void inputArray(int *p, int a){rep(i, a){cin >> p[i];
}
}
;

void inputVector(vector<int> *p, int a) {
  rep(i, a) {
    int input;
    cin >> input;
    p->push_back(input);
  }
}

template <typename T> void output(T a, int precision) {
  if (precision > 0) {
    cout << setprecision(precision) << a << "\n";
  } else {
    cout << a << "\n";
  }
}

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

  // source code
  int K = inputValue();
  int S = inputValue();

  int x, y, z;

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

  cout << counter << endl;

  return 0;
}

Fixed submission:
/*
 * Copyright (c) 2019 ... All rights reserved.
 * ...
 */
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <vector>

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

using namespace std;

int inputValue() {
  int a;
  cin >> a;
  return a;
};

void inputArray(int *p, int a){rep(i, a){cin >> p[i];
}
}
;

void inputVector(vector<int> *p, int a) {
  rep(i, a) {
    int input;
    cin >> input;
    p->push_back(input);
  }
}

template <typename T> void output(T a, int precision) {
  if (precision > 0) {
    cout << setprecision(precision) << a << "\n";
  } else {
    cout << a << "\n";
  }
}

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

  // source code
  int K = inputValue();
  int S = inputValue();

  int x, y, z;

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

  cout << counter << endl;

  return 0;
}
Problem p03835 (C++)

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

int main() {
  int k, s;
  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;

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;

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;

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;
int main() {
  int x, y, z, k, s, ans = 0;
  cin >> k >> s;
  for (x = 0; x <= k; x++) {
    for (y = 0; y <= k; y++) {
      for (z = 0; z <= k; z++) {
        if (x + y + z == s)
          ans++;
      }
    }
  }
  cout << ans;
  return 0;
}

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

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

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define DT long long
#define forn(i, n) for (i = 0; i < n; i++)
#define forc(i, c, n) for (i = c; i <= n; i++)
typedef vector<DT> vec;
typedef list<DT> li;

int main() {
  ifstream fin("Text.txt");
  int i, j, q;
  DT k, s, n, m, a, b, c, ans = 0;
  string st;
  cin >> k >> s;
  forn(i, k + 1) {
    forn(j, k + 1) {
      forn(q, k + 1) {
        if (i + j + q == s)
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define DT long long
#define forn(i, n) for (i = 0; i < n; i++)
#define forc(i, c, n) for (i = c; i <= n; i++)
typedef vector<DT> vec;
typedef list<DT> li;

int main() {
  ifstream fin("Text.txt");
  int i, j, q;
  DT k, s, n, m, a, b, c, ans = 0;
  string st;
  cin >> k >> s;
  forn(i, k + 1) {
    forn(j, k + 1) {
      if (i + j <= s && s - (i + j) <= k)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03835 (C++)

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

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

  int ans = 0;
  for (int 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) {
          ans++;
          break;
        }

        if (x + y + z > s)
          break;
      }
    }
  }

  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++) {
    if (x > s)
      break;

    for (int y = 0; y <= k; y++) {
      if (x + y > s)
        break;

      int z = s - x - y;
      if (z <= k)
        ans++;
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;

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++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;

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

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

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

  if (3 * K == S) {
    cout << 1 << endl;
    return 0;
  }
  if (3 * K < S) {
    cout << 0 << endl;
    return 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) {
          d++;
        }
      }
    }
  }
  cout << d << endl;
  return 0;
}

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

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

  if (3 * K == S) {
    cout << 1 << endl;
    return 0;
  }
  if (3 * K < S) {
    cout << 0 << endl;
    return 0;
  }

  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {

      if (S - (i + j) >= 0 && S - (i + j) <= K) {
        d++;
      }
    }
  }
  cout << d << 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++)
#define all(a) (a).begin(), (a).end()
#define INF (int)1e8
#define EPS 1e-9

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

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

  int res = 0;
  rep(i, K + 1) rep(j, K + 1) rep(k, K + 1) {
    if (i + j + k == 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++)
#define all(a) (a).begin(), (a).end()
#define INF (int)1e8
#define EPS 1e-9

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

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

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

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

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


Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(), (v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repr(i, a, b) for (int i = a; i > b; i--)
#define leng(n) (int)(log10(n) + 1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } //  最大公約数gcd
int lcm(int a, int b) { return a / gcd(a, b) * b; }     //  最小公倍数lcm

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

Fixed submission:
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(), (v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repr(i, a, b) for (int i = a; i > b; i--)
#define leng(n) (int)(log10(n) + 1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } //  最大公約数gcd
int lcm(int a, int b) { return a / gcd(a, b) * b; }     //  最小公倍数lcm

signed main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  rep(i, 0, k + 1) {
    rep(j, i, k + 1) {
      rep(l, j, k + 1) {
        if (i + l + j == s) {
          if (i == j && j == l)
            ans++;
          if (i == j && j != l)
            ans += 3;
          if (i != j && j == l)
            ans += 3;
          if (i != j && j != l)
            ans += 6;
        }
      }
    }
  }
  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;
  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 (S - i - j <= K && S - i - j >= 0) {
        count++;
      }
    }
  }
  cout << count << endl;
}
Problem p03835 (C++)

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


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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <type_traits>
#include <utility>
#include <vector>
#define INT_MAX 2147483647
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int max(int a, int b) {
  int max;
  if (a > b)
    max = a;
  else
    max = b;
  return max;
}
int min(int a, int b) {
  int min;
  if (a < b)
    min = a;
  else
    min = b;
  return min;
}

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

  cin >> k >> s;

  int count = 0;
  rep(i, k + 1) {
    rep(j, k + 1) {
      rep(d, k + 1) {
        int res = i + j + d;
        if (res == s) {
          ++count;
        }
      }
    }
  }
  cout << count << endl;
}

Fixed submission:
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <type_traits>
#include <utility>
#include <vector>
#define INT_MAX 2147483647
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int max(int a, int b) {
  int max;
  if (a > b)
    max = a;
  else
    max = b;
  return max;
}
int min(int a, int b) {
  int min;
  if (a < b)
    min = a;
  else
    min = b;
  return min;
}

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

  cin >> k >> s;

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
using namespace std;

int main(void) {
  int k, s, p, q;
  int count = 0;
  cin >> k >> s;
  p = s - k - k;
  if (p < 0) {
    p = 0;
  }
  FOR(i, p, k) {
    if (i + k + k < s) {
      continue;
    }
    if (i > s) {
      break;
    }
    FOR(t, p, k) {
      if (i + t + k < s) {
        continue;
      }
      if (i + t > s) {
        break;
      }
      FOR(u, p, k) {
        if (i + t + u == s) {
          count++;
          break;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
using namespace std;

int main(void) {
  int k, s, p, q;
  int count = 0;
  cin >> k >> s;
  p = s - k - k;
  if (p < 0) {
    p = 0;
  }
  FOR(i, p, k) {
    if (i + k + k < s) {
      continue;
    }
    if (i > s) {
      break;
    }
    FOR(t, p, k) {
      if (i + t + k < s) {
        continue;
      }
      if (i + t > s) {
        break;
      }
      if (s - i - t <= k) {
        count++;
        continue;
      }
    }
  }
  cout << count << endl;
  return 0;
}
Problem p03835 (C++)

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

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

  long long int ans = 0;

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


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

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

  long long int ans = 0;

  for (int x = 0; x < k + 1; x++) {
    if (x > s)
      continue;
    for (int y = 0; y < k + 1; y++) {
      if (x + y > s)
        continue;
      if (s - x - y > k)
        continue;
      ans += 1;
    }
  }
  cout << ans << endl;
}
Problem p03835 (C++)

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

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

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

int main() {
  int K, S;
  scanf("%d %d", &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 and z <= K) {
        cnt++;
      }
    }
  }
  printf("%d\n", cnt);
  return 0;
}
Problem p03835 (C++)

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

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

  cin >> K >> S;

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

  cout << cnt << endl;

  return 0;
}

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

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

  cin >> K >> S;

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

  cout << cnt << endl;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <string>
using namespace std;
int main() {
  int k, s;
  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++;
      }
    }
  }
  cout << counter << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <string>
using namespace std;
int main() {
  int k, s;
  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++;
      //}
      int z = s - x - y;
      if (0 <= z and z <= k)
        counter++;
    }
  }
  cout << counter << endl;
  return 0;
}
Problem p03835 (C++)

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

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

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

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

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

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

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

  cout << cnt << endl;
}


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

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

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

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

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

int main() {

  int K, S;
  cin >> K; // max of X,Y,Z
  cin >> S; // sum

  int ans;
  ans = 0;

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

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

int main() {

  int K, S;
  cin >> K; // max of X,Y,Z
  cin >> S; // sum

  int ans;
  ans = 0;

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

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

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

  int res = 0;

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

  cout << res << endl;

  return 0;
}

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

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

  int res = 0;

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

  cout << res << endl;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
  int i, k, s, j, p, t = 0;
  cin >> k;
  cin >> s;
  for (i = 0; i <= k; i++) {
    for (j = 0; j <= k; j++) {
      for (p = 0; p <= k; p++) {
        if (s == i + j + p) {
          t++;
          break;
        }
      }
    }
  }
  cout << t << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
  int i, k, s, j, p, t = 0;
  cin >> k;
  cin >> s;
  for (i = 0; i <= k; i++) {
    for (j = 0; j <= k; j++) {
      if (s - (i + j) <= k && s - (i + j) >= 0) {
        t++;
      }
    }
  }
  cout << t << endl;
  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 x, y, z;
  int cnt = 0;
  for (x = 0; x <= k; x++) {
    for (y = 0; y <= k && x + y <= s; y++) {
      for (z = 0; z <= k && x + y + z <= s; z++) {
        if (x + y + z == s)
          cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Fixed submission:
#include <iostream>
#include <string>
using namespace std;
int main() {
  int k, s;
  cin >> k >> s;
  int x, y, z;
  int cnt = 0;
  for (x = 0; x <= k; x++) {
    for (y = 0; y <= k && x + y <= s; y++) {
      if (x + y + k >= s)
        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 a, b, i, j, k, c = 0;
  cin >> a >> b;
  for (i = 0; i <= a; i++) {
    for (j = 0; j <= a; j++) {
      for (k = 0; k <= a; k++) {
        c += (i + j + k == b);
      }
    }
  }
  cout << c << endl;
}

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

int main() {
  int a, b, i, j, k, c = 0;
  cin >> a >> b;
  for (i = 0; i <= a; i++) {
    for (j = 0; j <= a; j++) {
      c += (0 <= b - i - j && b - i - j <= a);
    }
  }
  cout << c << 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 counter = 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++) {
        int res = x + y + z;
        if (res == S) {
          counter++;
        }
      }
    }
  }

  cout << counter << endl;
}

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

int main() {
  int K, S;

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

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

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int k, s;
  int count = 0;
  cin >> k >> s;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {

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

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int k, s;
  int count = 0;
  cin >> k >> s;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = s - x - y;
      if (z <= 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;

int main() {
  int K, S;
  cin >> K >> S;
  // Sの最大値は3K
  int x = 0;
  int y = 0;
  int z = 0;
  int count = 0;

  for (int i = 0; i <= K; i++) {
    x = i;
    for (int j = 0; j <= K; j++) {
      y = j;
      if (i + j > S)
        break;
      for (int k = 0; k <= K; k++) {
        z = k;
        if (i + j + k > S)
          break;
        else if (i + j + k == S) {
          count++;
          break;
        }
      }
    }
  }
  cout << count << endl;
}

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

int main() {
  int K, S;
  cin >> K >> S;
  // Sの最大値は3K
  int x = 0;
  int y = 0;
  int z = 0;
  int count = 0;

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

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  int count = 0;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= a; j++) {
      if (i + j > b)
        break;
      if (i + j + a >= b) {
        count++;
      }
    }
  }
  cout << count << endl;
}
Problem p03835 (C++)

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

#define mod 1e9 + 7;
#define INF 1e9 + 9;
#define ps(x, y) fixed << setprecision(y) << x
#define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int k, s, c = 0;
  cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int k1 = 0; k1 <= k; k1++) {
        if (i + j + k1 == s)
          c++;
      }
    }
  }
  cout << c << endl;
  return 0;
}

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

#define mod 1e9 + 7;
#define INF 1e9 + 9;
#define ps(x, y) fixed << setprecision(y) << x
#define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int k, s, c = 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)
        c++;
    }
  }
  cout << c << endl;
  return 0;
}