Language: C

#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
     
     
     
int n,cost;
int A[1001],B[1001];
int L[501],R[502];
     
     
void merge(int left,int mid,int right){
  int i,j,n1=mid-left,n2=right-mid;
  for(i=0;i<n1;i++) L[i]=A[left+i];
  L[n1]=INT_MAX;
  for(i=0;i<n2;i++) R[i]=A[mid+i];
  R[n2]=INT_MAX;
  int l=0,r=0;
  for(i=left;i<right;i++){
    if(L[l]<=R[r]){
      A[i]=L[l];
      l++;
    }
    else{
      A[i]=R[r];
      r++;
    }
  }
}
     
     
void m_sort(int left,int right){
  int mid;
  if( left+1 >= right) return;
  mid=(left+right)/2;
  m_sort(left,mid);
  m_sort(mid,right);
  merge(left,mid,right);
}
     
     
void swap(int a,int b,int *C){
  int swap;
  swap=C[a];
  C[a]=C[b];
  C[b]=swap;
}
     
     
     
     
     
     
       
      
       
     
int main(){
  scanf("%d",&n);
  int i,j;
  int cnt,sum,min,start,x;
  int C[1001]={};
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    B[i]=A[i];
  }
  m_sort(0,n);
  for(i=0;i<n;i++){
    if(A[i]==B[i]) C[i]=1;
  }
  cost=0;
  for(i=0;i<n;i++){
    if(C[i]!=1){
      C[i]=1;
      cnt=0;
      sum=0;
      min=B[i];
      x=i;
      while(1){
        for(j=0;j<n;j++){
          if(B[x]==A[j]){
            C[j]=1;
            cnt++;
            sum+=B[j];
            if(min > B[j]) min=B[j];
            x=j;
            break;
          }
        }
        if(x==i) break;
      }
      sum-=min;
      if( (cnt -1)*min > (cnt -1)*A[0]+2*(min +A[0])) cost+=sum+(cnt-1)*A[0]+2*(min +A[0]);
      else cost+=sum+(cnt-1)*min;
    }
  }
  printf("%d\n",cost);
  return 0;
}


Compiler output:
main.c:4:1: error: stray '\302' in program
    4 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      | ^~~~~~~~
main.c:4:2: error: stray '\302' in program
    4 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |         ^~~~~~~~
main.c:4:3: error: stray '\302' in program
    4 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |                 ^~~~~~~~
main.c:4:4: error: stray '\302' in program
    4 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |                         ^~~~~~~~
main.c:4:5: error: stray '\302' in program
    4 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |                                 ^~~~~~~~
main.c:5:1: error: stray '\302' in program
    5 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      | ^~~~~~~~
main.c:5:2: error: stray '\302' in program
    5 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |         ^~~~~~~~
main.c:5:3: error: stray '\302' in program
    5 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |                 ^~~~~~~~
main.c:5:4: error: stray '\302' in program
    5 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |                         ^~~~~~~~
main.c:5:5: error: stray '\302' in program
    5 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |                                 ^~~~~~~~
main.c:6:1: error: stray '\302' in program
    6 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      | ^~~~~~~~
main.c:6:2: error: stray '\302' in program
    6 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |         ^~~~~~~~
main.c:6:3: error: stray '\302' in program
    6 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |                 ^~~~~~~~
main.c:6:4: error: stray '\302' in program
    6 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |                         ^~~~~~~~
main.c:6:5: error: stray '\302' in program
    6 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |                                 ^~~~~~~~
main.c:10:1: error: stray '\302' in program
   10 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      | ^~~~~~~~
main.c:10:2: error: stray '\302' in program
   10 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |         ^~~~~~~~
main.c:10:3: error: stray '\302' in program
   10 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |                 ^~~~~~~~
main.c:10:4: error: stray '\302' in program
   10 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |                         ^~~~~~~~
main.c:10:5: error: stray '\302' in program
   10 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |                                 ^~~~~~~~
main.c:11:1: error: stray '\302' in program
   11 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      | ^~~~~~~~
main.c:11:2: error: stray '\302' in program
   11 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |         ^~~~~~~~
main.c:11:3: error: stray '\302' in program
   11 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |                 ^~~~~~~~
main.c:11:4: error: stray '\302' in program
   11 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |                         ^~~~~~~~
main.c:11:5: error: stray '\302' in program
   11 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>
      |                                 ^~~~~~~~
main.c: In function 'merge':
main.c:13:1: error: stray '\302' in program
   13 | <U+00A0><U+00A0>int i,j,n1=mid-left,n2=right-mid;
      | ^~~~~~~~
main.c:13:2: error: stray '\302' in program
   13 | <U+00A0><U+00A0>int i,j,n1=mid-left,n2=right-mid;
      |         ^~~~~~~~
main.c:14:1: error: stray '\302' in program
   14 | <U+00A0><U+00A0>for(i=0;i<n1;i++) L[i]=A[left+i];
      | ^~~~~~~~
main.c:14:2: error: stray '\302' in program
   14 | <U+00A0><U+00A0>for(i=0;i<n1;i++) L[i]=A[left+i];
      |         ^~~~~~~~
main.c:15:1: error: stray '\302' in program
   15 | <U+00A0><U+00A0>L[n1]=INT_MAX;
      | ^~~~~~~~
main.c:15:2: error: stray '\302' in program
   15 | <U+00A0><U+00A0>L[n1]=INT_MAX;
      |         ^~~~~~~~
main.c:16:1: error: stray '\302' in program
   16 | <U+00A0><U+00A0>for(i=0;i<n2;i++) R[i]=A[mid+i];
      | ^~~~~~~~
main.c:16:2: error: stray '\302' in program
   16 | <U+00A0><U+00A0>for(i=0;i<n2;i++) R[i]=A[mid+i];
      |         ^~~~~~~~
main.c:17:1: error: stray '\302' in program
   17 | <U+00A0><U+00A0>R[n2]=INT_MAX;
      | ^~~~~~~~
main.c:17:2: error: stray '\302' in program
   17 | <U+00A0><U+00A0>R[n2]=INT_MAX;
      |         ^~~~~~~~
main.c:18:1: error: stray '\302' in program
   18 | <U+00A0><U+00A0>int l=0,r=0;
      | ^~~~~~~~
main.c:18:2: error: stray '\302' in program
   18 | <U+00A0><U+00A0>int l=0,r=0;
      |         ^~~~~~~~
main.c:19:1: error: stray '\302' in program
   19 | <U+00A0><U+00A0>for(i=left;i<right;i++){
      | ^~~~~~~~
main.c:19:2: error: stray '\302' in program
   19 | <U+00A0><U+00A0>for(i=left;i<right;i++){
      |         ^~~~~~~~
main.c:20:1: error: stray '\302' in program
   20 | <U+00A0><U+00A0><U+00A0><U+00A0>if(L[l]<=R[r]){
      | ^~~~~~~~
main.c:20:2: error: stray '\302' in program
   20 | <U+00A0><U+00A0><U+00A0><U+00A0>if(L[l]<=R[r]){
      |         ^~~~~~~~
main.c:20:3: error: stray '\302' in program
   20 | <U+00A0><U+00A0><U+00A0><U+00A0>if(L[l]<=R[r]){
      |                 ^~~~~~~~
main.c:20:4: error: stray '\302' in program
   20 | <U+00A0><U+00A0><U+00A0><U+00A0>if(L[l]<=R[r]){
      |                         ^~~~~~~~
main.c:21:1: error: stray '\302' in program
   21 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>A[i]=L[l];
      | ^~~~~~~~
main.c:21:2: error: stray '\302' in program
   21 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>A[i]=L[l];
      |         ^~~~~~~~
main.c:21:3: error: stray '\302' in program
   21 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>A[i]=L[l];
      |                 ^~~~~~~~
main.c:21:4: error: stray '\302' in program
   21 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>A[i]=L[l];
      |                         ^~~~~~~~
main.c:21:5: error: stray '\302' in program
   21 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>A[i]=L[l];
      |                                 ^~~~~~~~
main.c:21:6: error: stray '\302' in program
   21 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>A[i]=L[l];
      |                                         ^~~~~~~~
main.c:22:1: error: stray '\302' in program
   22 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>l++;
      | ^~~~~~~~
main.c:22:2: error: stray '\302' in program
   22 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>l++;
      |         ^~~~~~~~
main.c:22:3: error: stray '\302' in program
   22 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>l++;
      |                 ^~~~~~~~
main.c:22:4: error: stray '\302' in program
   22 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>l++;
      |                         ^~~~~~~~
main.c:22:5: error: stray '\302' in program
   22 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>l++;
      |                                 ^~~~~~~~
main.c:22:6: error: stray '\302' in program
   22 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>l++;
      |                                         ^~~~~~~~
main.c:23:1: error: stray '\302' in program
   23 | <U+00A0><U+00A0><U+00A0><U+00A0>}
      | ^~~~~~~~
main.c:23:2: error: stray '\302' in program
   23 | <U+00A0><U+00A0><U+00A0><U+00A0>}
      |         ^~~~~~~~
main.c:23:3: error: stray '\302' in program
   23 | <U+00A0><U+00A0><U+00A0><U+00A0>}
      |                 ^~~~~~~~
main.c:23:4: error: stray '\302' in program
   23 | <U+00A0><U+00A0><U+00A0><U+00A0>}
      |                         ^~~~~~~~
main.c:24:1: error: stray '\302' in program
   24 | <U+00A0><U+00A0><U+00A0><U+00A0>else{
      | ^~~~~~~~
main.c:24:2: error: stray '\302' in program
   24 | <U+00A0><U+00A0><U+00A0><U+00A0>else{
      |         ^~~~~~~~
main.c:24:3: error: stray '\302' in program
   24 | <U+00A0><U+00A0><U+00A0><U+00A0>else{
      |                 ^~~~~~~~
main.c:24:4: error: stray '\302' in program
   24 | <U+00A0><U+00A0><U+00A0><U+00A0>else{
      |                         ^~~~~~~~
main.c:25:1: error: stray '\302' in program
   25 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>A[i]=R[r];
      | ^~~~~~~~
main.c:25:2: error: stray '\302' in program
   25 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>A[i]=R[r];
      |         ^~~~~~~~
main.c:25:3: error: stray '\302' in program
   25 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>A[i]=R[r];
      |                 ^~~~~~~~
main.c:25:4: error: stray '\302' in program
   25 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>A[i]=R[r];
      |                         ^~~~~~~~
main.c:25:5: error: stray '\302' in program
   25 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>A[i]=R[r];
      |                                 ^~~~~~~~
main.c:25:6: error: stray '\302' in program
   25 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>A[i]=R[r];
      |                                         ^~~~~~~~
main.c:26:1: error: stray '\302' in program
   26 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>r++;
      | ^~~~~~~~
main.c:26:2: error: stray '\302' in program
   26 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>r++;
      |         ^~~~~~~~
main.c:26:3: error: stray '\302' in program
   26 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>r++;
      |                 ^~~~~~~~
main.c:26:4: error: stray '\302' in program
   26 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>r++;
      |                         ^~~~~~~~
main.c:26:5: error: stray '\302' in program
   26 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>r++;
      |                                 ^~~~~~~~
main.c:26:6: error: stray '\302' in program
   26 | <U+00A0><U+00A0><U+00A0><U+00A0><U+00A0><U+00A0>r++;
      |                                         ^~~~~~~~
main.c:27:1: error: stray '\302' in program
   27 | <U+00A0><U+00A0><U+00A0><U+00A0>}
      | ^~~~~~~~
main.c:27:2: error: stray '\302' in program
   27 | <U+00A0><U+00A0><U+00A0><U+00A0>}
      |         ^~~~~~~~
main.c:27:3: error: stray '\302' in program
   27 | <U+00A0><U+00A0><U+00A0><U+00A0>}
      |                 ^~~~~~~~
main.c:27:4: error: stray '\302' in program
   27 | <U+00A0><U+00A0><U+00A0><U+00A0>}
      |                         ^~~~~~~~
main.c:28:1: error: stray '\302' in program
   28 | <U+00A0><U+00A0>}
      | ^~~~~~~~
main.c:28:2: e