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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAX = 300005;
int n, k, seq[MAX];
void dec(int x) {
  if (seq[x] == 0) {
    dec(x - 1);
  } else {
    seq[x]--;
    if (seq[x] != 0)
      for (int i = x + 1; i <= n; i++)
        seq[i] = k;
  }
}
int main() {
  scanf("%d%d", &k, &n);
  if (k % 2 == 0) {
    seq[1] = k / 2;
    for (int i = 2; i <= n; i++)
      seq[i] = k;
  } else {
    for (int i = 1; i <= n; i++)
      seq[i] = (k + 1) / 2;
    for (int i = 1; i <= n / 2; i++)
      dec(n);
  }
  for (int i = 1; i <= n && seq[i] != 0; i++)
    printf("%d ", seq[i]);
  printf("\n");
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAX = 300005;
int n, k, seq[MAX];
void dec(int x) {
  if (seq[x] == 0) {
    dec(x - 1);
  } else {
    seq[x]--;
    if (seq[x] != 0)
      for (int i = x + 1; i <= n; i++)
        seq[i] = k;
  }
}
int main() {
  scanf("%d%d", &k, &n);
  if (k == 1) {
    for (int i = 1; i <= n - n / 2; i++)
      seq[i] = k;
  } else if (k % 2 == 0) {
    seq[1] = k / 2;
    for (int i = 2; i <= n; i++)
      seq[i] = k;
  } else {
    for (int i = 1; i <= n; i++)
      seq[i] = (k + 1) / 2;
    for (int i = 1; i <= n / 2; i++)
      dec(n);
  }
  for (int i = 1; i <= n && seq[i] != 0; i++)
    printf("%d ", seq[i]);
  printf("\n");
}
Problem p03561 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const double eps = 1e-9;
const int maxn = 3e5 + 10;
int ans[maxn];
inline int read() {
  int x = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-')
    ch = getchar();
  if (ch == '-')
    flag = -1, ch = getchar();
  while (isdigit(ch))
    x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return x * flag;
}
int main() {
  int i, j, k, m, n;
  n = read();
  k = read();
  if (n % 2 == 0) {
    printf("%d", n / 2);
    for (i = 2; i <= k; i++)
      printf(" %d", n);
    puts("");
    return 0;
  }
  for (i = 1; i <= k; i++)
    ans[i] = (n + 1) / 2;
  int tmp = k;
  tmp = k / 2;
  while (tmp--) {
    if (ans[k] >= 0)
      ans[k]--;
    int pos = k;
    while (ans[pos] == 0) {
      if (tmp == 0)
        break;
      else
        tmp--;
      for (i = pos; i <= k; i++)
        ans[i] = n;
      ans[pos - 1]--;
      pos--;
    }
  }
  for (i = 1; i <= k; i++) {
    if (ans[i] == 0)
      break;
    printf("%d ", ans[i]);
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const double eps = 1e-9;
const int maxn = 3e5 + 10;
int ans[maxn];
inline int read() {
  int x = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-')
    ch = getchar();
  if (ch == '-')
    flag = -1, ch = getchar();
  while (isdigit(ch))
    x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return x * flag;
}
int main() {
  int i, j, k, m, n;
  n = read();
  k = read();
  if (n == 1) {
    for (i = 1; i <= (k + 1) / 2; i++)
      printf("1 ");
    puts("");
    return 0;
  }
  if (n % 2 == 0) {
    printf("%d", n / 2);
    for (i = 2; i <= k; i++)
      printf(" %d", n);
    puts("");
    return 0;
  }
  for (i = 1; i <= k; i++)
    ans[i] = (n + 1) / 2;
  int tmp = k;
  tmp = k / 2;
  while (tmp--) {
    if (ans[k] >= 0)
      ans[k]--;
    int pos = k;
    while (ans[pos] == 0) {
      if (tmp == 0)
        break;
      else
        tmp--;
      for (i = pos; i <= k; i++)
        ans[i] = n;
      ans[pos - 1]--;
      pos--;
    }
  }
  for (i = 1; i <= k; i++) {
    if (ans[i] == 0)
      break;
    printf("%d ", ans[i]);
  }
  return 0;
}
Problem p03561 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x, y, h, w) x >= 0 && x < h &&y >= 0 && y < w
using namespace std;

#define int long long
// typedef    long long          ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef pair<int, int> P;

const int INF = 1e+9;
const double EPS = 1e-9;
const int MOD = 1000000007;

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

signed main() {
  int n, k, a[300010], flag = 1;
  cin >> k >> n;
  if (k % 2 == 0) {
    for (int i = 0; i < n; i++)
      printf("%s%lld", (i ? " " : ""), (i ? k : k / 2));
    cout << endl;
    return 0;
  }
  for (int i = 0; i < n; i++)
    flag = (flag * k + 1) % 2;
  for (int i = 0; i < n; i++)
    a[i] = k / 2 + 1;
  flag = (flag + 1) % 2;
  for (int i = 0; i < n / 2; i++) {
    int pos = n - 1;
    while (!a[pos])
      pos--;
    a[pos]--;
    if (a[pos]) {
      pos++;
      while (pos < n)
        a[pos++] = k;
    }
  }
  for (int i = 0; i < n && a[i]; i++)
    printf("%s%lld", (i ? " " : ""), a[i]);
  cout << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x, y, h, w) x >= 0 && x < h &&y >= 0 && y < w
using namespace std;

#define int long long
// typedef    long long          ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef pair<int, int> P;

const int INF = 1e+9;
const double EPS = 1e-9;
const int MOD = 1000000007;

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

signed main() {
  int n, k, a[300010], flag = 1;
  cin >> k >> n;
  if (k % 2 == 0) {
    for (int i = 0; i < n; i++)
      printf("%s%lld", (i ? " " : ""), (i ? k : k / 2));
    cout << endl;
    return 0;
  } else if (k == 1) {
    for (int i = 0; i < (n + 1) / 2; i++)
      printf("%s%lld", (i ? " " : ""), 1);
    cout << endl;
    return 0;
  }
  for (int i = 0; i < n; i++)
    flag = (flag * k + 1) % 2;
  for (int i = 0; i < n; i++)
    a[i] = k / 2 + 1;
  flag = (flag + 1) % 2;
  for (int i = 0; i < n / 2; i++) {
    int pos = n - 1;
    while (!a[pos])
      pos--;
    a[pos]--;
    if (a[pos]) {
      pos++;
      while (pos < n)
        a[pos++] = k;
    }
  }
  for (int i = 0; i < n && a[i]; i++)
    printf("%s%lld", (i ? " " : ""), a[i]);
  cout << endl;
  return 0;
}
Problem p03561 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>
#include <iostream>
#define MN 300000
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, K, a[MN + 5];
int Del(int x) {
  --a[x];
  if (a[x] < 0)
    a[x] = K, Del(x - 1);
  else if (a[x] == 0)
    for (int i = x + 1; i <= n; ++i)
      a[i] = 0;
}
int main() {
  K = read();
  n = read();
  if (~K & 1)
    for (int i = 1; i <= n; ++i)
      printf("%d ", i == 1 ? K / 2 : K);
  else {
    for (int i = 1; i <= n; ++i)
      a[i] = K / 2 + 1;
    int d = n >> 1;
    for (int t = 1; t <= d; ++t)
      Del(n);
    for (; a[n] == 0; --n)
      ;
    for (int i = 1; i <= n; ++i)
      printf("%d ", a[i]);
  }
  return 0;
}


Fixed submission:
#include <cstdio>
#include <iostream>
#define MN 300000
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, K, a[MN + 5];
int Del(int x) {
  --a[x];
  if (a[x] < 0)
    a[x] = K, Del(x - 1);
  else if (a[x] == 0)
    for (int i = x + 1; i <= n; ++i)
      a[i] = 0;
}
int main() {
  K = read();
  n = read();
  if (K == 1)
    for (int i = 1; i <= n + 1 >> 1; ++i)
      printf("1 ");
  else if (~K & 1)
    for (int i = 1; i <= n; ++i)
      printf("%d ", i == 1 ? K / 2 : K);
  else {
    for (int i = 1; i <= n; ++i)
      a[i] = K / 2 + 1;
    int d = n >> 1;
    for (int t = 1; t <= d; ++t)
      Del(n);
    for (; a[n] == 0; --n)
      ;
    for (int i = 1; i <= n; ++i)
      printf("%d ", a[i]);
  }
  return 0;
}
Problem p03561 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int a[120000], n, k;
int del() {
  int top = n;
  while (a[top] == 0)
    top--;
  if (a[top] == 1) {
    a[top] = 0;
    return 0;
  }
  a[top]--;
  for (int i = top + 1; i <= n; i++)
    a[i] = k;
}
int main() {
  scanf("%d%d", &k, &n);
  if (k == 1) {
    for (int i = 1; i <= (n + 1) / 2; i++)
      printf("1 ");
    return 0;
  }
  if (k % 2 == 0) {
    printf("%d ", k / 2);
    for (int i = 1; i < n; i++)
      printf("%d ", k);
  }
  if (k % 2 == 1) {
    for (int i = 1; i <= n; i++)
      a[i] = (k + 1) / 2;
    for (int i = 1; i <= n / 2; i++)
      del();
    for (int i = 1; i <= n; i++)
      if (a[i] != 0)
        printf("%d ", a[i]);
  }
}


Fixed submission:
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int a[520000], n, k;
int del() {
  int top = n;
  while (a[top] == 0)
    top--;
  if (a[top] == 1) {
    a[top] = 0;
    return 0;
  }
  a[top]--;
  for (int i = top + 1; i <= n; i++)
    a[i] = k;
}
int main() {
  scanf("%d%d", &k, &n);
  if (k == 1) {
    for (int i = 1; i <= (n + 1) / 2; i++)
      printf("1 ");
    return 0;
  }
  if (k % 2 == 0) {
    printf("%d ", k / 2);
    for (int i = 1; i < n; i++)
      printf("%d ", k);
  }
  if (k % 2 == 1) {
    for (int i = 1; i <= n; i++)
      a[i] = (k + 1) / 2;
    for (int i = 1; i <= n / 2; i++)
      del();
    for (int i = 1; i <= n; i++)
      if (a[i] != 0)
        printf("%d ", a[i]);
  }
}
Problem p03561 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#pragma comment(linker, "/STACK:336777216")

using namespace std;

const int MAXN = 100000 + 10;

int K, N;
int ans[MAXN];

void Work() {
  scanf("%d%d", &K, &N);

  if (K % 2 == 0) {
    printf("%d", K / 2);
    for (int i = 0; i < N - 1; i++)
      printf(" %d", K);
    printf("\n");
    return;
  }

  if (K == 1) {
    int r = (N + 1) / 2;
    printf("1");
    for (int i = 0; i < r - 1; i++)
      printf(" 1");
    printf("\n");
    return;
  }

  for (int i = 0; i < N; i++)
    ans[i] = (K + 1) / 2;
  int cur = N / 2;
  for (int r = 0; r < cur; r++) {
    int j = N - 1;
    while (ans[j] == 0)
      j--;
    ans[j]--;
    if (ans[j] != 0) {
      for (int i = j + 1; i < N; i++)
        ans[i] = K;
    }
  }

  printf("%d", ans[0]);
  for (int i = 1; i < N; i++) {
    if (ans[i] == 0)
      break;
    printf(" %d", ans[i]);
  }
  printf("\n");
}

int main() {
  Work();
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#pragma comment(linker, "/STACK:336777216")

using namespace std;

const int MAXN = 300000 + 10;

int K, N;
int ans[MAXN];

void Work() {
  scanf("%d%d", &K, &N);

  if (K % 2 == 0) {
    printf("%d", K / 2);
    for (int i = 0; i < N - 1; i++)
      printf(" %d", K);
    printf("\n");
    return;
  }

  if (K == 1) {
    int r = (N + 1) / 2;
    printf("1");
    for (int i = 0; i < r - 1; i++)
      printf(" 1");
    printf("\n");
    return;
  }

  for (int i = 0; i < N; i++)
    ans[i] = (K + 1) / 2;
  int cur = N / 2;
  for (int r = 0; r < cur; r++) {
    int j = N - 1;
    while (ans[j] == 0)
      j--;
    ans[j]--;
    if (ans[j] != 0) {
      for (int i = j + 1; i < N; i++)
        ans[i] = K;
    }
  }

  printf("%d", ans[0]);
  for (int i = 1; i < N; i++) {
    if (ans[i] == 0)
      break;
    printf(" %d", ans[i]);
  }
  printf("\n");
}

int main() {
  Work();
  return 0;
}
Problem p03561 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string.h>
#define maxn 100005
using namespace std;
int k, n;
int ans[maxn];
int main() {
  scanf("%d%d", &k, &n);
  if (!(k & 1)) {
    printf("%d", k / 2);
    for (int i = 2; i <= n; i++)
      printf(" %d", k);
    return 0;
  }
  for (int i = 1; i <= n; i++)
    ans[i] = (k + 1) / 2;

  int top = n;
  for (int i = 1; i <= n / 2; i++) {
    if (ans[top] == 1)
      top--;
    else {
      ans[top]--;
      for (int i = top + 1; i <= n; i++)
        ans[i] = k;
      top = n;
    }
  }
  for (int i = 1; i <= top; i++)
    printf("%d ", ans[i]);
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string.h>
#define maxn 300005
using namespace std;
int k, n;
int ans[maxn];
int main() {
  scanf("%d%d", &k, &n);
  if (!(k & 1)) {
    printf("%d", k / 2);
    for (int i = 2; i <= n; i++)
      printf(" %d", k);
    return 0;
  }
  for (int i = 1; i <= n; i++)
    ans[i] = (k + 1) / 2;

  int top = n;
  for (int i = 1; i <= n / 2; i++) {
    if (ans[top] == 1)
      top--;
    else {
      ans[top]--;
      for (int i = top + 1; i <= n; i++)
        ans[i] = k;
      top = n;
    }
  }
  for (int i = 1; i <= top; i++)
    printf("%d ", ans[i]);
}
Problem p03561 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define syosu(x) fixed << setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int, P> pip;
typedef vector<pip> vip;
const int inf = 1 << 30;
const ll INF = 1ll << 60;
const double pi = acos(-1);
const double eps = 1e-10;
const ll mod = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

int k, n;

int main() {
  cin >> k >> n;
  vi a;
  if (n == 1)
    a = vi(n, (k + 1) / 2);
  else if (k % 2 == 0) {
    a = vi(n, k);
    a[0] = k / 2;
  } else {
    a = vi(n, k / 2 + 1);
    int t = n - 1;
    for (int i = 1; i < n; i++)
      (t += i) %= 2;
    t = (n - (t * k / 2 + n) % 2) / 2;
    assert(k < 3);
    for (int i = 0; i < t; i++) {
      int l = 0, r = n;
      while (r - l > 1) {
        int m = (l + r) / 2;
        if (a[m])
          l = m;
        else
          r = m;
      }
      a[l++]--;
      if (a[l - 1])
        while (l < n)
          a[l++] = k;
    }
  }
  cout << a[0];
  for (int i = 1; i < n && a[i]; i++)
    cout << ' ' << a[i];
  cout << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define syosu(x) fixed << setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int, P> pip;
typedef vector<pip> vip;
const int inf = 1 << 30;
const ll INF = 1ll << 60;
const double pi = acos(-1);
const double eps = 1e-10;
const ll mod = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

int k, n;

int main() {
  cin >> k >> n;
  vi a;
  if (n == 1)
    a = vi(n, (k + 1) / 2);
  else if (k % 2 == 0) {
    a = vi(n, k);
    a[0] = k / 2;
  } else {
    a = vi(n, k / 2 + 1);
    for (int i = 0; i < n / 2; i++) {
      int l = 0, r = n;
      while (r - l > 1) {
        int m = (l + r) / 2;
        if (a[m])
          l = m;
        else
          r = m;
      }
      a[l++]--;
      if (a[l - 1])
        while (l < n)
          a[l++] = k;
    }
  }
  cout << a[0];
  for (int i = 1; i < n && a[i]; i++)
    cout << ' ' << a[i];
  cout << endl;
}
Problem p03561 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

const ll INF = 1e9;

void out(VI &ans) {
  REP(i, ans.size()) {
    if (ans[i] == 0)
      break;
    printf("%d ", ans[i]);
  }
  cout << endl;
}

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

  if (n % 2 == 0) {
    printf("%d ", n / 2);
    REP(i, k - 1) printf("%d ", n);
    cout << endl;
    return 0;
  }

  VI ans(k, (n + 1) / 2);
  int d = k / 2;
  REP(i, d) {
    int j = k - 1;
    while (ans[j] == 0)
      j--;
    ans[j]--;
    if (ans[j] > 0) {
      j++;
      while (j < k)
        ans[j++] = n;
    }
    // out(ans);
  }

  out(ans);

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

const ll INF = 1e9;

void out(VI &ans) {
  REP(i, ans.size()) {
    if (ans[i] == 0)
      break;
    printf("%d ", ans[i]);
  }
  cout << endl;
}

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

  if (n % 2 == 0) {
    printf("%d ", n / 2);
    REP(i, k - 1) printf("%d ", n);
    cout << endl;
    return 0;
  }

  if (n == 1) {
    VI ans((k + 1) / 2, 1);
    out(ans);
    return 0;
  }

  VI ans(k, (n + 1) / 2);
  int d = k / 2;
  REP(i, d) {
    int j = k - 1;
    while (ans[j] == 0)
      j--;
    ans[j]--;
    if (ans[j] > 0) {
      j++;
      while (j < k)
        ans[j++] = n;
    }
    // out(ans);
  }

  out(ans);

  return 0;
}
Problem p03561 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
// INSERT ABOVE HERE
template <typename T> signed size(T x) { return x.size(); }
signed main() {
  Int k, n;
  cin >> k >> n;
  if (k % 2 == 0) {
    cout << k / 2;
    for (Int i = 1; i < n; i++)
      cout << " " << k;
    cout << endl;
    return 0;
  }
  vector<Int> ans(n, (k + 1) / 2);
  for (Int i = 0; i < n / 2; i++) {
    if (ans.back() == 1)
      ans.pop_back();
    else {
      ans.back()--;
      while (size(ans) < n)
        ans.emplace_back(k);
    }
  }
  for (Int i = 0; i < size(ans); i++) {
    if (i)
      cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
// INSERT ABOVE HERE
template <typename T> signed size(const T &x) { return x.size(); }
signed main() {
  Int k, n;
  cin >> k >> n;
  if (k % 2 == 0) {
    cout << k / 2;
    for (Int i = 1; i < n; i++)
      cout << " " << k;
    cout << endl;
    return 0;
  }
  vector<Int> ans(n, (k + 1) / 2);
  for (Int i = 0; i < n / 2; i++) {
    if (ans.back() == 1)
      ans.pop_back();
    else {
      ans.back()--;
      while (size(ans) < n)
        ans.emplace_back(k);
    }
  }
  for (Int i = 0; i < size(ans); i++) {
    if (i)
      cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
Problem p03561 (C++)

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

int K, N;
#define MAXN 300000
int d[MAXN];

int main() {
  scanf("%d%d", &K, &N);
  if (K % 2 == 0) {
    printf("%d", K / 2);
    for (int i = 0; i < N - 1; ++i)
      printf(" %d", K);
    printf("\n");
  } else {
    printf("%d", (K + 1) / 2);
    for (int i = 0; i < N - 1; ++i)
      d[i] = (K + 1) / 2;
    for (int rep = 0; rep < N / 2; ++rep) {
      for (int i = N - 2;; --i) {
        if (d[i] > 0) {
          --d[i];
          if (d[i] > 0) {
            for (int j = i + 1; j < N - 1; ++j)
              d[j] = K;
          }
          break;
        }
      }
    }
    for (int i = 0; i < N - 1; ++i) {
      if (d[i] == 0)
        break;
      printf(" %d", d[i]);
    }
    printf("\n");
  }
  return 0;
}


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

int K, N;
#define MAXN 300000
int d[MAXN];

int main() {
  scanf("%d%d", &K, &N);
  if (K % 2 == 0) {
    printf("%d", K / 2);
    for (int i = 0; i < N - 1; ++i)
      printf(" %d", K);
    printf("\n");
  } else if (K == 1) {
    printf("1");
    for (int i = 0; i < (N + 1) / 2 - 1; ++i)
      printf(" %d", 1);
    printf("\n");
  } else {
    printf("%d", (K + 1) / 2);
    for (int i = 0; i < N - 1; ++i)
      d[i] = (K + 1) / 2;
    for (int rep = 0; rep < N / 2; ++rep) {
      for (int i = N - 2;; --i) {
        if (d[i] > 0) {
          --d[i];
          if (d[i] > 0) {
            for (int j = i + 1; j < N - 1; ++j)
              d[j] = K;
          }
          break;
        }
      }
    }
    for (int i = 0; i < N - 1; ++i) {
      if (d[i] == 0)
        break;
      printf(" %d", d[i]);
    }
    printf("\n");
  }
  return 0;
}
Problem p03561 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int n, m, tot, a[maxn];
int main() {
  cin >> m >> n;
  if (~m & 1) {
    cout << m / 2 << " ";
    for (int i = 2; i <= n; ++i) {
      cout << m << " ";
    }
  } else {
    for (int i = 1; i <= n; ++i)
      a[i] = m / 2 + 1;
    for (int x = n / 2, p; x; --x) {
      for (p = n; a[p] == 0 && p; --p)
        ;
      if (--a[p++])
        for (int i = p; i <= n; ++i)
          a[i] = m;
    }
    for (int i = 1; i <= n; ++i) {
      if (!a[i])
        break;
      cout << a[i] << " ";
    }
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int n, m, tot, a[maxn];
int main() {
  cin >> m >> n;
  if (~m & 1) {
    cout << m / 2 << " ";
    for (int i = 2; i <= n; ++i) {
      cout << m << " ";
    }
  } else if (m == 1) {
    for (int i = 1; i <= (n + 1) / 2; ++i) {
      cout << 1 << " ";
    }
  } else {
    for (int i = 1; i <= n; ++i)
      a[i] = m / 2 + 1;
    for (int x = n / 2, p; x; --x) {
      for (p = n; a[p] == 0 && p; --p)
        ;
      if (--a[p++])
        for (int i = p; i <= n; ++i)
          a[i] = m;
    }
    for (int i = 1; i <= n; ++i) {
      if (!a[i])
        break;
      cout << a[i] << " ";
    }
  }
  return 0;
}
Problem p03561 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template <class T = int> using V = vector<T>;
template <class T = int> using VV = V<V<T>>;
template <class T> void assign(V<T> &v, int n, const T &a = T()) {
  v.assign(n, a);
}
template <class T, class... U> void assign(V<T> &v, int n, const U &...u) {
  v.resize(n);
  for (auto &&i : v)
    assign(i, u...);
}

int main() {
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int k, n;
  cin >> k >> n;
  V<> res(n);
  if (k & 1) {
    auto prev = [&] {
      int p = n - 1;
      while (res[p] == 0)
        p--;
      if (res[p] > 1) {
        res[p]--;
        for (int i = p + 1; i < n; i++)
          res[i] = k;
      } else {
        res[p] = 0;
      }
    };
    for (int i = 0; i < n; i++)
      res[i] = (k + 1) / 2;
    for (int i = 0; i < n / 2; i++)
      prev();
  } else {
    res[0] = k / 2;
    for (int i = 1; i < n; i++)
      res[i] = k;
  }
  for (int i = 0; i < n; i++)
    if (res[i])
      cout << res[i] << ' ';
  cout << '\n';
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template <class T = int> using V = vector<T>;
template <class T = int> using VV = V<V<T>>;
template <class T> void assign(V<T> &v, int n, const T &a = T()) {
  v.assign(n, a);
}
template <class T, class... U> void assign(V<T> &v, int n, const U &...u) {
  v.resize(n);
  for (auto &&i : v)
    assign(i, u...);
}

int main() {
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int k, n;
  cin >> k >> n;
  V<> res(n);
  if (k == 1) {
    for (int i = 0; i < (n + 1) / 2; i++)
      res[i] = 1;
  } else if (k & 1) {
    auto prev = [&] {
      int p = n - 1;
      while (res[p] == 0)
        p--;
      if (res[p] > 1) {
        res[p]--;
        for (int i = p + 1; i < n; i++)
          res[i] = k;
      } else {
        res[p] = 0;
      }
    };
    for (int i = 0; i < n; i++)
      res[i] = (k + 1) / 2;
    for (int i = 0; i < n / 2; i++)
      prev();
  } else {
    res[0] = k / 2;
    for (int i = 1; i < n; i++)
      res[i] = k;
  }
  for (int i = 0; i < n; i++)
    if (res[i])
      cout << res[i] << ' ';
  cout << '\n';
}
Problem p03561 (C++)

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

long long int exp(long long int a, long long int b) {
  long long int p = a;
  for (int i = 1; i < b; i++) {
    a *= p;
  }
  return a;
}

int main() {

  long long int n, m, a, b, c, k, memo, number, cou, check = 0;
  cin >> k >> n;
  if (k % 2 == 0) {
    cout << k / 2 << " ";
    for (int i = 1; i < n; i++) {
      cout << k << " ";
    }
  } else {

    for (int i = 1; i <= n; i++) {
      if (exp(k, i) > n - i) {
        memo = i;
        break;
      }
    }

    for (int i = 1; i <= n - memo; i++) {

      cout << k / 2 + 1 << " ";
    }
    number = n - memo;
    for (int i = 1; i <= memo; i++) {
      number += exp(k, i);
      check += exp(k, i);
    }
    if (number % 2 == 1) {
      number++;
    }
    number /= 2;
    number -= (n - memo);
    // numberは下i桁辞書順number目

    cou = 1;
    while (cou != memo + 1 && number != 0) {
      cout << (number - 1) / (check / k) + 1 << " ";
      number %= (check / k);
      if (number == 0) {
        number = check / k;
      }
      if (number == 1) {
        return 0;
      }
      check /= k;
      check--;
      cou++;
      number--;
    }
  }
}


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

long long int exp(long long int a, long long int b) {
  long long int p = a;
  for (int i = 1; i < b; i++) {
    a *= p;
  }
  return a;
}

int main() {

  long long int n, m, a, b, c, k, memo, number, cou, check = 0;
  cin >> k >> n;
  if (k == 1) {
    for (int i = 0; i < (n + 1) / 2; i++) {
      cout << "1 ";
    }
    return 0;
  }

  if (k % 2 == 0) {
    cout << k / 2 << " ";
    for (int i = 1; i < n; i++) {
      cout << k << " ";
    }
  } else {

    for (int i = 1; i <= n; i++) {
      if (exp(k, i) > n - i) {
        memo = i;
        break;
      }
    }

    for (int i = 1; i <= n - memo; i++) {

      cout << k / 2 + 1 << " ";
    }
    number = n - memo;
    for (int i = 1; i <= memo; i++) {
      number += exp(k, i);
      check += exp(k, i);
    }
    if (number % 2 == 1) {
      number++;
    }
    number /= 2;
    number -= (n - memo);
    // numberは下i桁辞書順number目

    cou = 1;
    while (cou != memo + 1 && number != 0) {
      cout << (number - 1) / (check / k) + 1 << " ";
      number %= (check / k);
      if (number == 0) {
        number = check / k;
      }
      if (number == 1) {
        return 0;
      }
      check /= k;
      check--;
      cou++;
      number--;
    }
  }
}
Problem p03561 (C++)

Buggy submission (status: Runtime Error):
/*  -*- coding: utf-8 -*-
 *
 * c.cc: E: Finite Encyclopedia of Integer Sequences
 */

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

int ds[MAX_N];

/* subroutines */

/* main */

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

  int kh = (k + 1) / 2;

  if (!(k & 1)) {
    printf("%d", kh);
    for (int i = 1; i < n; i++)
      printf(" %d", k);
  } else {
    fill(ds, ds + n, kh);
    int nh = n / 2;
    int li = n - 1;

    while (nh--) {
      if (ds[li] == 1)
        ds[li--] = k;
      else {
        ds[li]--;
        li = n - 1;
      }
    }

    for (int i = 0; i <= li; i++) {
      if (i)
        putchar(' ');
      printf("%d", ds[i]);
    }
  }
  putchar('\n');
  return 0;
}


Fixed submission:
/*  -*- coding: utf-8 -*-
 *
 * c.cc: E: Finite Encyclopedia of Integer Sequences
 */

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

/* constant */

const int MAX_N = 300000;

/* typedef */

/* global variables */

int ds[MAX_N];

/* subroutines */

/* main */

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

  int kh = (k + 1) / 2;

  if (!(k & 1)) {
    printf("%d", kh);
    for (int i = 1; i < n; i++)
      printf(" %d", k);
  } else {
    fill(ds, ds + n, kh);
    int nh = n / 2;
    int li = n - 1;

    while (nh--) {
      if (ds[li] == 1)
        ds[li--] = k;
      else {
        ds[li]--;
        li = n - 1;
      }
    }

    for (int i = 0; i <= li; i++) {
      if (i)
        putchar(' ');
      printf("%d", ds[i]);
    }
  }
  putchar('\n');
  return 0;
}
Problem p03563 (C++)

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

int main() {
  int R;
  int G;
  cin >> R >> G;
  cout << 2 * G / R << endl;
}

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

int main() {
  int R;
  int G;
  cin >> R >> G;
  cout << 2 * G - R << endl;
}
Problem p03563 (Python)

Buggy submission (status: Runtime Error):
r, g = map(int, input().split())
print((r + g) / 2)


Fixed submission:
r, g = [int(input()) for _ in range(2)]
print(2 * g - r)
Problem p03563 (C++)

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << (b / a) - a << endl;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  cout << 2 * b - a << endl;
}
Problem p03563 (C++)

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

int main() {
  int R;
  int G;

  cin >> R >> G;
  cout << (2 * G) / R << endl;
}

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

int main() {
  int R;
  int G;

  cin >> R >> G;
  cout << (2 * G) - R << endl;
}
Problem p03563 (C++)

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

int main() {
  int R, G;
  cin >> R >> G;
  cout << G * 2 / R << endl;
}


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

int main() {
  int R, G;
  cin >> R >> G;
  cout << 2 * G - R << endl;
}
Problem p03563 (C++)

Buggy submission (status: Runtime Error):
// 076 A - Rating Goal 2017/10/28

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main() {
  int r, g;
  cin >> r >> g;
  cout << 2 * g / r << endl;
}

Fixed submission:
// 076 A - Rating Goal 2017/10/28

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main() {
  int r, g;
  cin >> r >> g;
  cout << 2 * g - r << endl;
}
Problem p03563 (C++)

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

int main(void) {
  int a, b;
  cin >> a >> b;
  double c = 2 * b / a;
  cout << c << endl;
}


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

int main(void) {
  int a, b;
  cin >> a >> b;
  double c = 2 * b - a;
  cout << c << endl;
}
Problem p03563 (C++)

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

int main() {
  int R;
  int G;

  cin >> R;
  cin >> G;

  cout << 2 / R * G << endl;
}

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

int main() {
  int R;
  int G;

  cin >> R;
  cin >> G;

  cout << 2 * G - R << endl;
}
Problem p03563 (C++)

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

int main() {
  int R, G;
  cin >> R >> G;
  cout << 2 * G / R << endl;
}

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

int main() {
  int R, G;
  cin >> R >> G;
  cout << 2 * G - R << endl;
}
Problem p03563 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int R, G;
  cin >> R >> G;
  cout << G * 2 / R << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int R, G;
  cin >> R >> G;
  cout << G * 2 - R << endl;
}
Problem p03563 (C++)

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

  int r, g;
  cin >> r >> g;

  cout << 2 * g / r << endl;

  return 0;
}


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

  int r, g;
  cin >> r >> g;

  cout << 2 * g - r << endl;

  return 0;
}
Problem p03563 (C++)

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

  int r, g;
  cin >> r >> g;
  cout << (2 * g) / r;
}

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

  int r, g;
  cin >> r >> g;
  cout << (2 * g) - r;
}
Problem p03563 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, b, a) for (int i = (b); i >= (a); --i)
#define REP(i, n) FOR(i, 0, n - 1)
#define UNIQUE(a)                                                              \
  a.erase(unique(ALL(a)), a.end()) // <a> must be sorted in advance

lng power(lng b, lng e) {
  lng sol = 1;
  while (e > 0) {
    if (e & 1) {
      sol = sol * b;
    }
    e >>= 1;
    b *= b;
  }
  return sol;
}

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

  int R, G;
  cin >> R >> G;

  cout << 2 * G / R << endl;
}


Fixed submission:
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, b, a) for (int i = (b); i >= (a); --i)
#define REP(i, n) FOR(i, 0, n - 1)
#define UNIQUE(a)                                                              \
  a.erase(unique(ALL(a)), a.end()) // <a> must be sorted in advance

lng power(lng b, lng e) {
  lng sol = 1;
  while (e > 0) {
    if (e & 1) {
      sol = sol * b;
    }
    e >>= 1;
    b *= b;
  }
  return sol;
}

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

  int R, G;
  cin >> R >> G;

  cout << 2 * G - R << endl;
}
Problem p03563 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>
using namespace std;
int main() {
  int R, G, s;
  printf("\n");
  while (scanf(" %d%d", &R, &G)) {
    s = (2 * G) - R;
    printf("%d", s);
  }
  return 0;
}

Fixed submission:
#include <cstdio>
using namespace std;
int main() {
  int R, G, s;
  printf("\n");
  while (scanf(" %d%d", &R, &G) != EOF) {
    s = (2 * G) - R;
    printf("%d", s);
  }
  return 0;
}
Problem p03563 (C++)

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

int main() {
  int r;
  int g;
  cin >> r;
  cin >> g;

  cout << 2 * g / r << endl;
}

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

int main() {
  int r;
  int g;
  cin >> r;
  cin >> g;

  cout << 2 * g - r << endl;
}
Problem p03563 (C++)

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << b * 2 / a << endl;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  cout << b * 2 - a << endl;
}
Problem p03563 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
int main() {
  int r, g;
  cin >> r >> g;
  int x = 2 * g / r;
  cout << x << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
int main() {
  int r, g;
  cin >> r >> g;
  int x = 2 * g - r;
  cout << x << endl;
  return 0;
}
Problem p03563 (C++)

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

int main() {
  // ここにプログラムを追記
  int r, g;
  cin >> r >> g;
  cout << (r * 2) / g << endl;
}

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

int main() {
  // ここにプログラムを追記
  int r, g;
  cin >> r >> g;
  cout << (g * 2) - r << endl;
}
Problem p03563 (C++)

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << 2 * b / a << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << 2 * b - a << endl;
}
Problem p03563 (C++)

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

int main() {
  int targetRate, presentRate;
  cin >> presentRate >> targetRate;
  cout << 2 * targetRate / presentRate << endl;
}


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

int main() {
  int targetRate, presentRate;
  cin >> presentRate >> targetRate;
  cout << 2 * targetRate - presentRate << endl;
}
Problem p03563 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>
int main() {
  int a, b;
  while (scanf("%d%d", &a, &b)) {
    printf("%d\n", 2 * b - a);
  }
  return 0;
}

Fixed submission:
#include <cstdio>
int main() {
  int a, b;
  while (scanf("%d%d", &a, &b) != EOF) {
    printf("%d\n", 2 * b - a);
  }
  return 0;
}
Problem p03563 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int R, G;
  cin >> R >> G;
  cout << (2 * G) / R << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int R, G;
  cin >> R >> G;
  cout << 2 * G - R << endl;
}
Problem p03563 (Python)

Buggy submission (status: Runtime Error):
r, g = map(int, input().split())
x = g * 2 - r

print(x)


Fixed submission:
r = int(input())
g = int(input())
x = g * 2 - r

print(x)
Problem p03563 (Python)

Buggy submission (status: Runtime Error):
pres_rate = input()
goal_rate = input()
next_rate = goal_rate * 2 - pres_rate
print(next_rate)


Fixed submission:
pres_rate = int(input())
goal_rate = int(input())
next_rate = goal_rate * 2 - pres_rate
print(next_rate)
Problem p03563 (Python)

Buggy submission (status: Runtime Error):
r, g = map(int, input().split())
print(2 * g - r)


Fixed submission:
r, g = eval("int(input())," * 2)
print(2 * g - r)
Problem p03563 (C++)

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

int main() {
  int R, G;
  cin >> R >> G;
  cout << 2 * G / R << endl;
}

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

int main() {
  int r, g;
  cin >> r >> g;
  cout << 2 * g - r << endl;
  return 0;
}
Problem p03563 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (b * 2) / a << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << 2 * b - a << endl;
}
Problem p03564 (Python)

Buggy submission (status: Runtime Error):
xi, yi, xii, yii = map(int, input().split())
dx = xii - xi
dy = yii - yi

x = xii
y = yii
for i in range(2):
    dx, dy = -dy, dx
    x += dx
    y += dy
    print(x, y, end=" ")


Fixed submission:
n = int(input())
k = int(input())
ans = 1
for i in range(n):
    ans = min(ans * 2, ans + k)
print(ans)
Problem p03564 (C++)

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

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

  while (t > 0) {
    c++;
    t = N / 2;
  }

  int x = 1;

  for (int i = 0; i < c; i++) {
    x *= 2;
  }

  for (int i = 0; i < N - c; i++) {
    x += K;
  }

  cout << x << endl;
}


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

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

  while (t > 0) {
    c++;
    t /= 2;
    if (c >= N) {
      break;
    }
  }

  int x = 1;

  for (int i = 0; i < c; i++) {
    x *= 2;
  }

  for (int i = 0; i < N - c; i++) {
    x += K;
  }

  cout << x << endl;
}
Problem p03564 (C++)

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

using namespace std;

int32_t main() {
  int n, k;
  cin >> n >> k;
  int ans = 1;
  while (n) {
    ans = min(ans * 2, ans + k);
  }
  cout << ans;
  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int32_t main() {
  int n, k;
  cin >> n >> k;
  int ans = 1;
  while (n--) {
    ans = min(ans * 2, ans + k);
  }
  cout << ans;
  return 0;
}
Problem p03564 (C++)

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

using namespace std;

#define REP(i, k, n) for (int i = k; i < n; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define EPS 1e-14

#define all(v) v.begin(), v.end()
#define INF 1 << 30
#define mp make_pair
#define pb push_back

#define fi first
#define se second

#define each(it, c) for (auto it = (c).begin(); it != (c).end(); it++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

typedef long long ll;

void solve() {
  int N, K;
  cin >> N;
  cin >> K;
  int A = 1;
  rep(i, N) {
    if (A > K)
      A += K;
    else
      A *= 2;
  }
  cout << A << endl;
}

int main() {
  while (1) {
    solve();
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define REP(i, k, n) for (int i = k; i < n; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define EPS 1e-14

#define all(v) v.begin(), v.end()
#define INF 1 << 30
#define mp make_pair
#define pb push_back

#define fi first
#define se second

#define each(it, c) for (auto it = (c).begin(); it != (c).end(); it++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

typedef long long ll;

void solve() {
  int N, K;
  cin >> N;
  cin >> K;
  int A = 1;
  rep(i, N) {
    if (A > K)
      A += K;
    else
      A *= 2;
  }
  cout << A << endl;
}

int main() {
  solve();
  return 0;
}
Problem p03564 (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 llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n, 0);
  p[0] = 1;
  for (int i = 0; i < n; i++) {
    p[i + 1] = min(p[i] + k, p[i] * 2);
  }

  cout << p[n] << 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 llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n + 1, 0);
  p[0] = 1;
  for (int i = 0; i < n; i++) {
    p[i + 1] = min(p[i] + k, p[i] * 2);
  }

  cout << p[n] << endl;
}
Problem p03564 (C++)

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

int main() {
  int N, K;
  cin >> N >> K;
  int S = 1, A, B;
  for (int i = 0; i < N; N++) {
    A = S * 2;
    B = S + K;
    if (A <= B) {
      S = A;
    } else {
      S = B;
    }
  }
  cout << S << endl;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int S = 1, A, B;

  for (int i = 0; i < N; i++) {
    A = S * 2;
    B = S + K;
    if (A <= B) {
      S = A;
    } else {
      S = B;
    }
  }
  cout << S << endl;
}
Problem p03564 (C++)

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

int main() {
  int N, K;
  cin >> N >> K;
  int answer = 0;
  int count = 0;
  while (answer < K && count < N) {
    answer *= 2;
  }
  while (count < N) {
    answer += K;
  }
  cout << answer << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int answer = 1;
  for (int i = 0; i < N; i++) {
    if (answer < K) {
      answer *= 2;
    } else {
      answer += K;
    }
  }
  cout << answer << endl;
}