Problem p03224 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i, a, b) for (register sign i = (sign)(a); i <= (sign)(b); ++i)
#define Fordown(i, a, b) for (register sign i = (sign)(a); i >= (sign)(b); --i)
const int N = 320 + 5;
template <typename T> bool cmax(T &a, T b) { return (a < b) ? a = b, 1 : 0; }
template <typename T> bool cmin(T &a, T b) { return (a > b) ? a = b, 1 : 0; }
template <typename T> T read() {
  T ans = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-')
    ch = getchar();
  if (ch == '-')
    f = -1, ch = getchar();
  while (isdigit(ch))
    ans = (ans << 3) + (ans << 1) + (ch - '0'), ch = getchar();
  return ans * f;
}
template <typename T> void write(T x, char y) {
  if (x == 0) {
    putchar('0'), putchar(y);
    return;
  }
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  static char wr[20];
  int top = 0;
  for (; x; x /= 10)
    wr[++top] = x % 10 + '0';
  while (top)
    putchar(wr[top--]);
  putchar(y);
}
void file() {
#ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  freopen("out", "w", stdout);
#endif
}
int n;
void input() { n = read<int>(); }
vector<int> E[N];
#define pb push_back
void work() {
  int m = 0;
  for (int i = 1; i * (i - 1) <= n * 2; i++)
    if (i * (i - 1) == n * 2)
      m = i;
  if (!m) {
    puts("No");
    return;
  }
  int now = 1;
  puts("Yes");
  write(m, '\n');
  For(i, 1, m) For(j, i + 1, m) E[i].pb(now), E[j].pb(now), now++;
  For(i, 1, m) {
    write(E[i].size(), ' ');
    for (int v : E[i])
      write(v, ' ');
    puts("");
  }
}
int main() {
  // file();
  input();
  work();
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i, a, b) for (register sign i = (sign)(a); i <= (sign)(b); ++i)
#define Fordown(i, a, b) for (register sign i = (sign)(a); i >= (sign)(b); --i)
const int N = 1e3 + 5;
template <typename T> bool cmax(T &a, T b) { return (a < b) ? a = b, 1 : 0; }
template <typename T> bool cmin(T &a, T b) { return (a > b) ? a = b, 1 : 0; }
template <typename T> T read() {
  T ans = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-')
    ch = getchar();
  if (ch == '-')
    f = -1, ch = getchar();
  while (isdigit(ch))
    ans = (ans << 3) + (ans << 1) + (ch - '0'), ch = getchar();
  return ans * f;
}
template <typename T> void write(T x, char y) {
  if (x == 0) {
    putchar('0'), putchar(y);
    return;
  }
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  static char wr[20];
  int top = 0;
  for (; x; x /= 10)
    wr[++top] = x % 10 + '0';
  while (top)
    putchar(wr[top--]);
  putchar(y);
}
void file() {
#ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  freopen("out", "w", stdout);
#endif
}
int n;
void input() { n = read<int>(); }
vector<int> E[N];
#define pb push_back
void work() {
  int m = 0;
  for (int i = 1; i * (i - 1) <= n * 2; i++)
    if (i * (i - 1) == n * 2)
      m = i;
  if (!m) {
    puts("No");
    return;
  }
  int now = 1;
  puts("Yes");
  write(m, '\n');
  For(i, 1, m) For(j, i + 1, m) E[i].pb(now), E[j].pb(now), now++;
  For(i, 1, m) {
    write(E[i].size(), ' ');
    for (int v : E[i])
      write(v, ' ');
    puts("");
  }
}
int main() {
  // file();
  input();
  work();
  return 0;
}