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

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

int main() {
  int K, S;
  int K_buf, S_buf;
  int X, Y, Z;
  int cnt = 0;
  // for()
  cin >> K_buf >> S_buf;

  if (2 <= K_buf <= 2500) {
    if (0 <= S_buf <= 3 * K_buf) {
      K = K_buf;
      S = S_buf;
    }
  }

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

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

int main() {
  int K, S;
  int K_buf, S_buf;
  int X, Y, Z;
  int cnt = 0;
  // for()
  cin >> K_buf >> S_buf;

  if (2 <= K_buf <= 2500) {
    if (0 <= S_buf <= 3 * K_buf) {
      K = K_buf;
      S = S_buf;
    }
  }

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

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

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

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

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

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

using namespace std;

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

  cin >> K >> S;

  int count = 0;
  for (int x = 0; x <= K; x++) {
    if (x + K + K < S)
      continue;

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

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

  cout << count << "\n";

  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

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

  cin >> K >> S;

  int count = 0;
  for (int x = 0; x <= K; x++) {
    if (x + K + K < S)
      continue;

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

  cout << count << "\n";

  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 rrep(i, n) for (int i = 1; i <= (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

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

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = 1; i <= (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

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++) {
      int z = S - i - j;
      if (0 <= z && z <= K)
        counter++;
    }
  }
  cout << counter << endl;
}
Problem p03835 (C++)

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 300 + 5;
const int MAX_N = 1e5 + 5;

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


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 300 + 5;
const int MAX_N = 1e5 + 5;

int main() {
  int s, k;
  cin >> k >> s;
  int cnt = 0;
  rep(i, k + 1) {
    repeat(j, i, k + 1) {
      repeat(l, j, k + 1) {
        if (i + j + l == s) {
          if (i == j && j == l)
            cnt++;
          else if (i == j || j == l)
            cnt += 3;
          else
            cnt += 6;
        }
      }
    }
  }
  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 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++) {
      if (s - x - y >= 0 && s - x - y <= k)
        ans++;
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
  int k, s;
  cin >> k >> s;
  int x, y, z;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int t = 0; t <= k; t++) {
        if (i + j + t == s)
          ans++;
      }
    }
  }

  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
  int k, s;
  cin >> k >> s;
  int x, y, z;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      // for(int t = 0; t <= k; t++){
      if (0 <= s - i - j && s - i - j <= k)
        ans++;
    }
  }

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

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

using namespace std;
int K, S;

int main() {
  cin >> K >> S;
  int count;
  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 <math.h>

using namespace std;
int K, S;

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


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

int main() {
  int k, s, ans = 0;
  cin >> k >> s;
  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <= k; ++y) {
      int z = s - x - y;
      if (0 <= z && z <= k)
        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 REPR(i, n, m) for (int i = (n); i >= (m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLD = vector<PLD>;

const int INF = numeric_limits<int>::max();

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

  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>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n, m) for (int i = (n); i >= (m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLD = vector<PLD>;

const int INF = numeric_limits<int>::max();

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

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

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

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

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

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

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

int main() {
  int K, S;
  cin >> K >> S;
  int cnt = 0;
  for (int x = 0; x <= K; 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 <bits/stdc++.h>
using namespace std;

int main() {
  int K, S, x, y, z;
  cin >> K >> S;

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

  cout << res << endl;
}

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

int main() {
  int K, S, x, y, z;
  cin >> K >> S;

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

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

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
typedef long long ll;
int main(void) {
  // Your code here!
  ll 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 (S == X + Y + Z) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <iostream>
using namespace std;
typedef long long ll;
int main(void) {
  // Your code here!
  ll K, S, ans = 0;
  cin >> K >> S;
  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      int Z = S - X - Y;
      if (0 <= Z && Z <= K) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
Problem p03835 (C++)

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

using namespace std;

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

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

  return 0;
}


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

using namespace std;

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

  int k, s;
  cin >> k >> s;
  int res = 0;
  for (int i = 0; i <= k; ++i) {
    for (int j = 0; j <= k; ++j) {
      if (i + j > s)
        continue;
      if (s - i - j <= k) {
        ++res;
      } else
        continue;
    }
  }
  cout << res << endl;

  return 0;
}
Problem p03835 (C++)

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

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

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

  cout << t;

  return 0;
}

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

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

  for (int i = 0; i <= k; i++) {
    for (int j = i; j <= k; j++) {
      for (int z = j; z <= k; z++) {
        if (i + j + z == s) {
          if (i == j && j == z)
            t += 1;
          else if (i == j || i == z || j == z)
            t += 3;
          else
            t += 6;
        }
      }
    }
  }

  cout << t;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

Fixed submission:
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

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

using namespace std;

int l, s;
int n = 0;

int main() {
  cin >> l >> s;
  int i, j, k;
  for (i = 0; i < l + 1; ++i) {
    for (j = 0; j < l + 1; ++j) {
      for (k = 0; k < l + 1; ++k) {
        if (i + j + k == s) {
          ++n;
        }
      }
    }
  }
  printf("%d", n);
}


Fixed submission:
#include <iostream>
#include <stdio.h>

using namespace std;

int l, s;
int n = 0;

int main() {
  cin >> l >> s;
  int i, j, k;
  for (i = 0; i < l + 1; ++i) {
    for (j = 0; j < l + 1; ++j) {
      k = s - i - j;
      if (k >= 0 && k <= l) {
        ++n;
      }
    }
  }
  printf("%d", n);
}
Problem p03835 (C++)

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

using namespace std;

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

  int count = 0;
  for (int x = 0; x <= K; x++) {
    int a = S - x;
    if (a >= 0) {
      for (int y = 0; y <= K; y++) {
        int b = a - y;
        if (b >= 0) {
          for (int z = 0; z <= K; z++) {
            if (b - z == 0)
              count++;
          }
        }
      }
    }
  }
  cout << count << endl;

  return 0;
}

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

using namespace std;

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

  int count = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      int z = S - x - y;
      if (z >= 0 && z <= K)
        count++;
    }
  }
  cout << count << 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 (long long int i = 0; i <= K; i++) {
    for (long long int j = 0; j <= K; j++) {
      for (long long 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;
  long long int ans = 0;
  for (long long int i = 0; i <= K; i++) {
    for (long long int j = 0; j <= K; j++) {
      long long int k = S - i - j;
      if (0 <= k && k <= K) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
Problem p03835 (C++)

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define r(i, a, n) for (int i = a; i <= n; i++)
int main() {
  long long a, b, c, s = 0;
  cin >> a >> b;
  r(i, 0, a) {
    r(j, 0, a) {
      int z = b - i - j;
      if (0 <= z && z <= a)
        s++;
    }
  }
  cout << s << 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 res = 0;
  for (int x = 0; x < K + 1; x++) {
    for (int y = 0; y < K + 1; y++) {
      for (int z = 0; z < K + 1; z++) {
        if (x + y + z == S) {
          res += 1;
        }
      }
    }
  }
  cout << res << endl;
}

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

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

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

using namespace std;

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

int main() {
  int k, s;
  cin >> k >> s;
  int x, y, z;
  long long 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 <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

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

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


Fixed submission:
#include <bits/stdc++.h>
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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <= k; ++y) {
      int sum1 = x + y;
      for (int z = 0; z <= k; ++z) {
        int sum2 = z + sum1;
        if (sum2 == s)
          ++cnt;
      }
    }
  }
  cout << cnt << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <= k; ++y) {
      if (s >= x + y) {
        if (s - (x + y) <= k)
          cnt++;
      };
    }
  }
  cout << cnt << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <climits> //INT_MIN/MAX
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for (ll(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (ll(i) = (s); (i) > (e); (i)--)
#define MOD 1000000007
#define llong long long
#define debug(x) cout << #x << ": " << x << endl
typedef long long ll;
llong N;

/* 2010/00/00 問題 -----  Name/Link ----- */
/* -----解説等-----
問題:


*/

int K, S;

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

  ll ans = 0;
  cin >> K >> S;
  FOR(i, S - K, S + 1) {
    if (i > 2 * K)
      continue;
    FOR(x, 0, K + 1) {
      FOR(y, 0, K + 1) {
        if (x + y == i)
          ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <climits> //INT_MIN/MAX
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for (ll(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (ll(i) = (s); (i) > (e); (i)--)
#define MOD 1000000007
#define llong long long
#define debug(x) cout << #x << ": " << x << endl
typedef long long ll;
llong N;

/* 2010/00/00 問題 -----  Name/Link ----- */
/* -----解説等-----
問題:


*/

int K, S;

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

  ll ans = 0;
  cin >> K >> S;
  FOR(x, 0, K + 1) {
    FOR(y, 0, K + 1) {
      if ((S - (x + y) >= 0) && (S - (x + y) <= K))
        ans++;
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int k, s;
  cin >> k >> s;
  int res = 0;
  for (int a = 0; a < k + 1; a++) {
    for (int b = 0; b < k + 1; b++) {
      for (int c = 0; c < k + 1; c++) {
        int total = a + b + c;
        if (total == 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 a = 0; a < k + 1; a++) {
    for (int b = 0; b < k + 1; b++) {
      int total = a + b;
      if (0 <= s - total && s - total <= k)
        ++res;
    }
  }
  cout << res << 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 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;
  int count = 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) {
        count++;
      }
    }
  }
  cout << count << endl;
}
Problem p03835 (C++)

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

int main() {
  int K, S;
  cin >> K >> S;
  int X = 0;
  int Y = 0;
  int Z = 0;
  int long count = 0;

  for (int i = 0; i <= K; i++) {
    X = i;
    for (int j = 0; j <= K; j++) {
      Y = j;
      for (int k = 0; k <= K; k++) {
        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;
  cin >> K >> S;
  int X = 0;
  int Y = 0;
  int Z = 0;
  int long count = 0;

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

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

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
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 h = 0; h <= k; h++) {
        if (i + j + h == s)
          cnt++;
      }
    }
  }
  cout << cnt;
}


Fixed submission:
#include <iostream>
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 z = s - i - j;
      if (0 <= z && z <= k) {
        cnt = cnt + 1;
      }
    }
  }
  cout << cnt;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
long long k, s, x, y, z, he;
int main() {
  cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    x = i;
    for (int j = 0; j <= k; j++) {
      y = j;
      for (int l = 0; l <= k; l++) {
        if (x + y + l == s) {
          he++;
        }
      }
    }
  }
  cout << he;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
long long k, s, x, y, z, he;
int main() {
  cin >> k >> s;
  for (int i = 0; i <= k; i++) {
    x = i;
    for (int j = 0; j <= k; j++) {
      y = j;
      if (s - (x + y) >= 0 && s - (x + y) <= k) {
        he++;
      }
    }
  }
  cout << he;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1000000007;
const int MAX_N = 1000; // n の最大値

// nCk を取得
double nCk(int n, int k) {
  double res = 1.0;
  for (int i = 0; i < n; i++) {
    res *= 0.5;
  }
  for (int i = 0; i < k; i++) {
    res *= (double)(n - i);
    res /= (double)(k - i);
  }
  return res;
}

int main() {
  ll k, s;
  cin >> k >> s;
  ll ca = 0;
  for (ll i = 0; i <= k; i++) {
    for (ll q = 0; q <= k; q++) {
      for (ll w = 0; w <= k; w++) {
        if (i + q + w == s)
          ca++;
      }
    }
  }
  cout << ca << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1000000007;
const int MAX_N = 1000; // n の最大値

// nCk を取得
double nCk(int n, int k) {
  double res = 1.0;
  for (int i = 0; i < n; i++) {
    res *= 0.5;
  }
  for (int i = 0; i < k; i++) {
    res *= (double)(n - i);
    res /= (double)(k - i);
  }
  return res;
}

int main() {
  ll k, s;
  cin >> k >> s;
  ll ca = 0;
  for (ll i = 0; i <= k; i++) {
    for (ll q = 0; q <= k; q++) {
      if (0 <= s - i - q && s - i - q <= k)
        ca++;
    }
  }
  cout << ca << 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 a = 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)
          a++;
      }
    }
  }
  cout << a << endl;
  return 0;
}

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

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

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

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

#define NREP() for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x)                                                              \
  t ipt;                                                                       \
  cin >> ipt;                                                                  \
  x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

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

  MSG(ans)
}


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

#define NREP() for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x)                                                              \
  t ipt;                                                                       \
  cin >> ipt;                                                                  \
  x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
  ll s;
  cin >> k >> s;
  ans = 0;
  for (int i = 0; i <= k; ++i) {
    for (int j = 0; j <= k; ++j) {
      int l = s - i - j;
      if (0 <= l && k >= l && i + j + l == s)
        ans++;
    }
  }

  MSG(ans)
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <list>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define vecint vector<int>
#define listint list<int>

#define REP(i, x, n) for (int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define print(a) cout << a << endl

#define INF 1000000007;

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

  cin >> K >> S;
  rep(i, K + 1) {
    rep(j, K + 1) {
      rep(k, K + 1) {
        if (i + j + k == S)
          ans++;
      }
    }
  }
  print(ans);

  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <list>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define vecint vector<int>
#define listint list<int>

#define REP(i, x, n) for (int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define print(a) cout << a << endl

#define INF 1000000007;

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

  cin >> K >> S;
  rep(i, K + 1) {
    REP(j, i, K + 1) {
      REP(k, j, K + 1) {
        if (i + j + k == S) {
          if (i == j && j == k)
            ans++;
          else if (i == j || j == k)
            ans += 3;
          else
            ans += 6;
        }
      }
    }
  }
  print(ans);

  return 0;
}
Problem p03835 (C++)

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

int main() {
  int sum, num_sum;
  std::cin >> num_sum >> sum;
  int count = 0;
  for (int i = 0; i < num_sum + 1; i++) {
    for (int j = 0; j < num_sum + 1; j++) {
      for (int k = 0; k < num_sum + 1; k++) {
        if (i + j + k == sum) {
          count++;
          break;
        }
      }
    }
  }
  std::cout << count << std::endl;
}

Fixed submission:
#include <iostream>

int main() {
  int sum, num_sum;
  std::cin >> num_sum >> sum;
  int count = 0;
  for (int i = 0; i < num_sum + 1; i++) {
    for (int j = 0; j < num_sum + 1; j++) {
      if (sum - (i + j) < num_sum + 1 && sum - (i + j) > -1) {
        count++;
      }
    }
  }
  std::cout << count << std::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 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() {
  int k, s, count = 0;
  cin >> k >> s;

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

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < c; ++i)
int main() {
  int a, b;
  int count = 0;
  cin >> a >> 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) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000;

using ll = long long;
using namespace std;

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

Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000;

using ll = long long;
using namespace std;

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

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


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int a, b, ans = 0;
  cin >> a >> b;
  for (int i = 0; i <= a; i++)
    for (int k = 0; k <= a; k++)
      if (a >= b - i - k && 0 <= b - k - i) {
        ans++;
        continue;
      }
  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 i = 0; i <= K; i++) {
    for (int l = 0; l <= K; l++) {
      for (int m = 0; m <= K; m++) {
        if (i + l + m == 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 l = 0; l <= K; l++) {
      if (S - l - i >= 0 && S - l - i <= 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;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define rep_1(i, n) for (int(i) = 0; (i) <= (n); (i)++)
#define rep_2(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

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

  int count = 0;
  rep_1(x, k) {
    rep_1(y, k) {
      rep_1(z, k) {
        if (x + y + z == s)
          count++;
        else if (x + y + z > s)
          break;
      }
    }
  }
  cout << count << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define rep_1(i, n) for (int(i) = 0; (i) <= (n); (i)++)
#define rep_2(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

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

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

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

int main() {
  int k, s;
  cin >> k >> s;
  int res = 0;
  int a, b, c;
  for (int a = 0; a <= k; a++) {
    for (int b = 0; b <= k; b++) {
      for (int c = 0; c <= k; c++) {
        int total = a + b + c;
        if (total == s)
          res++;
      }
    }
  }
  cout << res << endl;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < int(n); i++)
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 and z <= k) {
        res += 1;
      }
    }
  }
  cout << res << endl;
}
Problem p03835 (C++)

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

int main() {
  int max, total, num = 0;
  cin >> max >> total;

  for (int i = 0; i <= max; i++) {
    for (int t = 0; t <= max; t++) {
      for (int j = 0; j <= max; j++) {
        if (i + t + j == total) {
          num++;
        }
      }
    }
  }

  cout << num << endl;

  return 0;
}

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

int main() {
  int max, total, num = 0;
  cin >> max >> total;

  for (int i = 0; i <= max; i++) {
    for (int t = 0; t <= max; t++) {
      int sub = total - (i + t);
      if (0 <= sub && sub <= max) {
        num++;
      }
    }
  }

  cout << num << endl;

  return 0;
}
Problem p03835 (C++)

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

int main() {
  int k, s;
  cin >> k >> s;
  int sum = 0;
  int z = 0;
  int count = 0;

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

  cout << count << endl;
}

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

int main() {
  int k, s;
  cin >> k >> s;
  int sum = 0;
  int z = 0;
  int count = 0;

  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      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 <cmath>
#include <iostream>
#include <vector>
using namespace std;

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

  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 <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

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

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

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

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <list>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  int K, S, num = 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) {
          num++;
          break;
        }
      }
    }
  }
  cout << num << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <list>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

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

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

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;

  return 0;
}


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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

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 z = s - i - j;
      if (0 <= z && 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;
  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 <bits/stdc++.h>
using namespace std;

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
int main() {
  int K, S, ans = 0;
  cin >> K >> S;

  K++;
  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>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
int main() {
  int K, S, ans = 0;
  cin >> K >> S;

  K++;
  rep(i, K) {
    rep(j, K) {
      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 <bits/stdc++.h>

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)

#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000

using namespace std;
typedef long long ll;

int main() {
  int K, S;
  cin >> K >> S;
  ll count = 0;
  REP(i, K + 1) {
    REP(j, K + 1) {
      REP(k, K + 1) {
        if (i + j + k == S) {
          count++;
          break;
        }
      }
    }
  }
  cout << count;
}

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

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)

#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000

using namespace std;
typedef long long ll;

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

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


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

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

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

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