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

#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
  
int main(){
  
  int n;
  cin>>n;
  string s;
  cin>>s;
  int q;
  cin>>q;
  int k[q];
  REP(i,q){
    cin>>k[i];
  }
  int dsum[n] = {};
  int msum[n] = {};
  REP(i,n){
    if(i==0){
      if(s[i] == 'D'){
        dsum[i]++;
      }else if(s[i] == 'M'){
        msum[i]++;
      }else{
        ;
      }
    }else{
      if(s[i] == 'D'){
        dsum[i] = dsum[i-1] + 1;
      }else if(s[i] == 'M'){
        msum[i] = msum[i-1] + 1;
      }else{
        ;
      }
    } 
  }
  REP(i,q){
    int dmnum[n] = {};
    REP(j,k[i]-2){
      if(s[j+1] == 'M'){
        dmnum[j+1] = dmnum[j] + dsum[j];
      }else{
        dmnum[j+1] = dmnum[j];
      }
    }
    for(int j = k[i]-2; j < n-1; j++){
      if(s[j+1] == 'M'){
        if(j-(k[i]-2) >= 1){
          dmnum[j+1] = dmnum[j] + dsum[j] - dsum[j-(k[i]-2)-1];
        }else{
          dmnum[j+1] = dmnum[j] + dsum[j];
        }
      }else{
        dmnum[j+1] = dmnum[j];
      }
      if(s[j-(k-2)] == 'D'){
        dmnum[j+1] -= msum[j+1] - msum[j-(k[i]-2)];
      }else{
        ;
      }
    }
    int res = 0;
    REP(i,n){
      if(s[i] == 'C'){
        if(i==0)continue;
        res += dmsum[i-1];
      }else{
        continue;
      }
    }
    cout<<res<<endl;
  }
  return 0; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:103:13: error: invalid operands of types 'int' and 'int*' to binary 'operator-'
  103 |       if(s[j-(k-2)] == 'D'){
      |            ~^~~~~~
      |            |   |
      |            int int*
a.cc:113:16: error: 'dmsum' was not declared in this scope; did you mean 'dmnum'?
  113 |         res += dmsum[i-1];
      |                ^~~~~
      |                dmnum
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(a, b) for (a = 0; a < b; a++)

int csum[1000005][3];

signed main() {
    int n;
    string s; cin >> s;
    int q; cin >> q;
    int k[q]; rep (i, q) cin >> k[i];
    rep (i, n) {
        rep (j, 3) csum[i + 1][j] = csum[i][j];
        if (s[i] == 'D') {
            csum[i + 1][0]++;
        }
        if (s[i] == 'M') {
            csum[i + 1][1]++;
        }
        if (s[i] == 'C') {
            csum[i + 1][2]++;
        }
    }
    rep (i, q) {
        int K = k[i];
        int ans = 0;
        rep (i, n) {
            if (i + K == n) break;
            if (s[i] == 'D' && s[i + K] == 'C') ans += csum[i + K][1] - csum[i][1];
        }
        cout << ans << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:20: error: 'i' was not declared in this scope
   12 |     int k[q]; rep (i, q) cin >> k[i];
      |                    ^
a.cc:4:24: note: in definition of macro 'rep'
    4 | #define rep(a, b) for (a = 0; a < b; a++)
      |                        ^
a.cc:13:10: error: 'i' was not declared in this scope
   13 |     rep (i, n) {
      |          ^
a.cc:4:24: note: in definition of macro 'rep'
    4 | #define rep(a, b) for (a = 0; a < b; a++)
      |                        ^
a.cc:14:14: error: 'j' was not declared in this scope
   14 |         rep (j, 3) csum[i + 1][j] = csum[i][j];
      |              ^
a.cc:4:24: note: in definition of macro 'rep'
    4 | #define rep(a, b) for (a = 0; a < b; a++)
      |                        ^
a.cc:25:10: error: 'i' was not declared in this scope
   25 |     rep (i, q) {
      |          ^
a.cc:4:24: note: in definition of macro 'rep'
    4 | #define rep(a, b) for (a = 0; a < b; a++)
      |                        ^
Language: C++

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

#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int   mod   = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 10){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  int N = input();

  string s = "_" + input< string >();

  vector< int64 > rd(N + 1), rm(N + 1);
  range(i, 1, N + 1) {
    rd[i] = rd[i - 1] + (s[i] == 'D');
    rm[i] = rm[i - 1] + (s[i] == 'M');
  }

  auto f = [&](int k) {
    int64 res = 0;

    int64 cnt = 0;
    range(i, 1, N + 1) {
      if (s[i] == 'C') res += cnt;

      if (s[i] == 'M') {
        cnt += (rd[i] - rd[max(0, i - k)]);
      }
      if (i - k >= 0 && s[i - k] == 'D') {
        cnt -= (rm[i] - rm[i - k]);
      }
    }

    return res;
  }

  int q = input();
  while (q--) cout << f(input()) << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}


Compiler output:
a.cc: In function 'void solver()':
a.cc:66:3: error: expected ',' or ';' before 'int'
   66 |   int q = input();
      |   ^~~
a.cc:67:10: error: 'q' was not declared in this scope
   67 |   while (q--) cout << f(input()) << endl;
      |          ^
Language: C++

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

#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int   mod   = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 10){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template < typename data_type >

void solver() {
  int N = input();

  string s;
  cin >> s;

  auto f = [&](int k) {
    int64 res = 0;
    int64 cnt_d = 0, cnt_m = 0, dm = 0;

    range(i, 0, N) {
      if (0 <= i - k && s[i - k] == 'D') {
        cnt_d--;
        dm -= cnt_m;
      }
      if (0 <= i - k && s[i - k] == 'M') {
        cnt_m--;
      }

      if (s[i] == 'D') {
        cnt_d++;
      }
      if (s[i] == 'M') {
        cnt_m++;
        dm += cnt_d;
      }

      if (s[i] == 'C') {
        res += dm;
      }
    }

    return res;
  };

  int q = input();
  while (q--) cout << f(input()) << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:78:9: error: no matching function for call to 'solver()'
   78 |   solver();
      |   ~~~~~~^~
a.cc:38:6: note: candidate: 'template<class data_type> void solver()'
   38 | void solver() {
      |      ^~~~~~
a.cc:38:6: note:   template argument deduction/substitution failed:
a.cc:78:9: note:   couldn't deduce template parameter 'data_type'
   78 |   solver();
      |   ~~~~~~^~
Language: C++

import numpy as np
 
def main():
	n = int(input())
	s = input()
	q = int(input())
	klist = list(map(int, input().split()))
	
	for times in range(q):
		r = 0
		k = klist[times]
		nowd, nowm, nowdm = 0, 0, 0
		for i in range(n):
			c = s[i]
			if (c == "D"):
				nowd += 1
			elif (c == "M"):
				nowm += 1
				nowdm += nowd
			elif(c == "C"):
				r += nowdm
			if(i >= k-1):
				cc = s[i-k+1]
				if (cc == "D"):
					nowd -= 1
					nowdm -= nowm
				elif (cc == "M"):
					nowm -= 1
		print(r)
main()

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import numpy as np
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C

#include<stdio.h>

typedef long long int int64;

char c;
int f;
int nextInt();

int N, Q, i, j, k;
long answer;
char S[1000000];
int K;
int M[1000001];

int main(void){
	N = nextInt();
	M[0] = 0;
	for(i=0; i<N; i++){
		S[i] = getchar();
		M[i+1] = (S[i]=='M' ? M[i]+1: M[i]);
	}
	Q = nextInt();
	for(i=0; i<Q; i++){
		K = nextInt();
		answer = 0;
		for(j=0; j<N; j++){
			if(S[j] == 'D'){
				for(k=j+2; k<N&&k<K[i]+j; k++){
					if(S[k] == 'C'){
						answer += M[k] - M[j+1];
						printf("(%d, %d), ", j, k);
					}
				}
			}
		}
		printf("%d\n", answer);
	}
	return 0;
}

int nextInt(){
	f=0;
	c = getchar();
	while((c<'0')||('9'<c)){
		c=getchar();
	}
	while((c>='0')&&(c<='9')){
		f=f*10+(c-'0');
		c=getchar();
	}
	return f;
}


Compiler output:
main.c: In function 'main':
main.c:28:52: error: subscripted value is neither array nor pointer nor vector
   28 |                                 for(k=j+2; k<N&&k<K[i]+j; k++){
      |                                                    ^
Language: C++

#include<iostream>
#define int long long
using namespace std;

signed main()
{
	char s[1000010];
	char a;
	int N, Q;
	int x = 0;
	int ans = 0;
	int k[100];
	int l[4];
	//int t[1000010][4];


	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a;
		if (a == 'D' || a == 'M' || a == 'C') {
			s[x] = a;
			x++;
		}
	}

	cin >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> k[i];

		int td = 0, tm = 0, tc = 0;
		int count = 0;
		int ans = 0;

		for (int j = 0; j < x; j++) {
			if (s[j] == 'D') {
				td++;
			}
			if (j >= k[i]) {
				if (s[j - k[i]] == 'D') {
					td--;
				}
			}

			if (j >= k[i]) {
				if (s[j - k[i]] == 'D') {
					tm -= count;
				}
			}

			if (s[j] == 'M') {
				tm += td;
				count++;
			}
			if (j >= k[i]) {
				if (s[j - k[i]] == 'M') {
					count--;
				}
			}



			if (s[j]] == 'C') {
				ans += tm;
			}
			
		}
		cout << ans << endl;

	}

	

	/*for (int i = 1; i <= x; i++) {
		if (s[i] == 'D') {
			l[0] ++;
			t[i][0] = t[i-1][0] + 1;
		}
		else {
			t[i][0] = 
		}
		if (s[i] == 'M') {
			l[1] += l[0];
			t[i][0] += 
		}
	}*/

	//system("pause");
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:62:33: error: expected ')' before ']' token
   62 |                         if (s[j]] == 'C') {
      |                            ~    ^
      |                                 )
a.cc:62:33: error: expected primary-expression before ']' token
Language: C++

#include <cassert>
#include <iostream>
#include <functional>
#include <iomanip>
#include <set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <deque>
#include <algorithm>
#include  <cstring>
#include <string>
#include <cmath> 
using namespace std;
typedef long long LL;
const int MAX = 210000;
const LL base = 1e9 + 7;


struct Node {
	int x, y, w;
};


void solve() {

	LL result = 0;
	int n;

	cin >> n;
	string S;
	cin >>S;
	int q;
	cin >>q;
	vector<int> zk(q);
	for (int i=0; i<q; ++i) {
		cin >>zk[i];
	}
	for (auto k : zk) {
		int tm = 0, tc = 0, tmc = 0;
		result = 0;
		for (int i=0; i<k-1; ++i) {
			if (S[i] == 'M') {
				tm+=1;
			}
			else if (S[i] =='C') {
				tc +=1;
				tmc += tm;
			}
		}
		int tail = k-2
		for (int i=0; i<N-2; ++i) {
		
			# move
			tail += 1;

			if (S[i] == 'M' ){
				tm -=1;
				tmc -= tc;
			}
			else if (S[i] =='C' ){
				tc -=1;
			}
			if (tail <N) {
				if (S[tail]=='M') {
					tm += 1 ;
				}
				else if (S[tail] =='C') {
					tc += 1;
					tmc += tm;
				}
			}
			#dprint(i, tmc)                
			if (S[i] =='D')
				re += tmc;
		}
		cout<<re<<endl;
	} 

}

int main() {
	const int inId = 0;
	const int outId = 0;
	if (inId>0) {
		cerr << "redirect stdin to input " << inId << endl;
		string s = "input";
		s += to_string(inId);
		s += ".txt";
		auto r = freopen(s.c_str(), "r", stdin);	
		if (r == nullptr) {
			cerr<< "invalid input file "<< s;
		}
	}
	if (outId>0) {
		cerr << "redirect stdout to stdout " << outId << endl;
		string s = "stdout";
		s += to_string(outId);
		s += ".txt";
		auto r = freopen(s.c_str(), "w", stdout);
		if (r == nullptr) {
			cerr<< "invalid output file "<< s;
		}		
	}
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // close sync between cout and printf
	cout.precision(10);
	solve();
}
 

Compiler output:
a.cc:54:27: error: invalid preprocessing directive #move
   54 |                         # move
      |                           ^~~~
a.cc:73:26: error: invalid preprocessing directive #dprint
   73 |                         #dprint(i, tmc)
      |                          ^~~~~~
a.cc: In function 'void solve()':
a.cc:52:17: error: expected ',' or ';' before 'for'
   52 |                 for (int i=0; i<N-2; ++i) {
      |                 ^~~
a.cc:52:31: error: 'i' was not declared in this scope
   52 |                 for (int i=0; i<N-2; ++i) {
      |                               ^
a.cc:52:33: error: 'N' was not declared in this scope
   52 |                 for (int i=0; i<N-2; ++i) {
      |                                 ^
a.cc:77:23: error: 're' was not declared in this scope
   77 |                 cout<<re<<endl;
      |                       ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,d;
struct node
{
    int x,y,z;
}a[N];
int sum[1005][1005];
ll xs[1005];
bool judge(ll m)
{
    ll a=m/d,b=m-m/d;
    for(int i=0;i<d;i++)
        if(i<=b) xs[i]=a+1;
    else xs[i]=a;
    for(int i=1;i<=n;i++)
        if(a[i].z>xs[a[i].x]*xs[a[i].y]) return false;
    return true;
}
int main()
{
    srand(time(0));
    scanf("%d%d",&n,&d);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&a[i].x,&a[i].y);
        a[i].x%=d;a[i].y%=d;
        sum[a[i].x][a[i].y]++;
    }
    n=0;
    for(int i=0;i<d;i++)
        for(int j=0;j<d;j++)
        if(sum[i][j])
        {
            n++;
            a[n].x=i;a[n].y=j;a[n].z=sum[i][j];
        }
    random_shuffle(a+1,a+1+n);
    ll ans=2000000000;
    for(int i=1;i<=n;i++)
    {
        swap(a[i],a[1]);
        for(int i=2;i<=n;i++)
        {
            a[i].x=((a[i].x-a[1].x)%d+d)%d;
            a[i].y=((a[i].y-a[1].y)%d+d)%d;
        }
        a[1].x=a[1].y=0;
        ll l=0,r=ans;
        while(l<=r)
        {
            ll m=l+r>>1;
            if(judge(m)) ans=m,r=m-1;
            else l=m+1;
        }
    }
    assert(ans<=1500000000);
    printf("%lld\n",ans);
}


Compiler output:
a.cc: In function 'bool judge(ll)':
a.cc:19:13: error: invalid types 'll {aka long long int}[int]' for array subscript
   19 |         if(a[i].z>xs[a[i].x]*xs[a[i].y]) return false;
      |             ^
a.cc:19:23: error: invalid types 'll {aka long long int}[int]' for array subscript
   19 |         if(a[i].z>xs[a[i].x]*xs[a[i].y]) return false;
      |                       ^
a.cc:19:34: error: invalid types 'll {aka long long int}[int]' for array subscript
   19 |         if(a[i].z>xs[a[i].x]*xs[a[i].y]) return false;
      |                                  ^
a.cc: In function 'int main()':
a.cc:40:19: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = node*]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
   40 |     random_shuffle(a+1,a+1+n);
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:4492:5: note: declared here
 4492 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int n,d,x,y,t,mx,v[2005][2005],s[2][2005][2005];
int S(int a1,int b1,int a2,int b2,int t){return s[t][a2][b2]-s[t][a1-1][b2]-s[t][a2][b1-1]+s[t][a1-1][b1-1];}
int chk(int x)
{
	int r=x%d;
	for(int i=1;i<=d;i++) for(int j=1;j<=d;j++)
	{
		int a1=i,b1=j,a2=a1+r,b2=b1+r,x3=a1+d-1,y3=b1+d-1;
		if(!S(a1,b2+1,x3,y3,1)&&!S(a2+1,b1,x3,y3,1)&&!S(a2+1,b2+1,x3,y3,0)) return 1;
	}
	return 0;
}
int main()
{
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++) scanf("%d%d",&x,&y),v[x%d+1][y%d+1]++;
	for(int i=1;i<=d;i++) for(int j=1;j<=d;j++) v[i+d][j]=v[i][j+d]=v[i+d][j+d]=v[i][j],mx=max(mx,v[i][j]);
	for(t=0;(t+1)*(t+1)<mx;t++);int l[3]={t*t+1,t*t+t+1,1e9};
	for(int i=1;i<=d*2;i++) for(int j=1;j<=d*2;j++) for(int k=0;k<2;k++)
		s[k][i][j]=(l[k]<=v[i][j])+s[k][i-1][j]+s[k][i][j-1]-s[k][i-1][j-1];
	int L=t*d,R=t*d+d,ans=R,mid;
	for(mid=(L+R)>>1;L<=R;mid=(L+R)>>1) if(chk(mid)) R=mid-1,ans=mid;else L=mid+1;
	printf("%d\n",ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:61: error: narrowing conversion of '1.0e+9' from 'double' to 'int' [-Wnarrowing]
   20 |         for(t=0;(t+1)*(t+1)<mx;t++);int l[3]={t*t+1,t*t+t+1,1e9};
      |                                                             ^~~
Language: C++

#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)
#define Maxm(A, B) (A > B ? A : B)
#define Minm(A, B) (A < B ? A : B)

ll N,D,D2,x[101010],y[101010];

ll block[1010][1010], mksq[2010][1020];
bool mk[2020][2020],mkyl[2020],mkxl[2020];
ll maxx,cy,cx,minsq,addsq;

ll ans;
double aave;
ll i,j,k,l;

double abss(double a){
    return a < 0 ? -a : a;
}

int main(){
    scanf("%lld%lld", &N,&D);
    fornum(i,0,N){
        scanf("%lld%lld", &x[i],&y[i]);
        block[y[i] % D][x[i] % D]++;
    }
    fornum(i,0,D){
        fornum(j,0,D){
            if(maxx<block[i][j]){
                maxx=block[i][j];
            }
        }
    }
    for (minsq = 0; minsq * minsq < maxx;minsq++)
        ;    
    minsq--;
    //printf("%lld\n", minsq);

    D2 = D * 2;
    fornum(i,0,D2){
        fornum(j,0,D2){
            //printf("%lld ", block[i%D][j%D]);
            if(minsq*minsq<block[i%D][j%D]){
                mk[i][j] = true;
            }
            if(minsq*minsq+minsq<block[i%D][j%D]){
                mkyl[i] = true;
                mkxl[j] = true;
            }
        }
        //printf("\n");
    }
    fornum(i,0,D2){
        if(mkyl[i]){
           continue;
        }
        fornum(j,0,D2){
            if(mkxl[j]||mk[i][j]){
                //printf("a");
                continue;
            }
            
            mksq[i+1][j+1] = Minm(Minm(mksq[i][j+1]+1,mksq[i+1][j]+1),mksq[i][j]+1);
        }
    }
    addsq = D-1;
    fornum(i,0,D2){
        fornum(j,0,D2){
            //printf("%lld ",mksq[i+1][j+1]);
            ll asq = D-1-Minm(mksq[i+1][j+1]);
            if(asq<addsq){
                addsq = asq;
            }
        }
        //printf("\n");
    }
    

    printf("%lld", (minsq)*D+addsq);

    return 0;
}

Compiler output:
a.cc:86:45: error: macro "Minm" requires 2 arguments, but only 1 given
   86 |             ll asq = D-1-Minm(mksq[i+1][j+1]);
      |                                             ^
a.cc:21:9: note: macro "Minm" defined here
   21 | #define Minm(A, B) (A < B ? A : B)
      |         ^~~~
a.cc: In function 'int main()':
a.cc:86:26: error: 'Minm' was not declared in this scope
   86 |             ll asq = D-1-Minm(mksq[i+1][j+1]);
      |                          ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL read(){
	LL x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)&&ch!='-')
		ch=getchar();
	if (ch=='-')
		f=0,ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?x:-x;
}
const int N=2005;
int n,d;
int v[N][N];
int s[4][N][N];
#define y1 __zzd001
int sum(int x1,int y1,int x2,int y2,int t){
	return s[t][x2][y2]-s[t][x2][y1-1]-s[t][x1-1][y2]+s[t][x1-1][y1-1];
}
int check(int x){
	int r=x%d;
	for (int i=1;i<=d;i++)
		for (int j=1;j<=d;j++){
			int x1=i,y1=j;
			int x2=x1+r,y2=y1+r;
			int x3=x1+d-1,y3=y1+d-1;
			if (!sum(x1,y2+1,x3,y3,3)
			  &&!sum(x2+1,y1,x3,y3,3)
			  &&!sum(x2+1,y2+1,x3,y3,2))
				return 1;
		}
	return 0;
}
int main(){
	n=read(),d=read();
	memset(v,0,sizeof v);
	while (n--){
		int x=read(),y=read();
		v[x%d+1][y%d+1]++;
	}
	for (int i=1;i<=d;i++)
		for (int j=1;j<=d;j++)
			v[i+d][j]=v[i][j+d]=v[i+d][j+d]=v[i][j];
	int Mx=0;
	for (int i=1;i<=d;i++)
		for (int j=1;j<=d;j++)
			Mx=max(Mx,v[i][j]);
	int t=(int)(sqrt(Mx-1)+1e-8);
	int l[5]={0,max(t*t,1),max(t*(t+1),1),(t+1)*(t+1),1e9};
	for (int i=1;i<=d*2;i++)
		for (int j=1;j<=d*2;j++)
			for (int t=1;t<=3;t++){
				s[t][i][j]=s[t][i-1][j]+s[t][i][j-1]-s[t][i-1][j-1];
				if (l[t]<=v[i][j]&&v[i][j]<l[t+1])
					s[t][i][j]++;
			}
	int L=t*d,R=t*d+d-1,ans=R;
	while (L<=R){
		int mid=(L+R)>>1;
		if (check(mid))
			R=mid-1,ans=mid;
		else
			L=mid+1;
	}
	cout << ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:59: error: narrowing conversion of '1.0e+9' from 'double' to 'int' [-Wnarrowing]
   52 |         int l[5]={0,max(t*t,1),max(t*(t+1),1),(t+1)*(t+1),1e9};
      |                                                           ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL read(){
	LL x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)&&ch!='-')
		ch=getchar();
	if (ch=='-')
		f=0,ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?x:-x;
}
const int N=1005;
int n,d;
int v[N][N];
int m1[N][N],m2[N][N],m3[N][N],m4[N][N];
int check(int x){
	LL v=x;
	LL v1=x*x,v2=x*(x+1),v3=(x+1)*(x+1);
	for (int i=1;i<=d;i++)
		for (int j=1;j<=d;j++){
			int x1=i,y1=j;
			int kx1=x1,kx2=x1+x%d;
			int ky1=y1,ky2=y1+y%d;
			if (kx2>=d)
				kx2-=d;
			if (ky2>=d)
				ky2-=d;
			if (
		}
}
int main(){
	n=read(),d=read();
	memset(v,0,sizeof v);
	while (n--){
		int x=read(),y=read();
		v[(x+d-1)%d+1][(y+d-1)%d+1]++;
	}
	for (int i=1;i<=d;i++)
		for (int j=1;j<=d;j++)
			m1[i][j]=max(max(m1[i-1][j],m1[i][j-1]),v[i][j]);
	for (int i=1;i<=d;i++)
		for (int j=d;j>=1;j--)
			m2[i][j]=max(max(m2[i-1][j],m2[i][j+1]),v[i][j]);
	for (int i=d;i>=1;i--)
		for (int j=1;j<=d;j++)
			m3[i][j]=max(max(m3[i+1][j],m3[i][j-1]),v[i][j]);
	for (int i=d;i>=1;i--)
		for (int j=d;j>=1;j--)
			m4[i][j]=max(max(m4[i+1][j],m4[i][j+1]),v[i][j]);
	int L=0,R=1e9,ans=R;
	while (L<=R){
		int mid=(L+R)>>1;
		if (check(mid))
			R=mid-1,ans=mid;
		else
			L=mid+1;
	}
	cout << ans;
	return 0;
}

Compiler output:
a.cc: In function 'int check(int)':
a.cc:26:43: error: 'y' was not declared in this scope; did you mean 'y1'?
   26 |                         int ky1=y1,ky2=y1+y%d;
      |                                           ^
      |                                           y1
a.cc:32:17: error: expected primary-expression before '}' token
   32 |                 }
      |                 ^
a.cc:31:29: error: expected ')' before '}' token
   31 |                         if (
      |                            ~^
      |                             )
   32 |                 }
      |                 ~            
a.cc:32:17: error: expected primary-expression before '}' token
   32 |                 }
      |                 ^
a.cc:33:1: warning: no return statement in function returning non-void [-Wreturn-type]
   33 | }
      | ^
Language: C++

#include <iostream>
#define llint long long

using namespace std;

llint n, d;
llint x[100005], y[100005];
llint cnt[1005][1005];
llint size[1005][1005];
llint cap[1005][1005];

llint count(llint x, llint y, llint px, llint py)
{
	llint ret = 0;
	ret += x/d*y/d;
	if(x%d >= px) ret += y/d;
	if(y%d >= py) ret += x/d;
	if(y%d >= py && x%d>=px) ret++;
	return ret;
}

int main(void)
{
	cin >> n >> d;
	for(int i = 1; i <= n; i++) cin >> x[i] >> y[i];
	for(int i = 1; i <= n; i++) cnt[x[i]%d][y[i]%d]++;
	if(d > 50) return 0;
	
	llint ans = 1e18
	for(int x = 0; x < d; x++){
		for(int y = 0; y < d; y++){
			
			llint ub = 1e10, lb = -1, mid;
			while(ub - lb > 1){
				mid = (ub+lb)/2;
				
				for(int px = 0; px < d; px++){
					for(int py = 0; py < d; py++){
						cap[px][py] = count(x+d, y+d, px, py) - count(x+d, y-1, px, py)
						- count(x-1, y+d, px, py) + count(x-1, y-1, px, py);
					}
				}
				
				bool flag = true;
				for(int px = 0; px < d; px++){
					for(int py = 0; py < d; py++){
						if(cnt[px][py] > cap[px][py]){
							flag = false;
							goto end;
						}
					}
				}
				end:;
				if(flag) ub = mid;
				else lb = mid;
			}
			ans = min(ans, ub);
		}
	}
	cout << ans << endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:9: error: expected ',' or ';' before 'for'
   30 |         for(int x = 0; x < d; x++){
      |         ^~~
a.cc:30:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   30 |         for(int x = 0; x < d; x++){
      |                        ~~^~~
a.cc:30:31: error: lvalue required as increment operand
   30 |         for(int x = 0; x < d; x++){
      |                               ^
Language: C++

#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 1e9+7
#define N 1000010
#define MAX_V 400010
#define vec vector<int>
#define ALL(c) (c).begin(),(c).end()

int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
using namespace std;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<ll,int,custom_hash>
struct pair_hash
{
    template<class T1,class T2>
    size_t operator() (const pair<T1,T2> &p)const{
        return hash<T1>()(p.first)^hash<T2>()(p.second);
    }
};

int calc(int m,int k){
    int l=0,r=1000;
    while(l<r-1){
        int mid=(l+r)/2;
        if(mid*(mid+k)<m)l=mid;
        else r=mid;
    }
    return r;
}

main(){
    int n,d;
    cin>>n>>d;
    int x[N],y[N],k[N],s[2000][2000]={};
    rep(i,n){
        x[i]=in();
        y[i]=in();
        s[x[i]%d][y[i]%d]++;
    }
    ll ans=INF;
    rep(i,d){
        rep(j,d){
            ll p=0;
            rep(k,d){
                rep(l,d){
                    int x=calc(s[k][l]);
                    bool c=false;
                    if(x*(x-1)>=s[k][l]) c=true;
                    if(x==0)continue;
                    int a;
                    a=(k+d-i)%d-(l+d-j)%d;
                    a=abs(a/d);
                    int f=calc(s[k][k],a);
                    p=max((k+d-i)%d,(l+d-j)%d)+(f-1)*d;
                }
            }
            ans=min(p,ans);
        }
    }
    cout<<ans;
}




Compiler output:
a.cc:56:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   56 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:71:31: error: too few arguments to function 'int calc(int, int)'
   71 |                     int x=calc(s[k][l]);
      |                           ~~~~^~~~~~~~~
a.cc:46:5: note: declared here
   46 | int calc(int m,int k){
      |     ^~~~
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int cnt[1010][1010];
bool ok[1010][1010],use[1010][1010],xok[1010],yok[1010],xuse[1010],yuse[1010];
bitset<1010> bs[1010];
int main(){
    int n,d;
    cin>>n>>d;
    assert(d<50);
    int x[n],y[n];
    rep(i,n){
        cin>>x[i]>>y[i];
        x[i]%=d;
        y[i]%=d;
        cnt[x[i]][y[i]]++;
    }
    rep(i,d)rep(j,d)ok[i][j]=true;
    rep(i,d)rep(j,d){
        int k=1;
        int rt=sqrt(cnt[i][j]);
        if(rt*rt<cnt[i][j])++rt;
        if(rt*(rt-1)<cnt[i][j])ok[i][j]=false;
        cnt[i][j]=rt;
    }
    int ma=0;

    rep(i,d)rep(j,d)ma=max(ma,cnt[i][j]);
    rep(i,d)rep(j,d)use[i][j]=(ma==cnt[i][j]);

    rep(i,d)rep(j,d)bs[i][j]=(use[i][j]&&!ok[i][j]);
    rep(i,d)xok[i]=true;
    rep(i,d)rep(j,d){
        if(use[i][j]&&!ok[i][j])xok[i]=false;
    }

    int r=d,l=-1,mid=0;
    while(r-l>1){
        mid=(r+l)/2;
        bool suc=false;
        rep(i,d){
            bitset<1010> res=0;
            bool can1=true;
            rep(j,d){
                if(j<i&&j+d>mid+i){
                    if(!xok[j])can1=false;
                    else res|=bs[j];
                }
                else if(j>i+mid){
                    if(!xok[j])can1=false;
                    else res|=bs[j];
                }
                else {
                    res|=bs[j];
                }
            }
            bool can2=false;
            vector<int> v;
            rep(j,d){
                if(res[j])v.push_back(j);
            }
            rep(j,d){
                if(res[j])v.push_back(j+d);
            }
            int maa=0;
            int s=v.size();
            rep(i,s-1)maa=max(v[i+1]-v[i],maa);
            can2=(ma>=d-mid);
            if(can1&&can2)suc=true;
        }
        if(suc)r=mid;
        else l=mid;
    }
    cout<<(ma-1)*d+r<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:5: error: 'assert' was not declared in this scope
   31 |     assert(d<50);
      |     ^~~~~~
a.cc:15:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
   14 | #include<functional>
  +++ |+#include <cassert>
   15 | using namespace std;
Language: C++

#include<bits/stdc++.h>
using namespace std;
int cnt[2000][2000];
int sum[2000][2000];
/*
int get(int i1, int j1, int i2, int j2)
{

    return sum[i2][j2] - sum[i2][j - 1] - sum[i - 1][j2] + sum[i - 1][j - 1];
}*/
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,d;
    cin >> n >> d;
    for(int i = 1; i <= n; i++)
    {
        int x, y;
        cin >> x >> y;
        cnt[x % d][y % d]++;
    }/*
    for(int i = 0; i < d; i++)
    {
        if(i == 0)
            sum[i][0] = cnt[i][0];
        else
            sum[i][0] = cnt[i][0] + sum[i - 1][0];
    }
    for(int i = 0; i < d; i++)
    {
        if(i == 0)
            sum[0][i] = cnt[0][i];
        else
            sum[0][i] = cnt[0][i] + sum[0][i - 1];
    }
    for(int i = 1; i < d; i++)
    {
        for(int j = 1; j < d; j++)
        {
            sum[i][j] = cnt[i][j] + sum[i - 1][j] + sum[i][ j - 1] - sum[i - 1][j - 1];
        }
    }*/
    long long ans = 1e9;
    long long k;
    long long k1;
    long long t;
    long long k2;
    long long i2;
    long long j2;
    long long m;
    bool f;
    for(int i = 0; i < d; i++)
    {
        for(int j = 0; j < d; j++)
        {
            long long l = 0;
            if(ans != 1e9)
                l = max(ans, l);
            long long r = ans, n * d + 3;
            while(r - l > 1)
            {
                 m = (r + l) / 2;
                f = 1;
                for(int i1 = 0; f && i1 < d; i1++)
                {
                    for(int j1 = 0; f && j1 < d; j1++)
                    {
                        k = (m + 1)/ (d);
                        t = (m + 1)%d;
                        i2 = (i1 - i + d) % d;
                        j2 = (j1 - j + d) % d;
                        k1 =  (t > i2);
                        k2 = (t > j2);
                        if((k + k1) * (k2 + k) < cnt[i1][j1])
                        {
                            f = 0;
                        }
                    }
                }
                if(f)
                    r = m;
                else
                    l = m;
            }
          //  cout << r<< ' ' << i <<' '<< j<<endl;
            ans = min(ans, r);
        }
    }
    cout << ans;
    //cin >> n;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:60:34: error: expected initializer before '*' token
   60 |             long long r = ans, n * d + 3;
      |                                  ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
const Int MAX = 1010;
Int cnt[MAX][MAX];
signed main(){
  Int n,d;
  cin>>n>>d;
  vector<Int> x(n),y(n);
  for(Int i=0;i<n;i++) cin>>x[i]>>y[i];

  memset(cnt,0,sizeof(cnt));
  for(Int i=0;i<n;i++)
    cnt[x[i]%d][y[i]%d]++;

  Int num=0;
  for(Int i=0;i<d;i++)
    for(Int j=0;j<d;j++)
      chmax(num,cnt[i][j]);

  Int sq=0;
  {
    Int l=0,r=num+1;
    while(l+1<r){
      Int m=(l+r)>>1;
      if(m*m>=num) r=m;
      else l=m;
    }
    assert(r*r>=num);
    assert(l*l<num);
    sq=l;
  }
  //cout<<num<<":"<<sq<<endl;

  Int bi=-1,bj=-1;
  for(Int i=0;i<d;i++)
    for(Int j=0;j<d;j++)
      if(cnt[i][j]==num) bi=i,bj=j;
  
  Int res=0;
  vector<Int> u,v;
  for(Int i=0;i<d;i++){
    for(Int j=0;j<d;j++){
      if((sq+(i==bi))*(sq+(j==bj))>=cnt[i][j]) continue;
      //cout<<i<<" "<<j<<":"<<cnt[i][j]<<endl;
      u.emplace_back((i+d-bi)%d);
      v.emplace_back((j+d-bj)%d);
      res++;
    }
  }
  
  //assert(res==0);
  if(res==0){
    cout<<sq*d<<endl;
    return 0;
  }
  if(d>30) return;
  
  Int ans=d;
  for(Int a=0;a<d;a++){
    for(Int b=0;b<d;b++){
      Int p=0,q=0;
      using P = pair<Int, Int>;
      map<P, Int> cnt;
      for(Int i=0;i<(Int)u.size();i++){
        if(u[i]<=a&&v[i]<=b) continue;
        ++cnt[P(u[i],v[i])];
        if(u[i]>a&&v[i]>b){     
          if(cnt[P(u[i],v[i])]<=sq){
            if(a-(u[i]-d)<=b-(v[i]-d)){
              chmin(p,u[i]-d);
            }else{
              chmin(q,v[i]-d);
            }
          }else{
            chmin(p,u[i]-d);
            chmin(q,v[i]-d);
          }
        }else{
          if(cnt[P(u[i],v[i])]<=sq) continue;
          if(u[i]<=a) chmin(q,v[i]-d);
          if(v[i]<=b) chmin(p,u[i]-d);
        }
      }
      //cout<<a<<" "<<b<<":"<<p<<" "<<q<<endl;
      chmin(ans,max(a-p,b-q));
    }
  }
  cout<<sq*d+ans<<endl;
  return 0;           
}


Compiler output:
a.cc: In function 'int main()':
a.cc:61:12: error: return-statement with no value, in function returning 'int' [-fpermissive]
   61 |   if(d>30) return;
      |            ^~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
int n, d;
const int N = 1e6;
int x[N], y[N];
int val[N];
int a[1002][1002];
int b[1002][1002];
int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> d;
    for (int i = 1; i <= n; i++) {
        cin >> x[i] >> y[i];
        b[x[i] % d][y[i] % d]++;
    }
    if (d > 30) return ;
    for (int i = 0; i * i <= n; i++) {
        val[i * i + 1] = i;
    }
    for (int i = 3; i <= n; i++) {
        if (val[i] == 0) val[i] = val[i - 1];
    }
    int ans = (int)1e9;
    for (int si = 0; si < d; si++) {
        for (int sj = 0; sj < d; sj++) {
            for (int i = 0; i < d; i++) {
                for (int j = 0; j < d; j++) {
                    a[i][j] = b[(i + si) % d][(j + sj) % d];
                }
            }
            int mx = 0;
            for (int i = 0; i < d; i++) {
                for (int j = 0; j < d; j++) {
                    if (a[i][j] == 0) continue;
                    int t = a[i][j];
                    int s = val[t];
                    if ((s + 1) * (s + 1) == t) {
                        mx = max(mx, i + s * d);
                        mx = max(mx, j + s * d);
                    }
                    else {
                        int k1 = min(i, j);
                        int k2 = max(i, j);
                        mx = max(mx, k1 + s * d);
                        mx = max(mx, k2 + max((s - 1), 0) * d);
                    }
                }
            }
            ans = min(ans, mx);
        }
    }
    cout << ans << "\n";
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:17: error: return-statement with no value, in function returning 'int' [-fpermissive]
   17 |     if (d > 30) return ;
      |                 ^~~~~~
Language: C++

#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
int main() {
	int N, D;
	cin >> N >> D;
	vector<vector<int> > cnt(D, vector<int>(D, 0));
	for (int i = 0; i < N; ++i) {
		int x, y;
		cin >> x >> y;
		++cnt[x % D][y % D];
	}
	int ans = inf;
	for (int i = 0; i < D; ++i) {
		for (int j = 0; j < D; ++j) {
			// START POINT IS (I, J)
			int mx = 0;
			for (int k = 0; k < D; ++k) {
				for (int l = 0; l < D; ++l) {
					if (cnt[k][l] != 0) {
						int adx = (k - i + D) % D, ady = (l - j + D) % D;
						int sq = int(sqrt(cnt[k][l]));
						if (cnt[k][l] < sq * (sq + 1)) {
							mx = max(mx, max(adx, ady) + (sq - 1) * D);
						}
						else {
							mx = max(mx, min(max(adx + (sq - 1) * D, ady + sq * D), max(adx + sq * D, ady + (sq - 1) * D)));
						}
					}
				}
			}
			ans = min(ans, mx);
		}
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:62: error: 'sqrt' was not declared in this scope; did you mean 'sq'?
   24 |                                                 int sq = int(sqrt(cnt[k][l]));
      |                                                              ^~~~
      |                                                              sq
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <utility>
#include <algorithm>
#include <ctime>
using namespace std;

struct pp {
	long long x, y;
	pp() :x(0), y(0) {}
	pp(long long x, long long y) :x(x), y(y) {}
} s[1024 * 1024], to_chk[1024 * 1024];
int to_chk_len = 0;

int n, D;
int cnt[1024][1024];

inline int Ok(long long X, long long st_x, long long st_y) {
	for (int q=0; q<to_chk_len; q++) {
		int i = to_chk[q].x;
		int j = to_chk[q].y;
		int rem = cnt[i][j];
		if (rem <= 0)
			continue;

		// i +- D*k    j += D*k   is rem points into [st_x...st_x+X][st_y...st_y+X]
		long long fx = i;
		if (st_x <= fx)
			fx -= ((fx - st_x) / D) * D;
		else {
			fx += ((st_x - fx) / D) * D;
			if (fx < st_x)
				fx += D;
		}

		long long fy = j;
		if (st_y <= fy)
			fy -= ((fy - st_y) / D) * D;
		else {
			fy += ((st_y - fy) / D) * D;
			if (fy < st_y)
				fy += D;
		}

		if (rem > 0) {
			if (!(fx >= st_x && fx <= st_x + X)) return 0;
			if (!(fy >= st_y && fy <= st_y + X)) return 0;
		}

		long long can_get = ((st_x + X - fx) / D + 1) * ((st_y + X - fy) / D + 1);
		if (can_get < rem)
			return 0;
	}
	return 1;
}

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

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	scanf("%d%d", &n, &D);
	for (int i = 0; i < n; i++) scanf("%lld%lld", &s[i].x, &s[i].y);

	for (int i = 0; i < n; i++)
		cnt[s[i].x%D][s[i].y%D]++;
	for (int i = 0; i < D; i++)
		for (int j = 0; j < D; j++)
			if (cnt[i][j] > 0)
				to_chk[to_chk_len++] = pp(i, j);
	
	clock_t t_BG = clock();

	long long mn = 1000000000000000LL;
	for (int len = 0; len <= 50; len++)
		for (int dx = -len; dx <= len; dx++) {
			for (int dy = -len; dy <= len; dy++)
				if (my_abs(dx) + my_abs(dy) == len) {
					int st_x = 0 + dx;
					int st_y = 0 + dy;
					long long down = 1, up = 2000000000;
					while (up > down) {
						long long mid = (up + down) / 2;
						if (Ok(mid, st_x, st_y)) up = mid;
						else down = mid + 1;
					}
					mn = min(mn, down);
					if ((((double)(clock() - t_BG)) / (CLOCKS_PER_SEC)) > 2.3) {
						cout << mn;
						return;
					}
				}
			if ((((double)(clock() - t_BG)) / (CLOCKS_PER_SEC)) > 2.3) {
				cout << mn;
				return;
			}
		}
	cout << mn;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:107:49: error: return-statement with no value, in function returning 'int' [-fpermissive]
  107 |                                                 return;
      |                                                 ^~~~~~
a.cc:112:33: error: return-statement with no value, in function returning 'int' [-fpermissive]
  112 |                                 return;
      |                                 ^~~~~~
Language: C++

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

#ifdef LOCAL
#define dbg(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define dbg(...) 17;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) { return os << "(" << p.first << ", " << p.second << ")"; }
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) { bool f = true; os << "{"; for (const auto &x : c) { if (!f) os << ", "; f = false; os << x; } return os << "}"; }
template<typename T> void debug(string s, T x) { cerr << s << " = " << x << "\n"; }
template<typename T, typename... Args> void debug(string s, T x, Args... args) { cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...); }
const int MOD = 998244353;
typedef decay<decltype(MOD)>::type T;
struct mi {
    T val;
    explicit operator T() const { return val; }
    mi() { val = 0; }
    mi(const long long& v) {
        val = (-MOD <= v && v <= MOD) ? v : v % MOD;
        if (val < 0) val += MOD; }
    friend ostream& operator<<(ostream& os, const mi& a) { return os << a.val; }
    friend bool operator==(const mi& a, const mi& b) { return a.val == b.val; }
    friend bool operator!=(const mi& a, const mi& b) { return !(a == b); }
    friend bool operator<(const mi& a, const mi& b) { return a.val < b.val; }
    mi operator-() const { return mi(-val); }
    mi& operator+=(const mi& m) {
        if ((val += m.val) >= MOD) val -= MOD;
        return *this; }
    mi& operator-=(const mi& m) {
        if ((val -= m.val) < 0) val += MOD;
        return *this; }
    mi& operator*=(const mi& m) { val = (long long) val * m.val % MOD;
        return *this; }
    friend mi pow(mi a, long long p) {
        mi ans = 1; assert(p >= 0);
        for (; p; p /= 2, a *= a) if (p & 1) ans *= a;
        return ans; }
    friend mi inv(const mi& a) { assert(a != 0); return pow(a, MOD - 2); }
    mi& operator/=(const mi& m) { return (*this) *= inv(m); }
    friend mi operator+(mi a, const mi& b) { return a += b; }
    friend mi operator-(mi a, const mi& b) { return a -= b; }
    friend mi operator*(mi a, const mi& b) { return a *= b; }
    friend mi operator/(mi a, const mi& b) { return a /= b; }
};
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
        cin >> a[i];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    bool ok = false;
    for (int i = 1; i < n; i++) {
        if (__gcd(a[0], a[i]) != 1) {
            ok = true;
        }
    }
    if (ok) {
        cout << a[0] << '\n';
        return 0;
    }
    assert(false);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:54:18: error: 'i' was not declared in this scope
   54 |         cin >> a[i];
      |                  ^
Language: C++

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

#define rep(i, n) for (int i=0; i<n; i++)

using LL = long long;
int N;
const LL MOD = 998244353;

LL gcd(LL a, LL b) {
  if (b ==  0) return a;
  return gcd(b, a%b);
}
 
int main() { 
  cin >> N;
  LL ans = 1;
  vector<int> as;
  rep(i, N) {
    int a;
    cin >> a;
    as.push_back(a);
  }
  sort(as.begin(), as.end());
  for (int a : as) {
    ans *= gcd(a, i-1);
     ans %= MOD;
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:19: error: 'i' was not declared in this scope
   26 |     ans *= gcd(a, i-1);
      |                   ^