criyle/codenet-compile-errors huggingface dataset:
Language: C++

 =#include<iostream>
using namespace std;
 
int main()
{
  int h, w, d;
  cin >> h;
  cin >> w;
  cin >> d;
  int a[300][300];
  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++)
      cin >> a[i][j];
  int q;
  cin >> q;
  for(int i = 0; i < q; i++){
    int sum = 0;
    int l,r;
    cin >> l;
    cin >> r;
    while(l < r){
      int startFlag = 1;
      int p[2] = {0,0};
      for(int j = 0; j < h && l<r; j++){
        for(int k=0;k<w && l<r;k++){
          if(a[j][k] == l){
            if(startFlag){
              startFlag = 0;
            }
            else{
              sum += p[0] > j ? p[0] - j : j - p[0];
              sum += p[1] > k ? p[1] - k : k - p[1];
            }
            p[0] = j; p[1] = k;
            l += d;
          }
        }
      }
    }
    cout << sum << endl;
  }

  return 0;
}


Compiler output:
a.cc:1:3: error: stray '#' in program
    1 |  =#include<iostream>
      |   ^
a.cc:1:2: error: expected unqualified-id before '=' token
    1 |  =#include<iostream>
      |  ^
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope
    7 |   cin >> h;
      |   ^~~
a.cc:40:5: error: 'cout' was not declared in this scope
   40 |     cout << sum << endl;
      |     ^~~~
a.cc:40:20: error: 'endl' was not declared in this scope
   40 |     cout << sum << endl;
      |                    ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int H, W, D, Q;
int X[100000] = {}, Y[100000] = {};
int L, R;

main()
{
    cin >> H >> W >> D;
    int A;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A;
            X[A] = i;
            Y[A] = j;
        }
    }
    cin >> Q;
    int now = 0;
    for (int i = 0; i < Q; i++) {
        cin >> L >> R;
        int magic = 0;
        now = L;
        while (now != R) {
            magi += abs(X[now] - X[now+D]) + abs(Y[now] - Y[now+D]);
            now += D;
        }
        cout << magic << "\n";
    }

}

Compiler output:
a.cc:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:26:13: error: 'magi' was not declared in this scope; did you mean 'magic'?
   26 |             magi += abs(X[now] - X[now+D]) + abs(Y[now] - Y[now+D]);
      |             ^~~~
      |             magic
Language: C++

#include<iostream>
#include<math.h>
using namespace std;
main(){
    int h,w,d;
    int q;
    cin>>h;
    cin>>w;
    cin>>d;
    int x[h*w];
    int y[h*w];
    for(int i=0;i<h*w;i++){
        int n;
        cin>>n;
        x[n]=i/w;
        y[n]=i%w;
    }
    cin>>q;
    int l[q],r[q];
    for(int i=0;i<q;i++){
        int ans=0;
        cin>>l[i];
        cin>>r[i];
    }
    for(int i=0;i<q;i++){
        for(int j=l[i];j<r[i];j+=d){
            ans+=abs(x[j+d]-x[j]);
            ans+=abs(y[j+d]-y[j]);
        }
        cout<<ans<<endl;
    }
    return 0;

}

Compiler output:
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:27:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   27 |             ans+=abs(x[j+d]-x[j]);
      |             ^~~
      |             abs
a.cc:30:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   30 |         cout<<ans<<endl;
      |               ^~~
      |               abs
Language: C++

#include<iostream>
#include<math.h>
using namespace std;
main(){
    int h,w,d;
    int q;
    cin>>h;
    cin>>w;
    cin>>d;
    int x[h*w];
    int y[h*w];
    for(int i=0;i<h*w;i++){
        int n;
        cin>>n;
        x[n]=i/w;
        y[n]=i%w;
    }
    cin>>q;
    int l[q]r[q];
    for(int i=0;i<q;i++){
        int ans=0;
        cin>>l[i];
        cin>>r[i];
    }
    for(int i=0;i<q;i++){
        for(int j=l[i];j<r[i];j+=d){
            ans+=abs(x[j+d]-x[j]);
            ans+=abs(y[j+d]-y[j]);
        }
        cout<<ans<<endl;
    }
    return 0;

}

Compiler output:
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:19:13: error: expected initializer before 'r'
   19 |     int l[q]r[q];
      |             ^
a.cc:22:14: error: 'l' was not declared in this scope
   22 |         cin>>l[i];
      |              ^
a.cc:23:14: error: 'r' was not declared in this scope
   23 |         cin>>r[i];
      |              ^
a.cc:26:19: error: 'l' was not declared in this scope
   26 |         for(int j=l[i];j<r[i];j+=d){
      |                   ^
a.cc:26:26: error: 'r' was not declared in this scope
   26 |         for(int j=l[i];j<r[i];j+=d){
      |                          ^
a.cc:27:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   27 |             ans+=abs(x[j+d]-x[j]);
      |             ^~~
      |             abs
a.cc:30:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   30 |         cout<<ans<<endl;
      |               ^~~
      |               abs
Language: C++

#include<iostream>
#include<cstring>
#include<utility>
#include<cmath>

using namespace std;

#define REPI(x) for(int i = 0; i < x; i++)
#define REPJ(x) for(int j = 0; j < x; j++)
#define H_MAX 300
#define W_MAX 300

pair<int, int> A[H_MAX*W_MAX];

void calc(int L, int R, int D)
{
	int num = 0;

	if (L == R){
		cout << num << endl;
		return 0;
	}

	int t = (R - L) / D;

	REPI(t){
		num += abs(A[(L+i*D)-1].first - A[(L+(i+1)*D)-1].first) + abs(A[(L+i*D)-1].second - A[(L+(i+1)*D)-1].second);

	}

	cout << num << endl;
	return 0;
}

int main(void)
{
	int H, W, D, Q, L, R;
	cin >> H >> W >> D;

	int a;

	REPI(H){
		REPJ(W){
			cin >> a;
			A[a-1].first = i;
			A[a-1].second = j;
		}
	}

	cin >> Q;

	while(Q--)
	{
		cin >> L;
		cin >> R;
		calc(L, R, D);
	}
	return 0;
}

Compiler output:
a.cc: In function 'void calc(int, int, int)':
a.cc:21:24: error: return-statement with a value, in function returning 'void' [-fpermissive]
   21 |                 return 0;
      |                        ^
a.cc:32:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
   32 |         return 0;
      |                ^
Language: C++

#include<iostream>
#include<cstring>
#include<utility>
#include<cmath>

using namespace std;

#define REPI(x) for(int i = 0; i < x; i++)
#define REPJ(x) for(int j = 0; j < x; j++)
#define H_MAX 300
#define W_MAX 300

pair<int, int> A[H_MAX*W_MAX];

void calc(int L, int R, int D)
{
	int num = 0;

	if (L == R){
		cout << num << endl;
		return 0;
	}

	int t = (R - L) / D;

	REPI(t){
		num += abs(A[(L+i*D)-1].first - A[(L+(i+1)*D)-1].first) + abs(A[(L+i*D)-1].second - A[(L+(i+1)*D)-1].second);

	}

	cout << num << endl;
	return 0;
}

int main(void)
{
	int H, W, D, Q;
	cin >> H >> W >> D;

	int a;

	REPI(H){
		REPJ(W){
			cin >> a;
			A[a-1].first = i;
			A[a-1].second = j;
		}
	}

	cin >> Q;

	pair<int, int> p[Q];
	while(Q--)
	{
		cin >> p[i].first;
		cin >> p[i].second;
		calc(p[i].first, p[i].second, D);
	}
	return 0;
}


Compiler output:
a.cc: In function 'void calc(int, int, int)':
a.cc:21:24: error: return-statement with a value, in function returning 'void' [-fpermissive]
   21 |                 return 0;
      |                        ^
a.cc:32:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
   32 |         return 0;
      |                ^
a.cc: In function 'int main()':
a.cc:55:26: error: 'i' was not declared in this scope
   55 |                 cin >> p[i].first;
      |                          ^
Language: C++

#include <cstdio>
#define abs (x)((x > 0) ? x : (-(x)))
int H, W, D, A;
int Q, L, R;
int px[90001], py[90001];
int d[90001];
int main() {
  scanf("%d %d %d", &H, &W, &D);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      scanf("%d ", &A);
      px[A] = i, py[A] = j;
    }
  }
  for (int i = D + 1; i <= H * W; i++)
    d[i] = d[i - D] + abs(px[i] - px[i - D]) + abs(py[i] - py[i - D]);
  scanf("%d", &Q);
  while (Q--) {
    scanf("%d %d", &L, &R);
    printf("%d\n ", d[R] - d[L]);
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:2:14: error: 'x' was not declared in this scope
    2 | #define abs (x)((x > 0) ? x : (-(x)))
      |              ^
a.cc:16:23: note: in expansion of macro 'abs'
   16 |     d[i] = d[i - D] + abs(px[i] - px[i - D]) + abs(py[i] - py[i - D]);
      |                       ^~~
Language: C++

#include <cstdio>
#define abs (x)((x > 0) ? x : (-(x)))
int H, W, D, A;
int Q, L, R;
int px[90001], py[90001];
int d[90001];
int main() {
  scanf("% d % d % d ", &H, &W, &D);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      scanf("% d ", &A);
      px[A] = i, py[A] = j;
    }
  }
  for (int i = D + 1; i <= H * W; i++)
    d[i] = d[i - D] + abs(px[i] - px[i - D]) + abs(py[i] - py[i - D]);
  scanf("% d ", &Q);
  while (Q - -) {
    scanf("% d % d ", &L, &R);
    printf("% d \ n ", d[R] - d[L]);
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:2:14: error: 'x' was not declared in this scope
    2 | #define abs (x)((x > 0) ? x : (-(x)))
      |              ^
a.cc:16:23: note: in expansion of macro 'abs'
   16 |     d[i] = d[i - D] + abs(px[i] - px[i - D]) + abs(py[i] - py[i - D]);
      |                       ^~~
a.cc:18:15: error: expected primary-expression before ')' token
   18 |   while (Q - -) {
      |               ^
a.cc:20:12: warning: unknown escape sequence: '\040'
   20 |     printf("% d \ n ", d[R] - d[L]);
      |            ^~~~~~~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<math.h>
using namespace std;

typedef struct ss
{
   int a,t1,t2;
}s;

int h,w;
s a[90000];

bool cm(s a,s b)
{
    return a.a<b.a;
}

int f(int *t1,int *t2,int n)
{
    int l=0,h1=h*w-1,m=(l+h1)/2;
    while(l!=h1)
    {
        if(n>a[m].a)l=m;
        else if(a[m].a==n)break;
        else h1=m;
        m=(l+h1)/2;
    }
    if(a[m].a==n)
    {
        (*t1)=a[m].t1;
        (*t2)=a[m].t2;
        return 0;
    }
    else return 1;
}

int main()
{
    int d,q,i,j,k,t1,t2,t3,t4,aa,sum;
    scanf("%d %d %d",&h,&w,&d);
    for(i=0; i<h; i++)
        for(j=0; j<w; j++)
            {
                scanf("%d",&(a[i*h+j].a));
                a[i*h+j].t1=i;
                a[i*h+j].t2=j;
            }
    sort(a,a+h*w,cm);
    scanf("%d",&q);
    int lr[q][2];
    for(i=0; i<q; i++)
        scanf("%d %d",&lr[i][0],&lr[i][1]);
    for(k=0; k<q; k++)
    {
        sum=0;
        aa=lr[k][0];
        f(&t1,&t2,lr[k][0]);
        while(aa!=lr[k][1])
        {
           
            aa+=d;
            if(f(&t3,&t4,aa))continue;
            sum+=(abs(t1-t3)+abs(t2-t4));
            t1=t3;
            t2=t4;
        }
        printf("%d\n",sum);
    }

    return 0;
}


Compiler output:
main.c:3:9: fatal error: algorithm: No such file or directory
    3 | #include<algorithm>
      |         ^~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include <cmath>
#include<cstdio>
int A[300][300];
int L[100000],R[100000];
using namespace std;
int magic(int x, int i, int y, int j){
        return abs(x-i)+abs(y-j);
}
void search(int *x, int *y, int H, int W, int l){
        for(int i=0; i<H; i++)
                for(int j=0; j<W; j++)
                        if(l==A[i][j]){
                                *x=i;
                                *y=j;
                                break;
                        }
}
int main(){
        int H,W,D;
        cin >> H >> W >> D;
        for(int i=0; i<H; i++)
                for(int j=0; j<W; j++)
                        scamf("%d",&A[i][j]);
        long long Q;
        cin >> Q;
        int mag[100000]={};
	for(int i=0; i<Q; i++){
                int ini,inj,inii,injj;
                scanf("%d %d",&L[i],&R[i]);
                int a=L[i];
                
                while(a!=R[i]){
                        search(&ini,&inj,H,W,a);
                        a+=D;
                        search(&inii,&injj,H,W,a);
                        mag[i]+=magic(inii+1,ini+1,injj+1,inj+1);
                }
        }
        for(int i=0; i<Q; i++)
                printf("%d\n",mag[i]);
        return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:25: error: 'scamf' was not declared in this scope; did you mean 'scanf'?
   24 |                         scamf("%d",&A[i][j]);
      |                         ^~~~~
      |                         scanf
Language: C++

P pos[90001];
    REP(i,H) REP(j,W) {
        int A;
        cin >> A;
        pos[A] = P(i, j);
    }

    //tblの構成
    vector<P> now_pos(D);
    vector<int> sum(D, 0);
    for (int i=1; i<=H*W; i++) {
        if (i <= D) {
            tbl[get_idx(i).first][get_idx(i).second] = 0;
            now_pos[i-1] = pos[i];
            sum[i-1] = 0;
        } else {
            sum[get_idx(i).first] += abs(now_pos[get_idx(i).first].first - pos[i].first) + abs(now_pos[get_idx(i).first].second - pos[i].second);
            now_pos[get_idx(i).first] = pos[i];
            tbl[get_idx(i).first][get_idx(i).second] = sum[get_idx(i).first];
        }
    }

    int Q;
    cin >> Q;
    REP(i,Q) {
        int L, R;
        cin >> L >> R;
        cout << tbl[get_idx(R).first][get_idx(R).second] - tbl[get_idx(L).first][get_idx(L).second] << endl;
    }

Compiler output:
a.cc:1:1: error: 'P' does not name a type
    1 | P pos[90001];
      | ^
a.cc:2:8: error: expected constructor, destructor, or type conversion before '(' token
    2 |     REP(i,H) REP(j,W) {
      |        ^
a.cc:9:5: error: 'vector' does not name a type
    9 |     vector<P> now_pos(D);
      |     ^~~~~~
a.cc:10:5: error: 'vector' does not name a type
   10 |     vector<int> sum(D, 0);
      |     ^~~~~~
a.cc:11:5: error: expected unqualified-id before 'for'
   11 |     for (int i=1; i<=H*W; i++) {
      |     ^~~
a.cc:11:19: error: 'i' does not name a type
   11 |     for (int i=1; i<=H*W; i++) {
      |                   ^
a.cc:11:27: error: 'i' does not name a type
   11 |     for (int i=1; i<=H*W; i++) {
      |                           ^
a.cc:24:5: error: 'cin' does not name a type
   24 |     cin >> Q;
      |     ^~~
a.cc:25:8: error: expected constructor, destructor, or type conversion before '(' token
   25 |     REP(i,Q) {
      |        ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
class StonesOnATree
{
    public:
int minStones(vector <int> p, vector <int> w)
{

}
};
int main()
{
int a,b,c;
while(cin>>a>>b>>c){
    pair<int,int>A[200005]={};
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
                int g;
        cin>>g;
            A[g].F=i;
            A[g].S=j;
        }
    }
    
    int sum[100005]={};
    for(int i=c;i<=a*b;i+=c){
        sum[i]=sum[i-c]+abs(A[i].F-A[i-d].F)+abs(A[i].S-A[i-d].S);
    }
    int x;
    cin>>x;
    for(int i=0;i<x;i++){
     int t1,t2;
     cin>>t1>>t2;
        cout<<sum[t2]-sum[t1]<<endl;







    }

}

    return 0;
}


Compiler output:
a.cc: In member function 'int StonesOnATree::minStones(std::vector<int>, std::vector<int>)':
a.cc:26:1: warning: no return statement in function returning non-void [-Wreturn-type]
   26 | }
      | ^
a.cc: In function 'int main()':
a.cc:44:40: error: 'd' was not declared in this scope
   44 |         sum[i]=sum[i-c]+abs(A[i].F-A[i-d].F)+abs(A[i].S-A[i-d].S);
      |                                        ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
class StonesOnATree
{
    public:
int minStones(vector <int> p, vector <int> w)
{

}
};
int main()
{
int a,b,c;
while(cin>>a>>b>>c){
    pair<int,int>A[200005]={};
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
            cin>>mapr[i][j];
            A[ mapr[i][j] ].F=i;
            A[ mapr[i][j] ].S=j;
        }
    }
    int sum[100005]={};
    for(int i=c;i<=a*b;i+=c){
        sum[i]=sum[i-c]+abs(A[i].F-A[i-d].F)+abs(A[i].S-A[i-d].S);
    }
    int x;
    cin>>x;
    for(int i=0;i<x;i++){
     int t1,t2;
     cin>>t1>>t2;   
        cout<<sum[t2]-sum[t1]<<endl;
        
        
        
        
        
        
        
    }
    
}

    return 0;
}


Compiler output:
a.cc: In member function 'int StonesOnATree::minStones(std::vector<int>, std::vector<int>)':
a.cc:26:1: warning: no return statement in function returning non-void [-Wreturn-type]
   26 | }
      | ^
a.cc: In function 'int main()':
a.cc:35:18: error: 'mapr' was not declared in this scope
   35 |             cin>>mapr[i][j];
      |                  ^~~~
a.cc:42:40: error: 'd' was not declared in this scope
   42 |         sum[i]=sum[i-c]+abs(A[i].F-A[i-d].F)+abs(A[i].S-A[i-d].S);
      |                                        ^
Language: C++

#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long ll;
struct Node{
    int x,y;
};
Node arr[100000];
int fbs(int x)
{
    if(x>0) return x;
    else return -x;
}
int main()
{
    int h,m,d;
    cin>>h>>m>>d;
    int xx;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=m;j++)
        {
            scanf(" %d",&xx);
            arr[xx].x=i;
            arr[xx].y=j;
        }
    }
    int q;
    cin>>q;
    int x,y;
    for(int i=0;i<q;i++)
    {
        scanf(" %d %d",&x,&y);
        int sum=0;
        int b=x,e=x+d;
        while(b!=y)
        {
            sum+=(fbs(y.x-x.x)+fbs(y.y-x.y));
            b+=d;
            e+=d;
        }
        cout<<sum<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:25: error: request for member 'x' in 'y', which is of non-class type 'int'
   39 |             sum+=(fbs(y.x-x.x)+fbs(y.y-x.y));
      |                         ^
a.cc:39:29: error: request for member 'x' in 'x', which is of non-class type 'int'
   39 |             sum+=(fbs(y.x-x.x)+fbs(y.y-x.y));
      |                             ^
a.cc:39:38: error: request for member 'y' in 'y', which is of non-class type 'int'
   39 |             sum+=(fbs(y.x-x.x)+fbs(y.y-x.y));
      |                                      ^
a.cc:39:42: error: request for member 'y' in 'x', which is of non-class type 'int'
   39 |             sum+=(fbs(y.x-x.x)+fbs(y.y-x.y));
      |                                          ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int xx[90001];
int yy[90001];
int d[90001]
int main()
{
	int i,j,H,W,D,a,x,y,m;
	scanf("%d",&H,&W,&D);
	for(i=0;i<H;i++)
	{
		for(j=0;j<W;j++)
		{
			scanf("%d",&a);
			xx[a]=i;
			yy[a]=j;
		}
	}
	for(i=D+1;i<=H*W;i++)
		d[i]=d[i-D]+abs(xx[i]-xx[i-D])+abs(yy[i]-yy[i-D]);
	scanf("%d",&m);
	for(i=0;i<m;i++)
	{
		scanf("%d%d",&x,&y);
		printf("%d\n",d[y]-d[x]);
	}
	return 0;
}

Compiler output:
a.cc:6:1: error: expected initializer before 'int'
    6 | int main()
      | ^~~
Language: C

/*
 AtCoder XXX 000
 */
 
#include <stdio.h>
 
int abs(int x){
	return (x>0) ? x : (-x);
}
 
int main(void){
	
	int n;
	int width,height,dist;
	int x[60000];
	int y[60000];
	int q;
	int l,r;
	int i,j,k;
	int maryoku;
	
	scanf("%d",&height);
	scanf("%d",&width);
	scanf("%d",&dist);
	
	for(j=0; j<height; j++) for(i=0; i<width; i++){
		scanf("%d",&n);
		x[n] = i;
		y[n] = j;
	}
	
	scanf("%d",&q);
	for(k=0; k<q; k++){
		maryoku=0;
		scanf("%d",&l);
		scanf("%d",&r);
		
		while(l =< r-dist){
			maryoku += abs(x[l] - x[l+dist]) + abs(y[l] - y[l+dist]);
			l += dist;
		}
		
		printf("%d\n",maryoku);
	}
	
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:38:26: error: expected expression before '<' token
   38 |                 while(l =< r-dist){
      |                          ^
Language: C

/*
 AtCoder XXX 000
 */
 
#include <stdio.h>

int abs(int x){
	return (x>0) ? x : (-x);
}

int main(void){
	
	int n;
	int width,height,dist;
	int x[300];
	int y[300]
	int q;
	int l,r;
	int i,j,k;
	int maryoku;
	
	scanf("%d",&height);
	scanf("%d",&width);
	scanf("%d",&dist);
	
	for(j=0; j<height; j++) for(i=0; i<width; i++){
		scanf("%d",&n);
		x[n] = i;
		y[n] = j;
	}
	
	scanf("%d",&q);
	for(k=0; k<q; k++){
		maryoku=0;
		scanf("%d",&l);
		scanf("%d",&r);
		
		while(l != r){
			maryoku += abs(x[l] - x[l+dist]) + abs(y[l] - y[l+dist]);
			l += dist;
		}
		
		printf("%d\n",maryoku);
	}
	
	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:16:19: error: expected ';' before 'int'
   16 |         int y[300]
      |                   ^
      |                   ;
   17 |         int q;
      |         ~~~        
main.c:29:17: error: 'y' undeclared (first use in this function)
   29 |                 y[n] = j;
      |                 ^
main.c:29:17: note: each undeclared identifier is reported only once for each function it appears in
Language: C

/*
 AtCoder XXX 000
 */
 
#include <stdio.h>

int abs(x){
	return (x>0) ? x : (-x);
}

int main(void){
	
	int n;
	int width,height,dist;
	int x[300];
	int y[300]
	int q;
	int l,r;
	int i,j,k;
	int maryoku;
	
	scanf("%d",&height);
	scanf("%d",&width);
	scanf("%d",&dist);
	
	for(j=0; j<height; j++) for(i=0; i<width; i++){
		scanf("%d",&n);
		x[n] = i;
		y[n] = j;
	}
	
	scanf("%d",&q);
	for(k=0; k<q; k++){
		maryoku=0;
		scanf("%d",&l);
		scanf("%d",&r);
		
		while(l != r){
			maryoku += abs(x[l] - x[l+dist]) + abs(y[l] - y[l+dist]);
			l += dist;
		}
		
		printf("%d\n",maryoku);
	}
	
	return 0;
}


Compiler output:
main.c: In function 'abs':
main.c:7:5: error: type of 'x' defaults to 'int' [-Wimplicit-int]
    7 | int abs(x){
      |     ^~~
main.c: In function 'main':
main.c:16:19: error: expected ';' before 'int'
   16 |         int y[300]
      |                   ^
      |                   ;
   17 |         int q;
      |         ~~~        
main.c:29:17: error: 'y' undeclared (first use in this function)
   29 |                 y[n] = j;
      |                 ^
main.c:29:17: note: each undeclared identifier is reported only once for each function it appears in
Language: C

/*
 AtCoder XXX 000
 */
 
#include <stdio.h>
#include <math.h>

int main(void){
	
	int n;
	int width,height,dist;
	int a[60000];
	int q;
	int l,r;
	int i,j,k;
	int from_x,from_y;
	int goto_x,goto_y;
	int maryoku;
	
	scanf("%d",&height);
	scanf("%d",&width);
	scanf("%d",&dist);
	
	for(j=0; j<height; j++) for(i=0; i<width; i++){
		scanf("%d",&n);
		a[n] = j*width + i;
	}
	
	scanf("%d",&q);
	
	for(k=0; k<q; k++){
		maryoku=0;
		scanf("%d",&l);
		scanf("%d",&r);
		
		from_x = a[l]%width;
		from_y = (a[l] - from_x);
		
		while(l != r){
			l += dist;
			goto_x = a[l]%widthx;
			goto_y = (a[l] - from_x);
			maryoku += (int)fabs(from_x - goto_x);
			maryoku += (int)fabs(from_y - goto_y);
			from_x = goto_x;
			from_y = goto_y;
		}
		printf("%d\n",maryoku);
	}
	
	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:41:39: error: 'widthx' undeclared (first use in this function); did you mean 'width'?
   41 |                         goto_x = a[l]%widthx;
      |                                       ^~~~~~
      |                                       width
main.c:41:39: note: each undeclared identifier is reported only once for each function it appears in
Language: C

/*
 AtCoder XXX 000
 */
 
#include <stdio.h>
#include <math.h>

int main(void){
	
	int n;
	int width,height,dist;
	int a[60000];
	int q;
	int l,r;
	int i,j,k;
	int from_x,from_y;
	int goto_x,goto_y;
	int maryoku;
	
	scanf("%d",&height);
	scanf("%d",&width);
	scanf("%d",&dist);
	
	for(j=0; j<height; j++) for(i=0; i<width; i++){
		scanf("%d",&n);
		a[n] = j*width + i;
	}
	
	scanf("%d",&q);
	
	for(k=0; k<q; k++){
		maryoku=0;
		scanf("%d",&l);
		scanf("%d",&r);
		
		a[l]%width = from_x;
		(a[l] - from_x) = from_y;
		
		while(l != r){
			l += dist;
			a[l]%width = goto_x;
			(a[l] - from_x) = goto_y;
			maryoku += (int)fabs(from_x - goto_x);
			maryoku += (int)fabs(from_y - goto_y);
			from_x = goto_x;
			from_y = goto_y;
		}
		printf("%d\n",maryoku);
	}
	
	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:36:28: error: lvalue required as left operand of assignment
   36 |                 a[l]%width = from_x;
      |                            ^
main.c:37:33: error: lvalue required as left operand of assignment
   37 |                 (a[l] - from_x) = from_y;
      |                                 ^
main.c:41:36: error: lvalue required as left operand of assignment
   41 |                         a[l]%width = goto_x;
      |                                    ^
main.c:42:41: error: lvalue required as left operand of assignment
   42 |                         (a[l] - from_x) = goto_y;
      |                                         ^
Language: C

/*
 AtCoder XXX 000
 */
 
#include <stdio.h>
#include <math.h>

int main(void){
	
	int width,height,dist;
	int a[300][300];
	int q;
	int l,r;
	int i,j,k;
	int from_x,from_y;
	int goto_x,goto_y;
	int maryoku;
	
	scanf("%d",&height);
	scanf("%d",&width);
	scanf("%d",&dist);
	
	for(i=0; i<width; i++) for(j=0; j<height; j++){
		scanf("%d",&a[i][j]);
	}
	
	scanf("%d",&q);
	
	for(k=0,maryoku=0; k<q; k++){
		scanf("%d",&l);
		scanf("%d",&r);
		
		for(i=0; i<width; i++) for(j=0; j<height; j++){
			if(a[i][j] == l){
				from_x = i;
				form_y = j;
				goto OUT;
			}
		}
		
		OUT:
		while(l != r){
			l += dist;
			for(i=0; i<width; i++) for(j=0; j<height; j++){
				if(a[i][j] == l){
					goto_x = i;
					goto_y = j;
					maryoku += (int)fabs(from_x - goto_x);
					maryoku += (int)fabs(from_y - goto_y);
					from_x = goto_x;
					from_y = goto_y;
					goto END;
				}
			}
			END:
		}
		printf("%d\n",maryoku);
	}
	
	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:36:33: error: 'form_y' undeclared (first use in this function); did you mean 'from_y'?
   36 |                                 form_y = j;
      |                                 ^~~~~~
      |                                 from_y
main.c:36:33: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <iostream>
using namespace std;
#include <algorithm>

#define main() int main()
#define int int64_t
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int nolm(int a){
	return max(a, -a);
}

main() {
int H, W, D, Q;
cin >> H >> W >> D;
int map[H*W+10][2];

rep(i,H){ rep(j,W) {
	int tmp;
	cin >> tmp;
	map[tmp-1][0] = i;
	map[tmp-1][1] = j;
}}

int cost[H*W+10];
rep(i,H*W){
	int count=0;
	if(i > D){
		count = cost[i-D];
		int mcost = 0;
		mcost += nolm(map[i][0] - map[i-D][0]) + nolm(map[i][1] - map[i-D][1]);
		count += mcost;
	}	
	
	cost[i] = count;
}


cin >> Q;

rep(n,Q){
	int L, R;
	cin >> L >> R;
	L--; R--;

	cout << cost[R] - cost[L]<<endl;
}

return 0;
}


Compiler output:
a.cc:6:13: error: '::main' must return 'int'
    6 | #define int int64_t
      |             ^~~~~~~
a.cc:5:16: note: in expansion of macro 'int'
    5 | #define main() int main()
      |                ^~~
a.cc:13:1: note: in expansion of macro 'main'
   13 | main() {
      | ^~~~
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vector<int> > vvi;
typedef vector<vector<double> > vvd;
#include "../template.hpp"

namespace std {
    template <>
    class hash<std::pair<int, int>> {
    public:
        size_t operator()(const std::pair<int, int>& x) const{
            return hash<int>()(x.first) ^ hash<int>()(x.second);
        }
    };
}

int recur(int L, int R, int D, unordered_map<pii, int> &memo, unordered_map<int, pii> &m){

    if( L == R ) return 0;
    if( memo.find(pii(L, R))!= memo.end() ) return memo[pii(L, R)];

    auto prev = m[L];
    auto next = m[L+D];
    int res = recur(L+D, R, D, memo, m) + abs(prev.first-next.first) + abs(prev.second-next.second);
    memo[pii(L, R)] = res;
    return res;

}

int main(){

    int H, W, D;
    cin >> H >> W >> D;

    unordered_map<int, pii> m;
    int tmp;

    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            cin >> tmp;
            m[tmp] = pii(i, j);
        }
    }

    int Q, L, R;
    cin >> Q;
    unordered_map<pii, int> memo;

    while(Q--){
        int result = 0;
        cin >> L >> R;
        cout << recur(L, R, D, memo, m) << endl;
    }

    return 0;
}

Compiler output:
a.cc:28:10: fatal error: ../template.hpp: No such file or directory
   28 | #include "../template.hpp"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <cmath>

int main(void) {
	int H, W, D, Q;
	int buf;
	int* L, R, cost;
	// stdin
	std::cin >> H >> W >> D;
	int* X = new int[H * W];
	int* Y = new int[H * W];
	for(int i = 0; i < H; ++i) {
		for(int j = 0; j < W; ++j) {
			std::cin >> buf;
			X[buf] = i;
			Y[buf] = j;
		}
	}
	// skill test, starts from L, ends at R
	std::cin >> Q;
	cost = new int[Q];
	L = new int[Q];
	R = new int[Q];
	for(int hoge = 0; hoge < Q; ++hoge) {
		std::cin >> L[hoge] >> R[hoge];
	}
	for(int hoge = 0; hoge < Q; ++hoge) {
		cost[hoge] = 0;
		//std::cin >> L >> R;
		for(int pos = L[hoge]; pos < R[hoge]; pos += D) {
			// cost btwn pos and (pos + D)
			cost[hoge] += std::abs(X[pos + D] - X[pos]) + std::abs(Y[pos + D] - Y[pos]);
		}
	}
	for(int hoge = 0; hoge < Q; ++hoge) {
		std::cout << cost[hoge] << std::endl;
	}
	delete [] X;
	delete [] Y;
	delete [] cost;
	delete [] L;
	delete [] R;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:16: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   21 |         cost = new int[Q];
      |                ^~~~~~~~~~
      |                |
      |                int*
a.cc:23:13: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   23 |         R = new int[Q];
      |             ^~~~~~~~~~
      |             |
      |             int*
a.cc:25:41: error: invalid types 'int[int]' for array subscript
   25 |                 std::cin >> L[hoge] >> R[hoge];
      |                                         ^
a.cc:28:21: error: invalid types 'int[int]' for array subscript
   28 |                 cost[hoge] = 0;
      |                     ^
a.cc:30:47: error: invalid types 'int[int]' for array subscript
   30 |                 for(int pos = L[hoge]; pos < R[hoge]; pos += D) {
      |                                               ^
a.cc:32:29: error: invalid types 'int[int]' for array subscript
   32 |                         cost[hoge] += std::abs(X[pos + D] - X[pos]) + std::abs(Y[pos + D] - Y[pos]);
      |                             ^
a.cc:36:34: error: invalid types 'int[int]' for array subscript
   36 |                 std::cout << cost[hoge] << std::endl;
      |                                  ^
a.cc:40:19: error: type 'int' argument given to 'delete', expected pointer
   40 |         delete [] cost;
      |                   ^~~~
a.cc:42:19: error: type 'int' argument given to 'delete', expected pointer
   42 |         delete [] R;
      |                   ^
Language: C++

#include <iostream>
#include <cmath>

int main(void) {
	int H, W, D, Q, L, R;
	int buf;
	int* cost;
	// stdin
	std::cin >> H >> W >> D;
	int* X = new int[H * W];
	int* Y = new int[H * W];
	for(int i = 0; i < H; ++i) {
		for(int j = 0; j < W; ++j) {
			std::cin >> buf;
			X[buf] = i;
			Y[buf] = j;
		}
	}
	// skill test, starts from L, ends at R
	std::cin >> Q;
	cost = new int[Q]
	for(int hoge = 0; hoge < Q; ++hoge) {
		cost[hoge] = 0;
		std::cin >> L >> R;
		for(int pos = L; pos < R; pos += D) {
			// cost btwn pos and (pos + D)
			cost[hoge] += std::abs(X[pos + D] - X[pos]) + std::abs(Y[pos + D] - Y[pos]);
		}
	}
	for(int hoge = 0; hoge < Q; ++hoge) {
		std::cout << cost[hoge] << std::endl;
	}
	delete [] X;
	delete [] Y;
	delete [] cost;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:26: error: expected ';' before 'for'
   21 |         cost = new int[Q]
      |                          ^
      |                          ;
   22 |         for(int hoge = 0; hoge < Q; ++hoge) {
      |         ~~~               
a.cc:22:27: error: 'hoge' was not declared in this scope
   22 |         for(int hoge = 0; hoge < Q; ++hoge) {
      |                           ^~~~
Language: C++

#include <iostream>
#include <cmath>

int main(void) {
	int H, W, D, Q, L, R;
	int buf;
	int cost = 0;
	// stdin
	std::cin >> H >> W >> D;
	int[] X = new int[H * W];
	int[] Y = new int[H * W];
	for(int i = 0; i < H; ++i) {
		for(int j = 0; j < W; ++j) {
			std::cin >> buf;
			X[buf] = i;
			Y[buf] = j;
		}
	}
	// skill test, starts from L, ends at R
	std::cin >> Q;
	for(int hoge = 0; hoge < Q; ++hoge) {
		std::cin >> L >> R;
		for(int pos = L; pos < R; pos += D) {
			// cost btwn pos and (pos + D)
			cost += std::abs(X[pos + D] - X[pos]) + std::abs(Y[pos + D] - Y[pos]);
		}
	}
	std::cout << cost << std::endl;
	delete [] X;
	delete [] Y;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: structured binding declaration cannot have type 'int'
   10 |         int[] X = new int[H * W];
      |            ^~
a.cc:10:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:10:12: error: empty structured binding declaration
a.cc:10:15: error: expected initializer before 'X'
   10 |         int[] X = new int[H * W];
      |               ^
a.cc:11:12: error: structured binding declaration cannot have type 'int'
   11 |         int[] Y = new int[H * W];
      |            ^~
a.cc:11:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:11:12: error: empty structured binding declaration
a.cc:11:15: error: expected initializer before 'Y'
   11 |         int[] Y = new int[H * W];
      |               ^
a.cc:15:25: error: 'X' was not declared in this scope
   15 |                         X[buf] = i;
      |                         ^
a.cc:16:25: error: 'Y' was not declared in this scope
   16 |                         Y[buf] = j;
      |                         ^
a.cc:25:42: error: 'X' was not declared in this scope
   25 |                         cost += std::abs(X[pos + D] - X[pos]) + std::abs(Y[pos + D] - Y[pos]);
      |                                          ^
a.cc:25:74: error: 'Y' was not declared in this scope
   25 |                         cost += std::abs(X[pos + D] - X[pos]) + std::abs(Y[pos + D] - Y[pos]);
      |                                                                          ^
a.cc:29:19: error: 'X' was not declared in this scope
   29 |         delete [] X;
      |                   ^
a.cc:30:19: error: 'Y' was not declared in this scope
   30 |         delete [] Y;
      |                   ^
Language: C++

#include <iostream>
#include <cmath>

int main(void) {
	int H, W, D, Q, L, R;
	int buf;
	int cost = 0;
	// stdin
	std::cin >> H >> W >> D;
	int X = new int[H * W];
	int Y = new int[H * W];
	for(int i = 0; i < H; ++i) {
		for(int j = 0; j < W; ++j) {
			std::cin >> buf;
			X[buf] = i;
			Y[buf] = j;
		}
	}
	// skill test, starts from L, ends at R
	std::cin >> Q;
	for(int hoge = 0; hoge < Q; ++hoge) {
		std::cin >> L >> R;
		for(int pos = L; pos < R; pos += D) {
			// cost btwn pos and (pos + D)
			cost += std::abs(X[pos + D] - X[pos]) + std::abs(Y[pos + D] - Y[pos]);
		}
	}
	std::cout << cost << std::endl;
	delete [] X;
	delete [] Y;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:30: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   10 |         int X = new int[H * W];
      |                              ^
      |                              |
      |                              int*
a.cc:11:30: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   11 |         int Y = new int[H * W];
      |                              ^
      |                              |
      |                              int*
a.cc:15:26: error: invalid types 'int[int]' for array subscript
   15 |                         X[buf] = i;
      |                          ^
a.cc:16:26: error: invalid types 'int[int]' for array subscript
   16 |                         Y[buf] = j;
      |                          ^
a.cc:25:43: error: invalid types 'int[int]' for array subscript
   25 |                         cost += std::abs(X[pos + D] - X[pos]) + std::abs(Y[pos + D] - Y[pos]);
      |                                           ^
a.cc:25:56: error: invalid types 'int[int]' for array subscript
   25 |                         cost += std::abs(X[pos + D] - X[pos]) + std::abs(Y[pos + D] - Y[pos]);
      |                                                        ^
a.cc:25:75: error: invalid types 'int[int]' for array subscript
   25 |                         cost += std::abs(X[pos + D] - X[pos]) + std::abs(Y[pos + D] - Y[pos]);
      |                                                                           ^
a.cc:25:88: error: invalid types 'int[int]' for array subscript
   25 |                         cost += std::abs(X[pos + D] - X[pos]) + std::abs(Y[pos + D] - Y[pos]);
      |                                                                                        ^
a.cc:29:19: error: type 'int' argument given to 'delete', expected pointer
   29 |         delete [] X;
      |                   ^
a.cc:30:19: error: type 'int' argument given to 'delete', expected pointer
   30 |         delete [] Y;
      |                   ^
Language: C

#include <stdio.h>
#include <math.h>
 
int main(){
	int h,w,d,q;
	scanf("%d",&h);
	scanf("%d",&w);
	scanf("%d",&d);
	int arr[90001][2],dif[90001];
	for(int i = 0;i < h ; i++){
		for(int j = 0;j < w ;j++){
			int num;
			scanf("%d",&num);
			arr[num][0] = i;
			arr[num][1] = j;
		}
	}
        for(int i=1;i<h*w+1-d;i++){
               dif[i]  = abs(arr[i+d][0]-arr[i][0])+abs(arr[i+d][1]-arr[i][1]);
        }
	scanf("%d",&q);
	int R,L;
	for(int i = 1;i < q+1;i++){
		scanf("%d",&L);
		scanf("%d",&R);
                int answer = 0;
		while(R-L > 0)
		{
			answer += dif[L]
			L += d;
		}
		printf("%d\n",answer);
	}
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:19:26: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   19 |                dif[i]  = abs(arr[i+d][0]-arr[i][0])+abs(arr[i+d][1]-arr[i][1]);
      |                          ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include <math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:29:41: error: expected ';' before 'L'
   29 |                         answer += dif[L]
      |                                         ^
      |                                         ;
   30 |                         L += d;
      |                         ~
Language: C

#include <stdio.h>
#include <math.h>
 
int main(){
	int h,w,d,q;
	scanf("%d",&h);
	scanf("%d",&w);
	scanf("%d",&d);
	int arr[90001][2],dif[90001];
	for(int i = 0;i < h ; i++){
		for(int j = 0;j < w ;j++){
			int num;
			scanf("%d",&num);
			arr[num][0] = i;
			arr[num][1] = j;
		}
	}
        for(i=1;i<h*w+1-d;i++){
               dif[i]  = abs(arr[i+d][0]-arr[i][0])+abs(arr[i+d][1]-arr[i][1]);
        }
	scanf("%d",&q);
	int R,L;
	for(int i = 1;i < q+1;i++){
		scanf("%d",&L);
		scanf("%d",&R);
                int answer = 0;
		while(R-L > 0)
		{
			answer += dif[L]
			L += d;
		}
		printf("%d\n",answer);
	}
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:18:13: error: 'i' undeclared (first use in this function)
   18 |         for(i=1;i<h*w+1-d;i++){
      |             ^
main.c:18:13: note: each undeclared identifier is reported only once for each function it appears in
main.c:19:26: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   19 |                dif[i]  = abs(arr[i+d][0]-arr[i][0])+abs(arr[i+d][1]-arr[i][1]);
      |                          ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include <math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:29:41: error: expected ';' before 'L'
   29 |                         answer += dif[L]
      |                                         ^
      |                                         ;
   30 |                         L += d;
      |                         ~
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <stack>
#define N 1005
using namespace std;
typedef long long ll;
int a[305][305];
struct node
{
    int x;
    int y;
}p[90005];
int ans[90005];
int main()
{
    int h,w,d,len;
    scanf("%d%d%d",&h,&w,&d);
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++){
          scanf("%d",&a[i][j]);
          int n=a[i][j];
           p[n].x=i;
           p[n].y=j;
        }
    int q;
    len=h*w;
    scanf("%d",&q);
    for(int i=1;i<=d;i++)
    {
        int l=i,r=len,sum=0;
        ans[i]=0;
        while(l<r)
        {
            sum=sum+abs(p[l].x-p[l+d].x)+abs(p[l].y-p[l+d].y);
            l=l+d;
            ans[l]=sum;
        }
 
    }
    while(q--)
    {
        int l,r;
        scanf("%d%d",&l,&r);
        printf("%d\n",ans[r]-ans[l]);
    }
}
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <stack>
#define N 1005
using namespace std;
typedef long long ll;
int a[305][305];
struct node
{
    int x;
    int y;
}p[90005];
int ans[90005];
int main()
{
    int h,w,d,len;
    scanf("%d%d%d",&h,&w,&d);
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++){
          scanf("%d",&a[i][j]);
          int n=a[i][j];
           p[n].x=i;
           p[n].y=j;
        }
    int q;
    len=h*w;
    scanf("%d",&q);
    for(int i=1;i<=d;i++)
    {
        int l=i,r=len,sum=0;
        ans[i]=0;
        while(l<r-d)
        {
            sum=sum+abs(p[l].x-p[l+d].x)+abs(p[l].y-p[l+d].y);
            l=l+d;
            ans[l]=sum;
        }

    }
    while(q--)
    {
        int l,r;
        scanf("%d%d",&l,&r);
        printf("%d\n",ans[r]-ans[l]);
    }
}


Compiler output:
a.cc:65:5: error: redefinition of 'int a [305][305]'
   65 | int a[305][305];
      |     ^
a.cc:13:5: note: 'int a [305][305]' previously declared here
   13 | int a[305][305];
      |     ^
a.cc:66:8: error: redefinition of 'struct node'
   66 | struct node
      |        ^~~~
a.cc:14:8: note: previous definition of 'struct node'
   14 | struct node
      |        ^~~~
a.cc:70:2: error: conflicting declaration 'int p [90005]'
   70 | }p[90005];
      |  ^
a.cc:18:2: note: previous declaration as 'node p [90005]'
   18 | }p[90005];
      |  ^
a.cc:71:5: error: redefinition of 'int ans [90005]'
   71 | int ans[90005];
      |     ^~~
a.cc:19:5: note: 'int ans [90005]' previously declared here
   19 | int ans[90005];
      |     ^~~
a.cc:72:5: error: redefinition of 'int main()'
   72 | int main()
      |     ^~~~
a.cc:20:5: note: 'int main()' previously defined here
   20 | int main()
      |     ^~~~
Language: C++

# include <cstdio >
# define abs(x) ((x >0)? x:( -(x )))
int H,W,D,A;
int Q,L,R;
int px [90001] , py [90001];
int d [90001];
int main ()
{
scanf ("% d%d%d",&H ,&W ,&D);
for (int i=0;i<H;i++)
{
for (int j=0;j<W;j++)
{
scanf ("% d",&A);
px[A]=i,py[A]=j;
}
}
for (int i=D+1;i <=H*W;i++)
d[i]=d[i-D]+ abs(px[i]-px[i-D ])+ abs(py[i]-py[i-D ]);
scanf ("% d",&Q);
while (Q --)
{
scanf ("% d%d",&L ,&R);
printf ("%d\n",d[R]-d[L]);
}
}

Compiler output:
a.cc:1:11: fatal error: cstdio : No such file or directory
    1 | # include <cstdio >
      |           ^~~~~~~~~
compilation terminated.
Language: C++

# include <cstdio >
# define abs(x) ((x >0)? x:( -(x )))
int H,W,D,A;
int Q,L,R;
int px [90001] , py [90001];
int d [90001];
int main ()
{
scanf ("% d%d%d",&H ,&W ,&D);
for (int i=0;i<H;i++)
{
for (int j=0;j<W;j++)
{
scanf ("% d",&A);
px[A]=i,py[A]=j;
}
}
for (int i=D+1;i <=H*W;i++)
d[i]=d[i-D]+ abs(px[i]-px[i-D ])+ abs(py[i]-py[i-D ]);
scanf ("% d",&Q);
while (Q --)
{
scanf ("% d%d",&L ,&R);
printf ("%d\n",d[R]-d[L]);
}
return 0;
}


Compiler output:
a.cc:1:11: fatal error: cstdio : No such file or directory
    1 | # include <cstdio >
      |           ^~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>

using namespace std;

int main(void){
	int h, w, d;

	scanf("%d%d%d", &h, &w, &d);
//	cin >> h >> w >> d;


	int array[901][2];

//	vector< vector<int> > array(h * w + 1, vector<int>(2, 0));

	int t;
	for (int i = 1; i < h+1; i++){
		for (int j = 1; j < w + 1; j++){
			scanf("%d", &t);
//			cin >> t;

			array[t] = {i, j};
		}
	}




	int q, l, r;

	scanf("%d", &q);

//	cin >> q;

	for (int i = 0; i < q; i++){
		scanf("%d%d", &l, &r);
//		cin >> l >> r;

		int sum = 0;

		int temp = l;

		while (l != r){
			sum += abs(array[l][0] - array[l+d][0])
					+ abs(array[l][1] - array[l+d][1]);


			l += d;
		}

		printf("%d\n", sum);

//		cout << sum << endl;
	}



}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:34: error: assigning to an array from an initializer list
   25 |                         array[t] = {i, j};
      |                         ~~~~~~~~~^~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string.h>
#include <math.h>
typedef long long ll;
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REP(i,x,y)	for (int (i)=(x);(i)<(y);(i)++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef pair<int, int> Point;
typedef vector<vector<Point>> Graph;
Point num[90001];
int d[90001];

int N,H,W,D,Q,R,L;

int A[301][301];

int main() {
	cin >> H >> W >> D;
	
	REP(i,0,H) REP(j,0,W) {
		cin >> A[i][j];
		num[A[i][j]].first = i+1;
		num[A[i][j]].second = j+1;
	}
	
	REP(i,D+1,H*W+1) 
	d[i] = dx[i-D] + ABS(num[i].first - num[i-D].first) + ABS(num[i].second - num[i-D].second);

	cin >> Q;
	
	REP(i,0,Q) {
		cin >> L >> R;
		cout << (d[R]-d[L]) << endl;
	}
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:16: error: 'dx' was not declared in this scope; did you mean 'd'?
   34 |         d[i] = dx[i-D] + ABS(num[i].first - num[i-D].first) + ABS(num[i].second - num[i-D].second);
      |                ^~
      |                d
Language: C++

#include<iostream>
using namespace std;
int main(){
	int h,w,d
	cin >> h >> w >> d;
        int n,m;
        int ans = 0;
		int masu[h][w];
        for(n=0;n<h;n++){
        	for(m=0;m<w;m++){
            	cin >> masu[n][m];
            }
        }
      	int num[h*w+1][2];
        for(n=0;n<h;n++){
        	for(m=0;m<w;m++){
            	num[masu[n][m]][0]=n;
                num[masu[n][m]][1]=m;
            }
        }
      	int q;
        cin >> q;
        int lr[q][2];
      	for(n=0;n<q;n++){
        	for(m=0;m<2;m++){
            	cin >> lr[n][m];
            }
        }
      	for(n=0;n<q;n++){
        ans = 0;
        	int s = (lr[n][1]-lr[n][0])/d;
          	int p = lr[n][0];
            for(int t=0;t<s;t++){
                ans += abs(num[p+d*(t+1)][0]-num[p+d*t][0]);
                ans += abs(num[p+d*(t+1)][1]-num[p+d*t][1]);
            }
        cout <<ans << endl;
        }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:9: error: expected initializer before 'cin'
    5 |         cin >> h >> w >> d;
      |         ^~~
a.cc:31:45: error: 'd' was not declared in this scope
   31 |                 int s = (lr[n][1]-lr[n][0])/d;
      |                                             ^