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

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

using namespace std;
int main(void) {
  int K, S;
  cin >> K >> S;
  int res = 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)
          res++;
    }
  }
  printf("%d", res);
}

Fixed submission:
#include <iostream>

using namespace std;
int main(void) {
  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 >= 0 && S - i - j <= K)
        res++;
    }
  }
  printf("%d", res);
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

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

Fixed submission:
#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

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

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

void solve();

int k, s;

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

  solve();

  return 0;
}

void solve() {
  int cnt = 0;

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

  cout << cnt << endl;
}

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

void solve();

int k, s;

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

  solve();

  return 0;
}

void solve() {
  int cnt = 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)
        cnt += 1;
    }
  }

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

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

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


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

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

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


Fixed submission:
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main() {
  cout << fixed << setprecision(10);
  int K, S;
  cin >> K >> S;
  int count = 0;
  for (int i = 0; i < K + 1; i++) {
    for (int j = 0; j < K + 1; j++) {
      if (i + j >= S - K && i + j <= S) {
        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 a, b, ans = 0;
  cin >> a >> b;
  for (int i = 0; i <= a; i++) {
    for (int n = 0; n <= a; n++) {
      for (int m = 0; m <= a; m++) {
        if (i + n + m == b)
          ans += 1;
      }
    }
  }
  cout << ans << endl;
}

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

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


Fixed submission:
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
int main() {
  int k, s;
  cin >> k >> s;
  k++;
  int cnt = 0;
  REP(i, k) {
    REP(l, k) {
      int z = s - i - l;
      if (0 <= z && z < k) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p03835 (C++)

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

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

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

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main() {

  int k, s;
  int cnt = 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 (s == x + y + z)
          cnt++;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main() {

  int k, s;
  int cnt = 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)
        cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}
Problem p03835 (C++)

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

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

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

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

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

int s, k;
int c = 0;

int main() {
  std::cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    for (int p = 0; p <= k; i++) {
      if (s - i - p >= 0 && s - i - p <= k) {
        c++;
      }
    }
  }
  std::cout << c << std::endl;
}


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

int s, k;
int c = 0;

int main() {
  std::cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    for (int p = 0; p <= k; p++) {
      if (s - i - p >= 0 && s - i - p <= k) {
        c++;
      }
    }
  }
  std::cout << c << std::endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int main() {
  ll k, s;
  cin >> k >> s;
  ll count = 0;
  for (ll x = 0; x <= k; x++) {
    for (ll y = 0; y <= k; y++) {
      for (ll z = 0; z <= k; z++) {
        if ((x + y + z) == s)
          count++;
      }
    }
  }
  cout << count;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int main() {
  ll k, s;
  cin >> k >> s;
  ll count = 0;
  for (ll x = 0; x <= k; x++) {
    for (ll y = 0; y <= k; y++) {
      if (s - (x + y) <= k && 0 <= s - (x + y)) {
        count++;
      }
    }
  }
  cout << count;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
typedef long long ll;
ll MM = 1000000000;
ll mod = MM + 7;
ll MMM = 9223372036854775807; // 2^63 -1
typedef vector<ll> lvec;
typedef vector<double> dvec;
typedef vector<string> svec;
ll GCD(ll x, ll y) {
  if (y == 0)
    return x;
  else
    return GCD(y, x % y);
}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y; }
// cout << fixed << setprecision(10);

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
typedef long long ll;
ll MM = 1000000000;
ll mod = MM + 7;
ll MMM = 9223372036854775807; // 2^63 -1
typedef vector<ll> lvec;
typedef vector<double> dvec;
typedef vector<string> svec;
ll GCD(ll x, ll y) {
  if (y == 0)
    return x;
  else
    return GCD(y, x % y);
}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y; }
// cout << fixed << setprecision(10);

int main() {
  ll k, s, ans = 0;
  cin >> k >> s;
  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>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int k, s;
  // 0<=x,y,z<=k,x+y+z=s
  cin >> k >> s;
  int sum = 0;
  rep(i, k + 1) {
    rep(j, k + 1) {
      rep(l, k + 1) {
        if (i + j + l == s) {
          sum++;
        } else if (i + j + l != s) {
          continue;
        }
      }
    }
  }
  cout << sum << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int k, s;
  // 0<=x,y,z<=k,x+y+z=s
  cin >> k >> s;
  int sum = 0;
  rep(i, k + 1) {
    rep(j, k + 1) {
      if (0 <= s - i - j && s - i - j <= k) {
        sum++;
      } else {
        continue;
      }
    }
  }
  cout << sum << 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 a = 0; a <= k; a++) {
    for (int b = 0; b <= k; b++) {
      for (int c = 0; c <= k; c++) {
        if (a + b + c == s)
          cnt++;
      }
    }
  }

  cout << cnt << endl;
}

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

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

  int cnt = 0;

  for (int a = 0; a <= k; a++) {
    for (int b = 0; b <= k; b++) {
      int S = s - a - b;
      if (0 <= S && S <= k)
        cnt++;
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
void solve() {
  int k, s, ans = 0;
  cin >> k >> s;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= min(s - x, k); y++) {
      for (int z = 0; z <= min(s - x - y, k); z++) {
        if (x + y + z == s)
          ans++;
        if (x + y + z > s)
          break;
      }
    }
  }
  cout << ans << endl;
  return;
}

int main() {
  solve();
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
void solve() {
  int k, s, ans = 0;
  cin >> k >> s;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= min(s - x, k); y++) {
      if (s - x - y <= k)
        ans++;
    }
  }
  cout << ans << endl;
  return;
}

int main() {
  solve();
  return 0;
}
Problem p03835 (C++)

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

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

int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  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 <bits/stdc++.h>

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

int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      int a = S - i - j;
      if (a <= K && 0 <= a)
        ans++;
    }
  }

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

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

int main() {
  int k, s;

  std::cin >> k >> s;

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

  std::cout << n << std::endl;

  return 0;
}


Fixed submission:
#include <iostream>

int main() {
  int k, s;

  std::cin >> k >> s;

  int n = 0;

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

  std::cout << n << std::endl;

  return 0;
}
Problem p03835 (C++)

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

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

using ll = long long;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;

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

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

using ll = long long;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      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;
int main(void) {
  int k, s;
  cin >> k >> s;
  int count = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int l = 0; l <= k; l++) {
        if (i + j + l == s) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

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

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

int main() {
  int a, b;
  long long cnt = 0;

  cin >> a >> b;
  // a1+a2+a3 == b
  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)
          cnt++;
        else if (i + j + k >= b)
          break;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

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

int main() {
  int a, b;
  long long cnt = 0;

  cin >> a >> b;
  // a1+a2+a3 == b
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= a; j++) {
      int k = b - i - j;
      if (k >= 0 && k <= a)
        cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  // 入力
  long K, S, x = 0, y = 0, z = 0, ans = 0;
  cin >> K >> S;
  // 処理
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      for (int l = 0; l <= K; l++) {
        if (i + j + l == S) {
          ans++;
        }
      }
    }
  }
  // 出力
  cout << ans << endl;
}


Fixed submission:
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  // 入力
  long K, S, x = 0, y = 0, z = 0, 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;
}
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;
  long long ans = 0;
  rep(i, K) rep(j, K) rep(k, K) {
    if (i + j + k == 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) <= (int)(n); ++(i))

int main() {
  int K, S;
  cin >> K >> S;
  long long ans = 0;
  rep(i, K) {
    int s = S - i;
    if (s > 2 * K)
      continue;
    else {
      int t = 0;
      rep(j, K) {
        int ss = s - j;
        if (K >= ss && ss >= 0)
          t++;
      }
      ans += t;
    }
  }
  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 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 <iostream>
using namespace std;
int main() {
  int K, S;
  cin >> K >> S;
  int cnt = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      int z = S - i - j;
      if (z >= 0 && z <= K)
        cnt++;
    }
  }
  cout << cnt << endl;
}
Problem p03835 (C++)

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

using ll = long long;
const int INF = 1e9 + 1;

int main() {

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

  int ans = 0;
  for (int i = 0; i <= K; i++)
    for (int j = 0; j <= K; j++)
      for (int k = 0; k <= K; k++)
        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 < n; i++)
using namespace std;

using ll = long long;
const int INF = 1e9 + 1;

int main() {

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

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

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

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

using ll = long long;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;
using Graph = vector<vector<int>>;

int main() {

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

  int ans = 0;
  for (int i = 0; i <= K; i++)
    for (int j = 0; j <= K; j++)
      for (int k = 0; k <= K; k++) {
        if (i + j + k > S)
          break;
        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 < n; i++)
#define repin(Array, n)                                                        \
  for (int i = 0; i < n; i++) {                                                \
    cin >> Array[i];                                                           \
  }
using namespace std;

using ll = long long;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;
using Graph = vector<vector<int>>;

int main() {

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

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

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

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

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

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

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

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

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

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


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

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

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

  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int n = 0; n <= k; n++) {
        sum = i + j + n;
        if (sum == s) {
          count++;
        }
      }
    }
  }

  cout << count << endl;
}

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

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

  int x, y, z;
  x = y = z = 0;
  int sum = 0;
  int count = 0;

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

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

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

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

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

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

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

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

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

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

int main() {
  int k, s, 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):
// スタックサイズ: 100MB

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()

int main() {

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

  ll 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:
// スタックサイズ: 100MB

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()

int main() {

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

  ll 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;
using ll = long long;
const int mod = 1000000007;

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;
using ll = long long;
const int mod = 1000000007;

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

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

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

  cin >> K >> S;

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

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

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

  cin >> K >> S;

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

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

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

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

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

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

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 x = 0; x <= k; x++) {
        if (s == i + j + x)
          ans++;
      }
    }
  }

  cout << ans;
}


Fixed submission:
#include <iostream>

using namespace std;

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

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

  cout << ans;
}
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 rest = S - (x + y);
      // z が表現できる値の範囲であれば、カウントアップする
      if (rest >= 0 && rest <= K) {
        ans++;
      }
    }
  }

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

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

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(), a.end())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MP(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define INF LLONG_MAX / 2

using namespace std;
int MOD = 1000000007;

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

  cout << ans << endl;

  return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://abc051.contest.atcoder.jp/tasks/abc051_b
// rm -r -f test;oj dl
// http://yahoo-procon2017-qual.contest.atcoder.jp/tasks/yahoo_procon2017_qual_c

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

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(), a.end())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MP(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define INF LLONG_MAX / 2

using namespace std;
int MOD = 1000000007;

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

  cout << ans << endl;

  return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://abc051.contest.atcoder.jp/tasks/abc051_b
// rm -r -f test;oj dl
// http://yahoo-procon2017-qual.contest.atcoder.jp/tasks/yahoo_procon2017_qual_c
Problem p03835 (C++)

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

using namespace std;

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


Fixed submission:
#include <iostream>

using namespace std;

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

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

using namespace std;

int main() {
  int s, n, i, j, k, counter = 0;
  scanf("%d %d", &s, &n);
  for (i = 0; i <= s; ++i) {
    for (j = 0; j <= s; ++j) {
      for (k = 0; k <= s; ++k) {
        if (i + j + k == n) {
          counter++;
        }
      }
    }
  }
  printf("%d", counter);

  return 0;
}


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

using namespace std;

int main() {
  int s, n, i, j, k, counter = 0;
  scanf("%d %d", &s, &n);
  for (i = 0; i <= s; ++i) {
    for (j = 0; j <= s; ++j) {
      if ((n - (i + j)) >= 0 && (n - (i + j)) <= s) {
        counter++;
      }
    }
  }
  printf("%d", counter);

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

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int k;
  int s;
  cin >> k;
  cin >> s;
  int m = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      if (0 <= s - (x + y) && s - (x + y) <= k) {
        m++;
      }
    }
  }
  cout << m << 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 i, j, y;
  int ans = 0;
  for (i = 0; i <= k; i++) {
    for (j = 0; j <= k; j++) {
      for (y = 0; y <= k; y++) {
        if (i + j + y > s)
          break;
        else if (i + j + y == s)
          ans++;
      }
    }
  }

  cout << ans << endl;
}

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

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

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

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

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

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

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

int main() {
  int k, s;
  ll cnt = 0;
  cin >> k >> s;
  rep(x, k + 1) rep(y, k + 1) if (x + y <= s && s - (x + y) <= k) cnt++;
  cout << cnt << endl;
  return 0;
}
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 mayz = s - x - y;
      if (0 <= mayz && mayz <= k) {
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}
Problem p03835 (C++)

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

int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  rep_eq(x, 0, K) {
    rep_eq(y, 0, K) {
      rep_eq(z, 0, K) {
        if (x + y + z == S)
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

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

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

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

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型
using pint = pair<int, int>;

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型
using pint = pair<int, int>;

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

Fixed submission:
#include <iostream>
#include <string>
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 (0 <= S - i - j && S - i - j <= K)
        c++;
    }
  }
  cout << c << endl;
  return 0;
}
Problem p03835 (C++)

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

using namespace std;

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

  cin >> K >> S;

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

  cout << count << endl;
}

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

using namespace std;

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

  cin >> K >> S;

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

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

Buggy submission (status: Time Limit Exceeded):

#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<ll, ll> P;

// 1. dp,変数
int n, m;
ll c;
// 2. 道（辺）と都市（頂点）
vector<P> road[100001];
ll d[200001] = {};
ll dp[100001] = {};
ll dp2[100001] = {};

int main() {
  // 3. 入力
  int k, s;
  cin >> k >> s;
  int total = 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)
          total++;
      }
    }
  }
  cout << total << endl;
  return 0;
}


Fixed submission:

#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<ll, ll> P;

// 1. dp,変数
int n, m;
ll c;
// 2. 道（辺）と都市（頂点）
vector<P> road[100001];
ll d[200001] = {};
ll dp[100001] = {};
ll dp2[100001] = {};

int main() {
  // 3. 入力
  int k, s;
  cin >> k >> s;
  int total = 0;
  for (int x = 0; x < k + 1; ++x) {
    for (int y = 0; y < k + 1; ++y) {
      if (((x + y) <= s) && ((x + y) >= (s - k)))
        total++;
    }
  }
  cout << total << endl;
  return 0;
}
Problem p03835 (C++)

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

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

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

int main() {
  int K, S, c = 0;
  cin >> K >> S;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      if ((S - i - j) <= K && (S - i - j) >= 0) {
        c += 1;
      }
    }
  }
  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 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 <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 z = S - x - y;
      if (x + y + z == S && z >= 0 && z <= K) {
        count++;
      }
    }
  }
  cout << count << endl;
}