#include <stdio.h>
#include <malloc.h>
int* solution(int n, long long left, long long right) {
int* answer=(int*)malloc(sizeof(int)*(right-left+1));
int i, j, div=0, mod=0;
int x1=left/n,y1=left%n;
int x2=right/n,y2=right%n;
/*for(j=y1;j<n;j++)
answer[x1*n+j+1-left]=0;
*/
for(j=y1;j<x1;j++) {
answer[x1*n+j-left]=i+1;
}
for(j=x1;j<n;j++) {
answer[x1*n+j-left]=j+1;
}
for(i=x1+1;i<x2;i++) {
for(j=0;j<i;j++)
answer[i*n+j-left]=i+1;
for(j=i;j<n;j++)
answer[i*n+j-left]=j+1;
}
for(j=0;j<=y2;j++) {
if(y2==n-1) {
answer[x2*n+j-left]=i+1;
}
else {
answer[x2*n+j-left]=i+j+1;
}
}
/*
for(i=left;i<=right;i++) {
div=i/n;
mod=i%n;
//printf("%d %d %d\n",i-left,div,mod);
if(div>=mod) {
answer[i-left]=div+1;
//*answer=answer[i-left];
}
else {
answer[i-left]=mod+1;
//*answer=answer[i-left];
}
}
*/
return answer;
}