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

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

int main() {
  int K, S;
  cin >> K >> S;
  int X = 0;
  int Y = 0;
  int Z = 0;
  int res = 0;
  for (int i = 0; i <= K; i++) {
    X = i;
    for (int j = 0; j <= K; j++) {
      Y = j;
      for (int k = 0; k <= K; k++) {
        Z = k;
        if (X + Y + Z == S) {
          res++;
        }
      }
    }
  }

  cout << res << endl;
}

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

int main() {
  int K, S;
  cin >> K >> S;
  int X = 0;
  int Y = 0;
  int Z = 0;
  int res = 0;
  for (int i = 0; i <= K; i++) {
    X = i;
    for (int j = 0; j <= K; j++) {
      Y = j;
      Z = S - X - Y;
      if (0 <= Z && Z <= K) {
        res++;
      }
    }
  }

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

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

int K, S;

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

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


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

int K, S;

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

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

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iso646.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter, initial_value, condition)                                 \
  for (int counter = initial_value; counter < condition; counter++)

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


Fixed submission:
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iso646.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter, initial_value, condition)                                 \
  for (int counter = initial_value; counter < condition; counter++)

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

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

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

  scanf("%d", &K);
  scanf("%d", &S);

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

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

Fixed submission:
#include <stdio.h>

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

  scanf("%d", &K);
  scanf("%d", &S);

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

  printf("%d", cnt);
  return 0;
}
Problem p03835 (C++)

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

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

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

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

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

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

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


Fixed submission:
#include <iostream>

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

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

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

using namespace std;
typedef long long ll;

// マクロ
// forループ関係
// 引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   // 最大値を求める
#define MIN(x) *min_element(ALL(x))   // 最小値を求める
// 定数
#define INF 1000000000000 // 10^12:極めて大きい値,∞
#define MOD 10000007      // 10^9+7:合同式の法
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
// 略記
#define PB push_back // vectorヘの挿入
#define MP make_pair // pairのコンストラクタ
#define F first      // pairの一つ目の要素
#define S second     // pairの二つ目の要素

// for (auto& e : array)
// cout << count << endl;

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

  ll count = 0;

  REP(i, K + 1) {
    REP(j, K + 1) {
      REP(k, K + 1) {
        if ((i + j + k) == S)
          ++count;
      }
    }
  }

  cout << count << endl;
}
/*
REP(bit, (1 << N))
{
    vector<int> S;
    REP(i, N)
    {
        if (bit & (1 << i))
        { // 列挙に i が含まれるか
            S.push_back(i);
        }
    }

    for (auto& s: S)
    {
        int hon = S[i];
        REP(j, M)
        {
            R[j] = R[j] + A[hon][j];
        }
        price2 += C[hon];
    }
}
*/

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

using namespace std;
typedef long long ll;

// マクロ
// forループ関係
// 引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   // 最大値を求める
#define MIN(x) *min_element(ALL(x))   // 最小値を求める
// 定数
#define INF 1000000000000 // 10^12:極めて大きい値,∞
#define MOD 10000007      // 10^9+7:合同式の法
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
// 略記
#define PB push_back // vectorヘの挿入
#define MP make_pair // pairのコンストラクタ
#define F first      // pairの一つ目の要素
#define S second     // pairの二つ目の要素

// for (auto& e : array)
// cout << count << endl;

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

  ll count = 0;

  REP(i, K + 1) {
    REP(j, K + 1) {
      if (0 <= S - i - j && S - i - j <= K)
        ++count;
    }
  }

  cout << count << endl;
}
/*
REP(bit, (1 << N))
{
    vector<int> S;
    REP(i, N)
    {
        if (bit & (1 << i))
        { // 列挙に i が含まれるか
            S.push_back(i);
        }
    }

    for (auto& s: S)
    {
        int hon = S[i];
        REP(j, M)
        {
            R[j] = R[j] + A[hon][j];
        }
        price2 += C[hon];
    }
}
*/
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans;
  int k, s;
  scanf("%d%d", &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;
  // printf("%d",ans);
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans;
  int k, s;
  scanf("%d%d", &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;
  // printf("%d",ans);
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int k, s, cnt = 0;
int main() {
  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 k, s, cnt = 0;
int main() {
  cin >> k >> s;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      if (s - x - y >= 0 && s - x - y <= k)
        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, c = 0;
  cin >> K >> S;
  for (int i = 0; i < K + 1; i++) {
    for (int j = 0; j < K + 1; j++) {
      for (int k = 0; k < K + 1; k++) {
        if (i + j + k == S) {
          c += 1;
        }
      }
    }
  }
  cout << c;
}


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

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

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


Fixed submission:
#include <bits/stdc++.h>
#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++)
using namespace std;
const long long INF = 1e9 + 5;
typedef long long ll;

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

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

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

  int ans = 0;
  rep(l, k) {
    rep(m, k) {
      rep(n, k) {
        if (l + m + n == 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;
using ll = long long;

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

  int ans = 0;
  rep(l, k) {
    rep(m, k) {
      int n = s - l - m;
      if (0 <= n && n <= k)
        ans++;
    }
  }

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

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

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

  int count = 0;
  for (int x = 0; x < k + 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;
}

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 + 1; x++) {
    for (int y = 0; y < k + 1; y++) {
      if (s - x - y >= 0 && s - x - y <= k)
        count++;
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <iostream>
typedef long long int ll;
using namespace std;
#define INF 1LL << 60;

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 <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <iostream>
typedef long long int ll;
using namespace std;
#define INF 1LL << 60;

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

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

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

int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  rep(a, k + 1) rep(b, k + 1) rep(c, k + 1) {
    if (a + b + c == s)
      cnt++;
  }
  cout << cnt;
}


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

int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  rep(a, k + 1) rep(b, k + 1) {
    int c = s - a - b;
    if (c >= 0 && c <= k)
      cnt++;
  }
  cout << cnt;
}
Problem p03835 (C++)

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

int main() {
  ios::sync_with_stdio(false);
  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 <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  int k, s, ans = 0;
  cin >> k >> s;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = s - (x + y);
      if (0 <= z && z <= k) {
        // printf("%d %d %d\n", x, y, z);
        ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
// ------------------------------------
// Date:2018/ 2/26
// Problem:ABC 051 SumOfThreeIntegers b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i, a) for (auto &&i : a)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RFOR(i, a, b) for (int i = (int)b - 1; i >= (int)a; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

#define MOD 1000000007

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


Fixed submission:
// ------------------------------------
// Date:2018/ 2/26
// Problem:ABC 051 SumOfThreeIntegers b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i, a) for (auto &&i : a)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RFOR(i, a, b) for (int i = (int)b - 1; i >= (int)a; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

#define MOD 1000000007

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

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

using namespace std;

int main(void) {
  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 <cstdio>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

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

  cout << cnt << endl;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
// #include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);
ll sum = 0;
int k, s;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(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)
          sum++;
      }
    }
  }
  cout << sum << endl;
}

Fixed submission:
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
// #include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);
ll sum = 0;
int k, s;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(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)
        sum++;
    }
  }
  cout << sum << endl;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iomanip>
#include <ios>
#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 <iomanip>
#include <ios>
#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++) {
      if (0 <= s - i - j && s - i - j <= k) {
        ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
// include
//------------------------------------------
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

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

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


Fixed submission:
// include
//------------------------------------------
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

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

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

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

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;
typedef long long ll;

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

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

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

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

using namespace std;

int main() {
  int k, s;
  cin >> k >> s;
  int cnt = 0, z;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      z = s - (x + y); // 仮定する
      if (s - (x + y) <= k && z >= 0) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p03835 (C++)

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

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

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

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (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(void) {
  // Your code here!
  int K, S;
  cin >> K >> S;
  int sum = 0;

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

  cout << sum;
}


Fixed submission:
#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  int K, S;
  cin >> K >> S;
  int sum = 0;

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

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

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

  return 0;
}
Problem p03835 (C++)

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

using namespace std;

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

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

  cout << count << endl;

  return 0;
}


Fixed submission:
#include <iostream>

using namespace std;

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

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

  cout << count << endl;

  return 0;
}
Problem p03835 (C++)

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

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


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

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

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

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

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

  cout << counter;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;

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

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

  cout << 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 ans = 0;
  for (int i = 0; i < K + 1; i++) {
    for (int j = 0; j < K + 1; j++) {
      for (int k = 0; k < K + 1; k++) {
        if (i + j + k == S)
          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 + 1; i++) {
    for (int j = 0; j < K + 1; j++) {
      int k = S - i - j;
      if (0 <= k and k <= 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++) {
        if (x + y + z == S)
          count++;
      }
    }
  }

  cout << count << endl;

  return 0;
}


Fixed submission:
#include <iostream>

using namespace std;

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

  int count = 0;

  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      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 <cmath>
#include <fstream>
#include <iostream>
#include <string>
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++;
          break;
        }
      }
    }
  }

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

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

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

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

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

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

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

  for (int i = 0; i <= K; ++i) {
    X = i;
    for (int j = 0; j <= K; ++j) {
      Y = j;
      for (int k = 0; k <= K; ++k) {
        Z = k;
        if (X + Y + Z == S)
          count++;
      }
    }
  }
  std::cout << count;
  return 0;
}


Fixed submission:
#include <iostream>

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

  for (int i = 0; i <= K; ++i) {
    X = i;
    for (int j = 0; j <= K; ++j) {
      Y = j;
      Z = S - X - Y;
      if (0 <= Z && Z <= K)
        count++;
    }
  }
  std::cout << count;
  return 0;
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#ifdef DEBUG

#else

#pragma GCC optimize("O3,no-stack-protector")
#pragma GCC optimize("unroll-loops")

#if __cplusplus < 201703L
#pragma GCC target("avx")
#else
#pragma GCC target("avx2")
#endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

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

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

  cout << ans << endl;

  return 0;
}


Fixed submission:
#ifdef DEBUG

#else

#pragma GCC optimize("O3,no-stack-protector")
#pragma GCC optimize("unroll-loops")

#if __cplusplus < 201703L
#pragma GCC target("avx")
#else
#pragma GCC target("avx2")
#endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

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

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

  cout << ans << endl;

  return 0;
}
Problem p03835 (C++)

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

using namespace std;

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

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

  int S;
  cin >> S;

  int count = 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) {
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}
Problem p03835 (C++)

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

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  rep(i, k + 1) {
    rep(j, k + 1) {
      rep(m, k + 1) {
        if (i + j + m == s)
          ans++;
      }
    }
  }
  cout << ans << "\n";
}


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

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  rep(i, k + 1) {
    rep(j, k + 1) {
      int m = s - i - j;
      if (0 <= m && m <= k)
        ans++;
    }
  }
  cout << ans << "\n";
}
Problem p03835 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<string>> ve_ves;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep2(i, n) for (int i = 2; i < (int)(n); i++)
#define fs first
#define sc second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<string>> ve_ves;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep2(i, n) for (int i = 2; i < (int)(n); i++)
#define fs first
#define sc second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

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

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

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

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

  cout << ans << endl;
}

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

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

Buggy submission (status: Runtime Error):
#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 SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend()) // vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int> vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int dx = tx - sx, dy = ty - sy;

  cout << string(dy, 'U') << string(sx, 'R');
  cout << string(dy, 'D') << string(sx, 'L');
  cout << 'L' << string(dy + 1, 'U') << string(sx + 1, 'R') << 'D';
  cout << 'R' << string(dy + 1, 'D') << string(sx + 1, 'L') << 'U';
  cout << endl;
}

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 SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend()) // vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int> vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int dx = tx - sx, dy = ty - sy;

  cout << string(dy, 'U') << string(dx, 'R');
  cout << string(dy, 'D') << string(dx, 'L');
  cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';
  cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U';
  cout << endl;
}
Problem p03836 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(int argc, char **argv) {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  int dx = tx - sx;
  int dy = ty - sx;

  std::cout << string(dy, 'U') << string(dx, 'R');

  std::cout << string(dy, 'D') << string(dx, 'L');

  cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';

  cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U' << endl;
}


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

int main(int argc, char **argv) {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  int dx = tx - sx;
  int dy = ty - sy;

  std::cout << string(dy, 'U') << string(dx, 'R');

  std::cout << string(dy, 'D') << string(dx, 'L');

  cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';

  cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U' << endl;
}
Problem p03836 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rer(i, l, u) for (int(i) = (int)(l); (i) <= (int)(u); ++(i))
#define reu(i, l, u) for (int(i) = (int)(l); (i) < (int)(u); ++(i))

int main() {
  int s1, s2, t1, t2;
  cin >> s1 >> s2 >> t1 >> t2;
  vector<string> vec(10000);

  int a, b;
  a = t1 - s1;
  b = t2 - s1;

  rep(i, a + 1) vec.at(i) = 'R';
  reu(i, a + 1, a + 1 + b) vec.at(i) = 'U';
  reu(i, a + 1 + b, 2 * a + 3 + b) vec.at(i) = 'L';
  reu(i, 2 * a + 3 + b, 2 * a + 3 + 2 * b) vec.at(i) = 'D';
  vec.at(2 * a + 3 + 2 * b) = 'R';
  vec.at(2 * a + 4 + 2 * b) = 'U';
  reu(i, 2 * a + 5 + 2 * b, 3 * a + 5 + 2 * b) vec.at(i) = 'R';
  reu(i, 3 * a + 5 + 2 * b, 3 * a + 5 + 3 * b) vec.at(i) = 'U';

  rep(i, 3 * a + 5 + 3 * b) cout << vec.at(i);
}


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

int main() {
  int sx;
  int sy;
  int tx;
  int ty;
  cin >> sx >> sy >> tx >> ty;
  int x = tx - sx, y = ty - sy;
  string ans;
  rep(i, x) ans += 'R';
  rep(i, y) ans += 'U';
  rep(i, x) ans += 'L';
  rep(i, y) ans += 'D';
  ans += 'L';
  rep(i, y + 1) ans += 'U';
  rep(i, x + 1) ans += 'R';
  ans += 'D';
  ans += 'R';
  rep(i, y + 1) ans += 'D';
  rep(i, x + 1) ans += 'L';
  ans += 'U';
  cout << ans;
}
Problem p03836 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <map>
#include <random>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#pragma warning(disable : 4996)

char s[2048];
char t[8192];

int main(void) {
  int sx, sy, tx, ty;
  scanf("%d %d %d %d", &sx, &sy, &tx, &ty);

  char *p = &s[0];
  for (int y = sy; y < ty; ++y) {
    if (ty > sy) {
      *(p++) = 'U';
    } else {
      *(p++) = 'D';
    }
  }
  for (int x = sx; x < tx; ++x) {
    if (tx > sx) {
      *(p++) = 'R';
    } else {
      *(p++) = 'L';
    }
  }
  *(p++) = '\0';
  strcpy(t, s);
  int len = strlen(s);
  p = t + len;
  for (int i = 0; i < len; ++i) {
    if (s[i] == 'U')
      *(p++) = 'D';
    if (s[i] == 'D')
      *(p++) = 'U';
    if (s[i] == 'R')
      *(p++) = 'L';
    if (s[i] == 'L')
      *(p++) = 'R';
  }
  char *r = p;
  if (tx > sx) {
    *(p++) = 'L';
  } else {
    *(p++) = 'R';
  }
  char c = s[0];
  for (int i = 0; i < len; ++i) {
    *(p++) = s[i];
    if ((i + 1 < len) && (s[i] != s[i + 1])) {
      *(p++) = s[i];
      *(p++) = s[i + 1];
    }
    if (!(i + 1 < len)) {
      if (ty > sy) {
        *(p++) = 'D';
      } else {
        *(p++) = 'U';
      }
    }
  }
  *p = '\0';
  len = strlen(r);
  for (int i = 0; i < len; ++i) {
    if (*(r + i) == 'U')
      *(p++) = 'D';
    if (*(r + i) == 'D')
      *(p++) = 'U';
    if (*(r + i) == 'R')
      *(p++) = 'L';
    if (*(r + i) == 'L')
      *(p++) = 'R';
  }
  *(p++) = '\0';
  printf("%s", t);
  return 0;
}


Fixed submission:
#include <algorithm>
#include <map>
#include <random>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#pragma warning(disable : 4996)

char s[4096];
char t[16384];

int main(void) {
  int sx, sy, tx, ty;
  scanf("%d %d %d %d", &sx, &sy, &tx, &ty);

  char *p = &s[0];
  for (int y = sy; y < ty; ++y) {
    if (ty > sy) {
      *(p++) = 'U';
    } else {
      *(p++) = 'D';
    }
  }
  for (int x = sx; x < tx; ++x) {
    if (tx > sx) {
      *(p++) = 'R';
    } else {
      *(p++) = 'L';
    }
  }
  *(p++) = '\0';
  strcpy(t, s);
  int len = strlen(s);
  p = t + len;
  for (int i = 0; i < len; ++i) {
    if (s[i] == 'U')
      *(p++) = 'D';
    if (s[i] == 'D')
      *(p++) = 'U';
    if (s[i] == 'R')
      *(p++) = 'L';
    if (s[i] == 'L')
      *(p++) = 'R';
  }
  char *r = p;
  if (tx > sx) {
    *(p++) = 'L';
  } else {
    *(p++) = 'R';
  }
  char c = s[0];
  for (int i = 0; i < len; ++i) {
    *(p++) = s[i];
    if ((i + 1 < len) && (s[i] != s[i + 1])) {
      *(p++) = s[i];
      *(p++) = s[i + 1];
    }
    if (!(i + 1 < len)) {
      if (ty > sy) {
        *(p++) = 'D';
      } else {
        *(p++) = 'U';
      }
    }
  }
  *p = '\0';
  len = strlen(r);
  for (int i = 0; i < len; ++i) {
    if (*(r + i) == 'U')
      *(p++) = 'D';
    if (*(r + i) == 'D')
      *(p++) = 'U';
    if (*(r + i) == 'R')
      *(p++) = 'L';
    if (*(r + i) == 'L')
      *(p++) = 'R';
  }
  *(p++) = '\0';
  printf("%s", t);
  return 0;
}
Problem p03836 (C++)

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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  const int dx = tx - sx, dy = ty - tx;
  cout << string(dy, 'U') << string(dx, 'R');
  cout << string(dy, 'D') << string(dx, 'L');
  cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';
  cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U';
  cout << endl;
}


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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  const int dx = tx - sx, dy = ty - sy;
  cout << string(dy, 'U') << string(dx, 'R');
  cout << string(dy, 'D') << string(dx, 'L');
  cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';
  cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U';
  cout << endl;
}