Problem Statement  
We have a box that consists of (sizeX x sizeY x sizeZ) = N unit cubes. These cubes have coordinates ranging from (1,1,1) to (sizeX,sizeY,sizeZ). We want to number the unit cubes, using integers from 1 to N. We will do this algorithmically. We will call a box "1dimensional (1D)" if at least two of its dimensions are 1, "2dimensional (2D)" if exactly one of its dimensions is 1, and "3dimensional (3D)" otherwise. The algorithm used to number a 1dimensional box is simple: order the cubes according to the sums of their coordinates (in ascending order), and number them in this order. To number a 2dimensional box, we follow this algorithm:
For example, a 4x5x1 box filled using this algorithm looks as follows: z=1 x:1 2 3 4 y:+++++ 1 1 2 3 4 +++++ 2 5 91011 +++++ 3 6121516 +++++ 4 7131719 +++++ 5 8141820 +++++ To number a 3dimensional box, we follow this algorithm:
For example, a 4x3x3 box filled using this algorithm looks as follows: z=1 x:1 2 3 4 y:+++++ 1 1 2 3 4 +++++ 2 5 7 8 9 +++++ 3 6101112 +++++ z=2 x:1 2 3 4 y:+++++ 113141516 +++++ 221252627 +++++ 322282930 +++++ z=3 x:1 2 3 4 y:+++++ 117181920 +++++ 223313233 +++++ 324343536 +++++ You will be given the box dimensions sizeX, sizeY, and sizeZ, and the coordinates of a single cube (cubeX,cubeY,cubeZ). Write a method that will compute the number assigned to the cube at the given coordinates, when using the algorithm described above.  
Definition  
 
Notes  
  Note that the box described by sizeX, sizeY, and sizeZ is not necessarily a 3D box.  
Constraints  
  sizeX, sizeY and sizeZ will be between 1 and 10^{9}, inclusive.  
  The volume of the box will not exceed 10^{18}.  
  cubeX will be between 1 and sizeX, inclusive.  
  cubeY will be between 1 and sizeY, inclusive.  
  cubeZ will be between 1 and sizeZ, inclusive.  
Examples  
0)  
 
1)  
 
2)  
 
3)  
 
4)  
 
5)  
 
6)  
