Language: C

#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

//set many funcs template
//Ver.20181228
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

void get_N1234 (int64 *n1, int64 *n2, int64 *n3, int64 *n4)
{
  int cnt;

  if (n2 == NULL) {
    cnt = scanf("%lld", n1);
    return;
  }
  if (n3 == NULL) {
    cnt = scanf("%lld %lld", n1, n2);
    return;
  }
  if (n4 == NULL) {
    cnt = scanf("%lld %lld %lld", n1, n2, n3);
    return;
  }
  cnt = scanf("%lld %lld %lld %lld", n1, n2, n3, n4);
  return;
}

void omit_LF (void)
{
  char c;
  int  cnt;
  
  cnt = scanf("%c", &c);
  return;
}

char *get_S (int64 n)
{
  char *buf;
  int  i;
  int  cnt;

  buf = malloc((size_t)(n * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  return buf;
}

char *get_SN (int64 max, int64 *size)
{
  char *buf;
  int  i;
  int  n;
  int  cnt;

  buf = malloc((size_t)(max * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  n = strlen(buf);

  *size = n;
  
  return buf;
}


typedef struct _tmp_t {
  int64    a; // num
  int64    b; // k
} tmp_t;

tmp_t *get_NSeq (int64 n)
{
  tmp_t *buf;
  int64 i;

  buf = malloc((size_t)(n * sizeof(tmp_t)));
  for (i=0; i<n; i++) {
    get_N(&buf[i].a);
    buf[i].b = i;
  }

  return buf;
}


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}

int64 r[2*(10*10*10*10*10)];

int main()
{
  int64 N;
  tmp_t *seq;
  int64 c;
  int64 si,ei;
  int64 ncr;

  get_N(&N);

  seq = get_NSeq(N);

  qsort_a(seq, N);

  si = 0;
  ei = 0;
  c  = 1;
  for (i=1; i<N; i++) {
    if (seq[i].a == seq[si].a) {
      ei = i;
      c++;
    } else {
      if (si != ei) {
        ncr = llnCr(c,2);
      } else {
        ncr = 0;
      }
      for (j=si; j<=ei; j++) {
        r[seq[j].b] = ncr;
      }
      c = 0;
      si = i;
      ei = i;
    }
  }

  for (i=0;i<N;i++) {
    printf("%lld\n", r[i]);
  }
  return 0;
}



Compiler output:
main.c: In function 'main':
main.c:186:8: error: 'i' undeclared (first use in this function); did you mean 'ei'?
  186 |   for (i=1; i<N; i++) {
      |        ^
      |        ei
main.c:186:8: note: each undeclared identifier is reported only once for each function it appears in
main.c:196:12: error: 'j' undeclared (first use in this function)
  196 |       for (j=si; j<=ei; j++) {
      |            ^