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

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

  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
int main() {
  int K, S;
  cin >> K >> S;
  int 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;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>
#include <iostream>
#include <string>
#define ULL unsigned long long
using namespace std;

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

Fixed submission:
#include <cstdio>
#include <iostream>
#include <string>
#define ULL unsigned long long
using namespace std;

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

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

using namespace std;

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

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

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

Fixed submission:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

int main() {
  int k, s;
  cin >> k >> s;
  int 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(void) {
  int K, S, cnt = 0;
  cin >> K >> S;

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

  cout << cnt << endl;
  return 0;
}


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

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

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

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 (z >= 0 && z <= K)
        count++;
    }
  }
  cout << count << endl;
}
Problem p03835 (C++)

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

using namespace std;

int main() {
  int 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;
  return 0;
}


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

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

int main() {
  int a, b;
  cin >> a >> b;

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

  cout << cnt << endl;
}


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

int main() {
  int a, b;
  cin >> a >> b;

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

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

int main() {

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

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

  cout << res;
}


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

int main() {

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

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

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

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

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

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

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

Fixed submission:
#include <iostream>
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) {
        // cout << "x = " << x << " " << "y = " << y << " " << "z = " << S - x -
        // y << endl;
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bits/stdc++.h>
#include <cctype>
#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++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <cctype>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      int z = S - x - y;
      if (0 <= z and 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, 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;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
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++) {
      int z = S - x - y;
      if (0 <= z and z <= K) {
        ans++;
      }
    }
  }

  cout << ans;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki, i, n) for (int i = shoki; i < n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
int main() {
  int k, s;
  cin >> k >> s;
  int res = 0;
  rep(0, x, k + 1) {
    rep(0, y, k + 1) {
      rep(0, z, k + 1) {
        if (x + y + z == s)
          res++;
      }
    }
  }
  cout << res << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki, i, n) for (int i = shoki; i < n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
int main() {
  int k, s;
  cin >> k >> s;
  int res = 0;
  rep(0, x, k + 1) {
    rep(0, y, k + 1) {
      if (x + y <= s && x + y >= s - k)
        res++;
    }
  }
  cout << res << endl;
}
Problem p03835 (C++)

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

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

  int ans = 0;
  rep(x, k + 1) {
    rep(y, k + 1) {
      rep(z, k + 1) {
        if (x + y + z == s)
          ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

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

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

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

  cout << cnt << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, S;
  cin >> K >> S;
  int cnt = 0;

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

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void) {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int l = 0; l <= s - i - j; l++) {
        if (i + j + l == s && l <= k) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void) {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      int l = s - i - j;
      if (l >= 0 && l <= k) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p03835 (C++)

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

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


Fixed submission:
#include <bits/stdc++.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;
  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;
}
Problem p03835 (C++)

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

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

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

  cout << cnt << endl;

  return 0;
}

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

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

  for (int X = 0; X < K + 1; X++) {
    for (int Y = 0; Y < K + 1; Y++) {
      int Z = S - X - Y;
      if (0 <= Z and Z <= K)
        cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, S;
  cin >> K >> S;

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, S;
  cin >> K >> S;

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

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

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

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

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

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

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

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

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

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

int main() {
  ios::sync_with_stdio(false);
  int k, s;
  cin >> k >> s;
  int a = 0, b = min(k, s);
  for (int i = 0; i <= b; i++) {
    for (int j = 0; j <= b; j++) {
      for (int l = 0; l <= b; l++) {
        if (i + j + l == s)
          a++;
      }
    }
  }
  cout << a;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  int k, s;
  cin >> k >> s;
  int a = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      int b = s - i - j;
      if (0 <= b && b <= k)
        a++;
    }
  }
  cout << a;
}
Problem p03835 (C++)

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

using namespace std;

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

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

using namespace std;

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

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


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

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

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

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

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

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

using namespace std;

int main() {
  int argK, argS;
  cin >> argK >> argS;

  argK++;
  int counter = 0;
  for (int x = 0; x < argK; ++x) {
    for (int y = 0; y < argK; ++y) {
      for (int z = 0; z < argK; ++z) {
        if (x + y + z == argS) {
          counter++;
        }
      }
    }
  }

  cout << counter;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main() {
  int argK, argS;
  cin >> argK >> argS;

  argK++;
  int counter = 0;
  for (int x = 0; x < argK; ++x) {
    for (int y = 0; y < argK; ++y) {
      if (argS - x - y < argK && argS - x - y >= 0) {
        counter++;
      }
    }
  }

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

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

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


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

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <map>
#include <regex>
#include <string>
using namespace std;
int main() {
  int K, S;
  cin >> K >> S;
  int cnt = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      for (int z = 0; z <= K; z++) {
        if (x + y + z == S)
          cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <map>
#include <regex>
#include <string>
using namespace std;
int main() {
  int K, S;
  cin >> K >> S;
  int cnt = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      if (x + y > S)
        break;
      if (S - x - y <= K)
        cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  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 << "\n";
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  int k, s, count = 0;

  cin >> k >> s;
  for (int x = 0; x <= k; x++)

  {
    for (int y = 0; y <= k; y++) {
      int z = s - x - y;
      {
        if (z <= k && z >= 0) {
          count++;
        }
      }
    }
  }
  cout << count << "\n";
}
Problem p03835 (C++)

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

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

  std::cout << count << std::endl;

  return 0;
}

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

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

  int count = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int sum = x + y;
      int z = s - sum;
      // std::cout << x << "," << y << "," << z << std::endl;
      if (0 <= z && z <= k) {
        count++;
      }
    }
  }

  std::cout << count << std::endl;

  return 0;
}
Problem p03835 (C++)

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

int main() {
  int X, Y, Z, K, S, counter;
  counter = 0;
  cin >> K >> S;
  for (X = 0; X <= K; X++) {
    for (Y = 0; Y <= K; Y++) {
      for (Z = 0; Z <= K; Z++) {
        if (X + Y + Z == S)
          counter += 1;
      }
    }
  }
  cout << counter << endl;
}


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

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

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

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


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

int main() {
  int K, S;
  int res = 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) {
        res += 1;
      }
    }
  }
  cout << res << endl;
  return 0;
}
Problem p03835 (C++)

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

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

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

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

// pow(llpow,modpow)
template <class T> ll llpow(T x, T n) {
  ll ans = 1;
  if (x == 0)
    ans = 0;
  while (n) {
    if (n & 1)
      ans *= x;
    x *= x;
    n >>= 1;
  }
  return ans;
}
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
// 最大公約数
template <class T> inline T gcd(T x, T y) {
  if (y == 0)
    return x;
  else {
    return gcd(y, x % y);
  }
}
// 最小公倍数
template <class T> inline T lcm(T x, T y) { return x / gcd(x, y) * y; }
// 逆元
long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL << 60;
int main() {
  int k, s;
  cin >> k >> s;
  ll res = 0;
  rep(i, k + 1) {
    rep(j, k + 1) {
      rep(l, k + 1) {
        if (i + j + l == s)
          res++;
      }
    }
  }
  cout << res << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using vll = vector<ll>;
using vi = vector<int>;

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

// pow(llpow,modpow)
template <class T> ll llpow(T x, T n) {
  ll ans = 1;
  if (x == 0)
    ans = 0;
  while (n) {
    if (n & 1)
      ans *= x;
    x *= x;
    n >>= 1;
  }
  return ans;
}
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
// 最大公約数
template <class T> inline T gcd(T x, T y) {
  if (y == 0)
    return x;
  else {
    return gcd(y, x % y);
  }
}
// 最小公倍数
template <class T> inline T lcm(T x, T y) { return x / gcd(x, y) * y; }
// 逆元
long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL << 60;
int main() {
  int k, s;
  cin >> k >> s;
  ll res = 0;
  rep(i, k + 1) {
    rep(j, k + 1) {
      if (s - (i + j) >= 0 && s - (i + j) <= k)
        res++;
    }
  }
  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 < (int)(n); i++)
using namespace std;
using ll = long long;

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

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

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

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

Buggy submission (status: Time Limit Exceeded):
[K, S] = map(int, input().split())
ret = 0
for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            if (x + y + z) == S:
                ret += 1
print(ret)


Fixed submission:
[K, S] = map(int, input().split())
ret = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= z and z <= K:
            ret += 1
print(ret)
Problem p03835 (C++)

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

using namespace std;

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

  int ret = 0;
  for (int i = 0; i <= k; i++) {
    if (i > s)
      break;

    for (int j = 0; j <= k; j++) {
      if (i + j > s)
        break;

      for (int l = 0; l <= k; l++) {
        if (i + j + l > s)
          break;
        if (i + j + l == s)
          ret++;
      }
    }
  }

  cout << ret << endl;

  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

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

  int ret = 0;
  for (int i = 0; i <= k; i++) {
    if (i > s)
      break;

    for (int j = 0; j <= k; j++) {
      if (i + j > s)
        break;
      if (s - (i + j) <= k)
        ret++;
    }
  }

  cout << ret << endl;

  return 0;
}
Problem p03835 (C++)

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

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

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

  cout << cnt << endl;
  return 0;
}

Fixed submission:
#include <iostream>
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 and s - x - y >= 0) {
        cnt++;
      }
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;

int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  rep(i, n + 1) {
    rep(j, n + 1) {
      rep(k, n + 1) {
        if (i + j + k == m) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
// Ctrl+Aを使わない

Fixed submission:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;

int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  rep(i, n + 1) {
    rep(j, n + 1) {
      int k = m - i - j;
      if (k >= 0 && k <= n) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
// Ctrl+Aを使わない
Problem p03835 (C++)

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

void solve(long long K, long long 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++;
        if (i + j + k > S)
          break;
      }
    }
  }
  cout << res << endl;
}

int main() {
  long long K;
  scanf("%lld", &K);
  long long S;
  scanf("%lld", &S);
  solve(K, S);
  return 0;
}


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

void solve(long long K, long long S) {
  int res = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      if (S - i - j <= K and S - i - j >= 0)
        res++;
    }
  }
  cout << res << endl;
}

int main() {
  long long K;
  scanf("%lld", &K);
  long long S;
  scanf("%lld", &S);
  solve(K, S);
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main(void) {
  int a, N;
  cin >> a >> N;

  int ans = 0;

  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= a; j++) {
      for (int k = 0; k <= a; k++) {
        if (i + j + k == N)
          ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;
int main(void) {
  int a, N;
  cin >> a >> N;

  int ans = 0;

  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= a; j++) {
      if (N - i - j <= a && N - i - j >= 0)
        ans++;
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

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

#define ll long long
#define ld long double
#define ull unsigned long long
#define pw(x) (1LL << (x))

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y)                                                              \
  cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
#define db3(x, y, z)                                                           \
  cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y   \
       << ", " << z << ")\n"

using namespace std;

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

  int K, S, 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)
        cnt += (X + Y + Z == S);

  cout << cnt;
  return 0;
}

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

#define ll long long
#define ld long double
#define ull unsigned long long
#define pw(x) (1LL << (x))

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y)                                                              \
  cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
#define db3(x, y, z)                                                           \
  cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y   \
       << ", " << z << ")\n"

using namespace std;

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

  int K, S, cnt = 0;
  cin >> K >> S;

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

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

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

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

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

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

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

  std::cout << count << std::endl;

  return EXIT_SUCCESS;
}


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

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

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

  std::cout << count << std::endl;

  return EXIT_SUCCESS;
}
Problem p03835 (C++)

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

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long lng;
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, b, a) for (int i = (b); i >= (a); --i)
#define REP(i, n) FOR(i, 0, n - 1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a)                                                              \
  a.erase(unique(ALL(a)), a.end()) // ATTENTION: <a> must be sorted in advance

lng power(lng b, lng n) {
  lng sol = 1;
  while (n > 0) {
    if (n & 1) {
      sol = sol * b;
    }
    n >>= 1;
    b *= b;
  }
  return sol;
} // calculate b^n

const int MOD = 1000000007; // 10^9+7

/*********** variables ************/
lng dp[8000];
/**********************************/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int K, S;
  cin >> K >> S;
  REP(i, K + 1) REP(j, K + 1) { dp[i + j]++; }
  lng cnt = 0;
  REP(i, K + 1) {
    int dd = S - i;
    cnt += dp[dd];
  }
  cout << cnt << endl;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long lng;
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, b, a) for (int i = (b); i >= (a); --i)
#define REP(i, n) FOR(i, 0, n - 1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a)                                                              \
  a.erase(unique(ALL(a)), a.end()) // ATTENTION: <a> must be sorted in advance

lng power(lng b, lng n) {
  lng sol = 1;
  while (n > 0) {
    if (n & 1) {
      sol = sol * b;
    }
    n >>= 1;
    b *= b;
  }
  return sol;
} // calculate b^n

const int MOD = 1000000007; // 10^9+7

/*********** variables ************/
lng dp[8000];
/**********************************/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int K, S;
  cin >> K >> S;
  REP(i, K + 1) REP(j, K + 1) { dp[i + j]++; }
  lng cnt = 0;
  REP(i, K + 1) {
    int dd = S - i;
    if (dd >= 0)
      cnt += dp[dd];
  }
  cout << cnt << endl;
}
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++) {
      int z = s - y - x;
      if (z >= 0 && z <= 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++)
using namespace std;
using ll = long long;
int main() {
  int cnt = 0;
  int K, S;
  cin >> K >> S;
  for (int z = 0; z <= K; z++) {
    for (int y = 0; y <= K; y++) {
      for (int x = 0; x <= K; x++) {
        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++)
using namespace std;
using ll = long long;
int main() {
  int cnt = 0;
  int K, S;
  cin >> K >> S;
  for (int z = 0; z <= K; z++) {
    for (int y = 0; y <= K; y++) {
      int x = S - z - y;
      if (x >= 0 && K >= x) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;

  return 0;
}
Problem p03835 (C++)

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

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

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

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      int l = s - i - j;
      if (0 <= l and l <= 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 /*saidaiti*/, s /*goukei*/, c = 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)
          c++;
      }
    }
  }
  cout << c << endl;
  return 0;
}


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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <vector>
typedef long long ll;
#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;
  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;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <vector>
typedef long long ll;
#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;
  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 <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

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


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

using namespace std;

int main() {
  int k;
  int s;
  scanf("%d %d\n", &k, &s);

  int ans = 0;

  for (auto x = 0; x <= k; x++) {
    for (auto y = 0; y <= k; y++) {
      auto z = s - x - y;
      if (0 <= z && z <= k)
        ans++;
      ;
    }
  }
  printf("%d\n", ans);
  return 0;
}
Problem p03835 (C++)

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

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

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

  cout << res << endl;
}


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

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

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

  cout << res << endl;
}