Language: C

#include <stdio.h>
#include <stdlib.h>
#define KATA long
/*型を入力して使うこと*/
void usort(KATA *a,KATA n){
    KATA *store;
    KATA hf=n,unit=1,a1,a2;
    store=malloc((KATA)sizeof(KATA)*n*2);
    for (int i=0;i<n;i++){
      store[i][0]=a[i][0];
      store[i][1]=a[i][1];
    }
    while (hf>1){
        if (hf==2){
            hf=(hf+1)/2;
            for (KATA i=0;i<hf;i++){
                a1=0;
                a2=0;
                while (a1+a2<2*unit && 2*i*unit+a1+a2<n){
                    if (a1==unit){
                        store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
                      store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
                        a2++;
                    }
                    else if (a2==unit || (2*i+1)*unit+a2==n){
                        store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
                      store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
                        a1++;
                    }
                    else if (a[(2*i+1)*unit+a2][0]>a[2*i*unit+a1][0]){
                        store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
                      store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
                        a1++;
                    }
                    else {
                        store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
                      store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
                        a2++;
                    }
                }
            }
            for (KATA i=0;i<n;i++) a[i]=store[i];
            break;
        }
        else if (hf%2){
            hf=(hf+1)/2;
            for (KATA i=0;i<hf-1;i++){
                a1=0;
                a2=0;
                while (a1+a2<2*unit && 2*i*unit+a1+a2<n){
                    if (a1==unit){
                        store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
                      store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
                        a2++;
                    }
                    else if (a2==unit || (2*i+1)*unit+a2==n){
                        store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
                      store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
                        a1++;
                    }
                    else if (a[(2*i+1)*unit+a2][0]>a[2*i*unit+a1][0]){
                        store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
                      store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
                        a1++;
                    }
                    else {
                        store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
                      store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
                        a2++;
                    }
                }
            }
        }
        else {
            hf=(hf+1)/2;
            for (KATA i=0;i<hf;i++){
                a1=0;
                a2=0;
                while (a1+a2<2*unit && 2*i*unit+a1+a2<n){
                    if (a1==unit){
                        store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
                      store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
                        a2++;
                    }
                    else if (a2==unit || (2*i+1)*unit+a2==n){
                        store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
                      store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
                        a1++;
                    }
                    else if (a[(2*i+1)*unit+a2][0]>a[2*i*unit+a1][0]){
                        store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
                      store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
                        a1++;
                    }
                    else {
                        store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
                      store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
                        a2++;
                    }
                }
            }
        }
        unit*=2;
        for (KATA i=0;i<n;i++) a[i]=store[i];
    }
    free(store);
    return;
}

int main(){
    KATA n,m,*d,cost=0;
    scanf("%lld%lld",&n,&m);
    d=malloc((KATA)sizeof(KATA)*n*2);
    for (KATA i=0;i<n;i++) scanf("%lld%lld",&d[i][0],&d[i][1]);
    usort(d,n);
    for (KATA i=0;i<n;i++){
      if (m>d[i][1]){
        cost+=d[i][0]*d[i][1];
        m-=d[i][1];
      }
      else {
        cost+=d[i][0]*m;
        break;
      }
    }
  printf("%lld\n",cost);
    free(d);
    return 0;
}


Compiler output:
main.c: In function 'usort':
main.c:10:15: error: subscripted value is neither array nor pointer nor vector
   10 |       store[i][0]=a[i][0];
      |               ^
main.c:10:23: error: subscripted value is neither array nor pointer nor vector
   10 |       store[i][0]=a[i][0];
      |                       ^
main.c:11:15: error: subscripted value is neither array nor pointer nor vector
   11 |       store[i][1]=a[i][1];
      |               ^
main.c:11:23: error: subscripted value is neither array nor pointer nor vector
   11 |       store[i][1]=a[i][1];
      |                       ^
main.c:21:46: error: subscripted value is neither array nor pointer nor vector
   21 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                              ^
main.c:21:68: error: subscripted value is neither array nor pointer nor vector
   21 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                                                    ^
main.c:22:44: error: subscripted value is neither array nor pointer nor vector
   22 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                            ^
main.c:22:66: error: subscripted value is neither array nor pointer nor vector
   22 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                                                  ^
main.c:26:46: error: subscripted value is neither array nor pointer nor vector
   26 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                              ^
main.c:26:64: error: subscripted value is neither array nor pointer nor vector
   26 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                                                ^
main.c:27:44: error: subscripted value is neither array nor pointer nor vector
   27 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |                                            ^
main.c:27:62: error: subscripted value is neither array nor pointer nor vector
   27 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |                                                              ^
main.c:30:48: error: subscripted value is neither array nor pointer nor vector
   30 |                     else if (a[(2*i+1)*unit+a2][0]>a[2*i*unit+a1][0]){
      |                                                ^
main.c:30:66: error: subscripted value is neither array nor pointer nor vector
   30 |                     else if (a[(2*i+1)*unit+a2][0]>a[2*i*unit+a1][0]){
      |                                                                  ^
main.c:31:46: error: subscripted value is neither array nor pointer nor vector
   31 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                              ^
main.c:31:64: error: subscripted value is neither array nor pointer nor vector
   31 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                                                ^
main.c:32:44: error: subscripted value is neither array nor pointer nor vector
   32 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |                                            ^
main.c:32:62: error: subscripted value is neither array nor pointer nor vector
   32 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |                                                              ^
main.c:36:46: error: subscripted value is neither array nor pointer nor vector
   36 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                              ^
main.c:36:68: error: subscripted value is neither array nor pointer nor vector
   36 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                                                    ^
main.c:37:44: error: subscripted value is neither array nor pointer nor vector
   37 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                            ^
main.c:37:66: error: subscripted value is neither array nor pointer nor vector
   37 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                                                  ^
main.c:52:46: error: subscripted value is neither array nor pointer nor vector
   52 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                              ^
main.c:52:68: error: subscripted value is neither array nor pointer nor vector
   52 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                                                    ^
main.c:53:44: error: subscripted value is neither array nor pointer nor vector
   53 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                            ^
main.c:53:66: error: subscripted value is neither array nor pointer nor vector
   53 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                                                  ^
main.c:57:46: error: subscripted value is neither array nor pointer nor vector
   57 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                              ^
main.c:57:64: error: subscripted value is neither array nor pointer nor vector
   57 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                                                ^
main.c:58:44: error: subscripted value is neither array nor pointer nor vector
   58 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |                                            ^
main.c:58:62: error: subscripted value is neither array nor pointer nor vector
   58 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |                                                              ^
main.c:61:48: error: subscripted value is neither array nor pointer nor vector
   61 |                     else if (a[(2*i+1)*unit+a2][0]>a[2*i*unit+a1][0]){
      |                                                ^
main.c:61:66: error: subscripted value is neither array nor pointer nor vector
   61 |                     else if (a[(2*i+1)*unit+a2][0]>a[2*i*unit+a1][0]){
      |                                                                  ^
main.c:62:46: error: subscripted value is neither array nor pointer nor vector
   62 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                              ^
main.c:62:64: error: subscripted value is neither array nor pointer nor vector
   62 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                                                ^
main.c:63:44: error: subscripted value is neither array nor pointer nor vector
   63 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |                                            ^
main.c:63:62: error: subscripted value is neither array nor pointer nor vector
   63 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |                                                              ^
main.c:67:46: error: subscripted value is neither array nor pointer nor vector
   67 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                              ^
main.c:67:68: error: subscripted value is neither array nor pointer nor vector
   67 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                                                    ^
main.c:68:44: error: subscripted value is neither array nor pointer nor vector
   68 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                            ^
main.c:68:66: error: subscripted value is neither array nor pointer nor vector
   68 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                                                  ^
main.c:81:46: error: subscripted value is neither array nor pointer nor vector
   81 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                              ^
main.c:81:68: error: subscripted value is neither array nor pointer nor vector
   81 |                         store[2*i*unit+a1+a2][0]=a[(2*i+1)*unit+a2][0];
      |                                                                    ^
main.c:82:44: error: subscripted value is neither array nor pointer nor vector
   82 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                            ^
main.c:82:66: error: subscripted value is neither array nor pointer nor vector
   82 |                       store[2*i*unit+a1+a2][1]=a[(2*i+1)*unit+a2][1];
      |                                                                  ^
main.c:86:46: error: subscripted value is neither array nor pointer nor vector
   86 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                              ^
main.c:86:64: error: subscripted value is neither array nor pointer nor vector
   86 |                         store[2*i*unit+a1+a2][0]=a[2*i*unit+a1][0];
      |                                                                ^
main.c:87:44: error: subscripted value is neither array nor pointer nor vector
   87 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |                                            ^
main.c:87:62: error: subscripted value is neither array nor pointer nor vector
   87 |                       store[2*i*unit+a1+a2][1]=a[2*i*unit+a1][1];
      |