stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

#include <cstdlib>

#include <iostream>

#include <algorithm>

#include <cstdlib>

#include <cstring>

#include <string>

#include <vector>

#include <cstdio>

#include <queue>

#include <stack>

#include <cmath>

#include <time.h>

using namespace std;



#define LL long long 

#define clr(x) memset(x,0,sizeof(x))

#define eps 1e-6

#define PI 3.1415926535897932384626433832795028          

#define MAXN 105



struct color

{

	double a,b,c;



}e[105];



double d[105][105];



int check[1005];



int main()

{

	int n,m;

	while(scanf("%d%d",&n,&m)!=EOF)

	{

		for(int i=0;i<n;i++)

			scanf("%lf%lf%lf",&e[i].a,&e[i].b,&e[i].c);



		for(int i=0;i<n;i++)

		{

			for(int j=i+1;j<n;j++)

			{

			    d[i][j]=(e[i].a-e[j].a)*(e[i].a-e[j].a)+(e[i].b-e[j].b)*(e[i].b-e[j].b)+(e[i].c-e[j].c)*(e[i].c-e[j].c);

				//printf("%lf\n",d[i][j]);

			}

		}

		double s=0,min=0;

		

		clr(check);



		for(int i=n-m;i<n;i++)

		{

			check[i]=1;

		}

		//s=0;

			//for(int i=0;i<n;i++)

			//	printf("%d",check[i]);

			//printf("\n");

			for(int i=0;i<n;i++)

			{   

				if(check[i])

				{

					for(int j=i+1;j<n;j++)

					{

						if(check[j])

							s+=d[i][j];

					}

				}

			}

			//printf("%d\n",s);

			if(s>min)

				min=s;

		while(next_permutation(check,check+n))

		{

			s=0;

			//for(int i=0;i<n;i++)

				//printf("%d",check[i]);

			//printf("\n");

			for(int i=0;i<n;i++)

			{   

				if(check[i])

				{

					for(int j=i+1;j<n;j++)

					{

						if(check[j])

							s+=d[i][j];

					}

				}

			}

			//printf("%d\n",s);

			if(s>min)

				min=s;

		}		

		printf("%lf\n",min);

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#define maxn 25



struct node 

{

       double x,y,z;

}a[maxn];

double dis[maxn][maxn];

int n,m;

int visit[maxn],use[maxn];

double ans;



double cal(struct node p,struct node q)

{

       return (p.x-q.x)*(p.x-q.x)+(p.y-q.y)*(p.y-q.y)+(p.z-q.z)*(p.z-q.z);

}



void judge()

{

     int i,j;

     double tmp=0;

     for (i=1;i<=m;i++)

         for (j=i+1;j<=m;j++)

             tmp+=dis[use[i]][use[j]]; 

     if (ans-tmp<0.000001)

        ans=tmp;    

}



void updata(int k,int p)

{

     int i;

     

     if (k==m+1)

     {

              judge();

              return;

     }

     for (i=p;i<=n;i++)

         if (!visit[i])

         {

            visit[i]=1;

            use[k]=i;

            updata(k+1,i+1);

            visit[i]=0;

         }

}

int main()

{

    scanf("%d %d",&n,&m);

    int i,j;

    for (i=1;i<=n;i++)

        scanf("%lf %lf %lf",&a[i].x,&a[i].y,&a[i].z);

    for (i=1;i<=n;i++)

        for (j=i+1;j<=n;j++)

        {

            dis[i][j]=cal(a[i],a[j]);

            dis[j][i]=dis[i][j];

        }

    updata(1,1);

    printf("%.20lf\n",ans); 

    return 0;   

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<cmath>

#include<algorithm>

using namespace std;

#define dis2(x) (x)*(x)

double map[21][21],maxn;

int m,n;

bool num[21];

struct node{

	double l,a,b;

}p[21];

double dis(node x,node y){

	return dis2(x.a-y.a)+dis2(x.b-y.b)+dis2(x.l-y.l);

}

void check(){

	int ln=0,cnt[21];

	double ans=0;

	for(int i=1;i<=n;i++)

		if(num[i])

			cnt[++ln]=i;

	if(ln>m)

		return;

	for(int i=1;i<=ln;i++)

		for(int j=i+1;j<=ln;j++)

			ans+=map[cnt[i]][cnt[j]];

	if(ans>maxn)

		maxn=ans;

}

void solve(int t){

	if(t>n){

		check();

		return;

	}

	num[t]=true;

	solve(t+1);

	num[t]=false;

	solve(t+1);



}

int main(){

	while(scanf("%d%d",&n,&m)!=EOF){

		for(int i=1;i<=n;i++)

			scanf("%lf%lf%lf",&p[i].l,&p[i].a,&p[i].b);

		memset(num,false,sizeof(num));

		for(int i=1;i<=n;i++){

			map[i][i]=0;

			for(int j=i+1;j<=n;j++)

				map[i][j]=map[j][i]=dis(p[i],p[j]);

		}

		maxn=-1;

		solve(1);

		printf("%lf\n",maxn);

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#define maxn 25



struct node 

{

       double x,y,z;

}a[maxn];

double dis[maxn][maxn];

int n,m;

int visit[maxn],use[maxn];

double ans;



double cal(struct node p,struct node q)

{

       return (p.x-q.x)*(p.x-q.x)+(p.y-q.y)*(p.y-q.y)+(p.z-q.z)*(p.z-q.z);

}



void judge()

{

     int i,j;

     double tmp=0;

     for (i=1;i<=m;i++)

         for (j=i+1;j<=m;j++)

             tmp+=dis[use[i]][use[j]]; 

     if (ans-tmp<0.000001)

        ans=tmp;    

}



void updata(int k,int p)

{

     int i;

     

     if (k==m+1)

     {

              judge();

              return;

     }

     for (i=p;i<=n;i++)

         if (!visit[i])

         {

            visit[i]=1;

            use[k]=i;

            updata(k+1,i+1);

            visit[i]=0;

         }

}

int main()

{

    scanf("%d %d",&n,&m);

    int i,j;

    for (i=1;i<=n;i++)

        scanf("%lf %lf %lf",&a[i].x,&a[i].y,&a[i].z);

    for (i=1;i<=n;i++)

        for (j=i+1;j<=n;j++)

        {

            dis[i][j]=cal(a[i],a[j]);

            dis[j][i]=dis[i][j];

        }

    updata(1,1);

    printf("%.20lf\n",ans); 

    return 0;   

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

#include <cstdlib>

#include <iostream>

#include <algorithm>

#include <cstdlib>

#include <cstring>

#include <string>

#include <vector>

#include <cstdio>

#include <queue>

#include <stack>

#include <cmath>

#include <time.h>

using namespace std;



#define LL long long 

#define clr(x) memset(x,0,sizeof(x))

#define eps 1e-6

#define PI 3.1415926535897932384626433832795028          

#define MAXN 105



struct node 

{

	double x,y,z;

}e[105],q[105];



double dis(node a, node b)

{

	return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z);

}

int main()

{

	int m,n,i,j,k,pp=1,t;

	scanf("%d%d",&n,&m);

	for(i=0;i<n;i++)

		scanf("%lf%lf%lf",&e[i].x,&e[i].y,&e[i].z);

	int a[105]={0};

	for(i=n-m;i<n;i++)

		a[i]=1;

	double mm=0;

	do

	{

		int count=0;

		for(i=0;i<n;i++)

			if(a[i]==1)

				q[count++]=e[i];

		double d=0;

		for(i=0;i<count;i++)

			for(j=i+1;j<count;j++)

				d+=dis(q[i],q[j]);

		mm=d>mm?d:mm;

	}while(next_permutation(a,a+n));

	printf("%lf\n",mm);

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#define maxn 25



struct node 

{

       double x,y,z;

}a[maxn];

double dis[maxn][maxn];

int n,m;

int visit[maxn],use[maxn];

double ans;



double cal(struct node p,struct node q)

{

       return (p.x-q.x)*(p.x-q.x)+(p.y-q.y)*(p.y-q.y)+(p.z-q.z)*(p.z-q.z);

}



void judge()

{

     int i,j;

     double tmp=0;

     for (i=1;i<=m;i++)

         for (j=i+1;j<=m;j++)

             tmp+=dis[use[i]][use[j]]; 

     if (ans-tmp<0.000001)

        ans=tmp;    

}



void updata(int k,int p)

{

     int i;

     

     if (k==m+1)

     {

              judge();

              return;

     }

     for (i=p;i<=n;i++)

         if (!visit[i])

         {

            visit[i]=1;

            use[k]=i;

            updata(k+1,i+1);

            visit[i]=0;

         }

}

int main()

{

    scanf("%d %d",&n,&m);

    int i,j;

    for (i=1;i<=n;i++)

        scanf("%lf %lf %lf",&a[i].x,&a[i].y,&a[i].z);

    for (i=1;i<=n;i++)

        for (j=i+1;j<=n;j++)

        {

            dis[i][j]=cal(a[i],a[j]);

            dis[j][i]=dis[i][j];

        }

    updata(1,1);

    printf("%.20lf\n",ans); 

    return 0;   

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <cstring>



using namespace std;



const int MAXN = 23;

int n, m;

double dis[MAXN][MAXN];

double ans, x[MAXN], y[MAXN], z[MAXN];

bool use[MAXN];

int arr[MAXN];



void dfs(int dp)

{

	if(dp == m + 1)

	{

		double sum=0;

		for(int i=1;i<dp;i++)

			for(int j=i+1;j<dp;j++)

				sum += dis[arr[i]][arr[j]];

		ans = max(ans, sum);

		return;

	}

	for(int i=arr[dp-1]+1;i<=n;i++)	if(!use[i])

	{

		use[i] = 1;

		arr[dp] = i;

		dfs(dp + 1);

		use[i] = 0;

	}

}



double caldis(int i, int j)

{

	double dx = x[i] - x[j],

		   dy = y[i] - y[j],

		   dz = z[i] - z[j];

	return dx * dx + dy * dy + dz * dz;

}



int main()

{

	while(~scanf("%d %d", &n, &m))

	{

		for(int i=1;i<=n;i++)

		{

			scanf("%lf %lf %lf", &x[i], &y[i], &z[i]);

		}

		for(int i=1;i<=n;i++)

			for(int j=1;j<=n;j++)

				dis[i][j] = caldis(i, j);

		ans = 0;

		memset(arr, 0, sizeof(arr));

		memset(use, 0, sizeof(use));

		dfs(1);

		printf("%.6lf\n", ans);

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cmath>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

using namespace std;

const double eps = 1e-10;

const int N=25;



struct point {

    double x,y,z;

}pt[N];

int n,m;

double dis[N][N];



double dist(point p1,point p2) {

    return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)+(p1.z-p2.z)*(p1.z-p2.z);

}



double ret;

int ans[N];

void dfs(int idx,int k,double sum) {

    if(k+(n-idx)+2<m) return;

    if(k==m) {

        ret=max(ret,sum);

        return;

    }



    dfs(idx+1,k,sum);

    double tmp=0;

    for(int i=0;i<k;i++) tmp+=dis[ans[i]][idx];

    ans[k]=idx;

    dfs(idx+1,k+1,sum+tmp);

}



int main()

{

    int i,j,t,cas=0;

    while(scanf("%d%d",&n,&m)!=EOF) {

        for(i=1;i<=n;i++) {

            scanf("%lf%lf%lf",&pt[i].x,&pt[i].y,&pt[i].z);

        }

        for(i=1;i<=n;i++) {

            for(j=1;j<=n;j++) {

                dis[i][j]=dist(pt[i],pt[j]);

            }

        }



        ret=0.0;

        dfs(1,0,0);



        printf("%.10f\n",ret);

    }

    return 0;

}



/*

20 10

0 0 0

1 1 1

2 2 2

3 3 3

4 4 4

5 5 5

6 6 6

7 7 7

8 8 8

9 9 9

10 10 10

11 11 11

12 12 12

13 13 13

14 14 14

15 15 15

16 16 16

17 17 17

18 18 18

19 19 19

*/

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<stdio.h>

#include<stdlib.h>

#include<iostream>

#include<stdlib.h>

#define rep(i,s,t) for (i=s;i<=t;i++)

using namespace std;

double a[30][3];

bool vis[30];

int i,j,m,n,k,l,o,p;

double ans,temp;

inline double sqr(double x)

{

	return x*x;

}

inline double dist(int x,int y)

{

	return (sqr(a[x][0]-a[y][0])+sqr(a[x][1]-a[y][1])+sqr(a[x][2]-a[y][2]));

}

void dfs(int k,int s)

{

	if (s == m)

	{

		if (ans < temp) ans = temp;

		return;

	}

	if (k > n) return;

	double st;

	int i;

	rep(i,k,n)

	{

		vis[i] = true;

		st = temp;

		rep(j,1,i-1) if (vis[j]) temp+=dist(i,j);

		dfs(i+1,s+1);

		temp = st;

		vis[i] = false;

	}

	dfs(i+1,s);

}

int main()

{

	while (scanf("%d%d",&n,&m) != EOF)

	{

	

	rep(i,1,n) scanf("%lf%lf%lf",&a[i][0],&a[i][1],&a[i][2]);

	ans = 0;

	temp = 0;

	dfs(1,0);

	printf("%.20f\n",ans);

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cmath>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

using namespace std;

const double eps = 1e-10;

const int N=25;



struct point {

    double x,y,z;

}pt[N];

int n,m;

double dis[N][N];



double dist(point p1,point p2) {

    return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)+(p1.z-p2.z)*(p1.z-p2.z);

}



double ret;

int ans[N];

void dfs(int idx,int k,double sum) {

    if(k+(n-idx)+2<m) return;

    if(k==m) {

        ret=max(ret,sum);

        return;

    }



    dfs(idx+1,k,sum);

    double tmp=0;

    for(int i=0;i<k;i++) tmp+=dis[ans[i]][idx];

    ans[k]=idx;

    dfs(idx+1,k+1,sum+tmp);

}



int main()

{

    int i,j,t,cas=0;

    while(scanf("%d%d",&n,&m)!=EOF) {

        for(i=1;i<=n;i++) {

            scanf("%lf%lf%lf",&pt[i].x,&pt[i].y,&pt[i].z);

        }

        for(i=1;i<=n;i++) {

            for(j=1;j<=n;j++) {

                dis[i][j]=dist(pt[i],pt[j]);

            }

        }



        ret=0.0;

        dfs(1,0,0);



        printf("%.10f\n",ret);

    }

    return 0;

}



/*

20 10

0 0 0

1 1 1

2 2 2

3 3 3

4 4 4

5 5 5

6 6 6

7 7 7

8 8 8

9 9 9

10 10 10

11 11 11

12 12 12

13 13 13

14 14 14

15 15 15

16 16 16

17 17 17

18 18 18

19 19 19

*/

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <cstdio>

#include <cstring>

#include <iostream>

using namespace std;



const int maxn = 2005;

const int P = 924844033;

int n, k, fact[maxn], dp[2][maxn][2][2];



void update(int &a, int b) {

	a += b;

	(a >= P) && (a -= P);

	(a < 0) && (a += P);

}



int main() {

	scanf("%d %d", &n, &k);

	fact[0] = 1;

	for (int i = 1; i <= 2000; i++) {

		fact[i] = 1ll * fact[i - 1] * i % P;

	}

 	int cur = 0, nxt = 1;

 	dp[0][0][1][0] = 1;

	for (int x = 1; x <= k; x++) {

		for (int j = x; j <= n; j += k) {

			memset(dp[nxt], 0, sizeof(dp[nxt]));

			for (int i = 0; i <= n; i++) {

				for (int v0 = 0; v0 < 2; v0++) {

					for (int v1 = 0; v1 < 2; v1++) {

						if (dp[cur][i][v0][v1]) {

							if (j + k > n) {

								update(dp[nxt][i][1][0], dp[cur][i][v0][v1]);

								if (v0 == 0) {

									update(dp[nxt][i + 1][1][0], dp[cur][i][v0][v1]);

								}

							} else {

								update(dp[nxt][i][v1][0], dp[cur][i][v0][v1]);

								if (v0 == 0) {

									update(dp[nxt][i + 1][v1][0], dp[cur][i][v0][v1]);

								}

								update(dp[nxt][i + 1][v1][1], dp[cur][i][v0][v1]);

							}

						}

					}

				}

			}

			swap(cur, nxt);

		}

	}

	int ans = 0;

	for (int i = 0; i <= n; i++) {

		int temp = 0;

		for (int v0 = 0; v0 < 2; v0++) {

			for (int v1 = 0; v1 < 2; v1++) {

				update(temp, dp[cur][i][v0][v1]);

			}

		}

		temp = 1ll * temp * fact[n - i] % P;

		if (i & 1) {

			update(ans, -temp);

		} else {

			update(ans, temp);

		}

	}

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

	return 0;//

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#define N 2002

#define p 924844033

inline int mod(int x){return x<p?x:x-p;}

int a[N],f[N][2],i,j,m,n,s,x;

int main()

{

	scanf("%d%d",&n,&m),f[0][0]=1;

	for(i=1;i<=m;i++)

	{

		for(j=0;j<=n;f[j++][0]=0)f[j][1]=mod(f[j][0]+f[j][1]);

		for(s=(n-i)/m+2>>1;s--;)

		for(j=n;j--;)

		{

			f[j+1][0]=mod(f[j+1][0]+f[j][0]);

			f[j+1][1]=mod(f[j+1][1]+mod(f[j][0]+f[j][1]));

			f[j][0]=mod(f[j][0]+f[j][1]);

			f[j][1]=0;

		}

		if(~((n-i)/m)&1)for(j=0;j<=n;j++)f[j][1]=0;

	}

	for(;i<=n&&i<=m<<1;i++)

	{

		for(j=0;j<=n;f[j++][1]=0)f[j][0]=mod(f[j][0]+f[j][1]);

		for(s=(n-i)/m+2>>1;s--;)

		for(j=n;j--;)

		{

			f[j+1][0]=mod(f[j+1][0]+f[j][0]);

			f[j+1][1]=mod(f[j+1][1]+mod(f[j][0]+f[j][1]));

			f[j][0]=mod(f[j][0]+f[j][1]);

			f[j][1]=0;

		}

		if(~((n-i)/m)&1)for(j=0;j<=n;j++)f[j][1]=0;

	}

	for(i=*a=1;i<=n;i++)a[i]=(long long)a[i-1]*i%p;

	for(i=0;i<=n;i++)x=i&1?(x+(long long)(p-a[n-i])*(f[i][0]+f[i][1]))%p:(x+(long long)a[n-i]*(f[i][0]+f[i][1]))%p;

	return 0&printf("%d\n",x);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstring>

#include<cstdio>

#include<cstdlib>

#include<algorithm>

#include<cmath>

#define mo  924844033

using namespace std;

typedef long long ll;

int n,k;

ll dp[2][2009][2][2],bin[2009];

int main()

{

  scanf("%d%d",&n,&k);

  dp[0][0][1][0]=1ll;

  int las=0,now=0;

  bin[0]=1;

  for (int i=1;i<=n;i++) bin[i]=(bin[i-1]*(ll)i)%mo;

  for (int t=1;t<=k;t++)

  {

    for (int i=t;i<=n;i+=k)

    {   

      las=now;now=now^1;

      for (int j=0;j<=n;j++)

      for (int x=0;x<=1;x++)

      for (int y=0;y<=1;y++)

      dp[now][j][x][y]=0;

    

      for (int j=0;j<=n;j++)

      for (int x=0;x<=1;x++)

      for (int y=0;y<=1;y++)

  	  {

  	    if (dp[las][j][x][y]==0) continue;

	    ll val=dp[las][j][x][y];

	    if (i+k>n)

	    {

	       dp[now][j][1][0]=(dp[now][j][1][0]+val)%mo;

		   if (x==0) dp[now][j+1][1][0]=(dp[now][j+1][1][0]+val)%mo;  

		}

		else 

		{

	      dp[now][j][y][0]=(dp[now][j][y][0]+val)%mo; 

	      if (x==0) dp[now][j+1][y][0]=(dp[now][j+1][y][0]+val)%mo;

	      dp[now][j+1][y][1]=(dp[now][j+1][y][1]+val)%mo;

	    }

      }

    }

  }

  ll ans=0;

  for (int i=0;i<=n;i++)

  {

  	ll sum=0;

  	for (int x=0;x<=1;x++)

  	for (int y=0;y<=1;y++)

  	sum=(sum+dp[now][i][x][y])%mo;

  	sum=(bin[n-i]*sum)%mo;

  	if (i%2==0) ans=(ans+sum)%mo;

  	else ans=(ans-sum)%mo;

  }

  ans=(ans+mo)%mo;

  printf("%lld\n",ans);

  return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#define N 2002

#define p 924844033

inline int mod(int x){return x<p?x:x-p;}

int a[N],f[N][2],i,j,m,n,s,x;

int main()

{

	scanf("%d%d",&n,&m),f[0][0]=1;

	for(i=1;i<=m;i++)

	{

		for(j=0;j<=n;f[j++][0]=0)f[j][1]=mod(f[j][0]+f[j][1]);

		for(s=(n-i)/m+2>>1;s--;)

		for(j=n;j--;)

		{

			f[j+1][0]=mod(f[j+1][0]+f[j][0]);

			f[j+1][1]=mod(f[j+1][1]+mod(f[j][0]+f[j][1]));

			f[j][0]=mod(f[j][0]+f[j][1]);

			f[j][1]=0;

		}

		if(~((n-i)/m)&1)for(j=0;j<=n;j++)f[j][1]=0;

	}

	for(;i<=n&&i<=m<<1;i++)

	{

		for(j=0;j<=n;f[j++][1]=0)f[j][0]=mod(f[j][0]+f[j][1]);

		for(s=(n-i)/m+2>>1;s--;)

		for(j=n;j--;)

		{

			f[j+1][0]=mod(f[j+1][0]+f[j][0]);

			f[j+1][1]=mod(f[j+1][1]+mod(f[j][0]+f[j][1]));

			f[j][0]=mod(f[j][0]+f[j][1]);

			f[j][1]=0;

		}

		if(~((n-i)/m)&1)for(j=0;j<=n;j++)f[j][1]=0;

	}

	for(i=*a=1;i<=n;i++)a[i]=(long long)a[i-1]*i%p;

	for(i=0;i<=n;i++)x=i&1?(x+(long long)(p-a[n-i])*(f[i][0]+f[i][1]))%p:(x+(long long)a[n-i]*(f[i][0]+f[i][1]))%p;

	return 0&printf("%d\n",x);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

const int N = 2000 + 10;

const int P = 924844033;

int n, k, dp[N << 1][N][2], a[N << 1], num, fac[N];

int main() {

    scanf("%d%d", &n, &k);

    for (int i = fac[0] = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % P;

    for (int i = 1; i <= k; i++) {

        for (int j = i; j <= n; j += k) a[++num] = j;

        for (int j = i; j <= n; j += k) a[++num] = j;

    }

    dp[1][0][0] = 1;

    for (int i = 2; i <= (n << 1); i++) {

        for (int j = 0; j <= (i / 2); j++) {

            dp[i][j][0] = (dp[i - 1][j][0] + dp[i - 1][j][1]) % P;

            if (j && a[i] - a[i - 1] == k) dp[i][j][1] = dp[i - 1][j - 1][0];

        }

    }

    int ans = 0;

    for (int i = 0; i <= n; i++) {

        int g = (dp[n << 1][i][0] + dp[n << 1][i][1]) % P;

        if (i & 1)

            ans = (ans - 1ll * fac[n - i] * g % P + P) % P;

        else

            ans = (ans + 1ll * fac[n - i] * g) % P;

    }

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

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#define N 2002

#define p 924844033

inline int mod(int x){return x<p?x:x-p;}

int a[N],f[N][2],i,j,m,n,s,x;

int main()

{

	scanf("%d%d",&n,&m),f[0][0]=1;

	for(i=1;i<=m;i++)

	{

		for(j=0;j<=n;f[j++][0]=0)f[j][1]=mod(f[j][0]+f[j][1]);

		for(s=(n-i)/m+2>>1;s--;)

		for(j=n;j--;)

		{

			f[j+1][0]=mod(f[j+1][0]+f[j][0]);

			f[j+1][1]=mod(f[j+1][1]+mod(f[j][0]+f[j][1]));

			f[j][0]=mod(f[j][0]+f[j][1]);

			f[j][1]=0;

		}

		if(~((n-i)/m)&1)for(j=0;j<=n;j++)f[j][1]=0;

	}

	for(;i<=n&&i<=m<<1;i++)

	{

		for(j=0;j<=n;f[j++][1]=0)f[j][0]=mod(f[j][0]+f[j][1]);

		for(s=(n-i)/m+2>>1;s--;)

		for(j=n;j--;)

		{

			f[j+1][0]=mod(f[j+1][0]+f[j][0]);

			f[j+1][1]=mod(f[j+1][1]+mod(f[j][0]+f[j][1]));

			f[j][0]=mod(f[j][0]+f[j][1]);

			f[j][1]=0;

		}

		if(~((n-i)/m)&1)for(j=0;j<=n;j++)f[j][1]=0;

	}

	for(i=*a=1;i<=n;i++)a[i]=(long long)a[i-1]*i%p;

	for(i=0;i<=n;i++)x=i&1?(x+(long long)(p-a[n-i])*(f[i][0]+f[i][1]))%p:(x+(long long)a[n-i]*(f[i][0]+f[i][1]))%p;

	return 0&printf("%d\n",x);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long LL;



const int N=2100,mod=924844033;

int n,K,cnt[N];

LL fac[N<<1],inv[N<<1],f[2][N],Ans;



LL qpow(LL x,int y)

{

	LL ret=1;

	while(y)

	{

		if(y&1) ret=ret*x%mod;

		x=x*x%mod, y>>=1;

	}

	return ret;

}



LL C(int x,int y)

{

	if(y>x) return 0;

	return fac[x]*inv[y]%mod*inv[x-y]%mod;

}



int main()

{

	scanf("%d%d",&n,&K);

	fac[0]=1;

	for(int i=1;i<=n<<1;++i) fac[i]=fac[i-1]*i%mod;

	inv[n<<1]=qpow(fac[n<<1],mod-2);

	for(int i=(n<<1)-1;i>=0;--i) inv[i]=inv[i+1]*(i+1)%mod;

	if(K*2>=n)

	{

		Ans=fac[n];

		for(int i=1;i<=(n-K)*2;++i)

			if(i&1) (Ans-=fac[n-i]*C((n-K)*2,i))%=mod;

			else (Ans+=fac[n-i]*C((n-K)*2,i))%=mod;

		(Ans+=mod)%=mod;

		printf("%lld",Ans); return 0;

	}

	for(int i=1;i<=K;++i) cnt[i]=(n-i-K)/(2*K)+1 + (n-i)/(2*K);

	f[0][0]=1;

	for(int i=1;i<=K;++i)

	{

		for(int j=0;j<=n;++j) f[1][j]=f[0][j];

		for(int j=0;j<=n;++j)

			for(int k=1;k<=min(j,cnt[i]);++k)

				(f[1][j]+=f[0][j-k]*C(cnt[i]-k+1,k)%mod)%=mod;

		for(int j=0;j<=n;++j) f[0][j]=f[1][j];

		for(int j=0;j<=n;++j)

			for(int k=1;k<=min(j,cnt[i]);++k)

				(f[0][j]+=f[1][j-k]*C(cnt[i]-k+1,k)%mod)%=mod;

	}

	Ans=fac[n];

	for(int i=1;i<=n;++i)

		if(i&1) (Ans-=f[0][i]*fac[n-i]%mod)%=mod;

		else (Ans+=f[0][i]*fac[n-i]%mod)%=mod;

	Ans=(Ans+mod)%mod;

	printf("%lld",Ans);

	return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#define N 2002

#define p 924844033

inline int mod(int x){return x<p?x:x-p;}

int a[N],f[N][2],i,j,m,n,s,x;

int main()

{

	scanf("%d%d",&n,&m),f[0][0]=1;

	for(i=1;i<=m;i++)

	{

		for(j=0;j<=n;f[j++][0]=0)f[j][1]=mod(f[j][0]+f[j][1]);

		for(s=(n-i)/m+2>>1;s--;)

		for(j=n;j--;)

		{

			f[j+1][0]=mod(f[j+1][0]+f[j][0]);

			f[j+1][1]=mod(f[j+1][1]+mod(f[j][0]+f[j][1]));

			f[j][0]=mod(f[j][0]+f[j][1]);

			f[j][1]=0;

		}

		if(~((n-i)/m)&1)for(j=0;j<=n;j++)f[j][1]=0;

	}

	for(;i<=n&&i<=m<<1;i++)

	{

		for(j=0;j<=n;f[j++][1]=0)f[j][0]=mod(f[j][0]+f[j][1]);

		for(s=(n-i)/m+2>>1;s--;)

		for(j=n;j--;)

		{

			f[j+1][0]=mod(f[j+1][0]+f[j][0]);

			f[j+1][1]=mod(f[j+1][1]+mod(f[j][0]+f[j][1]));

			f[j][0]=mod(f[j][0]+f[j][1]);

			f[j][1]=0;

		}

		if(~((n-i)/m)&1)for(j=0;j<=n;j++)f[j][1]=0;

	}

	for(i=*a=1;i<=n;i++)a[i]=(long long)a[i-1]*i%p;

	for(i=0;i<=n;i++)x=i&1?(x+(long long)(p-a[n-i])*(f[i][0]+f[i][1]))%p:(x+(long long)a[n-i]*(f[i][0]+f[i][1]))%p;

	return 0&printf("%d\n",x);

}

// Fastest known solution for this problem: