Problem:
B - Cube Coloring
Problem Statement
Great painter Cubic is famous for using cubes for his art. Now, he is engaged in a new work of art. He tries to form an $X \times Y \times Z$ rectangular parallelepiped by arranging and piling up many $1 \times 1 \times 1$ cubes such that the adjacent surfaces of cubes are fully shared.
Of course, he won't finish his work only arranging and piling up cubes. The position of each cube is denoted by $(0,0,0)$ through $(X-1,Y-1,Z-1)$ as by the ordinary coordinate system, and Cubic calls the cube $(A,B,C)$ the
origin cube
. Then, he paints a pattern on the rectangular parallelepiped with different colors according to the distance between each cube and the origin cube. He paints all cubes regardless of whether or not a cube is visible externally. This is his artistic policy. He uses
Manhattan distance
as the distance between cubes. The Manhattan distance between two cubes $(x_1,y_1,z_1)$ and $(x_2,y_2,z_2)$ is defined as $|x_1-x_2| + |y_1-y_2| + |z_1-z_2|$.
On the current work, Cubic decides to use $N$ colors, which are numbered from $1$ to $N$. He paints a cube with the $(i+1)$-th color if the distance $D$ between the cube and the origin cube satisfies $D \equiv i \pmod{N}$.
Cubic wants to estimate the consumption of each color in order to prepare for the current work. He asks a great programmer, you, to write a program calculating the number of cubes that will be painted by each color.
Input
The input contains seven integers $X$, $Y$, $Z$, $A$, $B$, $C$, and $N$. All integers are in one line and separated by a single space. Three integers $X$, $Y$, and $Z$ ($1 \leq X, Y, Z \leq 10^6$) represent the length of each side of the rectangular parallelepiped that Cubic tries to form. Three integers $A$, $B$, and $C$ ($0 \leq A \lt X$, $0 \leq B \lt Y$, $0 \leq C \lt Z$) represent the position of the origin cube. The number of kinds of colors is denoted by $N$ ($1 \leq N \leq 1{,}000$).
Output
The output contains $N$ integers in one line. The $i$-th integer ($1 \leq i \leq N$) represents the number of the cubes that will be painted by the $i$-th color. All integers must be separated by a single space.
Sample Input 1
2 2 2 0 0 0 5
Output for the Sample Input 1
1 3 3 1 0
Sample Input 2
4 3 3 1 1 1 3
Output for the Sample Input 2
13 10 13
Sample Input 3
2000 2000 2000 1000 1000 1000 1
Output for the Sample Input 3
8000000000

Submitted solutions:

code_snippet: #include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<cmath>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll N=1e3+10;
const ll P=1e9+7;
ll a[3][N],b[N],c[N];
int main()
{
    ll i,j,x[3],y[3],n;
    memset(a,0,sizeof a);memset(b,0,sizeof b);memset(c,0,sizeof c);
    for(i=0;i<3;i++)scanf("%lld",x+i);
    for(i=0;i<3;i++)scanf("%lld",y+i);
    cin>>n;
    for(i=0;i<3;i++)
        for(j=0;j<x[i];j++)
        a[i][abs(j-y[i])%n]++;
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        b[(i+j)%n]+=a[0][i]*a[1][j];
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        c[(i+j)%n]+=a[2][i]*b[j];
    printf("%lld",c[0]);
    for(i=1;i<n;i++)printf(" %lld",c[i]);
    printf("\n");
    return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3604
final_rank: 11

code_snippet: #include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
#define F first
#define S second
int X,Y,Z,A,B,C,N;
int imos[2][1111];
void add(int f,int x,int l,int k){
  //if(!f&&k) cout<<"-"<<f<<":"<<x<<" "<<l<<" "<<k<<endl;
  imos[f][x]+=k;
  if(x+l<=N) imos[f][x+l]-=k;
  else{
    int y=(x+l)%N;
    imos[f][N]-=k;
    imos[f][0]+=k;
    imos[f][y]-=k;
  }
}
P  calc(P p,P q){
  int x=p.F,y=p.S;
  int a=q.F,b=q.S;
  return P(((x-y)-(a-b))/2,((x+y)-(a+b))/2);
}
signed main(){
  cin>>X>>Y>>Z>>A>>B>>C>>N;
  
  memset(imos,0,sizeof(imos));
  for(int i=0;i<(X+Y-1);i++){
    int all=0;
    P ub(i,0);
    if(i>=X) ub=P(X-1,i-(X-1));
    P lb(0,i);
    if(i>=Y) lb=P(i-(Y-1),Y-1);

    /*/
    cout<<i<<":"<<endl;
    cout<<ub.F<<" "<<ub.S<<endl;
    cout<<lb.F<<" "<<lb.S<<endl;
    //*/    

    if(abs(A+B-i)%2){
      P p=calc(ub,P(A-1,B));
      P q=calc(lb,P(A-1,B));
      //cout<<p.F<<" "<<p.S<<":"<<q.F<<" "<<q.S<<endl;
      assert(p.S==q.S);
      int x=abs(p.S);
      if(0<p.S) x--;
      int u=p.F,v=q.F;
      //cout<<u<<" "<<v<<" "<<x<<endl;
      if(0<u){
	u--;
	add(1,x%N,1,min(u+1,x+1));
	if(x<u){
	  int k=u-x;
	  all+=k/N;
	  add(1,(x+1)%N,k%N,1);
	}
	u++;
      }
      v--;
      if(0<v){
	v--;
	add(1,x%N,1,-min(v+1,x+1));
	if(x<v){
	  int k=v-x;
	  all-=k/N;
	  add(1,(x+1)%N,k%N,-1);
	}
	v++;
      }
      v++;
      if(v<=0){
	add(1,x%N,1,min(-v+1,x+1));
	if(x<-v){
	  int k=-v-x;
	  all+=k/N;
	  add(1,(x+1)%N,k%N,1);
	}
      }
      u++;
      if(u<=0){
	add(1,x%N,1,-min(-u+1,x+1));
	if(x<-u){
	  int k=-u-x;
	  all-=k/N;
	  add(1,(x+1)%N,k%N,-1);
	}
      }
      u--;
      add(1,0,N,all);
    }else{
      P p=calc(ub,P(A,B));
      P q=calc(lb,P(A,B));
      //cout<<p.F<<" "<<p.S<<":"<<q.F<<" "<<q.S<<endl;
      assert(p.S==q.S);
      int x=abs(p.S);
      int u=p.F,v=q.F;
      if(v<=0&&0<=u) add(0,x%N,1,1);
      //cout<<u<<" "<<v<<" "<<x<<endl;
      if(0<u){
	add(0,x%N,1,min(u,x));
	if(x<u){
	  int k=u-x;
	  all+=k/N;
	  add(0,(x+1)%N,k%N,1);
	}
      }
      v--;
      if(0<v){
	add(0,x%N,1,-min(v,x));
	if(x<v){
	  int k=v-x;
	  all-=k/N;
	  add(0,(x+1)%N,k%N,-1);
	}
      }
      v++;
      if(v<0){
	add(0,x%N,1,min(-v,x));
	if(x<-v){
	  int k=-v-x;
	  all+=k/N;
	  add(0,(x+1)%N,k%N,1);
	}
      }
      u++;
      if(u<0){
	add(0,x%N,1,-min(-u,x));
	if(x<-u){
	  int k=-u-x;
	  all-=k/N;
	  add(0,(x+1)%N,k%N,-1);
	}
      }
      u--;
      add(0,0,N,all); 
    }
  }

  for(int k=0;k<2;k++) 
    for(int i=0;i<N;i++)
      imos[k][i+1]+=imos[k][i];
  
  int e[N];
  memset(e,0,sizeof(e));
  for(int k=0;k<2;k++) 
    for(int i=0;i<N;i++)
      e[(i*2+k)%N]+=imos[k][i];

  //for(int i=0;i<N;i++) cout<<i<<":"<<e[i]<<endl;
  
  int g[N];
  memset(g,0,sizeof(g));
  for(int i=0;i<Z;i++) g[abs(C-i)%N]++;

  int ans[N];
  memset(ans,0,sizeof(ans));
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      ans[(i+j)%N]+=e[i]*g[j];
  for(int i=0;i<N;i++)
    cout<<ans[i]<<" \n"[i==N-1];
  return 0;
}
accuracy: 1
time_ms: 90
memory_kb: 3472
final_rank: 17

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int x , y , z , a , b , c , n;
ll ans1[1010] , ans2[1010];
ll gaox[1010] , gaoy[1010] , gaoz[1010];
int main(){
    cin>>x>>y>>z>>a>>b>>c>>n;
    for(int i = 0 ; i < x ; ++ i)
        gaox[abs(i - a) % n] ++;
    for(int i = 0 ; i < y ; ++ i)
        gaoy[abs(i - b) % n] ++;
    for(int i = 0 ; i < z ; ++ i)
        gaoz[abs(i - c) % n] ++;
    //~ for(int i = 0 ; i < n ; ++ i)
        //~ gaox[i] += x / n ;
    //~ for(int j = 0  ; j < x % n ; ++ j)
            //~ gaox[(j + a) % n] ++;
    //~ for(int i = 0 ; i < n ; ++ i)
        //~ gaoy[i] += y / n ;
    //~ for(int j = 0  ; j < y % n ; ++ j)
            //~ gaoy[(j + b) % n] ++;
    //~ for(int i = 0 ; i < n ; ++ i)
        //~ gaoz[i] += z / n ;
    //~ for(int j = 0  ; j < z % n ; ++ j)
            //~ gaoz[(j + c) % n] ++;
    //~ for(int i = 0 ; i < n ; ++ i)
        //~ cout<<gaox[i]<<" "<<gaoy[i]<<" "<<gaoz[i]<<endl;
    for(int i = 0 ; i < n ; ++ i)
        for(int j = 0 ; j < n ; ++ j)
            ans1[(i + j) % n] += gaox[i] * gaoy[j];
    for(int i = 0 ; i < n ; ++ i)
        for(int j = 0 ; j < n ; ++ j)
            ans2[(i + j) % n] += ans1[i] * gaoz[j];
    for(int i = 0 ; i < n ; ++ i)
        cout<<ans2[i]<<(i == n - 1 ? "" : " ");
    cout<<endl;
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3480
final_rank: 3

code_snippet: #include<cstdio>
#include<cstdlib>
using namespace std;

#define MaxN 100005
#define MOD 1000000007
typedef long long LL;

int n,x,y,z,a,b,c;
LL ans[1005]={0},xx[3][1005]={0};

int main(){
	int i,j;
	scanf("%d%d%d%d%d%d%d",&x,&y,&z,&a,&b,&c,&n);
	for(i=0;i<x;i++)	xx[0][abs(i-a)%n]++;
	for(i=0;i<y;i++)	xx[1][abs(i-b)%n]++;
	for(i=0;i<z;i++)	xx[2][abs(i-c)%n]++;
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			ans[(i+j)%n]+=xx[0][i]*xx[1][j];
	for(i=0;i<n;i++)	xx[0][i]=ans[i],ans[i]=0;
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			ans[(i+j)%n]+=xx[0][i]*xx[2][j];
	for(i=0;i<n;i++)
		printf("%lld%s",ans[i], i==n-1 ? "\n" : " ");
	return 0;
	}
accuracy: 1
time_ms: 10
memory_kb: 3020
final_rank: 1

code_snippet: //#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <bitset>
#include <string>
#include <time.h>
using namespace std;
long double esp=1e-11;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define cle(a) while(!a.empty())a.pop()
#define mem(p) memset(p,0,sizeof(p))
#define memf(p) memset(p,0x3f,sizeof(p))
#define memn(p) memset(p,-1,sizeof(p))
#define mp(A, B) make_pair(A, B)
#define pb push_back
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
typedef long long int LL;
const long double PI = acos((long double)-1);
const LL INF=0x3f3f3f3f3f3f3f3fll;
const int MOD = 1000000007;
const int maxn=3010000;
LL tr[maxn][2];
LL sum[maxn];
int N;
void update(int x,LL val,int f)
{
    for (; x&&x<=N; x+=x&-x)
		tr[x][f]+=val;
}
LL query(int x,int f)
{
    x++;
    LL sum=0;
    for (; x; x^=x&-x)
		sum+=tr[x][f];
    return sum;
}
void update(int l,int r ,LL val, int f)
{
    update(l+1,val,f);
    update(r+1+1,-val,f);
}
LL ans[1100];
int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("inlay.in", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //map<long long int,int>ma;                 %lld
    //vector<int>::iterator iter;
    //memset(m,0,sizeof(int));
    //for(int x=1;x<=n;x++)
    //for(int y=1;y<=n;y++)
    //scanf("%d%d",&a,&b);
    //scanf("%d",&a);
    //printf("%d\n",ans);
    mem(tr);
    int X,Y,Z,A,B,C,n,tem;
    scanf("%d%d%d%d%d%d%d",&X,&Y,&Z,&A,&B,&C,&n);
    N=X+Y+Z;
    for(int y=0;y<=Y-1;y++)
    {
        tem=abs(y-B);
        update(tem+0,tem+Z-C-1,1,0);
        update(tem+1,tem+C,1,0);
    }
    mem(sum);
    for(int d=0;d<=N;d++)
    {
        sum[d]=query(d,0);      //printf("%d %d\n",d,sum[d]);
        if(!sum[d])break;
        update(d+0,d+X-A-1,sum[d],1);
        update(d+1,d+A,sum[d],1);
    }
    mem(ans);
    for(int d=0;d<=N;d++)
        ans[d%n]+=query(d,1);
    for(int x=0;x<n;x++)
        printf("%lld%s",ans[x], x==n-1?"\n":" ");
    return 0;
}
accuracy: 1
time_ms: 430
memory_kb: 74120
final_rank: 19

code_snippet: #include <cstdio>
#include <cstdlib>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define  maxn   100005
#define  MOD    1000000007
#define  hashm  17982571
using namespace std;
int n,x,y,z,a,b,c;
long long ans[1005]={0},xx[3][1005]={0};
int main()
{
    int i,j;
    scanf("%d%d%d%d%d%d%d",&x,&y,&z,&a,&b,&c,&n);
    for(i=0;i<x;i++) xx[0][abs(i-a)%n]++;
    for(i=0;i<y;i++) xx[1][abs(i-b)%n]++;
    for(i=0;i<z;i++) xx[2][abs(i-c)%n]++;
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            ans[(i+j)%n]+=xx[0][i]*xx[1][j];
    for(i=0;i<n;i++) xx[0][i]=ans[i],ans[i]=0;
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            ans[(i+j)%n]+=xx[0][i]*xx[2][j];
    for(i=0;i<n;i++) printf("%lld%s",ans[i],(i<n-1)?" ":"\n");
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3596
final_rank: 4

code_snippet: #include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <iostream>
#include<cstdlib>
#include  <string.h>
using namespace std;
long long x,y,z,a,b,c,k,have1[11111],have2[11111],have3[11111],have12[11111],have123[11111];
int main(){
  cin>>x>>y>>z>>a>>b>>c>>k;
  memset(have1,0,sizeof (have1));
  memset(have2,0,sizeof (have2));
  memset(have3,0,sizeof (have3));
  for (int i=0;i<x;i++)  have1[abs(i-a)%k]++;
  for (int i=0;i<y;i++)  have2[abs(i-b)%k]++;
  for (int i=0;i<z;i++)  have3[abs(i-c)%k]++;
  memset(have12,0,sizeof (have12));
  for (int i=0;i<k;i++)
    for (int j=0;j<k;j++)
      have12[(i+j)%k]+=have1[i]*have2[j];
  memset(have123,0,sizeof (have123));
  for (int i=0;i<k;i++)
    for (int j=0;j<k;j++)
       have123[(i+j)%k]+=have12[i]*have3[j];
   for (int i=0;i<k;i++)
        cout<<have123[i]<<(i<k-1?" ":"");
   cout<<endl;

}
accuracy: 1
time_ms: 30
memory_kb: 3872
final_rank: 16

code_snippet: #include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<cmath>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll N=1e3+10;
const ll P=1e9+7;
ll a[3][N],b[N],c[N];
int main()
{
    ll i,j,x[3],y[3],n;
    memset(a,0,sizeof a);memset(b,0,sizeof b);memset(c,0,sizeof c);
    for(i=0;i<3;i++)scanf("%lld",x+i);
    for(i=0;i<3;i++)scanf("%lld",y+i);
    cin>>n;
    for(i=0;i<3;i++)
        for(j=0;j<x[i];j++)
        a[i][abs(j-y[i])%n]++;
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        b[(i+j)%n]+=a[0][i]*a[1][j];
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        c[(i+j)%n]+=a[2][i]*b[j];
	for(i=0;i<n;i++) printf("%lld%s", c[i], (i == n - 1 ? "\n" : " "));
    return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3604
final_rank: 11

code_snippet: #include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<cmath>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll N=1e3+10;
const ll P=1e9+7;
ll a[3][N],b[N],c[N];
int main()
{
    ll i,j,x[3],y[3],n;
    memset(a,0,sizeof a);memset(b,0,sizeof b);memset(c,0,sizeof c);
    for(i=0;i<3;i++)scanf("%lld",x+i);
    for(i=0;i<3;i++)scanf("%lld",y+i);
    cin>>n;
    for(i=0;i<3;i++)
        for(j=0;j<x[i];j++)
        a[i][abs(j-y[i])%n]++;
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        b[(i+j)%n]+=a[0][i]*a[1][j];
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        c[(i+j)%n]+=a[2][i]*b[j];
    printf("%lld",c[0]);
    for(i=1;i<n;i++)printf(" %lld",c[i]);
	cout<<"\n";
    return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3604
final_rank: 11

code_snippet: #include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<cmath>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll N=1e3+10;
const ll P=1e9+7;
ll a[3][N],b[N],c[N];
int main()
{
    ll i,j,x[3],y[3],n;
    memset(a,0,sizeof a);memset(b,0,sizeof b);memset(c,0,sizeof c);
    for(i=0;i<3;i++)scanf("%lld",x+i);
    for(i=0;i<3;i++)scanf("%lld",y+i);
    cin>>n;
    for(i=0;i<3;i++)
        for(j=0;j<x[i];j++)
        a[i][abs(j-y[i])%n]++;
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        b[(i+j)%n]+=a[0][i]*a[1][j];
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        c[(i+j)%n]+=a[2][i]*b[j];
	for(i=0;i<n;i++) printf("%lld%s", c[i], (i == n - 1 ? "\n" : " "));    return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3604
final_rank: 11

code_snippet: //#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <bitset>
#include <string>
#include <time.h>
using namespace std;
long double esp=1e-11;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define cle(a) while(!a.empty())a.pop()
#define mem(p) memset(p,0,sizeof(p))
#define memf(p) memset(p,0x3f,sizeof(p))
#define memn(p) memset(p,-1,sizeof(p))
#define mp(A, B) make_pair(A, B)
#define pb push_back
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
typedef long long int LL;
const long double PI = acos((long double)-1);
const LL INF=0x3f3f3f3f3f3f3f3fll;
const int MOD = 1000000007;
const int maxn=3010000;
LL tr[maxn][2];
LL sum[maxn];
int N;
void update(int x,LL val,int f)
{
    for (; x&&x<=N; x+=x&-x)
		tr[x][f]+=val;
}
LL query(int x,int f)
{
    x++;
    LL sum=0;
    for (; x; x^=x&-x)
		sum+=tr[x][f];
    return sum;
}
void update(int l,int r ,LL val, int f)
{
    update(l+1,val,f);
    update(r+1+1,-val,f);
}
LL ans[1100];
int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("inlay.in", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //map<long long int,int>ma;                 %lld
    //vector<int>::iterator iter;
    //memset(m,0,sizeof(int));
    //for(int x=1;x<=n;x++)
    //for(int y=1;y<=n;y++)
    //scanf("%d%d",&a,&b);
    //scanf("%d",&a);
    //printf("%d\n",ans);
    mem(tr);
    int X,Y,Z,A,B,C,n,tem;
    scanf("%d%d%d%d%d%d%d",&X,&Y,&Z,&A,&B,&C,&n);
    N=X+Y+Z;
    for(int y=0;y<=Y-1;y++)
    {
        tem=abs(y-B);
        update(tem+0,tem+Z-C-1,1,0);
        update(tem+1,tem+C,1,0);
    }
    mem(sum);
    for(int d=0;d<=N;d++)
    {
        sum[d]=query(d,0);      //printf("%d %d\n",d,sum[d]);
        if(!sum[d])break;
        update(d+0,d+X-A-1,sum[d],1);
        update(d+1,d+A,sum[d],1);
    }
    mem(ans);
    for(int d=0;d<=N;d++)
        ans[d%n]+=query(d,1);
    for(int i=0;i<n;i++) printf("%lld%s", ans[i], (i == n - 1 ? "\n" : " "));
    return 0;
}
accuracy: 1
time_ms: 450
memory_kb: 74120
final_rank: 20

code_snippet: #include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<cmath>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll N=1e3+10;
const ll P=1e9+7;
ll a[3][N],b[N],c[N];
int main()
{
    ll i,j,x[3],y[3],n;
    memset(a,0,sizeof a);memset(b,0,sizeof b);memset(c,0,sizeof c);
    for(i=0;i<3;i++)scanf("%lld",x+i);
    for(i=0;i<3;i++)scanf("%lld",y+i);
    cin>>n;
    for(i=0;i<3;i++)
        for(j=0;j<x[i];j++)
        a[i][abs(j-y[i])%n]++;
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        b[(i+j)%n]+=a[0][i]*a[1][j];
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        c[(i+j)%n]+=a[2][i]*b[j];
for(i=0;i<n;i++) printf("%lld%s", c[i], (i == n - 1 ? "\n" : " "));    return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3604
final_rank: 11

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define srep(i, s, t) for(int i = (s); i < (t); i++)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
template < class T > bool chmin(T& a, T b) { if(a > b) { a = b; return true; } return false; }
template < class T > bool chmax(T& a, T b) { if(a < b) { a = b; return true; } return false; }
using i64 = long long;
using f64 = long double;
i64 floor_div(const i64 n, const i64 d) { assert(d != 0); return n / d - static_cast<i64>((n ^ d) <  0 && n % d != 0); }
i64  ceil_div(const i64 n, const i64 d) { assert(d != 0); return n / d + static_cast<i64>((n ^ d) >= 0 && n % d != 0); }

int main() {
    cin.tie(0)->sync_with_stdio(0);
    
    vector<int> m(3), c(3);
    rep(i, 3) cin >> m[i];
    rep(i, 3) cin >> c[i];
    int n; cin >> n;

    vector<i64> dp(n, 0);
    dp[0] = 1;
    rep(i, 3) {
        vector<i64> nt(n, 0), freq(n, 0);
        rep(x, m[i]) freq[abs(x - c[i]) % n] += 1;
        rep(u, n) rep(v, n) nt[(u + v) % n] += dp[u] * freq[v];
        dp = move(nt);
    }
    rep(i, n) cout << dp[i] << " \n"[i == n - 1];
}
accuracy: 1
time_ms: 10
memory_kb: 3468
final_rank: 2

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end())
#define SZ(v) (int)v.size()
#define MIN(v) *min_element(ALL(v))
#define MAX(v) *max_element(ALL(v))
#define LB(v, x) int(lower_bound(ALL(v), (x)) - (v).begin())
#define UB(v, x) int(upper_bound(ALL(v), (x)) - (v).begin())

using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
const int inf = 0x3fffffff;
const ll INF = 0x1fffffffffffffff;

template <typename T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T, typename U> T ceil(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U> T floor(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T> int popcnt(T x) {
    return __builtin_popcountll(x);
}
template <typename T> int topbit(T x) {
    return (x == 0 ? -1 : 63 - __builtin_clzll(x));
}
template <typename T> int lowbit(T x) {
    return (x == 0 ? -1 : __builtin_ctzll(x));
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "P(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#ifdef LOCAL
#define show(...) _show(0, #__VA_ARGS__, __VA_ARGS__)
#else
#define show(...) true
#endif
template <typename T> void _show(int i, T name) {
    cerr << '\n';
}
template <typename T1, typename T2, typename... T3>
void _show(int i, const T1 &a, const T2 &b, const T3 &...c) {
    for (; a[i] != ',' && a[i] != '\0'; i++)
        cerr << a[i];
    cerr << ":" << b << " ";
    _show(i + 1, a, c...);
}

/**
 * @brief template
 */

int main() {
    ll X, Y, Z, A, B, C, N;
    cin >> X >> Y >> Z >> A >> B >> C >> N;
    vector<ll> PX(N,0), PY(N,0), PZ(N,0);
    rep(i,0,X) PX[abs(A-i)%N]++;
    rep(i,0,Y) PY[abs(B-i)%N]++;
    rep(i,0,Z) PZ[abs(C-i)%N]++;
    vector<ll> P1(N,0), P2(N,0);
    rep(i,0,N) {
        rep(j,0,N) {
            P1[(i+j)%N] += PX[i] * PY[j];
        }
    }
    rep(i,0,N) {
        rep(j,0,N) {
            P2[(i+j)%N] += P1[i] * PZ[j];
        }
    }
    rep(i,0,N) cout << P2[i] << (i == N-1 ? '\n' : ' ');
}
accuracy: 1
time_ms: 30
memory_kb: 3452
final_rank: 8

code_snippet: #include <bits/stdc++.h>

#ifdef _MSC_VER
#  include <intrin.h>
#else
#  include <x86intrin.h>
#endif

#include <limits>
#include <type_traits>

namespace suisen {
// ! utility
template <typename ...Types>
using constraints_t = std::enable_if_t<std::conjunction_v<Types...>, std::nullptr_t>;
template <bool cond_v, typename Then, typename OrElse>
constexpr decltype(auto) constexpr_if(Then&& then, OrElse&& or_else) {
    if constexpr (cond_v) {
        return std::forward<Then>(then);
    } else {
        return std::forward<OrElse>(or_else);
    }
}

// ! function
template <typename ReturnType, typename Callable, typename ...Args>
using is_same_as_invoke_result = std::is_same<std::invoke_result_t<Callable, Args...>, ReturnType>;
template <typename F, typename T>
using is_uni_op = is_same_as_invoke_result<T, F, T>;
template <typename F, typename T>
using is_bin_op = is_same_as_invoke_result<T, F, T, T>;

template <typename Comparator, typename T>
using is_comparator = std::is_same<std::invoke_result_t<Comparator, T, T>, bool>;

// ! integral
template <typename T, typename = constraints_t<std::is_integral<T>>>
constexpr int bit_num = std::numeric_limits<std::make_unsigned_t<T>>::digits;
template <typename T, unsigned int n>
struct is_nbit { static constexpr bool value = bit_num<T> == n; };
template <typename T, unsigned int n>
static constexpr bool is_nbit_v = is_nbit<T, n>::value;

// ?
template <typename T>
struct safely_multipliable {};
template <>
struct safely_multipliable<int> { using type = long long; };
template <>
struct safely_multipliable<long long> { using type = __int128_t; };
template <>
struct safely_multipliable<unsigned int> { using type = unsigned long long; };
template <>
struct safely_multipliable<unsigned long int> { using type = __uint128_t; };
template <>
struct safely_multipliable<unsigned long long> { using type = __uint128_t; };
template <>
struct safely_multipliable<float> { using type = float; };
template <>
struct safely_multipliable<double> { using type = double; };
template <>
struct safely_multipliable<long double> { using type = long double; };
template <typename T>
using safely_multipliable_t = typename safely_multipliable<T>::type;

template <typename T, typename = void>
struct rec_value_type {
    using type = T;
};
template <typename T>
struct rec_value_type<T, std::void_t<typename T::value_type>> {
    using type = typename rec_value_type<typename T::value_type>::type;
};
template <typename T>
using rec_value_type_t = typename rec_value_type<T>::type;

} // namespace suisen

// ! type aliases
using i128 = __int128_t;
using u128 = __uint128_t;

template <typename T>
using pq_greater = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <typename T, typename U>
using umap = std::unordered_map<T, U>;

// ! macros (capital: internal macro)
#define OVERLOAD2(_1,_2,name,...) name
#define OVERLOAD3(_1,_2,_3,name,...) name
#define OVERLOAD4(_1,_2,_3,_4,name,...) name

#define REP4(i,l,r,s)  for(std::remove_reference_t<std::remove_const_t<decltype(r)>>i=(l);i<(r);i+=(s))
#define REP3(i,l,r)    REP4(i,l,r,1)
#define REP2(i,n)      REP3(i,0,n)
#define REPINF3(i,l,s) for(std::remove_reference_t<std::remove_const_t<decltype(l)>>i=(l);;i+=(s))
#define REPINF2(i,l)   REPINF3(i,l,1)
#define REPINF1(i)     REPINF2(i,0)
#define RREP4(i,l,r,s) for(std::remove_reference_t<std::remove_const_t<decltype(r)>>i=(l)+fld((r)-(l)-1,s)*(s);i>=(l);i-=(s))
#define RREP3(i,l,r)   RREP4(i,l,r,1)
#define RREP2(i,n)     RREP3(i,0,n)

#define rep(...)    OVERLOAD4(__VA_ARGS__, REP4   , REP3   , REP2   )(__VA_ARGS__)
#define rrep(...)   OVERLOAD4(__VA_ARGS__, RREP4  , RREP3  , RREP2  )(__VA_ARGS__)
#define repinf(...) OVERLOAD3(__VA_ARGS__, REPINF3, REPINF2, REPINF1)(__VA_ARGS__)

#define CAT_I(a, b) a##b
#define CAT(a, b) CAT_I(a, b)
#define UNIQVAR(tag) CAT(tag, __LINE__)
#define loop(n) for (std::remove_reference_t<std::remove_const_t<decltype(n)>> UNIQVAR(loop_variable) = n; UNIQVAR(loop_variable) --> 0;)

#define all(iterable) std::begin(iterable), std::end(iterable)
#define input(type, ...) type __VA_ARGS__; read(__VA_ARGS__)

#ifdef LOCAL
#  define debug(...) debug_internal(#__VA_ARGS__, __VA_ARGS__)

template <class T, class... Args>
void debug_internal(const char* s, T&& first, Args&&... args) {
    constexpr const char* prefix = "[\033[32mDEBUG\033[m] ";
    constexpr const char* open_brakets = sizeof...(args) == 0 ? "" : "(";
    constexpr const char* close_brakets = sizeof...(args) == 0 ? "" : ")";
    std::cerr << prefix << open_brakets << s << close_brakets << ": " << open_brakets << std::forward<T>(first);
    ((std::cerr << ", " << std::forward<Args>(args)), ...);
    std::cerr << close_brakets << "\n";
}

#else
#  define debug(...) void(0)
#endif

// ! I/O utilities

// __int128_t
std::ostream& operator<<(std::ostream& dest, __int128_t value) {
    std::ostream::sentry s(dest);
    if (s) {
        __uint128_t tmp = value < 0 ? -value : value;
        char buffer[128];
        char* d = std::end(buffer);
        do {
            --d;
            *d = "0123456789"[tmp % 10];
            tmp /= 10;
        } while (tmp != 0);
        if (value < 0) {
            --d;
            *d = '-';
        }
        int len = std::end(buffer) - d;
        if (dest.rdbuf()->sputn(d, len) != len) {
            dest.setstate(std::ios_base::badbit);
        }
    }
    return dest;
}
// __uint128_t
std::ostream& operator<<(std::ostream& dest, __uint128_t value) {
    std::ostream::sentry s(dest);
    if (s) {
        char buffer[128];
        char* d = std::end(buffer);
        do {
            --d;
            *d = "0123456789"[value % 10];
            value /= 10;
        } while (value != 0);
        int len = std::end(buffer) - d;
        if (dest.rdbuf()->sputn(d, len) != len) {
            dest.setstate(std::ios_base::badbit);
        }
    }
    return dest;
}

// pair
template <typename T, typename U>
std::ostream& operator<<(std::ostream& out, const std::pair<T, U>& a) {
    return out << a.first << ' ' << a.second;
}
// tuple
template <unsigned int N = 0, typename ...Args>
std::ostream& operator<<(std::ostream& out, const std::tuple<Args...>& a) {
    if constexpr (N >= std::tuple_size_v<std::tuple<Args...>>) {
        return out;
    } else {
        out << std::get<N>(a);
        if constexpr (N + 1 < std::tuple_size_v<std::tuple<Args...>>) {
            out << ' ';
        }
        return operator<<<N + 1>(out, a);
    }
}
// vector
template <typename T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& a) {
    for (auto it = a.begin(); it != a.end();) {
        out << *it;
        if (++it != a.end()) out << ' ';
    }
    return out;
}
// array
template <typename T, size_t N>
std::ostream& operator<<(std::ostream& out, const std::array<T, N>& a) {
    for (auto it = a.begin(); it != a.end();) {
        out << *it;
        if (++it != a.end()) out << ' ';
    }
    return out;
}
inline void print() { std::cout << '\n'; }
template <typename Head, typename... Tail>
inline void print(const Head& head, const Tail &...tails) {
    std::cout << head;
    if (sizeof...(tails)) std::cout << ' ';
    print(tails...);
}
template <typename Iterable>
auto print_all(const Iterable& v, std::string sep = " ", std::string end = "\n") -> decltype(std::cout << *v.begin(), void()) {
    for (auto it = v.begin(); it != v.end();) {
        std::cout << *it;
        if (++it != v.end()) std::cout << sep;
    }
    std::cout << end;
}

__int128_t parse_i128(std::string& s) {
    __int128_t ret = 0;
    for (int i = 0; i < int(s.size()); i++) if ('0' <= s[i] and s[i] <= '9') ret = 10 * ret + s[i] - '0';
    if (s[0] == '-') ret = -ret;
    return ret;
}
__uint128_t parse_u128(std::string& s) {
    __uint128_t ret = 0;
    for (int i = 0; i < int(s.size()); i++) if ('0' <= s[i] and s[i] <= '9') ret = 10 * ret + s[i] - '0';
    return ret;
}
// __int128_t
std::istream& operator>>(std::istream& in, __int128_t& v) {
    std::string s;
    in >> s;
    v = parse_i128(s);
    return in;
}
// __uint128_t
std::istream& operator>>(std::istream& in, __uint128_t& v) {
    std::string s;
    in >> s;
    v = parse_u128(s);
    return in;
}
// pair
template <typename T, typename U>
std::istream& operator>>(std::istream& in, std::pair<T, U>& a) {
    return in >> a.first >> a.second;
}
// tuple
template <unsigned int N = 0, typename ...Args>
std::istream& operator>>(std::istream& in, std::tuple<Args...>& a) {
    if constexpr (N >= std::tuple_size_v<std::tuple<Args...>>) {
        return in;
    } else {
        return operator>><N + 1>(in >> std::get<N>(a), a);
    }
}
// vector
template <typename T>
std::istream& operator>>(std::istream& in, std::vector<T>& a) {
    for (auto it = a.begin(); it != a.end(); ++it) in >> *it;
    return in;
}
// array
template <typename T, size_t N>
std::istream& operator>>(std::istream& in, std::array<T, N>& a) {
    for (auto it = a.begin(); it != a.end(); ++it) in >> *it;
    return in;
}
template <typename ...Args>
void read(Args &...args) {
    (std::cin >> ... >> args);
}

// ! integral utilities

// Returns pow(-1, n)
template <typename T>
constexpr inline int pow_m1(T n) {
    return -(n & 1) | 1;
}
// Returns pow(-1, n)
template <>
constexpr inline int pow_m1<bool>(bool n) {
    return -int(n) | 1;
}

// Returns floor(x / y)
template <typename T>
constexpr inline T fld(const T x, const T y) {
    return (x ^ y) >= 0 ? x / y : (x - (y + pow_m1(y >= 0))) / y;
}
template <typename T>
constexpr inline T cld(const T x, const T y) {
    return (x ^ y) <= 0 ? x / y : (x + (y + pow_m1(y >= 0))) / y;
}

template <typename T, suisen::constraints_t<suisen::is_nbit<T, 16>> = nullptr>
__attribute__((target("popcnt"))) constexpr inline int popcount(const T x) { return _mm_popcnt_u32(x); }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 32>> = nullptr>
__attribute__((target("popcnt"))) constexpr inline int popcount(const T x) { return _mm_popcnt_u32(x); }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 64>> = nullptr>
__attribute__((target("popcnt"))) constexpr inline int popcount(const T x) { return _mm_popcnt_u64(x); }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 16>> = nullptr>
constexpr inline int count_lz(const T x) { return x ? __builtin_clz(x) : suisen::bit_num<T>; }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 32>> = nullptr>
constexpr inline int count_lz(const T x) { return x ? __builtin_clz(x) : suisen::bit_num<T>; }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 64>> = nullptr>
constexpr inline int count_lz(const T x) { return x ? __builtin_clzll(x) : suisen::bit_num<T>; }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 16>> = nullptr>
constexpr inline int count_tz(const T x) { return x ? __builtin_ctz(x) : suisen::bit_num<T>; }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 32>> = nullptr>
constexpr inline int count_tz(const T x) { return x ? __builtin_ctz(x) : suisen::bit_num<T>; }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 64>> = nullptr>
constexpr inline int count_tz(const T x) { return x ? __builtin_ctzll(x) : suisen::bit_num<T>; }
template <typename T>
constexpr inline int floor_log2(const T x) { return suisen::bit_num<T> -1 - count_lz(x); }
template <typename T>
constexpr inline int ceil_log2(const T x) { return floor_log2(x) + ((x & -x) != x); }
template <typename T>
constexpr inline int kth_bit(const T x, const unsigned int k) { return (x >> k) & 1; }
template <typename T>
constexpr inline int parity(const T x) { return popcount(x) & 1; }

// ! container

template <typename T, typename Comparator, suisen::constraints_t<suisen::is_comparator<Comparator, T>> = nullptr>
auto priqueue_comp(const Comparator comparator) {
    return std::priority_queue<T, std::vector<T>, Comparator>(comparator);
}

template <typename Iterable>
auto isize(const Iterable& iterable) -> decltype(int(iterable.size())) {
    return iterable.size();
}

template <typename T, typename Gen, suisen::constraints_t<suisen::is_same_as_invoke_result<T, Gen, int>> = nullptr>
auto generate_vector(int n, Gen generator) {
    std::vector<T> v(n);
    for (int i = 0; i < n; ++i) v[i] = generator(i);
    return v;
}
template <typename T>
auto generate_range_vector(T l, T r) {
    return generate_vector(r - l, [l](int i) { return l + i; });
}
template <typename T>
auto generate_range_vector(T n) {
    return generate_range_vector(0, n);
}

template <typename T>
void sort_unique_erase(std::vector<T>& a) {
    std::sort(a.begin(), a.end());
    a.erase(std::unique(a.begin(), a.end()), a.end());
}

template <typename InputIterator, typename BiConsumer>
auto foreach_adjacent_values(InputIterator first, InputIterator last, BiConsumer f) -> decltype(f(*first++, *last), void()) {
    if (first != last) for (auto itr = first, itl = itr++; itr != last; itl = itr++) f(*itl, *itr);
}
template <typename Container, typename BiConsumer>
auto foreach_adjacent_values(Container c, BiConsumer f) -> decltype(c.begin(), c.end(), void()) {
    foreach_adjacent_values(c.begin(), c.end(), f);
}

// ! other utilities

// x <- min(x, y). returns true iff `x` has chenged.
template <typename T>
inline bool chmin(T& x, const T& y) {
    if (y >= x) return false;
    x = y;
    return true;
}
// x <- max(x, y). returns true iff `x` has chenged.
template <typename T>
inline bool chmax(T& x, const T& y) {
    if (y <= x) return false;
    x = y;
    return true;
}

template <typename T, std::enable_if_t<std::is_integral_v<T>, std::nullptr_t> = nullptr>
std::string bin(T val, int bit_num = -1) {
    std::string res;
    if (bit_num >= 0) {
        for (int bit = bit_num; bit-- > 0;) res += '0' + ((val >> bit) & 1);
    } else {
        for (; val; val >>= 1) res += '0' + (val & 1);
        std::reverse(res.begin(), res.end());
    }
    return res;
}

template <typename T, std::enable_if_t<std::is_integral_v<T>, std::nullptr_t> = nullptr>
std::vector<T> digits_low_to_high(T val, T base = 10) {
    std::vector<T> res;
    for (; val; val /= base) res.push_back(val % base);
    if (res.empty()) res.push_back(T{ 0 });
    return res;
}
template <typename T, std::enable_if_t<std::is_integral_v<T>, std::nullptr_t> = nullptr>
std::vector<T> digits_high_to_low(T val, T base = 10) {
    auto res = digits_low_to_high(val, base);
    std::reverse(res.begin(), res.end());
    return res;
}

template <typename T>
std::string join(const std::vector<T>& v, const std::string& sep, const std::string& end) {
    std::ostringstream ss;
    for (auto it = v.begin(); it != v.end();) {
        ss << *it;
        if (++it != v.end()) ss << sep;
    }
    ss << end;
    return ss.str();
}

namespace suisen {}
using namespace suisen;
using namespace std;

struct io_setup {
    io_setup(int precision = 20) {
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
        std::cout << std::fixed << std::setprecision(precision);
    }
} io_setup_ {};

// ! code from here

int main() {
    input(int, x, y, z, a, b, c, n);
    vector<long long> cnt(n);
    auto f = [&](int u, int v, int s) {
        int l = max(0, s - v);
        int r = min(u, s);
        return max(0, r - l + 1);
    };

    rep(d, y + z) {
        cnt[d % n] += f(y - 1 - b, z - 1 - c, d);
        cnt[(d + 1) % n] += f(b - 1, z - 1 - c, d);
        cnt[(d + 1) % n] += f(y - 1 - b, c - 1, d);
        cnt[(d + 2) % n] += f(b - 1, c - 1, d);
    }

    vector<long long> off_cnt(n);
    rep(p, x) {
        ++off_cnt[abs(a - p) % n];
    }

    vector<long long> ans(n);
    rep(i, n) rep(j, n) {
        ans[(i + j) % n] += cnt[i] * off_cnt[j];
    }
    print(ans);
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3464
final_rank: 5

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (int i = (int)(s); i < (int)(t); ++i)

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    for (int i = 0; i < (int) v.size(); ++i) os << v[i] << " ";
    return os;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    ll X, Y, Z, A, B, C, N;
    cin >> X >> Y >> Z >> A >> B >> C >> N;
    if (X > Y) swap(X, Y), swap(A, B);
    vector<ll> cnt(2*N+1);

    auto calc = [&](ll x, ll y, ll z, int c) {
        if (x==0 || y==0 || z==0) return;
        if (x > y) swap(x, y);
        ll q = z/N, r = z%N;
        rep(i,0,x+y-1) {
            ll d;
            if (i < x) {
                d = i+1;
            } else if (i < y) {
                d = x;
            } else {
                d = x+y-1-i;
            }
            cnt[0] += q*d;
            cnt[N] -= q*d;
            cnt[(c+i)%N] += d;
            cnt[(c+i)%N+r] -= d;
        }
    };

    rep(a,0,2) rep(b,0,2) rep(c,0,2) {
        int x = a ? A : (X-A);
        int y = b ? B : (Y-B);
        int z = c ? C : (Z-C);
        calc(x, y, z, a+b+c);
    }

    vector<ll> ans(N);
    rep(i,0,2*N) {
        ans[i%N] += cnt[i];
        cnt[i+1] += cnt[i];
    }

    rep(i,0,N) cout << ans[i] << (i<N-1 ? " " : "\n");
}
accuracy: 1
time_ms: 100
memory_kb: 3488
final_rank: 18

code_snippet: #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
using ld=long double;
ll ILL=2167167167167167167;
const int INF=2100000000;
const ll mod=1e9+9;
#define rep(i,a) for (ll i=0;i<a;i++)
#define all(p) p.begin(),p.end()
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
void yneos(bool a){if(a) cout<<"Yes\n"; else cout<<"No\n";}
template<class T> void vec_out(vector<T> &p){for(int i=0;i<(int)(p.size());i++){if(i) cout<<" ";cout<<p[i];}cout<<"\n";}


void solve();


// oddloop
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}

void solve(){
	vector<int> p(3),q(3);
	rep(i,3) cin>>p[i];
	rep(i,3) cin>>q[i];
	int N;
	cin>>N;
	vector<ll> ans(N);
	ans[0]=1;
	rep(k,3){
		vector<ll> tmp(N);
		rep(i,p[k]) tmp[abs(q[k]-i)%N]++;
		vector<ll> n_ans(N);
		rep(i,N) rep(j,N){
			n_ans[(i+j)%N]+=ans[i]*tmp[j];
		}
		swap(n_ans,ans);
	}
	vec_out(ans);
}
accuracy: 1
time_ms: 30
memory_kb: 3488
final_rank: 10

code_snippet: #include "bits/stdc++.h"
using namespace std;

typedef string::const_iterator State;
#define eps 1e-8L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
#define REP(a, b) for (long long(a) = 0; (a) < (b); ++(a))
#define ALL(x) (x).begin(), (x).end()

#define int long long
int x, y, z, a, b, c, n;
vector<int> calc_x(int itr)
{
  int start = a / n;
  vector<int> ans(n, start);
  for (int q = start * n; q < a; ++q)
  {
    ans[(itr + abs(q - a)) % n]++;
  }
  int diff = (x - a);
  start = diff / n;
  REP(i, n)
  {
    ans[i] += start;
  }
  for (int q = start * n; q < diff; ++q)
  {
    ans[(itr + q) % n]++;
  }
  return ans;
}

vector<int> calc_xy(int itr)
{
  int start = b / n;
  vector<int> ans(n, start * x);
  for (int q = start * n; q < b; ++q)
  {
    vector<int> tmps = calc_x((itr + abs(q - b)) % n);
    REP(t, n)
    {
      ans[t] += tmps[t];
    }
  }

  int diff = (y - b);
  start = diff / n;
  REP(i, n)
  {
    ans[i] += start * x;
  }
  for (int q = start * n; q < diff; ++q)
  {
    vector<int> tmps = calc_x((itr + q) % n);
    REP(t, n)
    {
      ans[t] += tmps[t];
    }
  }
  return ans;
}

void solve()
{
  cin >> x >> y >> z >> a >> b >> c >> n;

  int start = c / n;
  vector<int> ans(n, start * x * y);
  vector<int> tmps = calc_xy(abs(start * n - c) % n);
  for (int j = start * n; j < c; ++j)
  {
    REP(t, n)
    {
      ans[t] += tmps[t];
    }
    REP(t, n - 1)
    {
      swap(tmps[t], tmps[t + 1]);
    }
  }

  int diff = (z - c);
  start = diff / n;
  REP(i, n)
  {
    ans[i] += start * x * y;
  }
  tmps = calc_xy(0);
  for (int j = start * n; j < diff; ++j)
  {
    REP(t, n)
    {
      ans[t] += tmps[t];
    }
    for (int t = n - 2; t >= 0; --t)
    {
      swap(tmps[t], tmps[t + 1]);
    }
  }
  REP(i, n)
  {
    if (i)
      cout << " ";
    cout << ans[i];
  }
  cout << endl;
}
#undef int

// generated by oj-template v4.7.2
// (https://github.com/online-judge-tools/template-generator)
int main()
{
  // Fasterize input/output script
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(100);
  // scanf/printf user should delete this fasterize input/output script

  int t = 1;
  // cin >> t; // comment out if solving multi testcase
  for (int testCase = 1; testCase <= t; ++testCase)
  {
    solve();
  }
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3488
final_rank: 6

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define inc(i, a, b) for (int i = (a); i <= (b); ++i)
#define dec(i, a, b) for (int i = (a); i >= (b); --i)

int main() {
    ll x, y, z, a, b, c, n;
    cin >> x >> y >> z >> a >> b >> c >> n;

    ll ysum[n] = {}, xsum[n] = {}, zsum[n] = {};
    rep(i, x) xsum[abs(i - a) % n]++;
    rep(i, y) ysum[abs(i - b) % n]++;
    rep(i, z) zsum[abs(i - c) % n]++;

    ll xres[n] = {}, zres[n] = {};
    rep(i, n) rep(j, n) xres[(i + j) % n] += xsum[i] * ysum[j];
    rep(i, n) rep(j, n) zres[(i + j) % n] += zsum[i] * xres[j];

    rep(i, n) cout << zres[i] << (i == n - 1 ? '\n' : ' ');
}
accuracy: 1
time_ms: 30
memory_kb: 3460
final_rank: 9

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

// clang-format off
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << "(" << p.first << ", " << p.second << ")"; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "[ "; for (auto &z : v) os << z << " "; os << "]"; return os; }
template<class T> ostream &operator<<(ostream &os, const set<T> &v) { os << "{ "; for (auto &z : v) os << z << " "; os << "}"; return os; }
template<class T> ostream &operator<<(ostream &os, const multiset<T> &v) { os << "{ "; for (auto &z : v) os << z << " "; os << "}"; return os; }
#ifdef _DEBUG
#define show(x) cout << #x << " = " << x << endl;
#else
#define show(x)
#endif
// clang-format on

using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll X, Y, Z, A, B, C, N;
    cin >> X >> Y >> Z >> A >> B >> C >> N;
    vector<ll> ans(N, 0);
    // rep(i, X) rep(j, Y) rep(k, Z) ans[(abs(A - i) + abs(B - j) + abs(C - k)) % N]++;
    rep(i, X) ans[abs(i - A) % N]++;
    {
        // y方向
        ll y1 = B, y2 = Y - 1 - B;
        vector<ll> s1(N, 0);
        ll ind = N - 1;
        rep(i, y1) {
            s1[0] += ans[ind];
            ind = (ind - 1 + N) % N;
        }
        for (int i = N - 1; i > 0; i--) {
            s1[i] = s1[(i + 1) % N] - ans[i] + ans[ind];
            ind = (ind - 1 + N) % N;
        }
        vector<ll> s2(N, 0);
        ind = N - 1;
        rep(i, y2) {
            s2[0] += ans[ind];
            ind = (ind - 1 + N) % N;
        }
        for (int i = N - 1; i > 0; i--) {
            s2[i] = s2[(i + 1) % N] - ans[i] + ans[ind];
            ind = (ind - 1 + N) % N;
        }
        rep(i, N) ans[i] += s1[i] + s2[i];
    }
    {
        // z方向
        ll z1 = C, z2 = Z - 1 - C;
        vector<ll> s1(N, 0);
        ll ind = N - 1;
        rep(i, z1) {
            s1[0] += ans[ind];
            ind = (ind - 1 + N) % N;
        }
        for (int i = N - 1; i > 0; i--) {
            s1[i] = s1[(i + 1) % N] - ans[i] + ans[ind];
            ind = (ind - 1 + N) % N;
        }
        vector<ll> s2(N, 0);
        ind = N - 1;
        rep(i, z2) {
            s2[0] += ans[ind];
            ind = (ind - 1 + N) % N;
        }
        for (int i = N - 1; i > 0; i--) {
            s2[i] = s2[(i + 1) % N] - ans[i] + ans[ind];
            ind = (ind - 1 + N) % N;
        }
        rep(i, N) ans[i] += s1[i] + s2[i];
    }
    rep(i, N) { cout << ans[i] << (i == N - 1 ? '\n' : ' '); }
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3488
final_rank: 6