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

#include <bits/stdc++.h>
using namespace std;
int A[300][300];
int H,W,D;
typedef pair<int,int> pii;
pii points[90000];
vector<int> ans[90000];
int main()
{
    int i,j,Q;
    scanf("%d%d%d",&H,&W,&D);
    for(i=0;i<H;i++)
    {
        for(j=0;j<W;j++) scanf("%d",&A[i][j]);
    }
    for(i=0;i<H;i++)
    {
        for(j=0;j<W;j++)
            points[A[i][j]-1]=make_pair(i,j);
    }
    for(i=0;i<D;i++)
    {
        ans[i].push_back(0);
        for(j=i+D;j<H*W;j+=D)
        {
            int dist=abs(points[j].first-points[j-D].first)
                     +abs(points[j].second-points[j-D].second);
            ans[i].push_back(ans[i].back()+dist);
        }
    }
    scanf("%d",&Q);
    for(i=0;i<Q;i++)
    {
        int L,R;
        scanf("%d%d",&L,&R);
        L--;R--;
        int rem=L%D;
        int q1=L/D;
        int q2=R/D;
        printf("%d\n",ans[rem][q2]-ans[rem][q1]);
    }
    return 0;
} 

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
using namespace std;
int main(){
	Scanner sc = new Scanner(System.in);
	int h,w,d;
    cin >> h >>w >>d;
    int n,m,x;
    int num[][] = new int[h*w+1][2];
    for(n=0;n<h;n++){
   		for(m=0;m<w;m++){
        	cin >> x;
            num[x][0]=n;
            num[x][1]=m;
        }
    }
    cin >> h;
    int ans;
    int r,l;
    for(n=0;n<h;n++){
        cin >> l >>r;
        ans = 0;
        w = (r-l)/d;
        for(x=0;x<w;x++){
            ans += abs(num[l+d*(x+1)][0]-num[l+d*x][0])+abs(num[l+d*(x+1)][1]-num[l+d*x][1]);
        }
       	cout << ans << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:9: error: 'Scanner' was not declared in this scope
    4 |         Scanner sc = new Scanner(System.in);
      |         ^~~~~~~
a.cc:8:9: error: declaration of 'num' as multidimensional array must have bounds for all dimensions except the first
    8 |     int num[][] = new int[h*w+1][2];
      |         ^~~
a.cc:12:13: error: 'num' was not declared in this scope; did you mean 'enum'?
   12 |             num[x][0]=n;
      |             ^~~
      |             enum
a.cc:24:24: error: 'num' was not declared in this scope; did you mean 'enum'?
   24 |             ans += abs(num[l+d*(x+1)][0]-num[l+d*x][0])+abs(num[l+d*(x+1)][1]-num[l+d*x][1]);
      |                        ^~~
      |                        enum
Language: Java

import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int d = sc.nextInt();
        int n,m;
        int ans = 0;
		int masu[][] = new int[h][w]
        for(n=0;n<h;n++){
        	for(m=0;m<w;m++){
            	masu[n][m] = sc.nextInt();
            }
        }
      	int num[][] = new int[h*w][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 = sc.nextInt();
        int lr[][] = new int[q][2];
      	for(n=0;n<q;n++){
        	for(m=0;m<2;m++){
            	lr[n][m] = sc.nextInt();
            }
        }
      	for(n=0;n<q;n++){
        	int s = (lr[n][1]-lr[n][0])/d;
          	int p = lr[n][0];
            for(int t=0;t<s;t++){
                ans += Math.abs(num[p+d*(t+1)][0]-num[p+d*t][0])
                ans += Math.abs(num[p+d*(t+1)][1]-num[p+d*t][1])
            }
        System.out.println(ans);
        }

	}
}

Compiler output:
Main.java:10: error: ';' expected
		int masu[][] = new int[h][w]
		                            ^
Main.java:34: error: ';' expected
                ans += Math.abs(num[p+d*(t+1)][0]-num[p+d*t][0])
                                                                ^
Main.java:35: error: ';' expected
                ans += Math.abs(num[p+d*(t+1)][1]-num[p+d*t][1])
                                                                ^
3 errors
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
struct position{
    int y, x;
};

int need_magic_cost[H * W];
 
int main(){
    int H, W, D;
    cin >> H >> W >> D;
    position number_position[H * W];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            int num;
            cin >> num;
            number_position[num - 1] = {i, j};
        }
    }
    for(int i = H * W - D - 1; i >= 0; i--){
        need_magic_cost[i] = need_magic_cost[i + D] + abs(number_position[i].y - number_position[i + D].y) + abs(number_position[i].x - number_position[i + D].x);
    }
    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int left, right;
        cin >> left >> right;
        cout << need_magic_cost[left - 1] - need_magic_cost[right - 1] << endl;
    }
}

Compiler output:
a.cc:10:21: error: 'H' was not declared in this scope
   10 | int need_magic_cost[H * W];
      |                     ^
a.cc:10:25: error: 'W' was not declared in this scope
   10 | int need_magic_cost[H * W];
      |                         ^
a.cc: In function 'int main()':
a.cc:24:9: error: 'need_magic_cost' was not declared in this scope
   24 |         need_magic_cost[i] = need_magic_cost[i + D] + abs(number_position[i].y - number_position[i + D].y) + abs(number_position[i].x - number_position[i + D].x);
      |         ^~~~~~~~~~~~~~~
a.cc:31:17: error: 'need_magic_cost' was not declared in this scope
   31 |         cout << need_magic_cost[left - 1] - need_magic_cost[right - 1] << endl;
      |                 ^~~~~~~~~~~~~~~
Language: Java

import java.util.*;

public class main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int h, w, d, q, l, r;
		h = sc.nextInt();
		w = sc.nextInt();
		d = sc.nextInt();
		
		int[] px = new int[h * w + 1];
		int[] py = new int[h * w + 1];
		int[] m  = new int[h * w + 1];
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				int a = sc.nextInt();
				px[a] = i;
				py[a] = j;
			}
		}
		for(int i = d + 1; i < h * w; i++){
			m[i] = m[i-d] + Math.abs(px[i] - px[i - d]) + Math.abs(py[i] - py[i - d]);
		}
		q = sc.nextInt();
		
		for(int i = 0; i < q; i++){
			l = sc.nextInt();
			r = sc.nextInt();
			System.out.println(m[r] - m[l]);
		}
	}
}


Compiler output:
Main.java:3: error: class main is public, should be declared in a file named main.java
public class main {
       ^
1 error
Language: C++

#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int H, W, D, Q;
int v[301][301];
queue<pair<int, int>> qu;
int main() {
	cin >> H >> W >> D;//H=3, W=3, D=2
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> v[i][j];
		}
	}
	cin >> Q;
	for (int i = 0; i < Q; ++i) {
		int L, R; cin >> L >> R;
		int x = L, cnt = 0;
		bool flag = true;
		for (;;) {
			if (x == R || !flag) break;

			for (int j = 0; j < H; ++j) {
				for (int k = 0; k < W; ++k) {
					if (x == v[j][k]) qu.push({ j,k });
					if (j == H - 1 && k == W - 1 && qu.size() == 0) flag = false;
				}
			}
			for (int j = 0; j < H; ++j) {
				for (int k = 0; k < W; ++k) {
					if (x + D == v[j][k]) {
						cnt += abs(j - qu.front().first) + abs(k - qu.front().second);
						x += D;
						qu.pop();
					}
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'cin' was not declared in this scope
    9 |         cin >> H >> W >> D;//H=3, W=3, D=2
      |         ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include<queue>
  +++ |+#include <iostream>
    4 | using namespace std;
a.cc:39:17: error: 'cout' was not declared in this scope
   39 |                 cout << cnt << endl;
      |                 ^~~~
a.cc:39:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:39:32: error: 'endl' was not declared in this scope
   39 |                 cout << cnt << endl;
      |                                ^~~~
a.cc:4:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    3 | #include<queue>
  +++ |+#include <ostream>
    4 | using namespace std;
Language: C++

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

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

    int A, x[H * W], y[H * W];
    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 L[Q], R[Q];
    for (int i = 0; i < Q; i++) cin >> L[i] >> R[i];

    int d[H * W + 1] = {};
    for (int i = D + 1; i <= H * W; i++) {
        d[i] = d[i - D] + abs(x[i] - x[i - D]) + abs(y[i] - y[i - D]);
        d[i] = d[i - D] + abs(vp[i - D].second - vp[i].second) + abs(vp[i - D].first - vp[i].first);

    for (int i = 0; i < Q; i++) {
        cout << d[R[i]] - d[L[i]] << endl;
    }

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:31: error: 'vp' was not declared in this scope
   24 |         d[i] = d[i - D] + abs(vp[i - D].second - vp[i].second) + abs(vp[i - D].first - vp[i].first);
      |                               ^~
a.cc:31:2: error: expected '}' at end of input
   31 | }
      |  ^
a.cc:5:1: note: to match this '{'
    5 | {
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long intint main(void){
    int m[90000][90000];
    cout<<0;
}


Compiler output:
a.cc:5:5: error: 'cout' does not name a type
    5 |     cout<<0;
      |     ^~~~
a.cc:6:1: error: expected declaration before '}' token
    6 | }
      | ^
Language: C++

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

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

    vector<int> x(W*H+1);
    vector<int> y(W*H+1);
    vector<int> d(W*H+1);

    for (i=0;i<H;i++) {
        for (j=0;j<W;j++) {
            int a;
            cin >> a;
            x[a] = i;
            y[a] = j;
        }
    }

    for (int i=D+1;i<=W*H;i++) {
        d[i] = d[i - D] + abs(x[i] - x[i - D]) + abs(y[i] - y[i - D]);
    }

    int Q;
    cin >> Q;
    while (Q--) {
        int L, R;
        cin >> L >> R;
        cout << d[R] - d[L] << endl;
    }

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:10: error: 'i' was not declared in this scope
   12 |     for (i=0;i<H;i++) {
      |          ^
a.cc:13:14: error: 'j' was not declared in this scope
   13 |         for (j=0;j<W;j++) {
      |              ^
Language: C++

#include <cstdio>
using namespace std;

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

int main(){
    int H,W,D,Q,A,L,R;
    int *mp = new int[H*W];
    int *x = new int[H*W]; 
    int *y = new int[H*W];

    scanf("%d %d %d",&H,&W,&D);
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            scanf("%d", &A)
            x[j]=A;
            y[i]=A;
        }
    }

    for(int i=D+1;i<H*W;i++){
            mp[i]=mp[i-D]+abs(x[i]-x[i-D])+abs(y[i]-y[i-D]);
    }

    scanf("%d",&Q);
    for(int i=0;i<Q;i++){
        scanf("%d %d",&L,&R);
        printf("%d\n",mp[R]-mp[L]);
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:28: error: expected ';' before 'x'
   17 |             scanf("%d", &A)
      |                            ^
      |                            ;
   18 |             x[j]=A;
      |             ~
Language: C++

#include <cstdio>
using namespace std;
 
int main(){
    int H,W,D,Q,A,L,R;
    int *mp = new int[H*W];
    int *x = new int[H*W]; 
    int *y = new int[H*W];

    scanf("%d %d %d",&H,&W,&D);
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            scanf("%d", &A)
            x[j]=A;
            y[i]=A;
        }
    }

    for(int i=D+1;i<H*W;i++){
            mp[i]=mp[i-D]+abs(x[i]-x[i-D])+abs(y[i]-y[i-D]);
    }

    scanf("%d",&Q);
    for(int i=0;i<Q;i++){
        scanf("%d %d",&L,&R);
        printf("%d\n",mp[R]-mp[L]);
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:28: error: expected ';' before 'x'
   13 |             scanf("%d", &A)
      |                            ^
      |                            ;
   14 |             x[j]=A;
      |             ~               
a.cc:20:27: error: 'abs' was not declared in this scope
   20 |             mp[i]=mp[i-D]+abs(x[i]-x[i-D])+abs(y[i]-y[i-D]);
      |                           ^~~
Language: C++

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

/* REPmacro */
#define rep(i, a, n) for (ll i = (a); i < (ll)(n); ++i)

signed main() 
{
    int h,w,d;
    cin >> h >> w >> d;
    ll dp[90001];
    int px[90001],py[90001];
    rep(i,0,h) rep(j,0,w)
    {
        int tmp; cin >> tmp;
        px[tmp]=j,py[tmp]=i;
    }
    int q; cin >> q;
    rep(i,d+1,h*w)
    {
        dp[i]=dp[i-d]+abs(px[i]-px[i-d])+abs(py[i]-py[i-d]);
    }
    rep(i,0,q)
    {
        int l,r;
        cin >> l >> r;
        cout << dp[r]-dp[l] << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:5: error: 'll' was not declared in this scope
   11 |     ll dp[90001];
      |     ^~
a.cc:13:9: error: expected ';' before 'i'
   13 |     rep(i,0,h) rep(j,0,w)
      |         ^
a.cc:5:30: note: in definition of macro 'rep'
    5 | #define rep(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
      |                              ^
a.cc:13:9: error: 'i' was not declared in this scope
   13 |     rep(i,0,h) rep(j,0,w)
      |         ^
a.cc:5:39: note: in definition of macro 'rep'
    5 | #define rep(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
      |                                       ^
a.cc:13:20: error: expected ';' before 'j'
   13 |     rep(i,0,h) rep(j,0,w)
      |                    ^
a.cc:5:30: note: in definition of macro 'rep'
    5 | #define rep(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
      |                              ^
a.cc:13:20: error: 'j' was not declared in this scope
   13 |     rep(i,0,h) rep(j,0,w)
      |                    ^
a.cc:5:39: note: in definition of macro 'rep'
    5 | #define rep(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
      |                                       ^
a.cc:19:9: error: expected ';' before 'i'
   19 |     rep(i,d+1,h*w)
      |         ^
a.cc:5:30: note: in definition of macro 'rep'
    5 | #define rep(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
      |                              ^
a.cc:19:9: error: 'i' was not declared in this scope
   19 |     rep(i,d+1,h*w)
      |         ^
a.cc:5:39: note: in definition of macro 'rep'
    5 | #define rep(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
      |                                       ^
a.cc:21:9: error: 'dp' was not declared in this scope; did you mean 'd'?
   21 |         dp[i]=dp[i-d]+abs(px[i]-px[i-d])+abs(py[i]-py[i-d]);
      |         ^~
      |         d
a.cc:23:9: error: expected ';' before 'i'
   23 |     rep(i,0,q)
      |         ^
a.cc:5:30: note: in definition of macro 'rep'
    5 | #define rep(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
      |                              ^
a.cc:23:9: error: 'i' was not declared in this scope
   23 |     rep(i,0,q)
      |         ^
a.cc:5:39: note: in definition of macro 'rep'
    5 | #define rep(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
      |                                       ^
a.cc:27:17: error: 'dp' was not declared in this scope; did you mean 'd'?
   27 |         cout << dp[r]-dp[l] << endl;
      |                 ^~
      |                 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:16: error: 'x' was not declared in this scope
    2 | # define abs ( x ) (( x >0)? x :( -( x )))
      |                ^
a.cc:19:21: note: in expansion of macro 'abs'
   19 | d[ i ]= d [i - D ]+ abs ( px [ i ] - px [i - D ])+ abs ( py [ i ] - py [i - D ]);
      |                     ^~~
a.cc:21:13: error: expected primary-expression before ')' token
   21 | while (Q - -)
      |             ^
Language: C++

#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n,m,d;
    int ma[90005][2],ans[90005];
    cin >> n >> m >> d;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
        {
            int a;
            scanf("%d",&a);
            ma[a][0]=i;
            ma[a][1]=j;
        }
    for(int i=1;i<=n*m;i++)
    {
        if(i<=d) ans[i]=0;
        else
        {
            ans[i]=ans[i-d]+abs(ma[i][0]-ma[i-d][0])+abs(ma[i][1]-ma[i-d][1]);
        }
    }
    int q,l,r;
    cin >> q;
    while(q--)
    {
        scanf("%d %d",&l,&r);
        printf("%d\n",ans[r]-ans[l]);
    }
    return 0;
}
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,m,d;
    int ma[90005][2],ans[90005];
    cin >> n >> m >> d;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
        {
            int a;
            scanf("%d",&a);
            ma[a][0]=i;
            ma[a][1]=j;
        }
    for(int i=1;i<=n*m;i++)
    {
        if(i<=d) ans[i]=0;
        else
        {
            ans[i]=ans[i-d]+abs(ma[i][0]-ma[i-d][0])+abs(ma[i][1]-ma[i-d][1]);
        }
    }
    int q,l,r;
    cin >> q;
    while(q--)
    {
        scanf("%d %d",&l,&r);
        printf("%d\n",ans[r]-ans[l]);
    }
    return 0;
}
Submission

Compiler output:
a.cc:39:5: error: redefinition of 'int main()'
   39 | int main()
      |     ^~~~
a.cc:5:5: note: 'int main()' previously defined here
    5 | int main()
      |     ^~~~
a.cc:69:1: error: 'Submission' does not name a type
   69 | Submission
      | ^~~~~~~~~~
Language: C++

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

int main(){
	int H, W , D;
	int vv[300][300][2];
	scanf("%d %d %d",&H,&W,&D);
	for(int i = 0; i< W; i++){
		for(int j = 0; j < H ; j++){
		int temp;
		scanf("%d", &temp);		
		vv[temp %D][temp/D][0] = i;
		vv[temp %D][temp/D][1] = j;
		}
	}
	int sum[300][300];
	for (int i = 0; i< D; i++){
		for (int j = 0; j <= (H * W - i)/D;j++){
			if (j != 0 & (i + D * j <= H *w)){
				int x  =abs(vv[i][j][0] -vv[i][j-1][0]);
				int y = abs(vv[i][j][1] -vv[i][j-1][1]);
			 	sum[i][j] += x + y+   sum[i][j-1];
			}
			else sum[i][j] = 0;
		}
	}
	int Q;
	scanf("%d",&Q);
	for (int i = 0 ; i <Q; i++){
		int R,L;
		scanf("%d %d",&L,&R);
		int ans = sum[R%D][R/D] - sum[R%D][L/D]; 
		printf("%d\n",ans);
	}	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:55: error: 'w' was not declared in this scope
   22 |                         if (j != 0 & (i + D * j <= H *w)){
      |                                                       ^
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)
#define MAX 100000

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

//1-indexed
vector<int> xfields(MAX);
vector<int> yfields(MAX);
ll dp[MAX];

void solve(void){
    int H, W, D; scanf("%d %d %d\n", &H, &W, &D);
    rep(H, i) {
        rep(W, j) {
            int num;
            scanf("%d ", &num);
            xfields[num] = j;
            yfields[num] = i;
        }
        scanf("\n");
    }
    Rep(0, D-1, i){
        for (int d = 0; i+d+D < H*W; d+=D) {
            dp[i+d+D] = dp[i+d] + abs(xfields[i+d+D]-xfields[i+d]) + abs(yfields[i+d+D]-yfields[i+d]);
        }
    }
    int Q; scanf("%d\n", &Q);
    rep(Q, k){
        int l, r; scanf("%d %d\n", &l, &r);
        if (r == l) {
            printf("0\n"); continue;
        }
        printf("%lld\n", dp[r] - dp[l]);
    }
}

int main(void){
  solve();
  return 0;
}


Compiler output:
a.cc:29:1: error: 'll' does not name a type
   29 | ll dp[MAX];
      | ^~
a.cc: In function 'void solve()':
a.cc:44:13: error: 'dp' was not declared in this scope; did you mean 'd'?
   44 |             dp[i+d+D] = dp[i+d] + abs(xfields[i+d+D]-xfields[i+d]) + abs(yfields[i+d+D]-yfields[i+d]);
      |             ^~
      |             d
a.cc:53:26: error: 'dp' was not declared in this scope
   53 |         printf("%lld\n", dp[r] - dp[l]);
      |                          ^~
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using namespace std;

void SolveA()
{
	int n, cnt = 0;
	scanf("%d", &n);

	while (n >= 3)
	{
		n = n - 3;
		cnt++;
	}

	printf("%d\n", cnt);
}

void SolveB()
{
	int n;
	scanf("%d", &n);

	string s = "";
	for (int i = 0; i < n; i++)
	{
		string str;
		cin >> str;
		s.append(str);
	}
	

	bool isPink = false;

	if (s.find('Y') != string::npos)
	{
		isPink = true;
	}

	if (isPink)
	{
		printf("Four\n");
	}
	else
	{
		printf("Three\n");
	}
}

void SolveC()
{
	long long int n;
	cin >> n;

	vector<string> strs;
	for (long long int i = 0; i < n; i++)
	{
		string str;
		cin >> str;
		strs.push_back(str);
	}
}

void SolveD()
{
	int H, W, D;
	scanf("%d %d %d", &H, &W, &D);
	
	int posx[90001], posy[90001];
	
	for (int h = 0; h < H; h++)
	{
		for (int w = 0; w < W; w++)
		{
			int A;
			scanf("%d", &A);
			posx[A] = w + 1;
			posy[A] = h + 1;
		}
	}

	int Q;
	scanf("%d", &Q);

	//for (int q = 0; q < Q; q++)
	//{
	//	int L, R;
	//	scanf("%d %d", &L, &R);
	//	long long int mp = 0;
	//	if (L == R)
	//	{
	//		//cout << mp << "\n";
	//		printf("%d\n", mp);
	//		continue;
	//	}
	//	else
	//	{
	//		int sum = L + D;
	//		int prt = L;
	//		mp += abs(posx[sum] - posx[prt]) + abs(posy[sum] - posy[prt]);
	//		while (sum != R)
	//		{
	//			prt = sum;
	//			sum = sum + D;
	//			mp += abs(posx[sum] - posx[prt]) + abs(posy[sum] - posy[prt]);
	//		}
	//	}
	//	printf("%d\n", mp);
	//	//cout << mp << "\n";
	//}

	vector<int> d;
	d.resize(90001, 0);

	// 累積和の導出
	for (int i = D + 1; i <= H * W; i++)
	{
		d[i] = d[i - D] + abs(posx[i] - posx[i - D]) + abs(posy[i] - posy[i - D]);
	}

	int Q;
	scanf("%d", &Q);

	while (Q--)
	{
		int L, R;
		scanf("%d %d", &L, &R);
		printf("%d\n", d[R] - d[L]);
	}
}

void EditSolveC()
{

}

int main()
{
	//SolveA();
	//SolveB();
	//SolveC();
	SolveD();
}

Compiler output:
a.cc: In function 'void SolveD()':
a.cc:130:13: error: redeclaration of 'int Q'
  130 |         int Q;
      |             ^
a.cc:91:13: note: 'int Q' previously declared here
   91 |         int Q;
      |             ^
Language: C++

#include <stdio.h>
#include <complex>
int main(void)
{
    int H,W,D,Q;
    //int A[300][300];
    int x[301],y[301];
    int L,R;
    int f;
    x[0] = 0;
    y[0] = 0;
    scanf("%d %d %d",&H,&W,&D);

    for(int i=0; i < H; i++){
        for(int j=0; j < W;j++){
            scanf(" %d",&f);
            x[f] = i+1;
            y[f] = j+1;
        }
        (void)getchar();
    }

    scanf("%d",&Q);
int z;
int score = 0;
    for(int k=0;k < Q; k++){
        scanf("%d %d",&L,&R);
        z = L;
        while(z != R[k]){
            score += std::abs(x[z] - x[z+D]) + std::abs(y[z] - y[z+D]);
            z += D;
        }
        printf("%d\n",score);
        score = 0;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:21: error: invalid types 'int[int]' for array subscript
   29 |         while(z != R[k]){
      |                     ^
Language: C++

#include<bits/stdc++.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
long long INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int vpa[300*300+1],vpb[300*300+1],vl[300*300+1],answer[100000];

int inline dist(int i){
    return abs(vpa[i]-vpa[i-d]) + abs(vpb[i]-vpb[i-d]);
}

int main(){
    int h,w,d,q;
    scanf("%d %d %d",&h,&w,&d);
    FOR(i,1,h+1){
        FOR(j,1,w+1){
            int a;
            scanf("%d",&a);
            vpa[a] = i;
            vpb[a] = j;
        }
    }

    scanf("%d",&q);
    FOR(i,1,d+1) vl[i] = 0;
    FOR(i,d+1,h*w+1) vl[i] = vl[i-d] + dist(i);

    REP(i,q){
        int l,r;
        scanf("%d %d",&l,&r);
        answer[i] = vl[r] - vl[l];
    }
    REP(i,q) printf("%d\n",answer[i]);
    return 0;
}


Compiler output:
a.cc: In function 'int dist(int)':
a.cc:14:29: error: 'd' was not declared in this scope
   14 |     return abs(vpa[i]-vpa[i-d]) + abs(vpb[i]-vpb[i-d]);
      |                             ^
Language: C++

//
//  main.cpp
//  CompetitiveProgramming
//
//  Created by Yuma Kikuchi on 2018/03/02.
//  Copyright © 2018年 yumarimo. All rights reserved.
//

#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <random>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

int main() {
    int h, w, d, q, a;
    vector<int> Pos;
    vector<pair<int, pair<int, int> > > M;
    cin >> h >> w >> d;
    field[0][0] = 0;
    REP(i, h) {
        REP(j, w) {
            cin >> a;
            M.push_back(make_pair(a, make_pair(i, j)));
        }
    }
    
    int dp[h * w][h * w];
    
    sort(M.begin(), M.end());
    cin >> q;
    int l, r;
    REP(i, q) {
        int mahou = 0;
        cin >> l >> r;
        while (l != r) {
            if (!dp[l][l + d]) {
                int tmp_mahou = abs(M[l - 1 + d].second.first - M[l - 1].second.first) + abs(M[l - 1 + d].second.second - M[l - 1].second.second);
                mahou += tmp_mahou;
                dp[l][l + d] = mahou;
            } else {
                mahou += dp[l][l + d];
            }
            l += d;
        }
        cout << mahou << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:5: error: 'field' was not declared in this scope
   50 |     field[0][0] = 0;
      |     ^~~~~
Language: C

#include<stdio.h>
#include<math.h>
 
int main(){
  int h,w,d,q,l,r,a[90001][2],b,i,j,k;
  long di[90001]={};
  scanf("%d %d %d",&h,&w,&d);
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      scanf("%d",&b);
      a[b][0]=i;
      a[b][1]=j;
    }
  }
  for(i=d+1;i<=w*h;i++){
    di[i]+=abs(a[i][0]-a[i-d][0]);
    di[i]+=abs(a[i][1]-a[i-d][1]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d %d",&l,&r);
    printf("%ld\n,di[r]-di[l]);
  }
}


Compiler output:
main.c: In function 'main':
main.c:16:12: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   16 |     di[i]+=abs(a[i][0]-a[i-d][0]);
      |            ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:22:12: warning: missing terminating " character
   22 |     printf("%ld\n,di[r]-di[l]);
      |            ^
main.c:22:12: error: missing terminating " character
   22 |     printf("%ld\n,di[r]-di[l]);
      |            ^~~~~~~~~~~~~~~~~~~~
main.c:23:3: error: expected expression before '}' token
   23 |   }
      |   ^
main.c:22:12: error: expected ';' before '}' token
   22 |     printf("%ld\n,di[r]-di[l]);
      |            ^
      |            ;
   23 |   }
      |   ~
Language: C

#include<stdio.h>
#include<math.h>
 
int main(){
  int h,w,d,q,l,r,a[90001][2],b,i,j,k;
  long di[90001]={};
  scanf("%d %d %d",&h,&w,&d);
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      scanf("%d",&b);
      a[b][0]=i;
      a[b][1]=j;
    }
  }
  for(i=d+1;i<=n;i++){
    di[i]+=abs(a[i][0]-a[i-d][0]);
    di[i]+=abs(a[i][1]-a[i-d][1]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d %d",&l,&r);
    printf("%ld\n,di[r]-di[l]);
  }
}


Compiler output:
main.c: In function 'main':
main.c:15:16: error: 'n' undeclared (first use in this function)
   15 |   for(i=d+1;i<=n;i++){
      |                ^
main.c:15:16: note: each undeclared identifier is reported only once for each function it appears in
main.c:16:12: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   16 |     di[i]+=abs(a[i][0]-a[i-d][0]);
      |            ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:22:12: warning: missing terminating " character
   22 |     printf("%ld\n,di[r]-di[l]);
      |            ^
main.c:22:12: error: missing terminating " character
   22 |     printf("%ld\n,di[r]-di[l]);
      |            ^~~~~~~~~~~~~~~~~~~~
main.c:23:3: error: expected expression before '}' token
   23 |   }
      |   ^
main.c:22:12: error: expected ';' before '}' token
   22 |     printf("%ld\n,di[r]-di[l]);
      |            ^
      |            ;
   23 |   }
      |   ~
Language: C++

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

int x[90001],y[90001];
int ans[90001];

inline int my_abs(int input){
    if(input < 0){
        input = -input;
    }
    return input;
}

int main() {

    int h,w,d;

    scanf("%d %d %d",&h,&w,&d);

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            int a;
            scanf(" %d",&a);
            x[a] = j; y[a] = i;
        }
    }

    for(int i=d+1; i<=h*w; i++){
        ans[i] = ans[i-d] + my_abs(x[i] - x[i-d]) + my_abs(y[i] - y[i-d]);
    }

    int q;

    scanf(" %d",&q);

    while(q--){
        int l,r;

        scanf(" %d %d",&l,&r)

        cout << ans[r] - ans[l] << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:30: error: expected ';' before 'cout'
   39 |         scanf(" %d %d",&l,&r)
      |                              ^
      |                              ;
   40 | 
   41 |         cout << ans[r] - ans[l] << endl;
      |         ~~~~
Language: C

#include<stdio.h>
#include<math.h>
 
int main(){
  int h,w,d,q,l,r,a[90001][2],b,i,j,k;
  long d[90001]={};
  scanf("%d %d %d",&h,&w,&d);
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      scanf("%d",&b);
      a[b][0]=i;
      a[b][1]=j;
    }
  }
  for(i=d+1;i<=n;i++){
    d[i]+=abs(a[i][0]-a[i-d][0]);
    d[i]+=abs(a[i][1]-a[i-d][1]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d %d",&l,&r);
    printf("%ld\n,d[r]-d[l]);
  }
}


Compiler output:
main.c: In function 'main':
main.c:6:8: error: conflicting types for 'd'; have 'long int[90001]'
    6 |   long d[90001]={};
      |        ^
main.c:5:11: note: previous declaration of 'd' with type 'int'
    5 |   int h,w,d,q,l,r,a[90001][2],b,i,j,k;
      |           ^
main.c:15:16: error: 'n' undeclared (first use in this function)
   15 |   for(i=d+1;i<=n;i++){
      |                ^
main.c:15:16: note: each undeclared identifier is reported only once for each function it appears in
main.c:16:11: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   16 |     d[i]+=abs(a[i][0]-a[i-d][0]);
      |           ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:22:12: warning: missing terminating " character
   22 |     printf("%ld\n,d[r]-d[l]);
      |            ^
main.c:22:12: error: missing terminating " character
   22 |     printf("%ld\n,d[r]-d[l]);
      |            ^~~~~~~~~~~~~~~~~~
main.c:23:3: error: expected expression before '}' token
   23 |   }
      |   ^
main.c:22:12: error: expected ';' before '}' token
   22 |     printf("%ld\n,d[r]-d[l]);
      |            ^
      |            ;
   23 |   }
      |   ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,st,en) for(int i=st;i<=en;i++)
#define eps 1e-8
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)
 
const int N=100000;
typedef long long LL;
const LL MOD=1000000007;
int a[N][N];
int ans[N];
bool vis[N];
map < int, pair<int,int> > M;
 
int main(){
    pair <int,int> p,now;
    FAST_IO;
    int n,m,d,q;
    cin>>n>>m>>d;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
            p.first=i;p.second=j;
            M[a[i][j]]=p;
        }
    }
 
    for(int k=1;k<=n*m;k++){
        if(!vis[k]){
            vis[k]=true;
            int sum=ans[k];
            now=M[k];
            for(int i=k+d;i<=n*m;i+=d){
                vis[i]=true;
                p=M[i];
                sum+=(abs(p.first-now.first)+abs(p.second-now.second));
                ans[i]=sum;
                now=p;
            }
        }
    }
    int l,r;
    cin>>q;
    while(q--){
        cin>>l>>r;
        cout<<ans[r]-ans[l]<<endl;
    }
    return 0;
}

Compiler output:
/tmp/cc7l29H4.o: in function `main':
a.cc:(.text+0xe6): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/cc7l29H4.o
a.cc:(.text+0x138): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/cc7l29H4.o
a.cc:(.text+0x153): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/cc7l29H4.o
a.cc:(.text+0x16b): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cc7l29H4.o
a.cc:(.text+0x17f): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/cc7l29H4.o
a.cc:(.text+0x1b5): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/cc7l29H4.o
a.cc:(.text+0x1c7): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/cc7l29H4.o
a.cc:(.text+0x21a): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cc7l29H4.o
a.cc:(.text+0x2c3): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cc7l29H4.o
a.cc:(.text+0x2db): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cc7l29H4.o
/tmp/cc7l29H4.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x32b): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

#include <cmath>
#include <cstdlib>
#include <climits>

#include "show_vector.hh"
//#include <stdio.h>
//#include <stdlib.h>


using namespace std;

#define debug false


int magic(int &from, int &to, vector<int> const &x, vector<int> const &y){
  int d_x = abs(x[from] - x[to]);
  int d_y = abs(y[from] - y[to]);
  //printf("from %d to %d\n", from, to);
  //printf("d_x : %d\n", d_x);
  //printf("d_y : %d\n", d_y);
  return d_x + d_y;
}


int main(int argc, char *argv[]){

  int H, W, D;
  cin >> H >> W >> D;
  vector<int> x(H*W+1), y(H*W+1);
  int tmp;
  for(int h = 0; h < H; h++){
    for(int w = 0; w < W; w++){
      cin >> tmp;
      x[tmp] = w;
      y[tmp] = h;
    }
  }
  int Q;
  cin >> Q;
  int L[Q], R[Q];
  for(int i = 0; i < Q; i++){
    cin >> L[i] >> R[i];
  }

  // メモか
  // 0->...
  // 1 -> ...

  vector<int> from_to(W*H, 0);
  for(int i = 0; i < W*H; i++){
    int from = (i-D<0)?i:i-D;
    int to = i;
    from_to[i] = magic(from, to, x, y);
    if(i >= D) from_to[i] += from_to[i-D];
  }
  for(int i = 0; i < Q; i++){
    printf("%d\n", from_to[R[i]] - from_to[L[i]] );
  }
  //show_vector(from_to);



  return 0;
}


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

#include <utility>
#include <bitset>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <ios>
#include <iomanip>
#include <sstream>
#include <climits>
#include <cmath>

using namespace std;

#ifdef USE_LOG
#define LOG(str)  cout << str << endl
#define DMP(var)  cout << #var << " = " << var << endl
#else
#define LOG(...)
#define DMP(...)
#endif

#define FOR(v, b, e)   for (int v = (b); v < (e); ++v)
#define RFOR(v, b, e)  for (int v = (e) - 1; (b) <= v; --v)
#define REP(v, n)      FOR(v, 0, n)
#define RREP(v, n)     RFOR(v, 0, n)

#define ALL(c)         (c).begin(), (c).end()

typedef long long           ll;
typedef unsigned long long  ull;

int main () {
	ios::sync_with_stdio(false);
	cin.tie(0);

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

	vector<pair<int, int>> A(H * W + 1);
	int a;
	REP (i, H)
	REP (j, W)
	{
		cin >> a;
		A[a].first = i;
		A[a].second = j;
	}

	int Q;
	cin >> Q;
	vector<pair<int, int>> P(Q);
	int l, r;
	REP (q, Q)
	{
		cin >> l >> r;
		P.first = l;
		P.second = r;
	}

	int memo[90001] = {};

	for (auto p : P)
	{
		int magic = 0;
		auto c = A[p.first];

		while (p.first != p.second)
		{
			p.first += D;
			auto n = A[p.first];
			if (memo[p.first] == 0)
			{
				memo[p.first] = abs(c.first - n.first) + abs(c.second - n.second);
			}
			magic += memo[p.first];
			c = n;
		}

		cout << magic << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:64:19: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
   64 |                 P.first = l;
      |                   ^~~~~
a.cc:65:19: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
   65 |                 P.second = r;
      |                   ^~~~~~
Language: Java


import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
 		//hwd
		int h = sc.nextInt();
		int w = sc.nextInt();
		int d = sc.nextInt();
		//2jigen hairetu
		ArrayList<ArrayList<Integer>> arys;
		for(int i = 0; i<h; i++) {
			ArrayList<Integer> ary = new ArrayList<>();
			for(int r = 0; r < w; r++) {
				ary.add(sc.nextInt());
			}
			arys.add(ary);
		}
		//q kaisuu
		int q = sc.nextInt();
		for(int a = 0; a < q; a++) {
			int ans = 0;
			int l = sc.nextInt();
			int f = sc.nextInt();
			for (int b = 0; b < f/l; b++) {
				//Li syutoku
				l += d;
				int aa;
				int bb;
				for(int c = 0; c < h; c++) {
				aa = arys.get(c).indexOf(l);
				bb = c;
				}
				for(int dd = 0; c < h; c++) {
					aa = Math.abs(aa - arys.get(dd).indexOf(l-d));
					bb = Math.abs(bb - dd);
					}
				//li+1 sawomotomeru
				//ans kasan
				ans += aa + bb;
				
			}
			System.out.println(ans);
			
		}
		sc.close();
	}


Compiler output:
Main.java:51: error: reached end of file while parsing
	}
	 ^
1 error
Language: C++

#include <iostream>
using namespace std;

int power(int L, int R,int D, int H, int W, int A[][])
{
	int ans = 0;
	int x, y,px,py;
	for (int k = 0; k < (R - L) / D; k++) {
		for (int l = 0; l < H; l++)
			for (int m = 0; m < W; m++)
				if (A[l][m] == L)
					x, y = l, m;
		if (k != 0)
			ans += (x - px) > 0 ? x - px : -(x - px) + (y - py) > 0 ? y - py : -(y - py);
			px, py = x, y;
		L += D;
	}
	cout << ans
}

int main()
{
	int H, W, D,Q,L,R;
	int A[300][300];
	cin >> H >> W >> D;
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; i++)
			cin >> A[i][j];
	cin >> Q;
	for (int t = 0; t<Q; t++)
		cin >> L,R
		power(L,R,D ,H,W,A)



}

Compiler output:
a.cc:4:49: error: declaration of 'A' as multidimensional array must have bounds for all dimensions except the first
    4 | int power(int L, int R,int D, int H, int W, int A[][])
      |                                                 ^
a.cc: In function 'int power(...)':
a.cc:8:30: error: 'R' was not declared in this scope
    8 |         for (int k = 0; k < (R - L) / D; k++) {
      |                              ^
a.cc:8:34: error: 'L' was not declared in this scope
    8 |         for (int k = 0; k < (R - L) / D; k++) {
      |                                  ^
a.cc:8:39: error: 'D' was not declared in this scope
    8 |         for (int k = 0; k < (R - L) / D; k++) {
      |                                       ^
a.cc:9:37: error: 'H' was not declared in this scope
    9 |                 for (int l = 0; l < H; l++)
      |                                     ^
a.cc:10:45: error: 'W' was not declared in this scope
   10 |                         for (int m = 0; m < W; m++)
      |                                             ^
a.cc:11:37: error: 'A' was not declared in this scope
   11 |                                 if (A[l][m] == L)
      |                                     ^
a.cc:18:20: error: expected ';' before '}' token
   18 |         cout << ans
      |                    ^
      |                    ;
   19 | }
      | ~                   
a.cc:19:1: warning: no return statement in function returning non-void [-Wreturn-type]
   19 | }
      | ^
a.cc: In function 'int main()':
a.cc:31:27: error: expected ';' before 'power'
   31 |                 cin >> L,R
      |                           ^
      |                           ;
   32 |                 power(L,R,D ,H,W,A)
      |                 ~~~~~
Language: C++

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

size_t H, W;
int D, Q, L, R;
vector<vector<int>> A;
struct map {
    int x;
    int y;
};
vector<map> nump;
vector<int> cost_sub;

void calc_cost()
{
    for (size_t k = 1; k <= D; k -= D) {
        size_t j = k
            cost_sub[j]
            = 0;
        j += D;
        while (j <= H * W) {
            cost_sub[j] = cost_sub[j - D] + abs(nump[j].x - nump[j - D].x) + abs(nump[j].y - nump[j - D].y);
        }
    }
}

void map_num()
{
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cost_sub[A[i][j]] = 0;
            nump[A[i][j]] = {i, j};
        }
    }
    return;
}


int main()
{
    cin >> H >> W >> D;
    A.resize(H);
    for (size_t i = 0; i < H; i++) {
        A[i].resize(W);
        for (size_t j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }

    nump.resize(H * W + 1);
    cost_sub.resize(H * W + 1);
    map_num();
    calc_cost();


    cin >> Q;
    for (size_t i = 0; i < Q; i++) {
        cin >> L >> R;
        cout << cost_sub[R] - cost_sub[L] << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'void calc_cost()':
a.cc:26:13: error: expected ',' or ';' before 'cost_sub'
   26 |             cost_sub[j]
      |             ^~~~~~~~
Language: C++

h, w, d = gets.split.map(&:to_i)

mp = Array.new(h*w+1){[0, 0]}

h.times do |i|
  r = gets.split.map(&:to_i)
  w.times do |j|
    mp[r[j]] = [i, j]
  end
  r
end

t = Array.new(h*w+1){0}

((1+d)...(h*w+1)).each do |i|
  t[i] = t[i-d]+(mp[i-d][0]-mp[i][0]).abs+(mp[i-d][1]-mp[i][1]).abs
end

gets.to_i.times do
  l, r = gets.split.map(&:to_i)
  puts t[r]-t[l]
end


Compiler output:
a.cc:1:1: error: 'h' does not name a type
    1 | h, w, d = gets.split.map(&:to_i)
      | ^
a.cc:5:1: error: 'h' does not name a type
    5 | h.times do |i|
      | ^
a.cc:15:3: error: expected unqualified-id before numeric constant
   15 | ((1+d)...(h*w+1)).each do |i|
      |   ^
a.cc:15:3: error: expected ')' before numeric constant
   15 | ((1+d)...(h*w+1)).each do |i|
      |  ~^
      |   )
a.cc:15:3: error: expected ')' before numeric constant
   15 | ((1+d)...(h*w+1)).each do |i|
      | ~ ^
      |   )
Language: C++

#include <iostream>
#include <vector>
#include <utility>
using namespace std;

int H, W, D;

pair<int, int>searchA(int a, vector<vector<int>>vecA);
int abs(int a) noexcept;
int mdist(pair<int, int>a, pair<int, int>b);

int main(){
    cin >> H >> W >> D;
    vector<vector<int>>A(H, vector<int>(W));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> A[i][j];
            A[i][j]--;
        }
    }
    vector<vector<int>>Dists(D, vector<int>((H*W)/D + 1, 0));
    for(int k=0; k<D; k++){
        pair<int, int>prevP = searchA(k, A);
        Dists[k][0]=0;
        for(int i=1; i<(H*W)/D +1; i++){
            pair<int, int>tmpP = searchA(D*i+k, A);
            Dists[k][i]=mdist(tmpP, prevP);
            prevP = tmpP;
        }
    }
    int Q;
    cin >> Q;
    for(int i=0; i<Q; i++){
      int tmpl, intr;
        cin >> tmpl >> tmpr;
		tmpl--;
      tmpr--;
        int surp=tmpl % D;
        int ln=tmpl/D, rn=tmpr/D;
        int retd=0;
        for(int i=ln+1; i<=rn; i++){
            retd += Dists[surp][i];
        }
        cout << retd << '\n';
    }
    return 0;
}

pair<int, int>searchA(int a, vector<vector<int>>vecA){
    pair<int, int>retp = make_pair(1000, 1000);
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(vecA[i][j]==a){
                retp = make_pair(i, j);
                goto ret;
            }
        }
    }
    ret:
    return retp;
}

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

int mdist(pair<int, int>a, pair<int, int>b){
    return abs(b.first-a.first)+abs(b.second-a.second);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:24: error: 'tmpr' was not declared in this scope; did you mean 'tmpl'?
   35 |         cin >> tmpl >> tmpr;
      |                        ^~~~
      |                        tmpl
Language: C++

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <cmath>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long  ll;
const int MAXN=1e5;
int len[MAXN];
struct edge{
    int x,y,v;
};

bool cmp(const edge& a,const edge& b)
{
    return a.v<b.v;
}
edge dp[MAXN][MAXN];
int ans[MAXN][MAXN];
int vis[MAXN];
int main()
{
    int h,w,d;
    while (scanf("%d%d%d",&h,&w,&d)!=EOF) {
        memset(len, 0, sizeof(len));
        int id;
        for(int i=1;i<=h;i++)
            for(int j=1;j<=w;j++)
            {
                scanf("%d",&id);
                dp[id%d][len[id%d]++]=edge{i,j,id};
            }
        for(int i=0;i<d;i++)
            sort(dp[i],dp[i]+len[i],cmp);
        for(int i=0;i<d;i++)
        {
            vis[i]=dp[i][0].v;
            ans[i][0]=0;
            for(int j=1;j<len[i];j++)
                ans[i][j]=ans[i][j-1]+abs(dp[i][j].x-dp[i][j-1].x)+abs(dp[i][j].y-dp[i][j-1].y);
        }
        int q,x,y;
        scanf("%d",&q);
        while (q--) {
            scanf("%d%d",&x,&y);
            printf("%d\n",ans[y%d][(y-dp[y%d][0].v)/d]-ans[x%d][(x-dp[x%d][0].v)/d]);
        }
    }
    return 0;
}

Compiler output:
/tmp/ccemqpJ8.o: in function `main':
a.cc:(.text+0x212): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccemqpJ8.o
a.cc:(.text+0x228): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccemqpJ8.o
a.cc:(.text+0x262): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccemqpJ8.o
a.cc:(.text+0x367): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccemqpJ8.o
a.cc:(.text+0x435): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccemqpJ8.o
a.cc:(.text+0x491): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccemqpJ8.o
collect2: error: ld returned 1 exit status