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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <functional>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define MAX 100000
int main() {
  int s, l, c = 0, x, y, z;
  cin >> s >> l;
  set<int> set;
  for (int i = s; i >= 0; i--) {
    for (int j = i; j >= 0; j--) {
      for (int k = j; k >= 0; k--) {
        if (i + j + k == l) {
          set.clear();
          set.insert(i);
          set.insert(j);
          set.insert(k);
          int tm = 1;
          for (int m = 1; m <= 4 - set.size(); m++) {
            tm *= m;
          }
          c += 6 / tm;
        }
      }
    }
  }
  cout << c << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <functional>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define MAX 100000
int main() {
  int s, l, c = 0, x, y, z;
  cin >> s >> l;
  set<int> set;
  for (int i = 0; i <= s; i++) {
    for (int j = 0; j <= s; j++) {
      if (l - i - j >= 0 && l - i - j <= s) {
        c++;
      }
    }
  }
  cout << c << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define LL long long
using namespace std;

int main() {
  int K, S;
  int ans = 0;
  cin >> K >> S;
  REP(i, K + 1) {
    if (i > S)
      break;
    REP(j, K + 1) {
      if (i + j > S)
        break;
      REP(k, K + 1) {
        if (i + j + k == S)
          ans++;
        if (i + j + k > S)
          break;
      }
    }
  }
  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) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define LL long long
using namespace std;

int main() {
  int K, S;
  int ans = 0;
  cin >> K >> S;
  REP(i, K + 1) {
    if (i > S)
      break;
    REP(j, K + 1) {
      int k = S - (i + j);
      if (0 <= k && k <= K)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03835 (C++)

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

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>

#include <climits>

using namespace std;

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

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

  cout << count << endl;

  return 0;
}

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

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>

#include <climits>

using namespace std;

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

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

  cout << count << endl;

  return 0;
}
Problem p03835 (C++)

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

using namespace std;

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

  cout << ans << endl;
}

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

using namespace std;

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

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

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

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

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

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

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

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

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

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


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

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

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

Buggy submission (status: Time Limit Exceeded):
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#pragma GCC optimize("Ofast")
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

const int INF = 2147483647;
// const ll LINF = ll();今度書く

// マクロとかここまで

#include <algorithm>
#include <cmath>
#include <cstring>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int main() {

  int k, s, count = 0;
  scanf("%d%d", &k, &s);
  rep(x, k + 1) {
    rep(y, k + 1) {
      rep(z, k + 1) {
        if (x + y + z == s)
          ++count;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}


Fixed submission:
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#pragma GCC optimize("Ofast")
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

const int INF = 2147483647;
// const ll LINF = ll();今度書く

// マクロとかここまで

#include <algorithm>
#include <cmath>
#include <cstring>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int main() {

  int k, s, count = 0;
  scanf("%d%d", &k, &s);
  rep(x, k + 1) {
    rep(y, k + 1) {
      if (s - x - y >= 0 && s - x - y <= k)
        ++count;
    }
  }
  printf("%d\n", count);
  return 0;
}
Problem p03835 (C++)

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

#define pout(n) printf("%d\n", n)

#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, n, a) for (int i = n - 1; i >= a; i--)

typedef long long ll;
using namespace std;

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

  rep(i, 0, k + 1) {
    rep(j, 0, k + 1) {
      rep(n, 0, k + 1) {
        if (i + j + n == s)
          count++;
      }
    }
  }

  pout(count);
  return 0;
}

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

#define pout(n) printf("%d\n", n)

#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, n, a) for (int i = n - 1; i >= a; i--)

typedef long long ll;
using namespace std;

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

  rep(x, 0, k + 1) {
    rep(y, 0, k + 1) {
      int z = s - x - y;
      if (0 <= z && z <= k)
        count++;
    }
  }

  pout(count);
  return 0;
}
Problem p03835 (C++)

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

using namespace std;

int K, S;

void solve() {
  int num = 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) {
          num++;
        }
      }
    }
  }
  printf("%d\n", num);
}

int main() {
  cin >> K >> S;
  solve();
  return 0;
}

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

using namespace std;

int K, S;

void solve() {
  int num = 0;
  for (int x = 0; x <= K; ++x) {
    for (int y = 0; y <= K; ++y) {
      if (S - x - y >= 0 && S - x - y <= K) {
        num++;
      }
    }
  }
  printf("%d\n", num);
}

int main() {
  cin >> K >> S;
  solve();
  return 0;
}
Problem p03835 (C++)

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

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

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 count = 0;
  for (int x = 0; x <= k && 3 * x <= s; x++) {
    for (int y = x; y <= k; y++) {
      for (int z = y; z <= k; z++) {
        if (x + y + z == s) {
          if (x == y && y == z)
            count += 1;
          else if (x == y && y != z)
            count += 3;
          else if (y == z && z != x)
            count += 3;
          else if (z == x && x != y)
            count += 3;
          else
            count += 6;
        }
      }
    }
  }
  cout << count << endl;
}
Problem p03835 (C++)

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

int main() {
  int k, s, x, y, z;
  int count = 0;
  cin >> k >> s; // 範囲 和

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


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

int main() {
  int k, s, x, y, z;
  int count = 0;
  cin >> k >> s; // 範囲 和

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

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

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

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

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      int p = s - i - j;
      if (p <= k && p >= 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;
  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(void) {
  int k, s;
  cin >> k >> s;

  int count = 0;

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

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

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

using namespace std;
int main() {
  int K, S, kazu = 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) {
          kazu++;
        }
      }
    }
  }
  cout << kazu;
  return 0;
}

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

using namespace std;
int main() {
  int K, S, kazu = 0;
  cin >> K >> S;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      if (K >= S - (x + y) && x + y <= S) {
        kazu++;
      }
    }
  }
  cout << kazu;
  return 0;
}
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 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 <iostream>

using namespace std;

int main(void) {
  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;
      if (z >= 0 && z <= k)
        cnt++;
    }
  }

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

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

using namespace std;

int main() {

  int k, s;
  int 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 <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <math.h>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

int main() {

  int k, s;
  int 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 <iostream>

using namespace std;

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

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

  cout << count << endl;
}

Fixed submission:
#include <iostream>

using namespace std;

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

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

  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int k = 0, s = 0;
  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>
using namespace std;

int main() {

  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int k = 0, s = 0;
  cin >> k >> s;

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

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
// ABC051B.cpp : このファイルには 'main'
// 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

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

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント:
//    1. ソリューション エクスプローラー
//    ウィンドウを使用してファイルを追加/管理します
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード
//   ファイルを作成するか、[プロジェクト] > [既存の項目の追加]
//   と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] >
//   [プロジェクト] と移動して .sln ファイルを選択します


Fixed submission:
// ABC051B.cpp : このファイルには 'main'
// 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

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

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント:
//    1. ソリューション エクスプローラー
//    ウィンドウを使用してファイルを追加/管理します
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード
//   ファイルを作成するか、[プロジェクト] > [既存の項目の追加]
//   と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] >
//   [プロジェクト] と移動して .sln ファイルを選択します
Problem p03835 (C++)

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

using namespace std;

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

  // input
  cin >> K >> S;

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

  cout << count << endl;
  return 0;
}


Fixed submission:
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>

using namespace std;

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

  // input
  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)
        count++;
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using ll = long long int;

void prime(vector<int> &num, int n) {
  for (int i = 0; i <= n; i++) {
    num[i] = 1;
  }
  num[0] = 0;
  num[1] = 0;
  num[2] = 1;

  for (int i = 2; i <= sqrt(n); i++) {
    if (num[i] == 1) {
      for (int j = 2; j <= n / i; j++) {
        num[i * j] = 0;
      }
    }
  }
}

ll gcd(ll a, ll b) {
  ll tmp;
  if (b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b != 0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main(void) {

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

  int sum = 0;

  for (int i = 0; i <= k; i++) {
    if (i > s)
      break;
    for (int j = i; j <= k; j++) {
      if (i + j > s)
        break;
      for (int l = j; l <= k; l++) {
        if (i + j + l == s) {
          if (i == j && j == l)
            sum++;
          if (i == j && j != l)
            sum += 3;
          if (i != j && j == l)
            sum += 3;
          if (i == l && j != i)
            sum += 3;
          if (i != j && j != l && i != l)
            sum += 6;
          // cout<<i<<" "<<j<<" "<<l<<":"<<sum<<endl;
        }
        if (i + j + l > s)
          break;
      }
    }
  }
  cout << sum << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using ll = long long int;

void prime(vector<int> &num, int n) {
  for (int i = 0; i <= n; i++) {
    num[i] = 1;
  }
  num[0] = 0;
  num[1] = 0;
  num[2] = 1;

  for (int i = 2; i <= sqrt(n); i++) {
    if (num[i] == 1) {
      for (int j = 2; j <= n / i; j++) {
        num[i * j] = 0;
      }
    }
  }
}

ll gcd(ll a, ll b) {
  ll tmp;
  if (b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b != 0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main(void) {

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

  int sum = 0;

  for (int i = 0; i <= k; i++) {
    if (i > s)
      break;
    for (int j = i; j <= k; j++) {
      if (i + j > s)
        break;
      int start;
      if (j > s - i - j)
        start = j;
      else
        start = s - i - j;
      for (int l = start; l <= k; l++) {
        if (i + j + l == s) {
          if (i == j && j == l)
            sum++;
          if (i == j && j != l)
            sum += 3;
          if (i != j && j == l)
            sum += 3;
          if (i == l && j != i)
            sum += 3;
          if (i != j && j != l && i != l)
            sum += 6;
          // cout<<i<<" "<<j<<" "<<l<<":"<<sum<<endl;
        }
        if (i + j + l > s)
          break;
      }
    }
  }
  cout << sum << endl;

  return 0;
}
Problem p03835 (C++)

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

int main() {
  ull n, s;

  cin >> n >> s;
  ull c = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        if (i + j + k == s)
          c++;
      }
    }
  }
  cout << c << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;

int main() {
  ull n, s;

  cin >> n >> s;
  ull c = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      int s2 = s - i - j;

      if (s2 >= 0 && s2 <= n)
        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;
  for (int i = K; i >= 0; i--) {
    for (int j = K; j >= 0; j--) {
      for (int k = K; k >= 0; k--) {
        if ((i + j + k) == S) {
          sum++;
          break;
        }
      }
    }
  }

  cout << sum << endl;

  return 0;
}


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

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

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

  cout << sum << endl;

  return 0;
}
Problem p03835 (C++)

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

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

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

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

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

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

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

int main() {
  int k, s;
  int 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 += 1;
        }
      }
    }
  }
  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 i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      int z = s - i - j;
      if (0 <= z && z <= k) {
        count += 1;
      }
    }
  }
  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 < (int)(n); ++i)
using namespace std;
typedef long long ll;

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 < (int)(n); ++i)
using namespace std;
typedef long long ll;

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 (0 <= l && l <= 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 = 0;
  cin >> K >> S;

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

  cout << ans << endl;
  return 0;
}

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

int main() {

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

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

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

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

using namespace std;

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


Fixed submission:
#include <cstdio>

using namespace std;

int main() {
  int K;
  scanf("%d", &K);
  int S;
  scanf("%d", &S);
  int counter = 0;
  //(x, y) -> S-x-y=z -> 0<=z<=K
  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)
        counter++;
    }
  }
  printf("%d\n", counter);
  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;
}

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 (0 <= S - (x + y) && S - (x + y) <= K) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}
Problem p03835 (C++)

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

using namespace std;

int main() {
  long long ans = 0, i, j, k, K, S, X, Y, Z;

  cin >> K >> S;

  for (i = 0; (i <= K) && (i <= S); i++) {
    for (j = i; (j <= K) && (i + j <= S); j++) {
      for (k = j; (k <= K) && (i + j + k <= S); k++) {
        if (i + j + k == S) {
          if ((i == j) && (j == k) && (k == i))
            ans++;
          else if ((i == j) || (j == k) || (k == i))
            ans += 3;
          else
            ans += 6;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  long long ans = 0, i, j, k, K, S, X, Y, Z;

  cin >> K >> S;

  for (i = (S >= 2 * K ? S - 2 * K : 0); (i <= K) && (i <= S); i++) {
    for (j = i; (j <= K) && (i + j <= S); j++) {
      for (k = j; (k <= K) && (i + j + k <= S); k++) {
        if (i + j + k == S) {
          if ((i == j) && (j == k) && (k == i))
            ans++;
          else if ((i == j) || (j == k) || (k == i))
            ans += 3;
          else
            ans += 6;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

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

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

  int cnt = 0;

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


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

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

  int cnt = 0;

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#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 && j + k + i <= S; ++k) {
        if (i + j + k == S) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#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;
  ll 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;
using ll = long long;
using P = pair<int, int>;

int main() {
  int k, s;
  cin >> k >> s;
  ll ans = 0;
  for (int i = 0; i <= k; i++)
    for (int j = i; j <= k; j++)
      for (int l = j; l <= k; l++) {
        // cout << i << ' ' << j << ' ' << l;
        if (i + j + l == s) {
          // cout << " ok";
          if (i == j && j == l)
            ans++;
          if (l == i && i != j)
            ans += 3;
          if (i == j && j != l)
            ans += 3;
          if (j == l && l != i)
            ans += 3;
          if (i != j && j != l && l != i)
            ans += 6;
        }
        // cout << endl;
      }
  cout << ans << endl;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>
int main(void) {
  int K, S;
  std::cin >> K >> S;
  int a = 0, count = 0;
  for (int L1 = 0; L1 < K + 1; L1++) {
    if (L1 + K + K < S)
      continue;
    for (int L2 = 0; L2 < K + 1; L2++) {
      if (L1 + L2 + K < S)
        continue;
      for (int L3 = 0; L3 < K + 1; L3++)
        if (L3 + L1 + L2 == S) {
          count++;
          break;
        }
    }
  }
  std::cout << count << std::endl;
  system("pause");
}

Fixed submission:
#include <iostream>
#include <string>
int main(void) {
  int K, S;
  std::cin >> K >> S;
  int count = 0;
  for (int L1 = 0; L1 <= K; L1++)
    for (int L2 = 0; L2 <= K; L2++)
      if (S - L1 - L2 <= K && S - L1 - L2 >= 0)
        count++;
  std::cout << count << std::endl;
  system("pause");
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
/*2つの整数K,Sに対して x,y,z <= K, x + y + z = S
 * となるようなx,y,zの組み合わせは何通りありますか*/
using namespace std;

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


Fixed submission:
#include <iostream>
/*2つの整数K,Sに対して x,y,z <= K, x + y + z = S
 * となるようなx,y,zの組み合わせは何通りありますか*/
using namespace std;

int main() {
  int k, s, ans = 0;
  cin >> k >> s;
  if (3 * 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 <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define optimize_cin()                                                         \
  cin.tie(0);                                                                  \
  ios::sync_with_stdio(false)
#define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

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

  int cnt = 0;

  rep(X, K + 1) {
    rep(Y, K + 1) {
      rep(Z, K + 1) {
        if (X + Y + Z == S) {
          cnt++;
        }
      }
    }
  }

  cout << cnt << "\n";

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define optimize_cin()                                                         \
  cin.tie(0);                                                                  \
  ios::sync_with_stdio(false)
#define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

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

  int cnt = 0;

  rep(X, K + 1) {
    rep(Y, K + 1) {
      int Z = S - X - Y;
      if (0 <= Z && Z <= K) {
        cnt++;
      }
    }
  }

  cout << cnt << "\n";

  return 0;
}
Problem p03835 (C++)

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

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


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

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

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

using namespace std;
int main() {
  int K, S;
  cin >> K >> S;

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

  cout << count << endl;
  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;
int main() {
  int K, S;
  cin >> K >> S;

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

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

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

using namespace std;

int main() {

  int K, S, res = 0;

  cin >> K >> S;

  for (int i = 0; i <= K; i++) {
    if (i + K + K < S)
      continue;
    else if (i + K + K == S) {
      res++;
      continue;
    } else if (i + 0 + 0 > S)
      break;

    for (int j = 0; j <= K; j++) {
      if (i + j + K < S)
        continue;
      else if (i + j + K == S) {
        res++;
        continue;
      } else if (i + j + 0 > S)
        break;

      for (int k = 0; k <= K; k++) {
        if (i + j + k == S) {
          res++;
          continue;
        } else if (i + j + k > S)
          break;
      }
    }
  }

  cout << res << endl;
  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {

  int K, S, res = 0;

  cin >> K >> S;

  for (int i = 0; i <= K; i++) {
    if (i + K + K < S)
      continue;
    else if (i + K + K == S) {
      res++;
      continue;
    } else if (i + 0 + 0 > S)
      break;

    for (int j = 0; j <= K; j++) {
      if (i + j + K < S)
        continue;
      else if (i + j + K == S) {
        res++;
        continue;
      } else if (i + j + 0 > S)
        break;

      int q = S - i - j;
      if (q <= K && q >= 0)
        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, count = 0, sum;
  cin >> K >> S;
  int i, j, k;
  for (i = 0; i <= K; i++) {
    if (i > S)
      break;
    for (j = 0; j <= K; j++) {
      if (i + j > S)
        break;
      for (k = 0; k <= K; k++) {
        sum = i + j + k;
        if (sum == S) {
          count++;
          break;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}

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


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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define int long long
#define log(x, b) (log(x) / log(b))
using namespace std;

string s[101];

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

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

  cout << cnt << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define int long long
#define log(x, b) (log(x) / log(b))
using namespace std;

string s[101];

int32_t 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++) {
      int p = s - i - j;
      if (p >= 0 && p <= k)
        cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int k, s;
  cin >> k >> s;
  int sum = 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) {
          sum++;
        }
      }
    }
  }
  cout << sum;
  return 0;
}

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

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

int main() {
  int K;
  int 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;
  int S;
  cin >> K >> S;
  int count = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      if (0 <= S - x - y && S - x - y <= K) {
        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;

  return 0;
}


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

int main() {

  int k, s, ans = 0;

  cin >> k >> s;

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

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

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

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

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

  cout << count << endl;
}


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

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

  int count = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      int l = s - (i + j);
      if (0 <= l && l <= 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;
  int 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;
  int 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 (0 <= z && z <= k)
        n++;
    }
  }
  cout << n << endl;
}
Problem p03835 (C++)

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

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

  int count = 0;

  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int x = 0; x <= k; x++) {
        if (i + j + x == s)
          count++;
        else if (i + j + x >= 3 * k)
          break;
      }
    }
  }

  cout << count << endl;
}


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

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

  int count = 0;

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

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

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

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

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

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