Statistics

Problem Statement for "HiddenSquares"

Problem Statement

Little Greg got a set of pencils for Christmas. Since then, he has been spending hours drawing rectangles on a piece of paper. In this problem, the paper will be represented as an x-y plane. All the rectangles have sides parallel to the axes, and some of them may intersect, creating even more rectangles. Greg wonders how many squares (rectangles with sides of equal length) exist in his drawing.

For example, in the image below, Greg has drawn three rectangles, one in red, one in green, and one in blue. These three rectangles intersect to form a total of 36 rectangles, 14 of which are squares (nine 1 x 1, four 2 x 2, and one 3 x 3).

You are given the rectangles drawn by Greg in the int[]s x1, y1, x2, and y2. (x1[i], y1[i]) is the lower left corner of the ith rectangle, and (x2[i], y2[i]) is the upper right corner of the ith rectangle. Return the number of squares that exist in the drawing.

Definition

Class:
HiddenSquares
Method:
count
Parameters:
int[], int[], int[], int[]
Returns:
int
Method signature:
int count(int[] x1, int[] y1, int[] x2, int[] y2)
(be sure your method is public)

Constraints

  • x1, y1, x2, and y2 will each contain between 1 and 50 elements, inclusive.
  • x1, y1, x2, and y2 will each contain the same number of elements.
  • Each element of x1, y1, x2, and y2 will be between 0 and 1000000000, inclusive.
  • For all i, x1[i] will be less than x2[i], and y1[i] will be less than y2[i].

Examples

  1. {0,1,0}

    {0,0,1}

    {3,2,3}

    {3,3,2}

    Returns: 14

    The example from the problem statement.

  2. {0,2}

    {0,0}

    {2,4}

    {4,4}

    Returns: 1

    These two rectangles combine to form a single square.

  3. {0,0,3}

    {0,3,0}

    {1,4,4}

    {3,4,3}

    Returns: 0

    There are no squares here.

  4. {453453463,453453500,453453495,453453512,453453478,453453489, 453453466,453453500,453453498,453453510,453453472,453453512, 453453519,453453514,453453521,453453518,453453523,453453517, 453453466,453453525,453453496,453453495,453453463,453453461, 453453460,453453522,453453471,453453468,453453479,453453517, 453453485,453453518,453453499,453453464,453453494}

    {364646438,364646402,364646449,364646438,364646415,364646401, 364646446,364646416,364646456,364646414,364646463,364646407, 364646436,364646450,364646421,364646411,364646414,364646419, 364646445,364646427,364646405,364646442,364646418,364646464, 364646457,364646463,364646432,364646426,364646444,364646431, 364646450,364646418,364646434,364646458,364646402}

    {453453488,453453510,453453525,453453523,453453493,453453500, 453453470,453453511,453453499,453453521,453453518,453453524, 453453523,453453523,453453524,453453523,453453525,453453519, 453453473,453453526,453453511,453453517,453453470,453453464, 453453511,453453524,453453516,453453516,453453492,453453524, 453453513,453453522,453453520,453453505,453453512}

    {364646460,364646454,364646462,364646466,364646464,364646455, 364646457,364646461,364646457,364646450,364646466,364646453, 364646441,364646451,364646460,364646461,364646446,364646464, 364646447,364646460,364646454,364646450,364646444,364646466, 364646458,364646466,364646455,364646442,364646462,364646435, 364646464,364646444,364646455,364646459,364646430}

    Returns: 124

  5. {0,0,3,0}

    {0,3,0,0}

    {1,4,4,4}

    {4,4,4,1}

    Returns: 10

  6. {0}

    {0}

    {1}

    {1}

    Returns: 1

  7. {0}

    {0}

    {1000000000}

    {1000000000}

    Returns: 1

  8. {0,1,2}

    {0,0,0}

    {1,2,3}

    {3,3,3}

    Returns: 1

  9. {0,1,2,0}

    {0,0,0,0}

    {1,2,3,3}

    {3,3,3,3}

    Returns: 1

  10. {0,1,2,0}

    {0,0,0,0}

    {1,2,3,6}

    {3,3,3,3}

    Returns: 2

  11. {0,1,2,0,0}

    {0,0,0,0,1}

    {1,2,3,6,6}

    {3,3,3,3,2}

    Returns: 15

  12. {0,1,2,0,0}

    {0,0,0,0,1}

    {1,2,3,6,6}

    {4,5,6,7,8}

    Returns: 4

  13. {100,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,98,96,94,92,90,88,86,84,82,80,78,76,74,72,70,68,66,64,62,60,58,56,54,52}

    {100,98,96,94,92,90,88,86,84,82,80,78,76,74,72,70,68,66,64,62,60,58,56,54,52,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147}

    {149,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197}

    {149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148}

    Returns: 40425

  14. {100,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99}

    {100,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147}

    {149,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150}

    {149,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148}

    Returns: 40521

  15. {1,0,0,0}

    {0,2,0,3}

    {2,4,4,4}

    {3,3,2,4}

    Returns: 6

  16. {0,0,1}

    {0,1,0}

    {4,4,3}

    {4,3,4}

    Returns: 10

  17. {100,100,3000100,6000100}

    {200,200,3000200,200}

    {9000100,3000100,6000100,9000100}

    {9000200,9000200,6000200,9000200}

    Returns: 4

  18. {0,0,0,0,0,1000,1000,1000,1000,1000,2000,2000,2000,2000,2000,3000,3000,3000,3000,3000,4000,4000,4000,4000,4000,5000,5000,5000,5000,5000,6000,6000,6000,6000,6000,7000,7000,7000,7000,7000,8000,8000,8000,8000,8000,9000,9000,9000,9000,9000}

    {0,1000,2000,3000,4000,0,1000,2000,3000,4000,0,1000,2000,3000,4000,0,1000,2000,3000,4000,0,1000,2000,3000,4000,0,1000,2000,3000,4000,0,1000,2000,3000,4000,0,1000,2000,3000,4000,0,1000,2000,3000,4000,0,1000,2000,3000,4000}

    {2000,2000,2000,2000,2000,3000,3000,3000,3000,3000,4000,4000,4000,4000,4000,5000,5000,5000,5000,5000,6000,6000,6000,6000,6000,7000,7000,7000,7000,7000,8000,8000,8000,8000,8000,9000,9000,9000,9000,9000,10000,10000,10000,10000,10000,11000,11000,11000,11000,11000}

    {2000,3000,4000,5000,6000,2000,3000,4000,5000,6000,2000,3000,4000,5000,6000,2000,3000,4000,5000,6000,2000,3000,4000,5000,6000,2000,3000,4000,5000,6000,2000,3000,4000,5000,6000,2000,3000,4000,5000,6000,2000,3000,4000,5000,6000,2000,3000,4000,5000,6000}

    Returns: 196

  19. {503902435,857868899,879712414,720779737,59765604,679204960,70702537,375922619,906419634,555180718,577399069,132088436,253797590,238585279,996838830,151689406,772686161,769657199,749196593,486548968,778195201,207681868,859173438,985502919,254496527,810373962,292236081,806984242,285159015,382832610,318071394,118480166,504738467,613165580,158046368,9023558,939930792,968839593,788057737,391910222,584784045,278274232,214026437,57750927,582367194,401134669,229353058,658652010,315265033,251831538}

    {252787397,748706738,433359549,535217671,724823798,239941985,140677994,370254039,690395509,765481928,52085531,449456440,390478249,434780311,688842456,946720717,87582267,757090356,680318606,540727413,637906277,954259763,889797842,594033050,736031528,518303673,802013692,967263446,958023060,851689687,562221816,280354782,899363795,735169375,893265562,16940754,695615608,436248435,878548944,867799234,987417700,165124238,575558595,697422832,18088121,595125849,199018123,964331502,935423671,350504283}

    {784956322,905288741,881809602,792263662,674024850,829640497,963361668,717835094,926005437,649227516,960930419,581802742,935490191,792054925,997092533,718003678,960941469,950948960,855030479,529722324,931162613,681830741,959463843,999584161,919299122,913801570,978261522,985670016,984546529,419837487,982263370,498293394,620762359,886893210,477707138,857780913,965182659,991143716,859582005,511011978,885187048,486915963,635898280,246253459,874567981,831950902,399062023,778407680,535111749,631266829}

    {341942852,836326576,611628759,690804090,814080739,840028517,505006114,642025844,763048685,869879452,676044158,463636454,889902504,552708469,760056546,991445325,228190526,882777199,938632512,873892504,699185761,983090958,992523422,711531918,752053326,603928166,829401821,990295154,973526254,896199101,639519635,777339627,946461961,960084547,906191391,812236704,726043385,799413927,969446425,891593957,989091184,700594238,624806714,882895324,817018676,799271010,331536453,987220729,960957462,357072564}

    Returns: 0

  20. {999985,999254,999978,999317,999592,999376,999674,999437,999800,999689,999415,999477,999500,999676,999358,999600,999598,999865,999615,999192,999688,999485,999759,999374,999101,999674,999494,999903,999151,999377,999008,999116,999234,999550,999864,999288,999863,999892,999823,999157,999849,999283,999888,999742,999770,999440,999998,999102,999038,999181}

    {999847,999434,999569,999562,999596,999310,999298,999205,999363,999075,999477,999220,999452,999536,999504,999486,999908,999859,999522,999001,999241,999379,999617,999053,999436,999094,999508,999967,999857,999450,999490,999621,999528,999295,999016,999511,999679,999994,999701,999307,999957,999891,999777,999696,999695,999935,999528,999691,999805,999709}

    {999999,999645,999983,999429,999791,999469,999852,999713,999807,999953,999556,999749,999858,999680,999360,999752,999599,999994,999794,999212,999731,999795,999896,999859,999890,999801,999851,999942,999307,999852,999892,999217,999682,999756,999996,999965,999931,999924,999925,999793,999926,999986,1000000,999798,999990,999701,1000000,999966,999920,999235}

    {999881,999997,999716,999633,999630,999820,999406,999345,999815,999410,999963,999389,999990,999650,999829,999720,999923,999891,999538,999712,999461,999391,999742,999980,999995,999984,999548,999978,999989,999470,999597,999891,999848,999432,999885,999648,999756,999999,999829,999936,999972,999998,999893,999891,999844,999972,999942,999790,999848,999747}

    Returns: 43

  21. {3799085,3799054,3799078,3799017,3799092,3799076,3799074,3799037,3799000,3799089,3799015,3799077,3799000,3799076,3799058,3799000,3799098,3799065,3799015,3799092,3799088,3799085,3799059,3799074,3799001,3799074,3799094,3799003,3799051,3799077,3799008,3799016,3799034,3799050,3799064,3799088,3799063,3799092,3799023,3799057,3799049,3799083,3799088,3799042,3799070,3799040,3799098,3799002,3799038,3799081}

    {567047,567034,567069,567062,567096,567010,567098,567005,567063,567075,567077,567020,567052,567036,567004,567086,567008,567059,567022,567001,567041,567079,567017,567053,567036,567094,567008,567067,567057,567050,567090,567021,567028,567095,567016,567011,567079,567094,567001,567007,567057,567091,567077,567096,567095,567035,567028,567091,567005,567009}

    {3799099,3799071,3799083,3799051,3799100,3799097,3799100,3799082,3799007,3799091,3799096,3799096,3799058,3799092,3799072,3799052,3799100,3799094,3799059,3799099,3799095,3799100,3799062,3799097,3799030,3799097,3799095,3799042,3799070,3799082,3799020,3799057,3799076,3799056,3799080,3799097,3799080,3799098,3799035,3799074,3799099,3799093,3799100,3799066,3799080,3799061,3799100,3799040,3799098,3799097}

    {567092,567093,567098,567091,567098,567100,567100,567090,567081,567085,567090,567069,567098,567076,567073,567096,567023,567076,567098,567082,567044,567082,567081,567100,567053,567096,567096,567078,567067,567070,567097,567079,567044,567097,567021,567044,567090,567099,567014,567093,567072,567095,567094,567097,567099,567072,567098,567100,567048,567081}

    Returns: 208

  22. {3799020,3799028,3799031,3799028,3799010,3799030,3799036,3799027,3799020,3799023,3799016,3799046,3799029,3799013,3799012,3799035,3799012,3799017,3799030,3799048,3799039,3799003,3799030,3799003,3799028,8000018,8000035,8000005,8000040,8000026,8000000,8000048,8000043,8000003,8000020,8000002,8000009,8000009,8000013,8000012,8000009,8000044,8000021,8000004,8000021,8000049,8000041,8000017,8000021,8000005}

    {567024,567022,567002,567016,567010,567049,567008,567017,567048,567048,567041,567046,567008,567046,567024,567024,567039,567023,567026,567024,567002,567033,567011,567006,567047,1000030,1000000,1000042,1000010,1000011,1000019,1000043,1000047,1000010,1000039,1000020,1000038,1000029,1000016,1000039,1000030,1000024,1000011,1000032,1000033,1000007,1000034,1000023,1000024,1000041}

    {3799031,3799041,3799044,3799042,3799040,3799045,3799040,3799031,3799049,3799050,3799040,3799050,3799032,3799019,3799024,3799047,3799028,3799039,3799048,3799050,3799050,3799048,3799031,3799026,3799043,8000049,8000044,8000032,8000044,8000045,8000045,8000050,8000048,8000029,8000034,8000026,8000016,8000019,8000024,8000020,8000019,8000045,8000042,8000020,8000050,8000050,8000044,8000038,8000038,8000034}

    {567028,567047,567014,567038,567031,567050,567030,567046,567049,567050,567044,567047,567050,567047,567047,567050,567050,567032,567049,567033,567031,567043,567018,567016,567048,1000031,1000046,1000046,1000018,1000049,1000048,1000048,1000049,1000041,1000045,1000049,1000039,1000033,1000040,1000042,1000032,1000028,1000036,1000035,1000042,1000039,1000036,1000030,1000046,1000045}

    Returns: 195

  23. {3799007,3799013,3799037,3799047,3799034,3799034,3799001,3799021,3799047,3799012,3799014,3799009,3799032,3799021,3799003,3799003,3799001,3799030,3799010,3799006,3799030,3799037,3799022,3799015,3799011,3799014,3799017,3799004,3799037,3799019,3799028,3799015,3799016,3799034,3799049,3799002,3799049,3799020,3799011,3799007,3799037,3799041,3799004,3799008,3799005,3799033,3799049,3799012,3799043,3799015}

    {567010,567023,567044,567005,567036,567017,567021,567012,567030,567015,567024,567015,567009,567040,567002,567009,567015,567025,567027,567032,567008,567035,567009,567042,567046,466038,466003,466030,466015,466032,466013,466014,466026,466034,466034,466036,466010,466014,466021,466043,466002,466020,466019,466034,466042,466018,466022,466032,466047,466006}

    {3799034,3799026,3799043,3799049,3799048,3799044,3799046,3799030,3799048,3799015,3799021,3799013,3799041,3799037,3799034,3799041,3799018,3799031,3799042,3799017,3799036,3799044,3799028,3799050,3799019,3799046,3799024,3799009,3799044,3799042,3799040,3799028,3799018,3799048,3799050,3799011,3799050,3799048,3799042,3799033,3799042,3799048,3799027,3799046,3799025,3799050,3799050,3799023,3799047,3799025}

    {567035,567043,567048,567019,567050,567038,567042,567038,567042,567017,567039,567031,567033,567049,567045,567016,567024,567043,567038,567048,567045,567050,567019,567048,567049,466045,466014,466033,466050,466048,466046,466048,466041,466045,466044,466040,466038,466019,466042,466048,466028,466037,466043,466035,466050,466033,466047,466038,466048,466035}

    Returns: 140

  24. {1266,1281,1271,1237,1253,1279,1260,1270,1257,1258,1284,1269,1252,1244,1282,1260,1270,1239,1275,1238,1239,1268,1249,1258,1238,1270,1272,1278,1236,1251,1283,1270,1238,1238,1242,1274,1278,1273,1276,1253,1243,1281,1251,1258,1263,1244,1250,1251,1262,1251}

    {466602,466621,466635,466645,466628,466608,466611,466605,466624,466621,466628,466602,466641,466647,466626,466614,466643,466633,466638,466636,466606,466623,466645,466646,466604,466022,466029,466029,466014,466047,466024,466019,466025,466010,466032,466009,466045,466033,466025,466047,466008,466005,466046,466033,466023,466014,466042,466013,466000,466030}

    {1278,1282,1274,1270,1276,1281,1261,1279,1261,1263,1285,1276,1254,1252,1284,1262,1276,1260,1282,1251,1244,1281,1269,1269,1264,1274,1273,1279,1255,1255,1284,1284,1280,1252,1282,1284,1281,1279,1283,1276,1276,1282,1274,1284,1264,1273,1269,1276,1267,1270}

    {466650,466622,466647,466648,466646,466616,466626,466626,466645,466632,466631,466643,466650,466648,466642,466638,466649,466636,466650,466649,466643,466637,466648,466647,466645,466034,466049,466035,466015,466049,466049,466023,466037,466012,466034,466014,466049,466050,466040,466049,466030,466028,466047,466037,466033,466032,466050,466015,466047,466033}

    Returns: 82

  25. {120572,120810,121029,120056,120440,120796,120871,120281,121003,120271,120784,120043,121082,120374,120998,120111,120218,120842,120601,120388,120968,120223,120307,120097,120772,120382,120330,120821,120663,120949,120138,120346,120137,120321,120952,120663,120792,120636,120669,120212,120148,120489,120966,120672,120691,120544,120594,120523,120653,121061}

    {367466,366783,366713,367593,366996,366674,366942,367410,367063,367012,367622,366734,367641,366709,367161,367210,367643,367424,367026,366819,366631,366917,367062,366975,367158,296331,296235,296896,296437,296288,296899,296706,296031,296573,296694,296679,296376,297026,296809,296846,296812,297024,296690,296634,296599,296195,296284,296147,296444,296530}

    {120659,120874,121084,120353,120943,120978,120917,120553,121036,120892,120892,120378,121084,120667,121033,120304,120960,121006,120823,120576,121031,121063,121005,120874,120934,120708,120880,121036,120789,120996,120300,120837,120944,120494,120986,120813,120911,120864,120871,120751,120674,120883,121033,121040,120774,120959,120968,120602,120708,121073}

    {367503,366833,367556,367608,367071,367604,367003,367542,367076,367036,367643,366957,367648,367307,367617,367382,367644,367451,367504,367560,367596,367620,367070,367552,367426,296772,296659,296979,296700,297016,296957,297020,296460,296989,296807,296859,297013,297028,296965,296970,296820,297040,296696,296950,296734,296475,296891,296996,296478,297012}

    Returns: 5

  26. {999999922,999999984,999999938,999999943,999999955,999999971,999999957,999999986,999999969,999999926,999999905,999999918,999999960,999999952,999999922,999999929,999999993,999999982,999999957,999999957,999999940,999999979,999999923,999999944,999999961,999999939,999999933,999999926,999999954,999999903,999999996,999999950,999999995,999999948,999999964,999999995,999999986,999999948,999999926,999999975,999999936,999999969,999999957,999999932,999999977,999999912,999999984,999999926,999999963,999999950}

    {999999994,999999903,999999909,999999989,999999945,999999939,999999939,999999917,999999967,999999910,999999904,999999928,999999901,999999943,991234943,999999994,999999913,999000994,98899994,999999929,999999918,999666994,999999933,999999993,999999986,999999945,999999888,999999886,999999913,999999892,999999908,999999927,999999887,999999924,999999859,999999929,999999881,999999928,999999850,999999908,999999922,999999929,999999911,999999896,999999898,999999931,999999944,999999926,999999911,999999903}

    {999999937,999999994,999999941,999999979,999999968,999999998,999999990,999999997,999999989,999999966,999999941,999999960,999999967,999999993,999999943,999999943,999999996,999999998,999999993,999999990,999999959,999999994,999999954,999999946,999999971,999999944,999999935,999999959,999999988,999999987,999999997,999999958,999999999,999999958,999999985,999999999,999999994,999999976,999999940,999999984,999999937,999999990,999999998,999999971,999999990,999999991,999999995,999999940,999999968,999999962}

    {1000000000,999999938,999999914,999999990,1000000000,999999970,999999963,999999953,999999969,999999954,999999950,999999965,999999992,999999997,999999971,1000000000,999999983,1000000000,999999995,1000000000,999999998,999999986,999999990,999999997,999999989,999999947,999999938,999999904,999999929,999999933,999999917,999999928,999999900,999999932,999999902,999999930,999999895,999999942,999999871,999999929,999999943,999999946,999999947,999999944,999999908,999999946,999999947,999999928,999999929,999999907}

    Returns: 227

  27. {453453498,453453488,453453490,453453532,453453474,453453495,453453492,453453526,453453526,453453507,453453464,453453498,453453486,453453533,453453474,453453477,453453510,453453476,453453475,453453509,453453471,453453517,453453518,453453484,453453481,453453472,453453470,453453517,453453462,453453533,453453496,453453482,453453536,453453520,453453532,453453524,453453490,453453512,453453535,453453527,453453513,453453509,453453516,453453516,453453498,453453487,453453480,453453504,453453493,453453461}

    {364646441,364646459,364646443,364646418,364646415,364646448,364646439,364646468,364646401,364646441,364646463,364646438,364646465,364646404,364646466,364646410,364646465,364646403,364646468,364646430,364646475,364646409,364646430,364646449,364646432,757576626,757576625,757576579,757576620,757576625,757576572,757576564,757576597,757576598,757576565,757576574,757576563,757576561,757576603,757576553,757576582,757576594,757576570,757576623,757576623,757576620,757576617,757576583,757576623,757576586}

    {453453531,453453533,453453520,453453534,453453516,453453505,453453522,453453529,453453533,453453519,453453495,453453527,453453534,453453534,453453522,453453481,453453517,453453512,453453496,453453522,453453505,453453519,453453524,453453508,453453531,453453525,453453497,453453521,453453474,453453535,453453516,453453508,453453537,453453522,453453534,453453526,453453496,453453527,453453536,453453535,453453521,453453522,453453518,453453517,453453513,453453511,453453494,453453532,453453502,453453537}

    {364646451,364646460,364646455,364646434,364646423,364646454,364646460,364646473,364646472,364646452,364646464,364646451,364646477,364646408,364646468,364646419,364646469,364646472,364646476,364646457,364646477,364646414,364646475,364646462,364646439,757576627,757576626,757576603,757576623,757576627,757576619,757576570,757576613,757576620,757576581,757576620,757576626,757576567,757576607,757576617,757576605,757576596,757576593,757576624,757576625,757576626,757576627,757576604,757576627,757576597}

    Returns: 73

  28. {453453516,453453600,453453462,453453489,453453621,453453519,453453558,453453519,453453595,453453624,453453585,453453531,453453476,453453460,453453513,453453513,453453581,453453467,453453547,453453560,453453602,453453511,453453472,453453600,453453605,453453539,453453506,453453509,453453486,453453525,453453496,453453523,453453505,453453610,453453479}

    {364646560,364646529,364646464,364646541,364646425,364646438,364646473,364646526,364646430,364646527,364646449,364646523,364646492,364646500,364646432,364646545,364646450,364646485,364646456,364646550,364646462,364646484,364646508,364646440,364646469,364646431,364646485,364646493,364646503,364646539,364646452,364646454,364646560,364646457,364646517}

    {453453588,453453620,453453490,453453609,453453626,453453562,453453587,453453607,453453614,453453626,453453608,453453608,453453579,453453602,453453533,453453591,453453611,453453618,453453572,453453565,453453615,453453585,453453542,453453617,453453620,453453585,453453589,453453521,453453530,453453586,453453619,453453566,453453590,453453612,453453614}

    {364646564,364646538,364646495,364646551,364646432,364646467,364646519,364646559,364646438,364646550,364646536,364646544,364646534,364646532,364646463,364646548,364646521,364646509,364646463,364646564,364646500,364646555,364646546,364646461,364646519,364646514,364646539,364646551,364646509,364646557,364646545,364646548,364646563,364646485,364646524}

    Returns: 103

  29. {453453613,453453487,453453461,453453541,453453508,453453501,453453571,453453473,453453611,453453615,453453553,453453568,453453591,453453471,453453529,453453560,453453544,453453467,453453575,453453577,453453614,453453583,453453464,453453509,453453602,453453472,453453522,453453532,453453544,453453465,453453468,453453607,453453568,453453525,453453522,453453539,453453571,453453588,453453584,453453583,453453520,453453485,453453506,453453550,453453475,453453595,453453494,453453467,453453485,453453529}

    {364646549,364646560,364646517,364646455,364646458,364646546,364646468,364646423,364646503,364646433,364646437,364646505,364646465,364646429,364646503,364646511,364646459,364646492,364646537,364646511,364646555,364646449,364646491,364646506,364646543,364646411,364646453,364646500,364646546,364646416,364646412,364646421,364646501,364646421,364646439,364646415,364646484,364646473,364646432,364646451,364646553,364646492,364646430,364646508,364646468,364646523,364646484,364646459,364646425,364646534}

    {453453615,453453527,453453551,453453617,453453583,453453546,453453620,453453621,453453621,453453619,453453563,453453598,453453594,453453517,453453604,453453595,453453572,453453605,453453624,453453583,453453618,453453600,453453483,453453521,453453617,453453530,453453601,453453583,453453581,453453507,453453560,453453614,453453592,453453604,453453535,453453541,453453623,453453613,453453613,453453593,453453521,453453604,453453513,453453601,453453527,453453600,453453497,453453610,453453498,453453537}

    {364646557,364646563,364646550,364646490,364646495,364646551,364646476,364646562,364646522,364646445,364646539,364646532,364646513,364646523,364646534,364646548,364646497,364646528,364646560,364646520,364646566,364646457,364646503,364646537,364646563,364646457,364646518,364646549,364646550,364646518,364646514,364646459,364646520,364646500,364646470,364646523,364646485,364646507,364646513,364646542,364646560,364646533,364646530,364646516,364646508,364646535,364646506,364646555,364646486,364646543}

    Returns: 202

  30. {0,100000000,200000000,300000000,400000000,500000000,600000000,700000000,800000000,900000000,0,100000000,200000000,300000000,400000000,500000000,600000000,700000000,800000000,900000000,0,100000000,200000000,300000000,400000000,500000000,600000000,700000000,800000000,900000000,0,100000000,200000000,300000000,400000000,500000000,600000000,700000000,800000000,900000000,0,100000000,200000000,300000000,400000000,500000000,600000000,700000000,800000000,900000000}

    {0,0,0,0,0,0,0,0,0,0,100000000,100000000,100000000,100000000,100000000,100000000,100000000,100000000,100000000,100000000,200000000,200000000,200000000,200000000,200000000,200000000,200000000,200000000,200000000,200000000,300000000,300000000,300000000,300000000,300000000,300000000,300000000,300000000,300000000,300000000,400000000,400000000,400000000,400000000,400000000,400000000,400000000,400000000,400000000,400000000}

    {100000000,200000000,300000000,400000000,500000000,600000000,700000000,800000000,900000000,1000000000,100000000,200000000,300000000,400000000,500000000,600000000,700000000,800000000,900000000,1000000000,100000000,200000000,300000000,400000000,500000000,600000000,700000000,800000000,900000000,1000000000,100000000,200000000,300000000,400000000,500000000,600000000,700000000,800000000,900000000,1000000000,100000000,200000000,300000000,400000000,500000000,600000000,700000000,800000000,900000000,1000000000}

    {100000000,100000000,100000000,100000000,100000000,100000000,100000000,100000000,100000000,100000000,200000000,200000000,200000000,200000000,200000000,200000000,200000000,200000000,200000000,200000000,300000000,300000000,300000000,300000000,300000000,300000000,300000000,300000000,300000000,300000000,400000000,400000000,400000000,400000000,400000000,400000000,400000000,400000000,400000000,400000000,500000000,500000000,500000000,500000000,500000000,500000000,500000000,500000000,500000000,500000000}

    Returns: 130

  31. {0,100000000,200000000,300000000,400000000,500000000,600000000,0,100000000,200000000,300000000,400000000,500000000,600000000,0,100000000,200000000,300000000,400000000,500000000,600000000,0,100000000,200000000,300000000,400000000,500000000,600000000,0,100000000,200000000,300000000,400000000,500000000,600000000,0,100000000,200000000,300000000,400000000,500000000,600000000,0,100000000,200000000,300000000,400000000,500000000,600000000}

    {0,0,0,0,0,0,0,100000000,100000000,100000000,100000000,100000000,100000000,100000000,200000000,200000000,200000000,200000000,200000000,200000000,200000000,300000000,300000000,300000000,300000000,300000000,300000000,300000000,400000000,400000000,400000000,400000000,400000000,400000000,400000000,500000000,500000000,500000000,500000000,500000000,500000000,500000000,600000000,600000000,600000000,600000000,600000000,600000000,600000000}

    {100000000,200000000,300000000,400000000,500000000,600000000,700000000,100000000,200000000,300000000,400000000,500000000,600000000,700000000,100000000,200000000,300000000,400000000,500000000,600000000,700000000,100000000,200000000,300000000,400000000,500000000,600000000,700000000,100000000,200000000,300000000,400000000,500000000,600000000,700000000,100000000,200000000,300000000,400000000,500000000,600000000,700000000,100000000,200000000,300000000,400000000,500000000,600000000,700000000}

    {100000000,100000000,100000000,100000000,100000000,100000000,100000000,200000000,200000000,200000000,200000000,200000000,200000000,200000000,300000000,300000000,300000000,300000000,300000000,300000000,300000000,400000000,400000000,400000000,400000000,400000000,400000000,400000000,500000000,500000000,500000000,500000000,500000000,500000000,500000000,600000000,600000000,600000000,600000000,600000000,600000000,600000000,700000000,700000000,700000000,700000000,700000000,700000000,700000000}

    Returns: 140

  32. {0,104564560,206346000,300000000,400000360,504600000,600004600,0,100003460,200006340,300036400,400003640,506400000,600643000,0,100460000,200460000,300463000,400360000,500064000,603460000,0,103460000,234600000,345000000,400000400,505000000,633000000,0,133300000,200000100,346000000,402046000,502540000,602640000,0,100062300,202600000,354600000,423600000,500037000,600000370,0,100376500,203700000,300037000,400037000,503700000,603700000}

    {0,0,0,0,0,0,0,100036460,100000000,104645600,104600000,100000630,100000060,100000006,200046000,200640000,200036000,200046000,200003460,200460000,205000000,304630000,346000000,306400000,300000463,300460000,300004630,300540000,400043000,400000030,400003300,433030000,400100000,400046300,403460000,562000000,506430000,500002360,506200000,503600000,500370000,500037000,600000370,600350000,600370000,603700000,600003000,600003700,600370000}

    {100000567,204680000,304800000,400480000,500048000,600048600,700048600,100004800,204800000,300480000,400480000,504800000,600403000,700035600,103560000,200360000,300530000,403000000,500600000,606300000,703560000,100036500,203465000,320500000,400010500,500450000,600026000,700234600,100003246,202600000,300240000,400046000,500623400,602360000,700450000,100004600,207000000,304046000,400034600,500000560,600056000,700056000,100500000,200056000,300560000,400356000,556000000,600760000,700056800}

    {100007000,100768000,100870000,107860000,108700000,100000000,186000000,200067000,200006000,200007600,206700000,200670000,200760000,200006700,300007600,300067000,300670000,300007600,300076000,300760000,300056000,400004000,400007600,400007600,407600000,406700000,407600000,406700000,500086000,500080000,500060000,500080000,500907600,500789000,500089700,600078900,600008970,600789000,600008970,600879000,600879000,600008970,700008790,708900000,709800000,700978000,700089000,700089000,700089050}

    Returns: 0

  33. {23345724,22353158,23352026,24406894,24351762,25536630,25801598,26266366,26731534,27196102,27360970,28325838,28550706,59055574,29520442,29985310,30420178,30912046,31329914,31844722,32309250,32774518,33229386,33204254,34164522,23512290,23016290,23012280,23032290,23012290,22012290,23012290,23012290,23022290,22012290,23012290,23012290,23012290,23012290,23012460,23456290,23012290,23512290,23012290,23012290,23035290,23012590,25312290,23012290,124324}

    {23277935,23045501,23045501,23045501,23045501,23045501,23045501,23045501,23045501,23045501,23045501,23045501,23045501,23045501,23045501,23045501,23045501,23045501,23045501,23045501,23045501,23045501,23045501,23045501,23045501,23510369,23975237,24440105,24904973,25369841,25834709,26299577,26764445,27229313,27694181,28159049,28623917,29088785,29553653,30018521,30483389,30948257,31413125,31877993,32342861,32807729,33272597,33737465,34202333,54534}

    {34633990,23709592,24174460,24639328,25104196,25569064,26033932,26498800,26963668,27428536,27893404,28358272,28823140,69288008,29752876,30217744,30682612,31147480,31612348,32077216,32542084,33006952,33471820,33936688,34401556,34866424,34866424,34866424,34866424,34866424,34866424,34866424,34866424,34866424,34866424,34866424,34866424,34866424,34866424,34866424,34866424,34866424,34866424,34866424,34866424,34866424,34866424,34866424,34866424,243545}

    {34667201,34899635,34899635,34899635,34899635,34899635,34899635,34899635,34899635,34899635,34899635,34899635,34899635,34899635,34899635,34899635,34899635,34899635,34899635,34899635,34899635,34899635,34899635,34899635,34899635,23742803,24207671,24672539,25137407,25602275,26067143,26532011,26996879,27461747,27926615,28391483,28856351,29321219,29786087,30250955,30715823,31180691,31645559,32110427,32575295,33040163,33505031,33969899,34434767,124356663}

    Returns: 14178

  34. {0,0,2,2,4,4,1,1,1,3,3,3,5,5,5}

    {0,3,0,3,0,3,0,2,4,0,2,4,0,2,4}

    {1,1,3,3,5,5,2,2,2,4,4,4,6,6,6}

    {3,6,3,6,3,6,2,4,6,2,4,6,2,4,6}

    Returns: 1

  35. {0,0,0,95308642,95308642,95308642,190617284,190617284,190617284,285925926,285925926,285925926,381234568,381234568,381234568,476543210,476543210,476543210,47654321,47654321,47654321,47654321,142962963,142962963,142962963,142962963,238271605,238271605,238271605,238271605,333580247,333580247,333580247,333580247,428888889,428888889,428888889,428888889,524197531,524197531,524197531,524197531}

    {0,190617284,381234568,0,190617284,381234568,0,190617284,381234568,0,190617284,381234568,0,190617284,381234568,0,190617284,381234568,0,142962963,285925926,428888889,0,142962963,285925926,428888889,0,142962963,285925926,428888889,0,142962963,285925926,428888889,0,142962963,285925926,428888889,0,142962963,285925926,428888889}

    {47654321,47654321,47654321,142962963,142962963,142962963,238271605,238271605,238271605,333580247,333580247,333580247,428888889,428888889,428888889,524197531,524197531,524197531,95308642,95308642,95308642,95308642,190617284,190617284,190617284,190617284,285925926,285925926,285925926,285925926,381234568,381234568,381234568,381234568,476543210,476543210,476543210,476543210,571851852,571851852,571851852,571851852}

    {190617284,381234568,571851852,190617284,381234568,571851852,190617284,381234568,571851852,190617284,381234568,571851852,190617284,381234568,571851852,190617284,381234568,571851852,142962963,285925926,428888889,571851852,142962963,285925926,428888889,571851852,142962963,285925926,428888889,571851852,142962963,285925926,428888889,571851852,142962963,285925926,428888889,571851852,142962963,285925926,428888889,571851852}

    Returns: 1

  36. {0,0,0,95308642,95308642,95308642,190617284,190617284,190617284,285925926,285925926,285925926,381234568,381234568,381234568,476543210,476543210,476543210,47654321,47654321,47654321,47654321,142962963,142962963,142962963,142962963,238271605,238271605,238271605,238271605,333580247,333580247,333580247,333580247,428888889,428888889,428888889,428888889,524197531,524197531,524197531,524197531,47654321}

    {0,190617284,381234568,0,190617284,381234568,0,190617284,381234568,0,190617284,381234568,0,190617284,381234568,0,190617284,381234568,0,142962963,285925926,428888889,0,142962963,285925926,428888889,0,142962963,285925926,428888889,0,142962963,285925926,428888889,0,142962963,285925926,428888889,0,142962963,285925926,428888889,47654321}

    {47654321,47654321,47654321,142962963,142962963,142962963,238271605,238271605,238271605,333580247,333580247,333580247,428888889,428888889,428888889,524197531,524197531,524197531,95308642,95308642,95308642,95308642,190617284,190617284,190617284,190617284,285925926,285925926,285925926,285925926,381234568,381234568,381234568,381234568,476543210,476543210,476543210,476543210,571851852,571851852,571851852,571851852,524197531}

    {190617284,381234568,571851852,190617284,381234568,571851852,190617284,381234568,571851852,190617284,381234568,571851852,190617284,381234568,571851852,190617284,381234568,571851852,142962963,285925926,428888889,571851852,142962963,285925926,428888889,571851852,142962963,285925926,428888889,571851852,142962963,285925926,428888889,571851852,142962963,285925926,428888889,571851852,142962963,285925926,428888889,571851852,524197531}

    Returns: 22

  37. {16, 18}

    {19, 15}

    {19, 19}

    {20, 16}

    Returns: 1

  38. {0, 2}

    {4, 0}

    {3, 3}

    {5, 1}

    Returns: 1

  39. {2}

    {0}

    {3}

    {1}

    Returns: 1

  40. {16, 9, 12, 7, 4, 16, 1, 0, 5, 13, 9, 9, 4, 18, 5, 16, 17, 6, 7, 14, 2, 8, 2, 6, 0, 19, 9, 12, 3, 2, 9, 19, 17, 12, 5, 12, 7, 0, 8, 1, 10, 9, 18, 2, 19, 10, 0, 5, 6, 2 }

    {17, 14, 10, 17, 18, 17, 10, 0, 13, 6, 7, 17, 11, 10, 16, 10, 5, 2, 16, 7, 3, 11, 6, 2, 11, 18, 7, 15, 14, 8, 14, 11, 12, 1, 14, 13, 19, 8, 6, 7, 0, 9, 17, 0, 12, 16, 0, 16, 3, 12 }

    {31, 18, 16, 9, 11, 20, 20, 14, 11, 22, 24, 15, 8, 28, 23, 36, 21, 16, 10, 22, 11, 24, 12, 10, 6, 39, 10, 21, 17, 17, 12, 23, 36, 22, 10, 21, 21, 14, 11, 10, 30, 10, 36, 5, 21, 12, 12, 19, 18, 18 }

    {18, 22, 29, 29, 35, 35, 12, 12, 33, 15, 8, 24, 26, 13, 33, 27, 21, 11, 30, 17, 18, 22, 17, 11, 20, 32, 18, 21, 33, 9, 30, 13, 31, 20, 21, 23, 33, 9, 15, 14, 3, 18, 31, 11, 21, 32, 13, 17, 11, 14 }

    Returns: 745

  41. {453453463, 453453500, 453453495, 453453512, 453453478, 453453489, 453453466, 453453500, 453453498, 453453510, 453453472, 453453512, 453453519, 453453514, 453453521, 453453518, 453453523, 453453517, 453453466, 453453525, 453453496, 453453495, 453453463, 453453461, 453453460, 453453522, 453453471, 453453468, 453453479, 453453517, 453453485, 453453518, 453453499, 453453464, 453453494 }

    {364646438, 364646402, 364646449, 364646438, 364646415, 364646401, 364646446, 364646416, 364646456, 364646414, 364646463, 364646407, 364646436, 364646450, 364646421, 364646411, 364646414, 364646419, 364646445, 364646427, 364646405, 364646442, 364646418, 364646464, 364646457, 364646463, 364646432, 364646426, 364646444, 364646431, 364646450, 364646418, 364646434, 364646458, 364646402 }

    {453453488, 453453510, 453453525, 453453523, 453453493, 453453500, 453453470, 453453511, 453453499, 453453521, 453453518, 453453524, 453453523, 453453523, 453453524, 453453523, 453453525, 453453519, 453453473, 453453526, 453453511, 453453517, 453453470, 453453464, 453453511, 453453524, 453453516, 453453516, 453453492, 453453524, 453453513, 453453522, 453453520, 453453505, 453453512 }

    {364646460, 364646454, 364646462, 364646466, 364646464, 364646455, 364646457, 364646461, 364646457, 364646450, 364646466, 364646453, 364646441, 364646451, 364646460, 364646461, 364646446, 364646464, 364646447, 364646460, 364646454, 364646450, 364646444, 364646466, 364646458, 364646466, 364646455, 364646442, 364646462, 364646435, 364646464, 364646444, 364646455, 364646459, 364646430 }

    Returns: 124

  42. {78917053, 27100827, 2600785, 45248011, 99951567, 18585307, 703199216, 573714703, 275680090, 510320440, 723401032, 98183682, 11597961, 315461275, 69844923, 89017443, 213147837, 42227746, 300134328, 13649480, 733966678, 400011959, 363416242, 59253759, 336563455, 215013716, 154523136, 134594751, 347315106, 302572379, 269676381, 482824219, 125310639, 303742040, 169907872, 485614972, 382361684, 200158423, 745777927, 237390611, 48433401, 202956538, 8956512, 337551289, 208787970, 478464352, 266772940, 392083579, 117546963, 771058762 }

    {564563268, 273785882, 353340561, 787943265, 369925495, 9006977, 78612811, 619719417, 65258935, 1407500, 128115005, 619647528, 29370651, 179940547, 258764361, 336508828, 823327629, 176668191, 405613895, 775539390, 182335610, 113464773, 325338020, 668671307, 64381804, 226417232, 226550106, 108437109, 166748004, 179725029, 112325521, 248839995, 77240867, 201842218, 95152346, 687228544, 92036344, 695448715, 533877508, 364120022, 34198830, 711379068, 176441518, 647406407, 89169550, 367198268, 318721444, 356703067, 395962311, 411061638 }

    {143302914, 953210302, 755253631, 405390230, 433832350, 438263339, 813528929, 618906479, 766270699, 583583926, 965443329, 636505764, 980071615, 643279273, 157584038, 471560540, 498661368, 968401469, 353778505, 306246424, 884751139, 744509763, 440466707, 973726663, 639096332, 642837685, 593537720, 704035832, 605135681, 762719719, 774132919, 851737163, 746481261, 479089144, 899131941, 785335569, 907175364, 885626931, 859353594, 259412182, 902249868, 304920680, 348303940, 953439621, 640123668, 568675693, 272929208, 961288571, 871926821, 871172724 }

    {750588485, 642361269, 574227445, 989484854, 754683544, 32272541, 901495670, 688275301, 739043784, 365250910, 309519076, 907873872, 328722201, 814863231, 856243788, 459348625, 831386450, 585650860, 575135714, 964611456, 996883997, 784546367, 750896019, 733184191, 98435101, 670078807, 289726336, 134291104, 470964889, 923300341, 425512365, 639073655, 943711971, 278024538, 652376581, 829897961, 466960680, 800693317, 792298701, 709196857, 484828961, 935614090, 922421546, 672332529, 448149222, 827131437, 560474744, 616038263, 894062801, 900855244 }

    Returns: 0


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: