stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h> //Ithea Myse Valgulious

namespace chtholly{

typedef long long ll;

#define re0 register int

#define rec register char

#define rel register ll

#define gc getchar

#define pc putchar

#define p32 pc(' ')

#define pl puts("")

/*By Citrus*/

inline int read(){

  int x=0,f=1;char c=gc();

  for (;!isdigit(c);c=gc()) f^=c=='-';

  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');

  return f?x:-x;

  }

template <typename mitsuha>

inline bool read(mitsuha &x){

  x=0;int f=1;char c=gc();

  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';

  if (!~c) return 0;

  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');

  return x=f?x:-x,1;

  }

template <typename mitsuha>

inline int write(mitsuha x){

  if (!x) return pc(48);

  if (x<0) x=-x,pc('-');

  int bit[20],i,p=0;

  for (;x;x/=10) bit[++p]=x%10;

  for (i=p;i;--i) pc(bit[i]+48);

  return 0;

  }

inline char fuhao(){

  char c=gc();

  for (;isspace(c);c=gc());

  return c;

  }

}using namespace chtholly;

using namespace std;

int h=read(),w=read(),n=read(),ans[150][150],nx=1,ny=1;



int main(){

int i;

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

  int x=read();

  for (;nx<=h&&x>0;){

    if (nx&1){

      for (int &k=ny;k<=w&&x-->0;++k) ans[nx][k]=i;

	  }

	else{

	  for (int &k=ny;k&&x-->0;--k) ans[nx][k]=i;

	  }

	if (!ny||ny>w){

	  ++nx;

	  if (!ny) ++ny;

	  if (ny>w) --ny;

	  } 

    }

  }

for (i=1;i<=h;++i,pl){

  for (int j=1;j<=w;++j,p32) write(ans[i][j]);

  }

}

// Faster C++ solution for the same problem (measured speedup: 5.152024610517623x):
#include<stdio.h>



int integer_a[105][105],integer_b[10000+50];



int main ()

{

    int h,m;

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

    {

        int i,j,t,k=0;

        scanf("%d",&t);

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

            scanf("%d",&integer_b[i]);

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

        {

            if(i%2==0)

                for(j=0;j<m;j++)

                {

                    integer_a[i][j]=k+1;

                    integer_b[k]--;

                    if(integer_b[k]==0)

                        k++;

                }

            if(i%2==1)

                for(j=m-1;j>=0;j--)

                {

                    integer_a[i][j]=k+1;

                    integer_b[k]--;

                    if(integer_b[k]==0)

                        k++;

                }

        }

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

        {

            for(j=0;j<m-1;j++)

                printf("%d ",integer_a[i][j]);

            printf("%d\n",integer_a[i][m-1]);

        }

    }

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main()

{

    int h,w,n,b[10000+50],a[105][105],i,j,k;

    while(cin>>h>>w>>n)

    {

        k=0;

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

        {

            cin>>b[i];

        }

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

        {

            if(i%2==0)

            {

                for(j=0;j<w;j++)

                {

                    a[i][j]=k+1;

                    b[k]--;

                    if(b[k]==0)k++;

                }

            }

            else

            {

                for(j=w-1;j>=0;j--)

                {

                    a[i][j]=k+1;

                    b[k]--;

                    if(b[k]==0)k++;

                }

            }

        }

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

            for(j=0;j<w;j++)

        {

            cout<<a[i][j];

            if(j==w-1)cout<<endl;

            else cout<<" ";

        }

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.252377020103629x):
#include<stdio.h>



int integer_a[105][105],integer_b[10000+50];



int main ()

{

    int h,m;

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

    {

        int i,j,t,k=0;

        scanf("%d",&t);

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

            scanf("%d",&integer_b[i]);

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

        {

            if(i%2==0)

                for(j=0;j<m;j++)

                {

                    integer_a[i][j]=k+1;

                    integer_b[k]--;

                    if(integer_b[k]==0)

                        k++;

                }

            if(i%2==1)

                for(j=m-1;j>=0;j--)

                {

                    integer_a[i][j]=k+1;

                    integer_b[k]--;

                    if(integer_b[k]==0)

                        k++;

                }

        }

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

        {

            for(j=0;j<m-1;j++)

                printf("%d ",integer_a[i][j]);

            printf("%d\n",integer_a[i][m-1]);

        }

    }

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cmath>

#include<algorithm>

#include<set>

using namespace std;

typedef long long LL;

const int INF=0x3f3f3f3f;

const int MAXN=1e5+5;

int a[MAXN];

int G[105][105];



int main()

{

    int h,w;

    while(scanf("%d%d",&h,&w)!=EOF)

    {

        int n;

       cin>>n;

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

            scanf("%d",&a[i]);

        int cnt=1;

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

        {

            if(i&1)

            {

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

                {

                   if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}

                   else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}

                }

            }else

            {

                for(int j=w;j>=1;--j)

                {

                    if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}

                    else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}

                }

            }

        }

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

        {

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

            {

                if(j!=w) printf("%d ",G[i][j]);

                else printf("%d\n",G[i][j]);

            }

        }

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.172888595537309x):
#include<stdio.h>



int integer_a[105][105],integer_b[10000+50];



int main ()

{

    int h,m;

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

    {

        int i,j,t,k=0;

        scanf("%d",&t);

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

            scanf("%d",&integer_b[i]);

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

        {

            if(i%2==0)

                for(j=0;j<m;j++)

                {

                    integer_a[i][j]=k+1;

                    integer_b[k]--;

                    if(integer_b[k]==0)

                        k++;

                }

            if(i%2==1)

                for(j=m-1;j>=0;j--)

                {

                    integer_a[i][j]=k+1;

                    integer_b[k]--;

                    if(integer_b[k]==0)

                        k++;

                }

        }

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

        {

            for(j=0;j<m-1;j++)

                printf("%d ",integer_a[i][j]);

            printf("%d\n",integer_a[i][m-1]);

        }

    }

}
// Slower C++ solution:
//20-27行描述了填色标准，算法核心

//为什么这么移动？

//走S形

//在奇数行时，向右移动；在偶数行时，向左移动

//奇数行末尾，列数达到最大，向下移动；偶数行末尾，列数为1，向下移动

//用代码描述一下就是这样

//理论上还可以选择另一种S形状，即“竖过来”

#include <bits/stdc++.h>

using namespace std;

int r,c;//行数、列数

int n;//颜色总数

int x,y;//当前待着色点坐标

int ans[200][200];//答案记录表



int main()

{

    cin>>r>>c>>n;//分别输入行数、列数、颜色总数

    x=1,y=1;//初始坐标设置为（1，1）

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

    {

        int cnt;//“当前颜色剩余着色块数”计数器

        cin>>cnt;

        while(cnt--)//对当前颜色一块一块着色

        {

            ans[x][y]=i;//着色

            if(y==c&&x%2==1)//如果该点在右边缘 且 在奇数行上

                y=c,x++;//下移一行，列数不变

            else if(y==1&&x%2==0)//如果该点在第一列上，且在偶数行上

                y=1,x++;//列数不变，下移一行

            else if(x&1)//如果在奇数行上

                y++;//右移一列

            else//否则左移一列

                y--;

        }

    }

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

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

            printf("%d%c",ans[i][j],j==c?'\n':' ');//在到达当前行最后一列前，每次空一格；到达后，换行；

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.1889054949144855x):
#include<stdio.h>



int integer_a[105][105],integer_b[10000+50];



int main ()

{

    int h,m;

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

    {

        int i,j,t,k=0;

        scanf("%d",&t);

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

            scanf("%d",&integer_b[i]);

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

        {

            if(i%2==0)

                for(j=0;j<m;j++)

                {

                    integer_a[i][j]=k+1;

                    integer_b[k]--;

                    if(integer_b[k]==0)

                        k++;

                }

            if(i%2==1)

                for(j=m-1;j>=0;j--)

                {

                    integer_a[i][j]=k+1;

                    integer_b[k]--;

                    if(integer_b[k]==0)

                        k++;

                }

        }

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

        {

            for(j=0;j<m-1;j++)

                printf("%d ",integer_a[i][j]);

            printf("%d\n",integer_a[i][m-1]);

        }

    }

}
// Slower C++ solution:
#include<cstdio>

#include<iostream>

#include<cstring>



using namespace std;



int a[10010];

int pic[110][110];



int main()

{

    int H,W,N;

    int i,j,k=0;

    memset(a,0,sizeof(a));

    scanf("%d%d%d",&H,&W,&N);

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

    {

        scanf("%d",&a[i]);

    }

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

    {

        if(i%2==0)

        {

            for(j=0;j<W;++j)

            {

                pic[i][j]=k+1;

                --a[k];

                if(a[k]==0)++k;

            }

        }

        if(i%2==1)

        {

            for(j=W-1;j>=0;--j)

            {

                pic[i][j]=k+1;

                --a[k];

                if(a[k]==0)++k;

            }

        }

    }

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

    {

        for(j=0;j<W;++j)

        {

            printf("%d",pic[i][j]);

            if(j==W-1)printf("\n");

            else printf(" ");

        }

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.384787943637727x):
#include<stdio.h>



int integer_a[105][105],integer_b[10000+50];



int main ()

{

    int h,m;

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

    {

        int i,j,t,k=0;

        scanf("%d",&t);

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

            scanf("%d",&integer_b[i]);

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

        {

            if(i%2==0)

                for(j=0;j<m;j++)

                {

                    integer_a[i][j]=k+1;

                    integer_b[k]--;

                    if(integer_b[k]==0)

                        k++;

                }

            if(i%2==1)

                for(j=m-1;j>=0;j--)

                {

                    integer_a[i][j]=k+1;

                    integer_b[k]--;

                    if(integer_b[k]==0)

                        k++;

                }

        }

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

        {

            for(j=0;j<m-1;j++)

                printf("%d ",integer_a[i][j]);

            printf("%d\n",integer_a[i][m-1]);

        }

    }

}
// Slower C++ solution:
#include <cstdio>

#include <iostream>

using namespace std;

int xx[110][110];

int main(){

    int h,w,n,x=0;

    cin>>h>>w>>n;

    int a[n];

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

        cin>>a[i];

        for(int j=0;j<a[i];j++){

            if((x/w)%2==0) xx[x/w][x%w]=i+1;

            else xx[x/w][w-(x%w)-1]=i+1;

            x++;

        }

    }

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

        for(int j=0;j<w;j++){

            if(j==w-1) printf("%d\n",xx[i][j]);

            else printf("%d ",xx[i][j]);

        }

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.186897748882001x):
#include<stdio.h>



int integer_a[105][105],integer_b[10000+50];



int main ()

{

    int h,m;

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

    {

        int i,j,t,k=0;

        scanf("%d",&t);

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

            scanf("%d",&integer_b[i]);

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

        {

            if(i%2==0)

                for(j=0;j<m;j++)

                {

                    integer_a[i][j]=k+1;

                    integer_b[k]--;

                    if(integer_b[k]==0)

                        k++;

                }

            if(i%2==1)

                for(j=m-1;j>=0;j--)

                {

                    integer_a[i][j]=k+1;

                    integer_b[k]--;

                    if(integer_b[k]==0)

                        k++;

                }

        }

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

        {

            for(j=0;j<m-1;j++)

                printf("%d ",integer_a[i][j]);

            printf("%d\n",integer_a[i][m-1]);

        }

    }

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cmath>

#include<algorithm>

#include<set>



using namespace std;

typedef long long LL;

const int INF=0x3f3f3f3f;

int a[100005];

int G[105][105];



int main()

{

    int h,w;

    while(scanf("%d%d",&h,&w)!=EOF)

    {

        int n;

        scanf("%d",&n);

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

            scanf("%d",&a[i]);

        int cnt=1;

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

        {

            if(i&1)

            {

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

                {

                   if(a[cnt]>0)

                        {G[i][j]=cnt;--a[cnt];}

                   else if(a[cnt]==0)

                   {++cnt;G[i][j]=cnt;--a[cnt];}

                }

            }

            else

            {

                for(int j=w;j>=1;--j)

                {

                    if(a[cnt]>0)

                        {G[i][j]=cnt;--a[cnt];}

                    else if(a[cnt]==0)

                     {++cnt;G[i][j]=cnt;--a[cnt];}

                }

            }

        }

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

        {

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

            {

                if(j!=w)

                    printf("%d ",G[i][j]);

                else printf("%d\n",G[i][j]);

            }

        }

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.144399246331974x):
#include<stdio.h>



int integer_a[105][105],integer_b[10000+50];



int main ()

{

    int h,m;

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

    {

        int i,j,t,k=0;

        scanf("%d",&t);

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

            scanf("%d",&integer_b[i]);

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

        {

            if(i%2==0)

                for(j=0;j<m;j++)

                {

                    integer_a[i][j]=k+1;

                    integer_b[k]--;

                    if(integer_b[k]==0)

                        k++;

                }

            if(i%2==1)

                for(j=m-1;j>=0;j--)

                {

                    integer_a[i][j]=k+1;

                    integer_b[k]--;

                    if(integer_b[k]==0)

                        k++;

                }

        }

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

        {

            for(j=0;j<m-1;j++)

                printf("%d ",integer_a[i][j]);

            printf("%d\n",integer_a[i][m-1]);

        }

    }

}
// Slower C++ solution:
/*===============================================================

*  Filename: B.cpp

*  Author: zhuyutian

*  Date: 2018.04.16

================================================================*/

#include <bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef unsigned long long ull;

const int maxn = 100005;



int H,W;

int N;

int c[maxn];

int res[105][105];



int main()

{

    //freopen("B.in","r",stdin);

    //freopen("B.out","w",stdout);

    cin>>H>>W>>N;

	for(int i = 1; i <= N; i++) cin>>c[i];

	int x = 1,y = 1,dy = 1;

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

		while(c[i]--){

			res[x][y] = i;

			y += dy;

			if(y > W || y < 1){

				x++;

				dy = -dy;

				if(dy > 0) y = 1;

				else y = W;

			}

		}

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

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

			cout<<res[i][j]<<" ";

		cout<<endl;

	}

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.209000737264733x):
#include <cstdio>

#include <queue>;

using namespace std;



int cols[10010];

int res[101][101];

int main()

{

	int row, col, n;

	scanf("%d %d %d", &row, &col, &n);

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

		scanf("%d", &cols[i]);

	int c = 1;

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

	{

		if (i % 2 == 0)

		{

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

			{ 

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}



		}

		else

		{

			for (int j = col - 1; j >= 0; j--)

			{

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}

		}

	}

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

	{

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

		{

			printf("%d", res[i][j]);

			if (j != col - 1)

				printf(" ");

		}

		printf("\n");

	}

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define LL long long

using namespace std;



#define maxn 10007

const int INF=0x3f3f3f3f;





vector <int> v;

int a[107][107];

int main()

{

    int h,w,n,i,j,k,x,y;

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

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

    {

        scanf("%d",&x);

        for(j=1;j<=x;j++)

        {

            v.push_back(i);

        }

    }

    int cnt=0;

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

    {

        if(i%2==1)

        {

            for(j=1;j<=w;j++)

                a[i][j]=v[cnt++];

        }

        else

        {

            for(j=w;j>=1;j--)

                a[i][j]=v[cnt++];

        }

        printf("%d",a[i][1]);

        for(j=2;j<=w;j++)

        {

            printf(" %d",a[i][j]);

        }

        printf("\n");

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.158482834237585x):
#include <cstdio>

#include <queue>;

using namespace std;



int cols[10010];

int res[101][101];

int main()

{

	int row, col, n;

	scanf("%d %d %d", &row, &col, &n);

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

		scanf("%d", &cols[i]);

	int c = 1;

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

	{

		if (i % 2 == 0)

		{

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

			{ 

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}



		}

		else

		{

			for (int j = col - 1; j >= 0; j--)

			{

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}

		}

	}

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

	{

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

		{

			printf("%d", res[i][j]);

			if (j != col - 1)

				printf(" ");

		}

		printf("\n");

	}

	return 0;

}
// Slower C++ solution:
#include <map>

#include <set>

#include <stack>

#include <queue>

#include <vector>

#include <cmath>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <iostream>

#include <algorithm>

#define ll long long

#define ms(a,b) memset(a,b,sizeof(a))

using namespace std;



const int MAXN = 1e2 + 100;

const int INF = 0x3FFFFFFF;

const ll MOD = 1e9+7;



int color[MAXN][MAXN];

int a[MAXN * MAXN];



int main()

{

    int r, c;

    cin >> r >> c;

    //int pro = r * c;

    int n;

    cin >> n;

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

        cin >> a[i];

    int index = 1;

    int cnt = a[1];

    int num = 1;

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

    {

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

        {

            if(!cnt)

            {

//                if(index + 1 > n)

//                {

//                    for(int q = 1; q <= r; q++)

//                    {

//                        for(int k = 1; k <= c - 1; k++)

//                        {

//                            cout << color[q][k] << " ";

//                        }

//                        cout << color[q][c] << endl;

//                    }

//                    return 0;

//                }

//                else

//                {

                    cnt = a[++index];

                    num++;

//                    color[i][j] = num;

//                    cnt--;

//                }

            }

//            else

//            {

                color[i][j] = num;

                cnt--;

//            }

//            cout << index << endl;

        }

    }

    for(int q = 1; q <= r; q++)

    {

        if(q % 2)

        {

            //cout << "--" << endl;

            for(int k = 1; k <= c - 1; k++)

            {

                cout << color[q][k] << " ";

            }

            cout << color[q][c] << endl;

        }

        else

        {

            //cout << n << endl;

            for(int k = c; k >= 2; k--)

            {

                cout << color[q][k] << " ";

            }

            cout << color[q][1] << endl;

        }

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.206389046020152x):
#include <cstdio>

#include <queue>;

using namespace std;



int cols[10010];

int res[101][101];

int main()

{

	int row, col, n;

	scanf("%d %d %d", &row, &col, &n);

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

		scanf("%d", &cols[i]);

	int c = 1;

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

	{

		if (i % 2 == 0)

		{

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

			{ 

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}



		}

		else

		{

			for (int j = col - 1; j >= 0; j--)

			{

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}

		}

	}

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

	{

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

		{

			printf("%d", res[i][j]);

			if (j != col - 1)

				printf(" ");

		}

		printf("\n");

	}

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



int h,w,n;

int num[100010];

int MAP[110][110];

int x,y,d;



int dir[][2] = { 1 , 0 , 

			0 , 1,

			-1 , 0,

			0 , -1};



int main(){

	memset(MAP,0,sizeof(MAP));

	d = 0;

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

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

		scanf("%d",num+i);

	x = y = 1;

	int cnt = 0;

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

		for(int j=1;j<=num[i];j++){

			MAP[x][y] = i;

			if(++cnt == w*h)

				break;

			while(x+dir[d][0] > h 

				|| y+dir[d][1] > w 

				|| y+dir[d][1] <= 0 

				|| x+dir[d][0] <= 0

				|| MAP[x+dir[d][0]][y+dir[d][1]])

				d++,

				d%=4;

			x += dir[d][0];

			y += dir[d][1];

		}

	}

	for(int i=1;i<=h;i++,printf("\n")){

		printf("%d",MAP[i][1]);

		for(int j=2;j<=w;j++)

			printf(" %d",MAP[i][j]);

	}

	

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.420720774433346x):
#include <cstdio>

#include <queue>;

using namespace std;



int cols[10010];

int res[101][101];

int main()

{

	int row, col, n;

	scanf("%d %d %d", &row, &col, &n);

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

		scanf("%d", &cols[i]);

	int c = 1;

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

	{

		if (i % 2 == 0)

		{

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

			{ 

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}



		}

		else

		{

			for (int j = col - 1; j >= 0; j--)

			{

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}

		}

	}

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

	{

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

		{

			printf("%d", res[i][j]);

			if (j != col - 1)

				printf(" ");

		}

		printf("\n");

	}

	return 0;

}