alexjercan/bugnet huggingface dataset:
Problem p02640 (C++) — buggy submission, verdict: Time Limit Exceeded

// https://atcoder.jp/contests/abc170/tasks/abc170_b
#include <iostream>
// #include <bits/stdc++.h>
// #include "../../macro.h"
using namespace std;

/*
mm	:	tc(linear) sc(memo+stack)
                        idea-
                                        generate all combinations

                        TLE: without memorization
                        WA: with memorization

ba	:	tc(x) sc(array)
                        idea-
                                        let x=3 (animal) y=8 (legs total)
                                        crans possible, c = [0,1,2,3]
                                        turtle possible, t = [3,2,1,0]
                                        c, t contain possible number of crane &
turtle

                        iterate over i=0 to x+1
                                check if 2*c[i]+4*t[i] == y, then return true

*/
int memo[101];
void recursion(int x, int y, int animal, int legs, int &ans) {
  if (legs == y && animal == x) {
    ans = 1;
    return;
  }
  if (legs > y || animal > x) {
    return;
  }

  // memorization
  if (memo[legs] == -1) {
    memo[legs] = 1;
    recursion(x, y, animal + 1, legs + 2, ans);
    recursion(x, y, animal + 1, legs + 4, ans);
  }
}

int editorial(int x, int y) {
  int c[x + 1], t[x + 1];
  for (int i = 0; i < x + 1; i++) {
    c[i] = i;
    t[i] = x - i;
  }
  for (int i = 0; i < x + 1; i++) {
    if (2 * c[i] + 4 * t[i] == y)
      return 1;
  }
  return 0;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int x, y;
  cin >> x >> y;
  int ans = editorial(x, y);
  if (ans)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

#define px(x) cout << #x << "=" << x << endl;
#define pxln(x) cout << x << " ";
#define pxy(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl;
#define pxyz(x, y, z)                                                          \\
  cout << #x << "=" << x << ",\\t" << #y << "=" << y << ",\\t" << #z << "=" << z \\
       << endl;

int memo[101];

void recursion(int x, int y, int animal, int legs, int &ans) {
  if (legs == y && animal == x) {
    ans = 1;
    return;
  }
  if (legs > y || animal > x) {
    return;
  }

  {
    memo[legs] = 1;
    recursion(x, y, animal + 1, legs + 2, ans);
    recursion(x, y, animal + 1, legs + 4, ans);
  }
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int x, y;
  cin >> x >> y;
  int ans = 0;
  for (int i = 0; i < 101; i++)
    memo[i] = -1;
  recursion(x, y, 0, 0, ans);
  if (ans) {
    cout << "Yes";
  } else {
    cout << "No";
  }

  return 0;
}
Problem p02640 (C++) — buggy submission, verdict: Time Limit Exceeded

#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int X, Y;
  cin >> X >> Y;

  if (Y <= 1) {
    cout << "No" << endl;
    return 0;
  }

  if (Y % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  if ((double)Y / 4 > X) {
    cout << "No" << endl;
    return 0;
  }

  if (Y / 2 < X) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;

  return 0;
}


Error: TLE

Fixed submission:

#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

int X, Y;

bool dfs(vector<int> &v, int depth) {
  // ベースケース
  if (depth == v.size()) {
    int count = 0;
    rep(i, v.size()) { count += v[i] == 0 ? 2 : 4; }
    if (count == Y) {
      return true;
    } else {
      return false;
    }
  }

  // 再帰ステップ
  bool ok = false;

  rep(i, 2) {
    v[depth] = i;
    if (dfs(v, depth + 1)) {
      ok = true;
    }
  }
  return ok;
}

int main() {
  cin >> X >> Y;

  vector<int> v(X);
  if (dfs(v, 0)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}
Problem p02640 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
int main() {

  int x, y;
  cin >> x >> y;
  rep(i, x) {
    if (2 * i + 4 * (x - i) == y) {
      cout << "Yes  ";
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Error: 1

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
int main() {

  int x, y;
  cin >> x >> y;
  rep(i, x) {
    if (2 * i + 4 * (x - i) == y) {
      cout << "Yes  ";
      exit(1);
    }
  }
  cout << "No" << endl;
  return 0;
}
Problem p02640 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

#define MOD 1000000007
#define PI 3.141592653589793

typedef unsigned long long ull;
typedef long long ll;
using namespace std;

set<pair<int, int>> dp;
string ans = "No";
void func(int x, int y) {
  if (y < 0 || x < 0)
    return;
  if (!y && !x) {
    ans = "Yes";
    return;
  }
  if (dp.find({x - 1, y - 2}) == dp.end()) {
    dp.insert({x - 1, y - 2});
    func(x - 1, y - 2);
  }
  if (dp.find({x - 1, y - 4}) == dp.end()) {
    dp.insert({x - 1, y - 4});
    func(x - 1, y - 4);
  }
}

void testCase() {
  int x, y;
  cin >> x >> y;
  if (y & 1 || x * 4 < y || x * 2 > y) {
    cout << "No\\n";
    return;
  }
  cout << "Yes" << endl;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) {
    testCase();
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define MOD 1000000007
#define PI 3.141592653589793

typedef unsigned long long ull;
typedef long long ll;
using namespace std;

string ans = "No";
void func(int x, int y) {
  if (y < 0 || x < 0)
    return;
  if (!y && !x) {
    ans = "Yes";
    return;
  }
  func(x - 1, y - 2);
  func(x - 1, y - 4);
}

void testCase() {
  int x, y;
  cin >> x >> y;
  if (y & 1 || x * 4 < y) {
    cout << "No\\n";
    return;
  }
  func(x, y);
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) {
    testCase();
  }
}
Problem p02640 (C++) — buggy submission, verdict: Runtime Error

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

void t(string a);

int main() {

  bool istrue = false;
  int c, f;
  cin >> c >> f;
  cerr << c << f << endl;
  // if(f%2 == 1 || f > c*4 ) istrue = false;//奇数・足が多すぎるなら終了

  for (int i = 0; i <= c; i++) { // 動物の数だけ試行
    cerr << i << c << f << endl;
    // 亀
    if ((i * 4 + (c - i) * 2) == f) {
      cerr << "s" << endl;
      istrue = true;
      break;
    }
  }

  if (istrue == true)
    cout << "Yes" << endl;
  if (istrue == false)
    cout << "No" << endl;
}


Error: WA

Fixed submission:

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

int t(string a);

int main() {

  int c, f;
  cin >> c >> f;
  cerr << c << f << endl;
  if (f % 2 == 1 || f > c * 4)
    t("No"); // 奇数・足が多すぎるなら終了

  for (int i = 0; i <= c; i++) { // 動物の数だけ試行
    cerr << i << c << f << endl;
    // 亀
    if ((i * 4 + (c - i) * 2) % f == 0) {
      cerr << "s" << endl;
      t("Yes");

      break;
    }
  }
  t("No");
}

int t(string a) { cout << a << endl; }
Problem p02640 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define MOD 1000000007
#define mp make_pair
#define ll long long
#define pb push_back
#define faster                                                                 \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define debug cout << "Debugging.." << endl
using namespace std;
map<pair<int, int>, bool> m;
bool animal(int n, int x) {
  if (m.find({n, x}) != m.end())
    return m[{n, x}];
  if (x < 0)
    return false;
  if (n == 0 && x == 0)
    return true;
  if (n == 0 && x > 0)
    return false;

  if (n > 0 && x == 0)
    return false;

  return m[{n, x}] = animal(n - 1, x - 2) || animal(n - 1, x - 4);
}
int main() {
  faster;

  ll int n, x;
  cin >> n >> x;
  if (animal(n, x))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define MOD 1000000007
#define mp make_pair
#define ll long long
#define pb push_back
#define faster                                                                 \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define debug cout << "Debugging.." << endl
using namespace std;
bool animal(int n, int x) {
  if (x < 0)
    return false;
  if (n == 0 && x == 0)
    return true;
  if (n == 0 && x > 0)
    return false;

  if (n > 0 && x == 0)
    return false;

  return animal(n - 1, x - 2) || animal(n - 1, x - 4);
}
int main() {
  faster;

  ll int n, x;
  cin >> n >> x;
  if (animal(n, x))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p02640 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int X, Y, x, y;
  bool ans = false;
  cin >> X >> Y;

  if (X == 1) {
    if (Y == 4 || Y == 2) {
      ans = true;
    }
  } else {
    for (int i = 0; i < X + 1; i++) {
      x = i;     // 亀
      y = X - i; // 鶴
      if (x * 4 + y * 2 == Y) {
        ans = true;
        break;
      }
    }
  }

  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int X, Y, ans;
  bool x = false;
  cin >> X >> Y;

  if (X == 1) {
    if (Y == 4 || Y == 2) {
      x = true;
    }
  } else {
    for (int i = 0; i < pow(2, X); i++) {
      ans = 0;
      for (int j = 0; j < X; j++) {
        if ((i & (1 << j)) == 0) {
          ans += 4;
        } else {
          ans += 2;
        }
      }
      if (ans == Y) {
        x = true;
        goto OUT;
      }
    }
  }

OUT:
  if (x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}
Problem p02640 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll)(1e15)
#define mod (ll)(1e9 + 7)
#define endl "\\n"
#define tt                                                                     \\
  ll testcase;                                                                 \\
  cin >> testcase;                                                             \\
  while (testcase--)

const int mxn = 1 * (1e5) + 5;
ll n;

int solve() {
  ll x, y;
  cin >> x >> y;
  if ((4 * x - y >= 0) && ((4 * x - y) % 2 == 0)) {
    if (y % 2 == 0) {
      if ((y - 2 * x >= 0) && ((y - 2 * x) % 2 == 0)) {
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
  return 0;
}

int main() {
  fast;
  // tt
  solve();
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll)(1e15)
#define mod (ll)(1e9 + 7)
#define endl "\\n"
#define tt                                                                     \\
  ll testcase;                                                                 \\
  cin >> testcase;                                                             \\
  while (testcase--)

const int mxn = 1 * (1e5) + 5;
ll n;

int solve() {
  ll x, y;
  cin >> x >> y;
  if ((4 * x - y >= 0) && ((4 * x - y) % 2 == 0)) {
    if (y % 2 == 0) {
      if ((y - 2 * x >= 0) && ((y - 2 * x) % 2 == 0)) {
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
}

int main() {
  fast;
  // tt
  solve();
}
Problem p02640 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int X, Y;

bool dfs(int i, int sum) {
  if (i == X)
    return sum == Y;
  if (dfs(i + 1, sum + 2))
    return true;
  if (dfs(i + 1, sum + 4))
    return true;

  return false;
}

int main() {
  cin >> X >> Y;
  if (Y >= X * 2 && Y <= X * 4 && Y % 2 == 0) {
    if (dfs(0, 0))
      cout << "Yes";
  } else
    cout << "No";
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int X, Y;

bool dfs(int i, int sum) {
  if (i == X)
    return sum == Y;
  if (dfs(i + 1, sum + 2))
    return true;
  if (dfs(i + 1, sum + 4))
    return true;

  return false;
}

int main() {
  cin >> X >> Y;
  if (Y / 4 > X) {
    cout << "No";
    return 0;
  }
  if (dfs(0, 0))
    cout << "Yes";
  else
    cout << "No";
}
Problem p02640 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int X, Y;
  cin >> X >> Y;

  for (int i = 0; i <= X; i++) {
    if (i * 2 + (X - i) * 4 == Y) {
      cout << "Yes";
      return 0;
    }
  }

  cout << "No";
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

bool check(int X, int Y, int n) {
  if (Y == 0 && n == X)
    return true;
  if (Y < 0 || n > X)
    return false;

  bool b1 = check(X, Y - 2, n + 1);
  if (b1)
    return true;
  bool b2 = check(X, Y - 4, n + 1);
  if (b2)
    return true;

  return false;
}

int main() {
  int X, Y;
  cin >> X >> Y;
  bool b = check(X, Y, 0);
  if (b)
    cout << "Yes";
  else
    cout << "No";
}
Problem p02640 (C++) — buggy submission, verdict: 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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int X, Y;
bool ans = false;
void rec(int s, int n, int d) {
  if (n == 1) {
    int a = s - d;
    if (a == 0) {
      ans = true;
    }
    return;
  }
  rec(s - d, n - 1, 2);
  rec(s - d, n - 1, 4);
}
int main() {
  cin >> X >> Y;
  if (Y > 4 * X || Y % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }
  if (X * 2 > Y) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}

Error: TLE

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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int X, Y;
bool ans = false;
void rec(int s, int n, int d) {
  if (n == 1) {
    int a = s - d;
    if (a == 0) {
      ans = true;
    }
    return;
  }
  rec(s - d, n - 1, 2);
  rec(s - d, n - 1, 4);
}
int main() {

  cin >> X >> Y;
  rec(Y, X, 2);
  rec(Y, X, 4);
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
Problem p02640 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);

int dp[100][100];
bool solve(int x, int y) {

  if (x == 0 && y == 0) {
    return true;
  }

  if (x <= 0) {
    return false;
  }

  if (dp[x][y] != -1)
    return dp[x][y];

  int ans = solve(x - 1, y - 2) || solve(x - 1, y - 4);
  dp[x][y] = ans;
  return ans;
}

int main() {

  fastio;

  int x, y;
  cin >> x >> y;
  memset(dp, -1, sizeof(dp));
  if (solve(x, y)) {
    cout << "Yes";
  } else
    cout << "No";
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);

bool solve(int x, int y) {

  if (x == 0 && y == 0) {
    return true;
  }

  if (x <= 0) {
    return false;
  }
  return solve(x - 1, y - 2) || solve(x - 1, y - 4);
}

int main() {

  fastio;

  int x, y;
  cin >> x >> y;
  if (solve(x, y)) {
    cout << "Yes";
  } else
    cout << "No";
  return 0;
}
Problem p02640 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++) // rep(i,回数){処理}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int x, y;
  bool check = false;
  cin >> x >> y;
  rep(i, x + 1) {
    if (y == (((x - i) * 2) + (i * 4))) {
      check = true;
      break;
    }
  }
  if (check) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Error: 1

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++) // rep(i,回数){処理}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int x, y;
  cin >> x >> y;
  rep(i, x + 1) {
    if (y == (((x - i) * 2) + (i * 4))) {
      cout << "Yes" << endl;
      exit(1);
    }
  }
  cout << "No" << endl;
  return 0;
}
Problem p02640 (C++) — buggy submission, verdict: Runtime Error


#include <iostream>

using namespace std;

int main() {
  int x, y;
  double a;
  cin >> x >> y;
  a = (double)y / x;
  if (a <= 4 && a >= 2 && y > x && y % 2 == 0) {
    cout << "Yes";

  } else {
    cout << "No";
  }
  return 0;
}


Error: WA

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int x, y;
  cin >> x >> y;
  if (y / x <= 4) {
    if (y / x == 2 or y / x == 4) {
      cout << "Yes";
    } else {
      for (int i = 1; i <= x; i++) {
        if ((y - (i * 4)) / (x - i) == 2 or (y - (i * 2)) / (x - i) == 4) {
          cout << "Yes";
        } else {
          cout << "No";
        }
      }
    }

  } else {
    cout << "No";
  }
  return 0;
}
Problem p02640 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
bool so(int x, int y) {

  bool a[x + 1][y + 1];
  for (int i = 0; i <= y; i++)
    a[0][i] = false;
  for (int i = 0; i <= y; i++)
    if (i == 2 || i == 4)
      a[1][i] = true;
    else
      a[1][i] = false;
  for (int i = 2; i <= x; i++) {
    for (int j = 0; j <= y; j++) {
      a[i][j] = false;
      if (j >= 2)
        a[i][j] = (a[i][j] || a[i - 1][j - 2]);
      if (j >= 4)
        a[i][j] = (a[i][j] || a[i - 1][j - 4]);
    }
  }

  return a[x][y];
}
int main() {
  int x, y;
  cin >> x >> y;
  if (so(x, y))
    cout << "Yes";
  else
    cout << "No";
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
bool so(int x, int y) {
  if (x == 1 && (y == 2 || y == 4))
    return true;
  if (x == 0)
    return false;

  return (so(x - 1, y - 2) || so(x - 1, y - 4));
}
int main() {
  int x, y;
  cin >> x >> y;
  if (so(x, y))
    cout << "Yes";
  else
    cout << "No";
}
Problem p02640 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int X, Y, answer = 0;
  cin >> X >> Y;
  for (int i = 0; i <= X; i++) {
    int a = 2 * i + 4 * (X - i);
    if (a == Y) {
      cout << "Yes" << endl;
      answer = 1;
      break;
    }
  }
  if (answer == 0)
    cout << "No" << endl;
}

Error: 1

Fixed submission:

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

int main() {
  int X, Y;
  cin >> X >> Y;
  for (int i = 0; i <= X; i++) {
    int a = 2 * i + 4 * (X - i);
    if (a == Y) {
      cout << "Yes" << endl;
      exit(1);
    }
  }
  cout << "No" << endl;
}
Problem p02640 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int x, y, a, b;
  cin >> x >> y;
  if (y % 2 == 1) {
    cout << "No";
  } else {
    a = (y - 2 * x) / 2;
    b = (4 * x - y) / 2;
    if (a < 0 || b < 0) {
      cout << "No";
    } else {
      cout << "Yes";
    }
  }

  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int x, y, a, b;
  cin >> x >> y;
  if (y % 2 == 1) {
    cout << "No";
    return 1;
  }
  a = (y - 2 * x) / 2;
  b = (4 * x - y) / 2;
  if ((y - 2 * x) / 2 < 0 || (4 * x - y) / 2 < 0)
    cout << "No";
  else
    cout << "Yes";

  return 0;
}
Problem p02640 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

bool fun(int X, int Y, vector<int> &dp) {

  if (Y == 0 && X == 0)
    return true;
  if (X == 0 || Y < 2 * X || Y > 4 * X)
    return false;

  if (!dp[X])
    return false;
  if (fun(X - 1, Y - 2, dp)) {
    return true;
  }
  if (fun(X - 1, Y - 4, dp)) {
    return true;
  }

  dp[X] = false;
  return false;
}

bool fun2(int X, int Y) {
  int i, j;
  for (i = 0; i <= X; i++) {
    j = X - i;
    if (i * 2 + j * 4 == Y)
      return true;
  }
  return false;
}

void Sol2() {
  int X, Y;
  cin >> X >> Y;
  vector<int> dp(101, 1);

  bool ret = fun(X, Y, dp);
  // bool ret = fun2(X, Y);

  if (ret)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
int main() {
#define endl '\\n'
  std::ios::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(0);
  {
    // freopen("handmade09", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // Sol1();
    Sol2();
    // Sol3();
    // Sol4();
    // Sol5();
    // Sol6();
  }
  // cin.get();
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
bool fun(int X, int Y, vector<int> &dp) {

  if (Y == 0 && X == 0)
    return true;
  if (X == 0 || Y < 2 * X || Y > 4 * X)
    return false;

  //	if (!dp[X])
  //		return false;
  if (fun(X - 1, Y - 2, dp)) {
    return true;
  }
  if (fun(X - 1, Y - 4, dp)) {
    return true;
  }

  dp[X] = false;
  return false;
}

bool fun2(int X, int Y) {
  int i, j;
  for (i = 0; i <= X; i++) {
    j = X - i;
    if (i * 2 + j * 4 == Y)
      return true;
  }
  return false;
}

void Sol2() {
  int X, Y;
  cin >> X >> Y;
  vector<int> dp(101, 1);

  bool ret = fun(X, Y, dp);
  // bool ret = fun2(X, Y);

  if (ret)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
int main() {
#define endl '\\n'
  std::ios::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(0);
  {
    // freopen("handmade09", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // Sol1();
    Sol2();
    // Sol3();
    // Sol4();
    // Sol5();
    // Sol6();
  }
  // cin.get();
}