C Solution
Code

# Code
```c []
int perfectSizes[2000];
int len;
int perfectTreeSize(struct TreeNode *ins) {
  if (ins == NULL) // leaf's child
    return 0;
  int l = perfectTreeSize(ins->left), r = perfectTreeSize(ins->right);
  if (l == r && l > -1) { // perfect
    perfectSizes[len++] = 1 + l + r;
    return 1 + l + r; // return tree size
  }
  return -1; // non-perfect, return -1
}
int cmp(const void *a, const void *b) { return *(int *)b - *(int *)a; }
int kthLargestPerfectSubtree(struct TreeNode *root, int k) {
  len = 0;
  perfectTreeSize(root);
  qsort(perfectSizes, len, sizeof(int), cmp);
  if (k > len)
    return -1;
  else
    return perfectSizes[k - 1];
}

```
['C']