/*****************************************************************************/
/*									     */
/*  REGENERATE CYCLES							     */
/*  09/25/11 (dkc)							     */
/*									     */
/*  This C program regenerates cycles for the 3n+c sequence given entry      */
/*  points.  The number of even and odd elements in the extended sequences   */
/*  are counted.							     */
/*									     */
/*    "jump=0" indicates a no-jump attachment point                          */
/*    "jump=1" indicates a one-jump attachment point                         */
/*    "jump=2" indicates a multiple-jump attachment point                    */
/*    "jump=3" indicates a jumped-over attachment point                      */
/*									     */
/*  "delta" denotes the number of odd elements in the jump minus j where     */
/*  t=u(mod 2^j) (for one-jump or multiple-jump attachment points).  The     */
/*  domains of the cycles are also computed.				     */
/*									     */
/*****************************************************************************/
#include <stdio.h>
#include <math.h>
int main () {
int sin[4075+982]={-68,
  2,38,1562,1496,374,1436,1334,
  10,
  8,2,62,26,
  4,1048,262,358,844,682,454,574,502,
  -130,8,2,62,140,50,
  -374,-230,10,28,
  -7330,-19330,-8134,-11878,-7486,-9436,-14686,-12364,-9052,-12526,-23704,
     -5926,20,14,1244,392,98,110,
  -1502,-452,-242,88,22,28,34,
  -226,8,2,98,44,36902,1707830,1441016,360254,577232,144308,20306,7622,194366,
     788552,197138,73934,41606,79082,18794,
  -380,34,106,58,52,
  104,26,68,
  76,58,46,
  38,128,32,8,2,
  28,16,4,
  494,200,50,98,20,38,26,44,260,206,146,170,
  814,400,100,178,
  206,350,230,
  64,16,4,28,244,82,634,
  104,26,92,32,8,2,38,578,362,1064,266,740,434,596,
  16,4,24958,5974,3850,2878,1258,586,
  332,134,116,38,62,
  1060,340,184,46,34,
  248,62,116,13874,22472,5618,48488,12122,18692,7970,17042,41360,10340,22724,
  58,40,10,22,202,94,166,328,82,958,1216,304,76,100,46,
  -14254,-5326,-1978,-3874,-18448,-4612,74,284,128,32,8,2,20,
  136,34,268,70,46,88,22,28,142,460,106,172,52,64,16,4,1864,466,1060,658,
  218,1052,314,566,1646,638,260,
  142,112,28,214,2146,826,1174,2194,844,364,736,184,46,
  266,122,68,
  58,1018,748,220,64,16,4,400,100,118,
  -1426,416,104,26,74,254,2288,572,122,128,32,8,2,68,236,182,92,
  -2222,-1250,-1010,-5516,106,64,16,4,34,52,

 224,56,14,98,62,200,50,44,116,152,38,74,92,
 52,160,40,10,70,58,286,214,106,124,184,46,
 68,86,80,20,230,194,176,44,554,1862,9104,2276,512,128,32,8,2,
 2170,658,274,130,76,
 -13138,-13678,-5668,-5098,-3076,50,1064,266,128,32,8,2,
 -422,196,124,52,1036,442,964,286,136,34,
 -622,110,92,218,296,74,116,3698,4922,2162,2978,2654,3350,1286,512,128,32,8,2,
    80,20,38,44,1196,254,
 -55928,-13982,-7166,-4340,-4178,-5042,-10244,790,520,130,238,670,562,202,106,
    70,184,46,304,76,40,10,34,124,196,628,148,58,52,
 32,8,2,926,752,188,3218,1238,734,764,572,136328,34082,12812,42584,10646,42764,
    61538,23108,4364,8852,3002,29462,
 94,82,220,274,382,154,166,1030,418,622,598,256,64,16,4,
 -133108,-70342,-21766,-155020,-146716,-41182,-43018,-60694,-108628,-756598,
    -638224,-159556,-29884,-31750,-134566,-170044,104,26,266,380,236,1694,668,
	158,92,50,110,74,218,542,326,338,272,68,
 142,358,460,352,88,22,298,1942,2728,682,250,226,118,
 128,32,8,2,692,164,1916,1178,476,3212,776,194,206,13418,5066,1934,2726,2972,
    3806,3374,80000,20000,5000,1250,
 -5366,-7886,-6374,-7022,-7034,-35102,-19658,-5468,-10316,-21602,-8066,-2990,
    -9182,-5078,-13556,-4982,-5942,-7238,-8858,-14546,-5420,-17624,-4406,-5294,
	-6446,-4694,-10154,-16472,-4118,-6062,-12098,-4502,-8876,-11612,-7724,
	-17240,-4310,-10328,-2582,-8492,-7994,-5798,-7418,-5414,706,484,202,538,
    916,862,358,1510,490,868,220,76,142,88,22,
 350,698,482,24476,18032,4508,33224,8306,7178,2384,596,1148,224,56,14,392,
    98,1022,536,134,86,68,116,122,158,
 -1454,-482,-5486,-3758,64,16,4,328,82,166,184,46,94,802,226,616,154,
 194,110,29450,8348,1868,608,152,38,4826,5798,4412,1334,
 370,502,226,538,730,2854,1108,406,190,856,214,118,82,1018,
 152,38,602,692,476,128,32,8,2,98,
 52,76,544,136,34,
 86,152,38,122,134,176,44,800,200,50,464,116,62,158,1286,824,206,314,
 1012,1498,1324,508,136,34,238,130,172,184,46,58,4738,2116,886,658,472,118,
    1822,724,352,88,22,
 140,68,212,164,374,182,110,104,26,266,254,686,542,380,
 154,100,88,22,118,172,1630,1576,394,190,250,136,34,766,
 92,134,434,206,224,56,14,116,164,74,188,
 1222,502,232,58,142,664,166,106,358,178,412,286,202,292,
 374,320,80,20,2420,1466,5354,4730,6350,2426,3434,3110,1184,296,74,
 -39218,-12266,-136562,-57482,-54242,-30398,-11354,-165956,-46562,-26078,
    -9734,-173798,328,82,76,460,352,88,22,8050,3064,766,544,136,34,58,1732,
	370,184,46,220,310,760,190,
 -29092,-18034,-75544,-18886,-7036,452,2882,3794,1148,704,176,44,128,32,8,2,
 406,196,172,106,514,1000,250,604,160,40,10,
 110,938,488,122,188,8450,54458,30752,7688,1922,9746,19466,12572,4994,22868,
 -51896,-12974,-36938,-50438,-18866,-26246,-9794,-34994,-73766,-27614,-7682,
    -13826,-145046,-54344,-13586,-11234,-24212,-31118,-33266,-29054,112,28,
	220,322,1060,646,484,256,64,16,4,160,40,10,52,58,70,418,202,124,754,13714,
	6790,3940,1006,1078,1456,364,1390,1402,574,1726,
 3182,1484,860,2372,494,350,320,80,20,116,914,392,98,86,608,152,38,266,170,
    134,2336,584,146,104,26,
 220,118,94,154,208,52,

128,32,8,2,362,7796,3530,4880,1220,470,614,338,776,194,236,122,
344,86,254,146,
1288,322,172,316,214,424,106,286,268,586,376,94,
128,32,8,2,92,3338,1304,326,314,170,116,74,80,20,56,14,
260,350,3176,794,818,854,1880,470,
592,148,484,268,130,1474,4768,1192,298,502,292,214,
1418,932,2444,512,128,32,8,2,188,662,302,518,248,62,
-6494,-4766,-1814,-626,-1850,-1490,-1634,-2174,-1394,1714,2980,514,1066,454,2200,550,
388,472,118,202,130,136,34,334,3172,460,244,100,
362,320,80,20,
82,334,1258,574,250,280,70,610,2332,694,316,142,262,154,226,
80,20,278,458,656,164,188,92,74,332,146,224,56,14,62,
292,112,28,94,196,178,124,184,46,304,76,232,58,130,106,148,
62,530,428,266,158,410,212,98,386,374,356,152,38,896,224,56,
14,698,320,80,20,4622,8312,2078,2030,7352,1838,3614,3326,14018,4652,1454,
11912,2978,8996,2222,7538,7052,5270,3110,6026,2318,5756,6746,2588,3302,3932,4892,
3938,4316,
406,352,88,22,76,1336,334,184,46,262,544,136,34,166,
182,128,32,8,2,488,122,218,272,68,5618,5024,1256,314,326,1094,
470,236,104,26,164,212,2432,608,152,38,74,3566,3188,1046,452,
298,172,622,2080,520,130,142,406,430,766,1792,448,112,28,250,154,
118,1054,14428,4840,1210,514,
206,398,344,86,83996,17894,22508,9602,3662,1352,338,188,4238,1964,2672,668,
88,22,70,700,526,256,64,16,4,274,3706,2956,616,154,160,40,10,
3886,2320,580,538,112,28,814,862,
338,500,8990,3434,4856,1214,518,446,230,728,182,22028,4874,22838,57830,55562,
179576,44894,16898,9662,3686,6314,
562,274,166,724,382,544,136,34,76,1048,262,3154,1246,1750,1396,88240,
22060,10966,7228,4342,3964,1018,334,346,208,52,118,400,100,82,94,64,
16,4,
176,44,194,680,170,128,32,8,2,2936,734,2732,
802,1342,568,142,118,1618,1072,268,178,262,892,232,58,964,484,298,
856,214,340,430,226,
548,1088,272,68,4736,1184,296,74,206,182,134,116,386,638,686,308,
254,584,146,902,404,278,170,260,422,224,56,14,
214,286,556,322,376,94,394,7348,1444,706,538,268,19654,8482,5794,3136,
784,196,
3146,7952,1988,440,110,230,3578,1124,278,554,1976,494,446,1202,518,878,
662,1880,470,716,1364,1688,422,986,566,1148,734,638,746,842,908,1004,
388,796,688,172,100,364,136,34,958,
2414,974,434,416,104,26,956,248,62,92,86,866,1064,266,482,536,
134,158,128,32,8,2,
2980,628,1036,766,604,802,370,208,52,262,550,664,166,358,5986,2314,
772,214,3142,
1196,512,128,32,8,2,296,74,98,200,50,272,68,152,38,218,
146,164,131444,24716,20582,6734,20636,30842,11636,2252,578,818,
160,40,10,952,238,3262,1294,556,202,7042,4138,5812,2788,1258,1696,424,
106,8458,16990,6442,8728,2182,11362,6568,1642,
248,62,206,332,134,122,2840,710,338,626,914,1112,278,176,44,80,
20,3518,908,242,1070,926,386,2060,458,
2200,550,490,256,64,16,4,580,208,52,82,460,310,
884,452,158,272,68,86,704,176,44,
5086,2248,562,5896,1474,1594,3862,1522,5704,1426,2404,4348,3214,1618,2458,1762,
1978,2782,1954,2302,3268,2788,2494,
620,218,434,398,224,56,14,80,20,290,350,206,152,38,3284,3152,
788,1106,

1012,274,178,142,268,1066,1492,1510,23542,11506,4390,10624,2656,664,166,3130,
232,58,148,304,76,1672,418,
266,176,44,662,824,206,536,134,374,968,242,644,224,56,14,
86,2912,728,182,296,74,104,26,
166,670,328,82,238,1264,316,136,34,13090,4384,1096,274,346,994,
640,160,40,10,1300,820,9688,2422,66550,28354,151168,37792,9448,2362,11182,4270,1678,
706,2722,1732,586,
-66382,-532300,-168010,-62926,-118786,-70222,-250162,-78766,-166876,-298258,-62734,-222460,-176668,-111166,-633616,-158404,
-237022,-199618,-83932,-104830,-279484,-117538,-279322,-104668,-331486,-222514,-62446,-278998,-156742,-65902,-469726,-395962,
-148408,-37102,-104038,-104290,-220678,-186754,-139612,-87406,-370852,-77998,-92902,-496240,-124060,-311218,-87394,-331144,
-82786,-92542,-130606,-246922,-92518,-86758,-521170,-164554,-61630,-68782,-274948,-274840,-68710,-488950,-412162,-246640,
-61660,-109150,-91726,-153826,-145186,-325654,-182986,-68542,-153292,-51118,-458818,-193282,-91222,-128482,-192586,-72142,
-228292,-143782,-90574,-607048,-151762,-113926,-681622,-383218,-107644,-84814,-42478,-1928212,-361462,-203128,-50782,-604456,
-151114,-56590,-70990,-112558,-89662,-239242,-89638,-213046,-119644,-126214,-199876,-140974,-168028,-158470,-168190,-106078,
-89134,-237202,-423340,-118870,-66670,-111586,-397420,-111580,-353572,-140326,-74158,-235474,-55534,-156526,-1066036,-199804,
-105802,-39598,-98350,-185686,-104254,-392938,-147274,-55150,-73582,-350584,-87646,-261880,-65470,-109870,-207556,-416356,
-58414,-122830,-184444,-232486,-312262,-131512,-32878,-260044,-122722,-259882,-97378,-146002,-463192,-115798,-64942,-162940,
-244006,-115420,-289528,-72382,-345346,-103108,-242692,-106726,-253240,-63310,-200590,-253078,-142162,-190204,-567682,-286018,
-120382,-127672,-31918,-106204,-159100,-299410,-52846,-502072,-125518,-168394,-63070,-178006,-99934,-83950,-561850,-210616,
-52654,-175966,-148102,-102958,-194434,-137302,-77038,-217762,-434842,-162988,-45646,-434032,-108508,-90466,-322348,-151810,
-1295368,-323842,-129028,-151756,-80446,-226510,-214456,-53614,-169420,-301354,-112930,-125566,-79294,-78286,-348982,-196108,
-130012,-206242,-231100,-97126,-777634,-491596,-174328,-43582,-194116,-127582,-107278,-135142,-361714,-101596,-169366,-95074,
-158290,-222622,-187468,-165580,-467080,-116770,-130054,-181150,-152476,-160510,-101218,-133198,-188746,-70702,-99502,-158236,
-132322,-124774,-209500,-197836,-747232,-186808,-46702,-206404,-171430,-108070,-200644,-112390,-217372,-136924,-142204,-95782,
-131074,-161116,-113854,-116878,-147292,-152638,-108130,722,2396,2252,500,5312,1328,332,140,104,
26,932,1910,794,1166,464,116,248,62,308,
-2093642,-1177478,-441476,-185876,-52082,-219950,-61724,82,160,40,10,664,166,2152,538,280,
70,460,322,7342,9928,2482,29134,42334,40798,39340,11260,5122,20464,5116,2530,16012,
5482,2134,1396,340,142,3124,6040,1510,862,1432,358,376,94,1558,1072,268,
700,946,502,478,88,22,208,52,
854,902,25154,9512,2378,1928,482,260,128,32,8,2,80,20,2924,1610,
1226,1286,
1258,760,190,9682,8548,6178,6430,1948,700,238,664,166,142,592,148,
1202,878,410,962,638,320,80,20,392,98,
1228,904,226,166,526,742,1012,508,346,
542,848,212,122,128,32,8,2,704,176,44,218,164,950,740,248,
62,1346,866,2630,1676,590,4250,
334,208,52,394,1288,322,388,316,142,136,34,226,880,220,124,106,
6598,4708,1006,460,
596,1034,812,236,128,32,8,2,14822,5642,3158,1268,566,296,74,272,
68,1646,998,458,434,764,254,218,332,146,
292,2308,472,118,940,934,736,184,46,574,1798,1222,898,400,100,
376,94,3112,778,454,466,502,364,1492,1384,346,214,418,
9590,12830,7430,6674,2588,1454,2318,2006,7484,
796,262,184,46,208,52,472,118,130,1138,6106,7600,1900,442,1441828,1734034,
3293086,2084458,1172722,1113778,1410322,2008990,1271866,11032066,59645188,28308838,10615900,1119844,709348,
452,344,86,176,44,158,146,320,80,20,806,4394,6266,14312,3578,2660,
4808,1202,1526,3350,1094,776,194,326,92,104,26,434,1190,2054,15500,3584,
896,224,56,14,
196,124,550,1330,586,1486,1054,2224,556,574,430,460,1000,250,712,178,
154,334,406,2026,2842,952,238,352,88,22,412,
650,332,314,206,488,122,134,296,74,116,110,512,128,32,8,2,
4718,4400,1100,530,3080,770,638,5534,10340,1964,668,614,566,1802,764,
256,64,16,4,94,124,112,28,1222,436,2104,526,286,196,165994,105448,
26362,307582,115432,28858,84022,346948,110248,27562,426382,159982,60082,34018,146758,31162,68026,74506,
63286,61018,57706,36922,120514,73654,106378,90178,82402,150586,545386,345532,64876,182032,45508,99394,
91636,131974,42154,235654,56308,399436,56326,180688,45172,66082,60898,65074,36826,128068,
350,4172,872,218,1160,290,1526,662,338,770,1076,1808,452,968,242,1322,
1256,314,1832,458,482,674,836,764,1052,
94,508,802,2164,496,124,640,160,40,10,994,1210,544,136,34,382,
1696,424,106,130,490,274,316,562,226,724,1018,472,118,292,262,370,
868,280,70,388,
416,104,26,254,2612,7148,2678,4826,7814,12188,3656,914,434,176,44,452,
164,122,194,
718,1810,1564,1720,430,514,1396,622,538,532,376,94,232,58,262,190,
214,172,124,178,586,448,112,28,
-1126,524,236,386,1766,1340,344,86,1070,494,278,2798,1142,818,692,1880,
470,5282,1964,5354,4958,1952,488,122,908,290,1466,2468,926,440,110,134,
200,50,260,
394,274,196,130,142,328,82,124,268,556,83986,31588,6016,1504,376,94,
286,880,220,454,826,2338,970,436,430,1960,490,592,148,184,46,
530,314,212,134,1652,404,170,158,140,116684,24884,4760,1190,674,626,350,
4064,1016,254,662,608,152,38,932,296,74,122,
3820,622,328,82,1714,1588,1120,280,70,244,820,796,
164,524,194,1460,650,920,230,182,596,18398,5342,1670,722,1064,266,
2144,536,134,146,578,2360,590,
-24074,-10946,-88766,-27656,-6914,-45026,-56204,-10442,-61172,-16964,178,424,106,136,34,
3502,3412,736,184,46,496,124,8326,4924,3898,1558,934,766,5596,2818,628,214,
13292,20306,7712,1928,482,278,1142,4052,740,236,1496,374,3086,296,74,458,
4706,1862,1622,20654,6842,4616,1154,530,326,650,362,272,68,110,
556,202,358,232,58,346,418,1480,370,2884,3958,1582,616,154,454,268,
148,286,292,832,208,52,
266,1088,272,68,1544,386,464,116,518,1868,752,188,134,278,314,734,
374,1328,332,428,
490,1840,460,16744,4186,1768,442,298,2110,1450,2434,1012,316,352,88,22,

3092,680,170,164,398,812,3098,1262,1256,314,218,182,374,446,1802,776,
194,230,380,2714,1118,6176,1544,386,284,596,212,140,290,320,80,20,
104,26,110,
466,514,2188,484,388,658,622,334,226,8236,88372,216514,137548,14740,7786,7048,
1762,1414,574,316,160,40,10,
-31996,-72010,-26902,-14878,-12070,-72388,-24760,-6190,668,272,68,512,128,32,8,2,
800,200,50,890,398,290,728,182,170,350,5264,1316,2018,2186,1484,380,
3968,992,248,62,542,998,476,530,2348,2258,112670,71954,137942,51830,19538,57752,
14438,5516,1136,284,218,
5992,1498,664,166,364,358,436,184,46,310,430,2806,1834,790,700,
688,172,304,76,5884,2968,742,1510,
872,218,242,194,176,44,3806,1844,440,110,320,80,20,7124,1958,3644,
4778,2390,
3178,982,472,118,148,598,328,82,562,1192,298,424,106,1102,1912,
478,316,226,2398,856,214,184,46,
308,1046,2822,1814,1550,686,362,1478,554,2126,902,878,434,506,2342,842,
1208,302,218,950,2018,2246,716,284,158,164,2090,5114,11090,6500,
214,1126,1450,592,148,808,202,286,424,106,268,502,1648,412,27424,6856,
1714,748,2098,892,514,298,
6632,1658,728,182,368,92,746,386,548,1046,854,1226,566,584,146,1772,
764,1196,602,332,
292,1096,274,2722,1798,2320,580,430,268,772,484,652,1192,298,1912,478,
286,214,
-7870,-6706,-3550,338,1166,16070,6134,2408,602,608,152,38,122,554,800,200,
50,1850,1310,896,224,56,14,908,278,212,242,716,1004,296,74,134,
158,1376,344,86,140,410,500,584,146,518,302,1040,260,662,356,824,
206,680,170,572,314,446,350,404,422,266,476,7484,2606,1490,2948,6170,
3740,33242,18968,4742,1886,
364,388,244,154,166,2416,604,622,14296,3574,1846,1090,496,124,958,2092,
1036,562,2080,520,130,226,298,220,4654,10972,6220,2020,1336,334,796,850,
26524,11704,2926,5548,3604,784,196,2884,940,1588,406,832,208,52,118,6598,
3982,3874,3196,2902,
194,182,1118,902,1280,320,80,20,650,374,1130,2588,860,1388,1766,1616,
404,248,62,308,698,968,242,200,50,128,32,8,2,110,28982,37568,
9392,2348,29306,
478,2224,556,214,190,988,358,244,520,130,280,70,136,34,550,316,
7144,1786,1936,484,1198,1414,640,160,40,10,502,298,442,370,1360,340,
586,604,1312,328,82,748,250,82450,237070,66868,422722,24779422,35283502,8373418,4710322,96710014,
62038126,14722498,13975732,4422592,1105648,276412,99460,72208,18052,
152,38,1106,1160,290,440,110,434,758,416,104,26,548,674,656,164,
182,1520,380,944,236,
1258,934,2086,3544,886,1276,526,574,562,322,232,58,1438,1906,826,1048,
262,3058,112,28,286,772,256,64,16,4,
788,260,2570,1076,314,230,410,266,212,152,38,302,
-2966,-8852,1822,796,262,316,172,13072,3268,1702,676,472,118,
37598,16274,212276,45104,11276,2228,1688,422,272,68,1532,2594,7832,1958,848,212,
344,86,146,914,4052,1424,356,1838,716,248,62,974,3296,824,206,
1144,286,784,196,2080,520,130,466,658,952,238,3052,178,250,208,52,
124,1360,340,5320,1330,574,1630,1918,1006,32212,6154,2422,1648,412,
1106,530,314,290,224,56,14,296,74,452,200,50,134,
2806,1168,292,2644,4246,1708,436,412,8320,2080,520,130,5722,3508,1276,382,
310,232,58,322,1348,
-15101950,-16125466,-7652398,-4304182,-2907388,-58615924,-8242660,-1545382,-7421692,-8459902,-10161586,-3810478,-2143102,-6804958,-2870506,-2723494,
-11629606,-33114694,-41909836,-44752366,-25172914,-9439726,-5309554,-1990966,-3187174,-19324522,-23213602,-8704984,-2176246,-1161190,-10045180,-36193990,
-45807070,-4236934,-5088262,-16297474,-6111436,-5799550,-26446810,-5578354,-2091766,-7838680,-1959670,-7057318,-67818010,-32186164,-5091430,-9664222,
-4076758,-3439210,-10578532,-1983358,-27121702,-77230858,-24435892,-1932598,-3914758,-53062966,-35856730,-6056668,-1703146,-1615414,-7757158,-14724940,
-2578486,-10448950,-25102858,-11307532,-8048632,-2012158,-3623158,-3655678,-28124284,-273938872,-68484718,-38522362,-10834210,-4062712,-1015678,-10366330,
-2915326,-7875796,-9457726,-8519878,-10782022,-13645048,-3411262,-2329510,-33569590,-47795836,-11341594,-21818812,-4602070,-3882442,-1637482,-3651916,
-120005092,-22500838,-30408628,-3206890,-3042796,-9064984,-2266246,-148916218,-41882482,-15705814,-13251226,-3144070,-2983582,-3159166,-4496422,-12801838,
-7200742,-23065240,-5766310,-105191464,-26297866,-9360130,-3509932,-1480198,5234,3236,1202,968,242,428,782,410,
2318,986,170,698,1832,458,5246,2084,878,446,284,1322,1670,674,620,554,
1022,500,
226,202,262,778,424,106,4540,1570,706,382,508,436,496,124,328,82,
148,
-1330,398,2900,662,668,7160,1790,2072,518,956,842,434,392,98,470,560,
140,8876,2792,698,380,722,410,272,68,794,416,104,26,128,32,8,
2,1262,2558,2720,680,170,182,
-13724,-8054,-29762,-11042,-4022,-13886,-7514,-10124,-8534,-9836,-13346,-4886,-17282,-6362,-12428,214,
268,484,784,196,352,88,22,232,58,4588,3124,1882,2152,538,1018,1186,
964,568,142,172,
2420,980,794,746,614,350,308,386,2312,578,9602,19808,4952,1238,584,146,
692,494,5390,2708,1604,1988,6410,16406,6272,1568,392,98,278,224,56,14,
440,110,5228,1100,326,242,3932,2906,1934,1250,2036,872,218,422,254,902,
458,926,470,296,74,632,158,6686,2090,1226,1412,3494,1430,656,164,638,
274,3616,904,226,382,8116,1642,736,184,46,610,1240,310,430,934,826,
3040,760,190,508,2068,700,1420,2218,952,238,772,1732,454,556,562,706,
868,922,466,
-13132,-14458,-8596,-22204,-4042,-17374,-6394,-9082,-5194,-9094,2678,174614,187736,46934,60386,22766,
7586,2966,5876,2192,548,224,56,14,248,62,338,242,212,158,392,98,
608,152,38,368,92,476,458,404,962,482,302,188,356,878,1112,278,
1124,332,716,464,116,782,2498,1058,518,662,2354,1004,2552,638,1754,12434,
4784,1196,1742,296,74,6548,6386,2516,566,11102,
47506,61114,150250,84820,24160,6040,1510,688,172,154,11512,2878,2548,1576,394,526,
3766,1534,4252,730,658,1822,1210,8140,1648,412,670,724,508,
-4282,-4012,-8158,2306,1604,758,428,2156,518,1118,542,326,13016,3254,1130,3764,
1436,392,98,362,248,62,146,1982,866,794,13646,5240,1310,614,704,176,
44,956,302,236,
-10088,-2522,-5876,-5714,-2906,-5300,-7172,-3194,-4418,124,694,10600,2650,844,
12058,4366,2764,3310,2170,826,448,112,28,316,802,424,106,1414,3448,862,
718,712,178,190,1180,640,160,40,10,4096,1024,256,64,16,4,
188,22094,19232,4808,1202,1604,974,1412,416,104,26,134,386,326,494,5462,
5672,1418,656,164,488,122,170,632,158,3032,758,1244,1298,998,872,218,
206,764,1520,380,1250,1082,530,674,4490,1808,452,1682,1160,290,
574,340,736,184,46,142,178,412,202,1096,274,466,664,166,610,
616,154,2398,1024,256,64,16,4,1636,772,1588,43432,10858,9754,333484,159604,259234,
69898,50620,9616,2404,988,310,562,628,1012,1654,1150,556,18484,561202,315988,133900,
19048,4762,27778,176020,42322,24118,6196,88324,20122,101662,38248,9562,19798,13210,40210,22930,
82222,30958,11734,18826,58012,11002,14938,30004,72502,23404,75202,22324,34378,23092,53332,20986,
27574,18646,43126,42856,10714,12442,28642,12730,79576,19894,36052,15802,24010,15682,36322,28690,
16450,37780,14170,28546,29842,17098,15034,22858,31786,27412,41764,12058,62296,15574,45070,17026,
31606,13786,49444,14218,21634,19030,20002,20020,20866,86704,21676,28750,10906,17674,84166,23890,
13750,24340,28276,29734,44908,28804,37390,14146,22966,30100,23830,

-75622,-70654,-121762,-90334,224,56,14,134,176,44,4028,2084,95882,54248,13562,4688,
1172,644,1292,368,92,152,38,140,320,80,20,374,266,464,116,386,
818,48956,12140,2402,2624,656,164,1814,806,428,206,278,230,212,5162,3218,
7988,2366,1454,1022,
922,472,118,382,784,196,418,634,364,532,226,676,316,
128,32,8,2,320,80,20,9020,3530,1940,1202,578,344,86,1676,
7562,8534,265466,215408,53852,15464,3866,1310,1256,314,668,506,428,716,2558,2648,
662,3206,11774,3848,962,488,122,
136,34,2836,1576,394,928,232,58,352,88,22,1900,484,736,184,46,
520,130,8998,3502,7156,2332,844,286,304,76,142,604,1648,412,550,334,
1006,1222,586,1702,766,1378,2782,
782,422,344,86,506,9584,2396,578,614,398,278,584,146,404,
134,326,3242,2108,524,668,254,224,56,14,
3976,994,502,11104,2776,694,3022,574,646,7882,7234,2842,26836,4000,1000,250,
1516,7396,6730,5182,3238,3346,1384,346,1942,3508,2092,2374,5938,2356,886,4036,
1030,4804,4210,1708,1978,2740,
5588,1178,572,860,2534,8366,17600,4400,1100,1040,260,1508,440,110,3020,
562,2614,964,598,766,418,3748,4558,1840,460,550,706,724,3100,712,178,
4270,1732,814,436,
-9592,-2398,-3310,284,938,2072,518,326,254,302,1010,1478,686,662,380,164,
1064,266,500,470,308,416,104,26,344,86,338,6662,2630,1118,2450,2120,
530,35336,8834,9320,2330,1640,410,560,140,158,
232,58,154,190,1810,1204,358,532,7390,26998,11770,4546,1510,1180,1126,964,
880,220,610,784,196,622,
548,236,1232,308,
238,1462,682,718,436,2758,1168,292,130588,18598,7108,3634,5686,2266,
20842,12058,9718,3778,6646,2626,2272,568,142,274,2284,562,1798,808,202,448,112,28,
4444,778,772,3742,3832,958,14434,12814,3838,2104,526,382,646,376,94,
194,446,302,248,62,158,152,38,1472,368,92,
6952,1738,15700,3802,1306,604,508,496,124,16132,3160,790,784,196,172,1522,
706,400,100,154,280,70,3010,1264,316,6628,1378,652,
1226,596,248,62,3008,752,188,236,1334,1568,392,98,266,
880,220,178,442,9568,2392,598,748,13942,7414,5572,3040,760,190,208,52,
1144,286,244,1384,346,5032,1258,1420,466,604,250,2278,32788,14482,8488,2122,
2440,610,29608,7402,5308,1132,
980,620,254,1838,758,422,296,74,386,362,548,1466,2108,944,236,182,
206,650,710,404,458,602,14058854,5272208,1318052,2678786,2260880,565220,538334,1165022,38388152,9597038,
2699408,674852,428174,730898,926162,990362,8605196,1613612,302690,25077608,6269402,2645300,628532,2170322,1392794,1886984,
471746,398690,1922462,811538,1028222,1133846,425330,2306888,576722,4166324,879230,1254212,942308,1134974,1820882,5837354,
3283856,820964,585956,
2284,988,1912,478,1060,148,166,3490,4786,1588,436,220,2032,508,3328,832,
208,52,502,628,256,64,16,4,
752,188,440,110,410,152,38,3002,1088,272,68,530,338,266,602,476,
482,320,80,20,872,218,368,92,374,
1138,1624,406,292,730,760,190,298,838,454,310,256,64,16,4,
398,290,536,134,284,194,25184,6296,1574,986,3728,932,614,482,608,152,
38,1310,632,158,200,50,380,212,758,830,452,500,1460,3242,3404,1892,
884,1418,2450,1730,5306,4448,1112,278,1082,5792,1448,362,974,506,1784,446,
308,5186,7310,2882,3998,1640,410,9560,2390,6764,1670,716,698,5348,1856,464,
116,2288,572,248,62,164,
5002,1654,2572,1756,1306,5752,1438,1162,574,676,268,784,196,178,208,52,
5914,3736,934,10342,7912,1978,1762,802,442,916,376,94,406,19414,43912,10978,
4258,1738,736,184,46,334,1594,1918,1432,358,808,202,304,76,1144,286,
514,
476,1988,5426,10448,2612,632,158,704,176,44,368,92,1214,1700,488,122,
188,1046,944,236,422,1016,254,890,
304,76,850,1222,1282,1078,2158,952,238,232,58,688,172,274,526,340,
1174,580,520,130,430,2968,742,5164,976,244,1996,4576,1144,286,250,
386,9554,8744,2186,1754,1346,3482,2318,1268,716,278,248,62,662,392,98,
1292,1916,1562,1238,608,152,38,158,296,74,
1504,376,94,1588,442,310,4504,1126,994,532,244,190,5260,1840,460,490,
328,82,856,214,1264,316,1372,262,508,5638,3532,1354,652,544,136,34,
604,940,868,706,364,2344,586,
356,212,284,29234,11108,2228,1640,410,1598,1262,950,43976,10994,4268,3056,764,
578,362,
754,5176,1294,610,934,496,124,1612,448,112,28,340,460,232,58,
9548,2546,1496,374,362,2366,1034,10466,6254,2492,614,740,578,692,1574,1196,
274,250,328,82,178,214,880,220,430,610,376,94,814,826,490,
1258,1744,436,1186,592,148,3616,904,226,232,58,4930,1996,5902,3688,922,970,
4282,1462,1156,364,
188,6188,6548,1376,344,86,842,464,116,170,212,2174,3956,890,482,
11732,2348,2444,1058,566,1796,512,128,32,8,2,260,296,74,176,44,1958,
1472,368,92,878,1232,308,206,
8086,21208,5302,2776,694,832,208,52,2236,568,142,202,2062,922,3712,928,
232,58,1282,9544,2386,1714,1336,334,274,526,346,
1388,410,4844,1058,1604,6626,6302,4952,1238,614,380,1118,4046,1400,350,
1928,482};

unsigned char cflag[4075+982+1]={
 0, 0, 1, 2, 2, 2, 3, 3, 0, 0, 0, 1, 1, 0, 1, 1, 1, 2, 3, 4, 5,
 6, 0, 1, 1, 2, 2, 2, 0, 0, 1, 1, 0, 1, 1, 2, 2, 3, 4, 4, 5, 6,
 6, 6, 7, 8, 9, 9, 9, 9, 0, 0, 0, 1, 1, 1, 2, 0, 1, 1, 2, 2, 3,
 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 0, 1, 1, 1, 1, 0, 0,
 1, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2,
 3, 4, 5, 0, 0, 0, 0,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33,34,34,34,34,35,36,36,37,38,38,39,39,40,
41,41,41,41,42,42,42,42,42,43,43,43,43,43,44,45,45,46,46,47,48,
48,49,49,50,50,50,51,52,52,52,53,54,54,55,56,57,57,58,58,58,58,
58,58,59,59,59,60,60,60,61,61,61,62,62,63,63,63,63,64,65,66,66,
66,66,67,67,68,68,69,70,70,70,71,72,72,73,73,74,74,75,76,77,77,
77,78,78,79,80,80,80,80,80,81,82,83,84,84,84,84,84,85,85,85,86,
86,86,87,87,88,88,89,89,89,90,90,90,91,91,92,92,93,94,94,94,95,
96,97,97,97,98,99,99,100,101,102,103,103,104,104,105,105,106,106,106,106,107,
108,108,108,109,109,110,110,111,112,112,113,114,114,115,116,116,117,117,118,118,118,
119,119,120,120,121,121,122,122,122,123,124,124,125,126,127,127,128,129,130,131,131,
132,132,133,133,134,134,134,134,134,134,134,134,134,134,135,135,135,135,135,135,135,
135,135,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,
3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,
1,2,2,2,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,2,2,2,2,2,2,2,2,2,0,0,0,0,1,1,1,1,1,2,
2,2,2,2,2,3,3,3,3,4,4,4,5,5,6,6,6,7,0,0,0,
0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,
1,1,1,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0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,
0,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,5,5,5,
6,6,6,6,6,6,6,6,6,7,7,8,8,9,9,9,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,
2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,
0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,2,2,2,2,3,3,3,3,0,0,0,0,0,0,0,
0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,0,
0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,
255};

int cval[200]={1,5,7,11,13,17,19,23,25,29,31,35,37,41,43,47,49,53,55,59,61,
	      65,67,71,73,77,79,83,85,89,91,95,97,101,103,107,109,113,115,
	      119,121,125,127,131,133,137,139,143,145,149,151,155,157,161,
	      163,167,169,173,175,179,181,185,187,191,193,197,199,203,205,
	      209,211,215,217,221,223,227,229,233,235,239,241,245,247,251,
	      253,257,259,263,265,269,271,275,277,281,283,287,289,293,295,
	      299,301,305,307,311,313,317,319,323,325,329,331,335,337,341,
	      343,347,349,353,355,359,361,365,367,371,373,377,379,383,385,
	      389,391,395,397,401,403,407,409,413,415,419,421,425,427,431,
	      433,437,439,443,445,449,451,455,457,461,463,467,469,473,475,
	      479,481,485,487,491,493,497,499,503,505,509,511,515,517,521,
	      523,527,529,533,535,539,541,545,547,551,553,557,559,563,565,
	      569,571,575,577,581,583,587,589,593,595,599};


unsigned int size[200]={1,7,1,4,9,6,4,18,7,20,5,3,3,5,3,12,4,3,7,14,8,5,5,14,
  15,13,20,7,13,3,10,17,10,
  13,12,17,5,12,10,25,29,23,15,34,13,24,59,25,17,12,14,10,5,18,23,14,14,11,14,
  15,34,16,11,15,52,25,6,
  20,12,24,12,14,28,4,15,15,16,50,14,31,22,16,25,22,34,12,21,28,18,32,9,22,19,
  28,25,25,13,9,23,18,23,23,36,298,56,18,15,10,9,23,20,26,28,9,29,36,27,31,62,
  25,36,19,24,35,31,27,12,22,32,30,22,20,16,
  35,23,53,23,18,23,30,22,20,18,69,52,35,57,21,26,12,13,31,30,13,21,146,17,
  39,36,64,35,74,29,36,45,46,139,
  52,13,38,39,24,38,15,20,42,22,4,47,11,28,13,38,67,24,25,15,70,49,24,31,26,
  39,18,15,16,36,39,27,17};

unsigned int conv[27*2]={5,3,6,4,8,5,9,6,11,7,16,10,19,12,24,15,27,17,38,24,
  46,29,57,36,65,41,76,48,84,53,130,82,149,94,168,106,233,147,252,159,317,200,
  336,212,401,253,420,265,485,306,504,318,569,359};

int hflag=0;	 // selects which c value to histogram k values
int hflag1=0;	 // selects which c value to histogram j values
unsigned int indmin=6;	 // selects (l,m) value
unsigned int indmax=6;	 // Note: Could include different (l,m) values.
unsigned int bypass=0;	 // normally set to 0
unsigned int wflag=1;	 // normally set to 0
unsigned int infin=0;	 // normally set to 0
int k,max,temp,order,s[500],t,u,savek,oldk,c,olds,cmax,cmin,delta,locmin,locmax;
unsigned int g,h,i,m,iters,j,count,first,odds,evens,flag,lodds,levens,jump,jcnt;
unsigned int flag0,offset,index,sumtu,total,stu[1000*2],county,countn,countx;
unsigned int histo[100],mincnt,hismin[10],savjmp,second,histoj[100],histom[10];
int lastodd,glomax,usave,tmps,cyccnt,mcount,hcount,icount,lcount,oddsum,oldt,oldu;
unsigned int jumps[500],mflag,attcnt,savind,newhis[100],oldhis[100],histon[20];
unsigned int histoh[100],histoi[100],histox[100],badcnt,badcntu,primary,jmpcnt;
unsigned int firstt,savcnt,savjump,jmphop,twojmp,tmpcnt,lasthop,glohop,glojmp;
unsigned int twojmp0,twojmp1,twojmp2,twojmp3,tmpjump,jmpsum,offset1,histoy[100];
int glomin,a,badcomp,savet,lastt,lalat,jsum,evensum,hsum,compcnt,sum,offset5;
unsigned int histoz[100],histow[100],histov[100],histos[100],offset2,badtucnt,tempi;
unsigned int concov[27*3],histot[30],histou[30],offset4,histoa[30],histob[30];
unsigned int concove[27*3],patcnt,cyccntu,cyccntb,histor[100],equcnt,histoc[400];
unsigned int histod[400],offset6;
double lambda,d,dmin,dmax,del,maxdel,mindel,sumrec,tempf,chain,rat,oldchn,bp,bm;
double ratdel,tempg,cap,cam,savchain,tmpchain,maxcmp,mean,std,var;
FILE *Outfp;
Outfp = fopen("out0ce.dat","w");
for (i=0; i<100; i++) {
   histo[i]=0;
   histoj[i]=0;
   newhis[i]=0;
   oldhis[i]=0;
   histoh[i]=0;
   histoi[i]=0;
   histox[i]=0;
   histoy[i]=0;
   histoz[i]=0;
   histow[i]=0;
   histov[i]=0;
   histos[i]=0;
   histor[i]=0;
   }
for (i=0; i<10; i++) {
   hismin[i]=0;
   histom[i]=0;
   }
for (i=0; i<20; i++)
   histon[i]=0;
for (i=0; i<27*3; i++) {
   concov[i]=0;
   concove[i]=0;
   }
for (i=0; i<30; i++) {
   histot[i]=0;
   histou[i]=0;
   histoa[i]=0;
   histob[i]=0;
   }
for (i=0; i<400; i++) {
   histoc[i]=0;
   histod[i]=0;
   }
badcnt=0;
badcntu=0;
badtucnt=0;
badcomp=0;
compcnt=0;
cyccntu=0;
cyccntb=0;
equcnt=0;
maxcmp=0.0;
primary=0;
offset=20;
offset1=30;
offset2=50;
offset4=15;
offset5=20;
offset6=100;
index=0;
maxdel=-1000000.0;
mindel=1000000.0;
rat=log(3.0)/log(2.0);
ratdel=rat/(rat-1.0);
county=0;
countn=0;
countx=0;
cyccnt=0;
mcount=0;
twojmp=0;
twojmp0=0;
twojmp1=0;
twojmp2=0;
twojmp3=0;
jmphop=0;
glohop=0;
glojmp=0;
for (h=0; h<200; h++) {
   c=cval[h];
// if (c>100)
//    break;
   iters=size[h];
   printf("c=%d \n",c);
   for (i=0; i<iters; i++)
      s[i]=sin[i+index];
//
// compute order (of loop)
//
   sumtu=0;
   total=0;
   olds=0;
   glomax=0;
   glomin=1000000000;
   a=0;
   mflag=0;
   attcnt=0;
   patcnt=0;
   savind=0;
   sumrec=0.0;
   oddsum=0;
   jmpsum=0;
   oldt=0;
   lastt=0;
   lalat=1000000000;
   firstt=1;
   oldchn=1000000000.0;
   oldu=0;
   jsum=0;
   evensum=0;
   hcount=0;
   for (i=0; i<iters; i++) {
      k=s[i];
      savek=k;
      max=k;
      if (max<0)
	 max=-max;
      levens=0;
      while (k==(k/2)*2) {
	 k=k/2;
	 levens=levens+1;
	 }
      lodds=1;
      for (j=1; j<100000; j++) {
	 k=3*k+c;
	 if ((k&7)==0) {
	    oldk=savek;
	    savek=k;
	    }
	 temp=k;
	 if (temp<0)
	    temp=-temp;
	 if (temp>max)
	    max=temp;
	 while (k==(k/2)*2) {
	    if (k==s[i]) {
	       levens=levens-1;
	       goto bskip;
	       }
	    k=k/2;
	    levens=levens+1;
	    }
	 levens=levens-1;
	 lodds=lodds+1;
	 }
      printf("error: i=%d, s[i]=%d \n",i,s[i]);
      goto zskip;
bskip:
      order=3;
      while (order<max)
	 order=order*2;
      while ((oldk&1)==0)
	 oldk=oldk/2;
      u=oldk;
//
// find odd natural number divisible by 3
//
      k=s[i];
      max=k;
      if (max<0)
	 max=-max;
      while (k!=(k/3)*3) {
	 if (k==(k/2)*2) {
	    if ((k-c)==((k-c)/3)*3) {
	       k=(k-c)/3;
	       temp=k;
	       if (temp<0)
		  temp=-temp;
	       if (temp>max)
		  max=temp;
	       }
	    else {
	       k=k*2;
	       temp=k;
	       if (temp<0)
		  temp=-temp;
	       if (temp>max)
		  max=temp;
	       }
	    }
	 else {
	    k=k*2;
	    temp=k;
	    if (temp<0)
	       temp=-temp;
	    if (temp>max)
	       max=temp;
	    }
	 }
//
// include even natural numbers to the left of the odd natural number divisible
// by 3
//
      t=k;
      jump=1;
      flag0=3;
      if ((3*t+c)==s[i]) {
	 jump=0;
	 flag0=0;
	 }
      temp=t-u;
      m=0;
      jcnt=0;
      while ((temp&1)==0) {
	 m=m+1;
	 temp=temp/2;
	 }
      while (order<max)
	 order=order*2;
      temp=k;
      if (temp<0)
	 temp=-temp;
      while (temp<(order/2)) {
	 temp=temp*2;
	 k=k*2;
	 }
//
// compute sequence
//
      hsum=0;
      count=1;
      first=1;
      while (k==(k/2)*2) {
	 k=k/2;
	 count=count+1;
	 }
      evens=count-1;
      odds=1;
      for (j=1; j<10000; j++) {
	 k=3*k+c;
	 count=count+1;
	 if (first==0) {
	    if (((k&3)==0)&&((k&7)!=0))
	       hsum=hsum+1;
	    }
	 flag=0;
	 while (k==(k/2)*2) {
	    if (k==s[i]) {
	       if (first==1)
		  first=0;
	       else
		  goto askip;
	       }
	    k=k/2;
	    count=count+1;
	    flag=flag+1;
	    }
	 if (first==1) {
	    evens=evens+(flag-1);
	    odds=odds+1;
	    if (flag==2) {
	       jcnt=jcnt+1;
	       if ((3*k+c)==s[i])
		  flag0=1;
	       }
	    }
	 }
      printf("error \n");
      goto zskip;
askip:
      if ((jcnt==1)&&(flag0==1))
	 jump=1;
      if ((jcnt>1)&&(flag0==1))
	 jump=2;
      if ((jcnt>0)&&(flag0==0))
	 jump=3;
      if (flag0==3)
	 jump=3;
      jumps[i]=jump;
      attcnt=attcnt+1;
//
// check order of jump types for primary, secondary, tertiary, etc.
//
      if ((4*s[i])!=olds) {
	 tmpjump=jump;
	 if (jump==3) {
	    printf("error: primary jumped-over attachment points \n");
	    goto zskip;
	    }
	 }
      else {
	 if (tmpjump==0) {
	    if (jump!=3) {
	       printf("error: incorrect order \n");
	       fprintf(Outfp,"error: incorrect order \n");
	       goto zskip;
	       }
	    }
	 if (tmpjump==3) {
	    if ((jump!=1)&&(jump!=2)) {
	       printf("error: incorrect order \n");
	       fprintf(Outfp,"error: incorrect order \n");
	       goto zskip;
	       }
	    }
	 if ((tmpjump==1)||(tmpjump==2)) {
	    if (jump!=0) {
	       printf("error: incorrect order \n");
	       fprintf(Outfp,"error: incorrect order \n");
	       goto zskip;
	       }
	    }
	 tmpjump=jump;
	 }
//
// check hops in multiple-jumps
//
      jmpcnt=0;
      if (jump==2) {
	 first=0;
	 second=0;
	 flag0=0;
	 k=t;
	 if (((3*k+c)&3)==0) {	      // check for hop
	    first=1;		      // hop count
	    lasthop=1;		      // set last hop flag
	    }
	 else {
	    second=1;		      // jump count
	    flag0=1;		      // set first jump flag
	    lasthop=0;
	    }
	 while ((3*k+c)!=s[i]) {
	    k=k+c;
	    tmpcnt=0;
	    while ((k&1)==0) {
	       k=k/2;
	       tmpcnt=tmpcnt+1;
	       }
	    for (j=0; j<tmpcnt; j++)
	       k=k*3;
	    k=(k-c)/2;
	    if ((((3*k+c)&3)==0)&&((3*k+c)!=s[i])) {  // check for hop
	       first=first+1;	      // increment hop count
	       lasthop=1;	      // set last hop flag
	       }
	    if ((((3*k+c)&3)!=0)&&((3*k+c)!=s[i])) {  // check for jump
	       second=second+1;       // increment jump count
	       lasthop=0;
	       }
	    jmpcnt=jmpcnt+1;
	    }
	 if ((flag0==0)&&(second>0)&&(lasthop==1)) {  // first and last are hops
	    if (wflag==5) {
	       printf("warning: non-adjacent hops, c=%d, s=%d \n",c,s[i]);
	       fprintf(Outfp,"warning: non-adjacent hops, c=%d, s=%d \n",c,s[i]);
	       }
	    jmphop=jmphop+1;
	    }
	 if ((flag0==1)&&(first>0)&&(lasthop==0)) {  // first and last are jumps
	    if (wflag==5) {
	       printf("warning: non-adjacent jumps, c=%d, s=%d \n",c,s[i]);
	       fprintf(Outfp,"warning: non-adjacent jumps, c=%d, s=%d \n",c,s[i]);
	       }
	    jmphop=jmphop+1;
	    }
	 glohop=glohop+first;	     // total number of hops
	 glojmp=glojmp+second;	     // total number of jumps
	 if (jmpcnt==2) {
	    twojmp=twojmp+1;	     // total number of two-"jumps"
	    if (first==2)
	       twojmp0=twojmp0+1;
	    if ((first==1)&&(second==1)) {
	       if (lasthop==1)
		  twojmp1=twojmp1+1;
	       else
		  twojmp2=twojmp2+1;
	       }
	    if (second==2)
	       twojmp3=twojmp3+1;
	    }
	 mcount=mcount+1;
	 }
//
// check chain (t values)
//
      if ((4*s[i])!=olds) {
	 temp=t+c;
	 if (temp<0)
	    temp=-temp;
	 chain=(double)temp;
	 temp=s[i];
	 if (temp<0)
	    temp=-temp;
	 while ((temp&1)==0)	 // next u value
	    temp=temp/2;
	 chain=rat*log(chain);
	 chain=exp(chain);
	 tmpchain=chain;
	 if (jump==1)
	    chain=chain*2.0;
	 if (jump==2)
	    chain=chain*(double)(1<<jmpcnt);
	 if (chain<(double)temp) {
	    if (wflag!=2) {
	       printf("error:  bad t-u chain, c=%d, t=%d, u=%d, jump=%d, count=%d \n",c,t,temp,jump,jmpcnt);
	       fprintf(Outfp,"error:  bad t-u chain, c=%d, t=%d, u=%d, jump=%d, count=%d \n",c,t,temp,jump,jmpcnt);
	       }
	    badtucnt=badtucnt+1;
	    }
	 if (chain<(double)oldt) {
	    if (wflag!=2) {
	       printf("error: bad chain, c=%d \n",c);
	       printf("chain=%e, oldt=%d, t=%d, jump=%d, count=%d, s=%d \n",chain,oldt,t,jump,jmpcnt,s[i]);
	       fprintf(Outfp,"error: bad chain, c=%d \n",c);
	       fprintf(Outfp,"chain=%e, oldt=%d, t=%d, jump=%d, count=%d, s=%d \n",chain,oldt,t,jump,jmpcnt,s[i]);
	       }
	    badcnt=badcnt+1;
	    }
	 oldt=t;
	 if (oldt<0)
	    oldt=-oldt;
	 if (firstt==1) {
	    savchain=chain;
	    savet=t;
	    savjump=jump;
	    savcnt=jmpcnt;
	    firstt=0;
	    }
	 }
//
// check for powers of 2
//
      if (((4*s[i])!=olds)&&(jump==2)&&(jmpcnt==2)) {
	 temp=t;
	 temp=temp+c;
	 if (temp<0)
	    temp=-temp;
	 while ((temp&1)==0)
	    temp=temp/2;
	 if ((wflag==3)&&(temp==1)) {
	    printf("power of two:  c=%d, u=%d, t=%d, s=%d \n",c,u,t,s[i]);
	    fprintf(Outfp,"power of two:  c=%d, u=%d, t=%d, s=%d \n",c,u,t,s[i]);
	    }
	 if (tmpchain<(double)lastt) {
	    printf("error: bad chain, chain=%e, lastt=%d \n",chain,lastt);
	    fprintf(Outfp,"error: bad chain, chain=%e, lastt=%d \n",chain,lastt);
	    goto zskip;
	    }
	 if (wflag==4) {
	    if (tmpchain>(double)lalat) {
	       printf("warning: chain=%e, t=%d, last t=%d, last last t=%d \n",chain,t,lastt,lalat);
	       fprintf(Outfp,"warning: chain=%e, t=%d, last t=%d, last last t=%d \n",chain,t,lastt,lalat);
	       }
	    }
	 }
      if (lastt!=0)
	 lalat=lastt;
      lastt=t;
      if (lastt<0)
	 lastt=-lastt;
//
// count hops up until attachment point
//
      if ((4*s[i])!=olds) {
	 icount=0;
	 k=u;
	 k=3*k+c;
	 while (k!=(4*s[i])) {
	    if ((k&3)==0) {
	       icount=icount+1;
	       k=k/4;
	       }
	    else
	       k=k/2;
	    k=3*k+c;
	    }
//
	 lcount=1;
	 k=s[i];
	 while ((k&1)==0) {
	    lcount=lcount+1;
	    k=k/2;
	    }
	 delta=odds+icount-lcount;
	 if (jump==1) {
	    delta=delta-1;
	    jmpsum=jmpsum+1;
	    }
	 if (jump==2) {
	    delta=delta-jmpcnt;
	    jmpsum=jmpsum+jmpcnt;
	    }
	 if ((delta<-10)&&(wflag==0)) {
	    printf("warning: delta less than -10 \n");
	    printf("lcount=%d, icount=%d, delta=%d \n",lcount,icount,odds+icount-lcount);
	    fprintf(Outfp,"warning: delta less than -2 \n");
	    fprintf(Outfp,"lcount=%d, icount=%d, delta=%d \n",lcount,icount,odds+icount-lcount);
	    }
	 delta=delta+offset;
	 if (delta<0) {
	    printf("error: offset not big enough \n");
	    goto zskip;
	    }
	 if (delta>99) {
	    printf("error: histogram array not big enough \n");
	    goto zskip;
	    }
	 histoi[delta]=histoi[delta]+1;
//
	 delta=(int)m-lcount+icount;
	 if (jump==1)
	    delta=delta-1;
	 if (jump==2)
	    delta=delta-jmpcnt;
	 delta=delta+offset;
	 if (delta<0) {
	    printf("error: offset not big enough \n");
	    goto zskip;
	    }
	 if (delta>99) {
	    printf("error: histogram array not big enough \n");
	    goto zskip;
	    }
	 histox[delta]=histox[delta]+1;
//
	 if (((c==hflag1)&&(cflag[index+i]>=indmin)&&(cflag[index+i]<=indmax))||(hflag1==0)) {
	    delta=(int)m-lcount;
	    delta=delta+offset;
	    if (delta<0) {
	       printf("error: offset not big enough \n");
	       goto zskip;
	       }
	    if (delta>99) {
	       printf("error: histogram array not big enough \n");
	       goto zskip;
	       }
	    histoy[delta]=histoy[delta]+1;
	    }
//
	 delta=icount;
	 if (jump==1)
	    delta=delta-1;
	 if (jump==2)
	    delta=delta-jmpcnt;
	 delta=delta+offset;
	 if (delta<0) {
	    printf("error: offset not big enough \n");
	    goto zskip;
	    }
	 if (delta>99) {
	    printf("error: histogram array not big enough \n");
	    goto zskip;
	    }
	 histoz[delta]=histoz[delta]+1;
//
	 delta=odds-lcount;
	 delta=delta+offset;
	 if (delta<0) {
	    printf("error: offset not big enough \n");
	    goto zskip;
	    }
	 if (delta>99) {
	    printf("error: histogram array not big enough \n");
	    goto zskip;
	    }
	 histor[delta]=histor[delta]+1;
	 }
//
      k=(int)odds-(int)m;
      if (wflag==0) {
	 printf("c=%d, s=%d, o=%d, t=%d, u=%d, e=%d, o=%d, e=%d, o=%d, jump=%d, j=%d, g=%d, d=%d \n",c,s[i],order,t,u,evens,odds,levens,lodds,jump,m,lcount,k);
	 fprintf(Outfp,"c=%d, s=%d, o=%d, t=%d, u=%d, e=%d, o=%d, e=%d, o=%d, jump=%d, j=%d, g=%d, d=%d \n",c,s[i],order,t,u,evens,odds,levens,lodds,jump,m,lcount,k);
	 if (evens<odds) {
	    printf("warning: even count less than odd count \n");
	    fprintf(Outfp,"warning: even count less than odd count \n");
	    }
	 }
//
// continued-fraction convergents
//
      for (tempi=0; tempi<27; tempi++) {
	 if ((conv[2*tempi]==(levens+lodds))&&(conv[2*tempi+1]==lodds)) {
	    if ((concov[3*tempi]==0)||(concov[3*tempi]==(unsigned int)c))
	       concov[3*tempi]=c;
	    else {
	       if ((concov[3*tempi+1]==0)||(concov[3*tempi+1]==(unsigned int)c))
		  concov[3*tempi+1]=c;
	       else
		  concov[3*tempi+2]=c;
	       }
	    if ((4*s[i])!=olds) {
	       delta=(int)m-lcount;
	       delta=delta+offset4;
	       if (delta<0) {
		  printf("array not big enough \n");
		  goto zskip;
		  }
	       if (delta>29) {
		  printf("array not big enough \n");
		  goto zskip;
		  }
	       histot[delta]=histot[delta]+1;
	       }
	    }
	 if (conv[2*tempi+1]>lodds)
	    break;
	 }
//
      for (tempi=0; tempi<27; tempi++) {
	 if ((conv[2*tempi+1]==levens)&&(conv[2*tempi+1]==lodds)) {
	    if ((concove[3*tempi]==0)||(concove[3*tempi]==(unsigned int)c))
	       concove[3*tempi]=c;
	    else {
	       if ((concove[3*tempi+1]==0)||(concove[3*tempi+1]==(unsigned int)c))
		  concove[3*tempi+1]=c;
	       else
		  concove[3*tempi+2]=c;
	       }
	    if ((4*s[i])!=olds) {
	       delta=(int)m-lcount;
	       delta=delta+offset4;
	       if (delta<0) {
		  printf("array not big enough, delta=%d \n",delta);
		  goto zskip;
		  }
	       if (delta>29) {
		  printf("array not big enough, delta=%d \n",delta);
		  goto zskip;
		  }
	       histoa[delta]=histoa[delta]+1;
	       }
	    }
	 if (conv[2*tempi+1]>lodds)
	    break;
	 }
//
// total odds, evens, and m values
//
      if ((4*s[i])!=olds) {
	 oddsum=oddsum+odds;
	 evensum=evensum+lcount;
	 jsum=jsum+m;
	 hcount=hcount+icount;
	 patcnt=patcnt+1;
	 }
//
// compute sum of reciprocals
//
      if ((4*s[i])!=olds) {
	 temp=t;
	 if (temp<0)
	    temp=-temp;
	 sumrec=sumrec+(1.0/(double)temp);
	 temp=u;
	 if (temp<0)
	    temp=-temp;
	 sumrec=sumrec+(1.0/(double)temp);
	 primary=primary+1;
	 }
//
// check chain (u values)
//
      if ((4*s[i])!=olds) {
	 temp=u;
	 if (temp<0)
	    temp=-temp;
	 if (oldchn<(double)temp) {
	    if (wflag!=2) {
	       printf("error: bad chain, c=%d \n",c);
	       printf("chain=%e, u=%d, old u=%d, jump=%d, s=%d \n",oldchn,u,oldu,jump,s[i]);
	       fprintf(Outfp,"error: bad chain, c=%d \n",c);
	       fprintf(Outfp,"chain=%e, u=%d, old u=%d, jump=%d, s=%d \n",oldchn,u,oldu,jump,s[i]);
	       }
	    badcntu=badcntu+1;
	    }
	 temp=u+c;
	 if (temp<0)
	    temp=-temp;
	 oldchn=(double)temp;
	 oldchn=rat*log(oldchn);
	 oldchn=exp(oldchn);
	 oldu=u;
	 }
//
// check j values for no-jumps
//
      if (jump==0) {
	 if ((m>10)&&(wflag==0)) {
	    printf("warning: no-jump with j>10 \n");
	    fprintf(Outfp,"warning: no-jump with j>10 \n");
	    }
	 if (((c==hflag)&&(cflag[index+i]>=indmin)&&(cflag[index+i]<=indmax))||(hflag==0)) {
	    if ((4*s[i])!=olds) {
	       if (m>19) {
		  printf("histogram array not big enough \n");
		  goto zskip;
		  }
	       histon[m]=histon[m]+1;
	       }
	    }
	 }
//
// check j values for multiple-jumps
//
      if (jump==2) {
	 if ((m>3)&&(wflag==0)) {
	    printf("warning: multiple-jump with j>3 \n");
	    fprintf(Outfp,"warning: multiple-jump with j>3 \n");
	    }
	 if ((4*s[i])!=olds) {
	    if (m>9) {
	       printf("histogram array not big enough \n");
	       goto zskip;
	       }
	    histom[m]=histom[m]+1;
	    }
	 }
//
// histogram k values
//
      if (((c==hflag)&&(cflag[index+i]>=indmin)&&(cflag[index+i]<=indmax))||(hflag==0)) {
	 if ((jump==1)&&((4*s[i])!=olds)) {
	    delta=k+offset;
	    if (delta<0) {
	       printf("error: offset not big enough \n");
	       goto zskip;
	       }
	    if (delta>99) {
	       printf("error: histogram array not big enough \n");
	       goto zskip;
	       }
	    histoj[delta]=histoj[delta]+1;
	    }
	 }
//
// histogram evens minus odds
//
      if (jump==1) {
	 delta=(int)evens-(int)odds;
	 delta=delta+offset;
	 if (delta<0) {
	    printf("error: offset not big enough \n");
	    goto zskip;
	    }
	 if (delta>99) {
	    printf("error: histogram array not big enough \n");
	    goto zskip;
	    }
	 histo[delta]=histo[delta]+1;
	 }
//
// find minimum t or u
//
      if ((4*s[i])!=olds) {
	 temp=t;
	 if (temp<0)
	    temp=-temp;
	 if (temp<glomin)
	    glomin=temp;
	 temp=u;
	 if (temp<0)
	    temp=-temp;
	 if (temp<glomin)
	    glomin=temp;
	 a=a+1;
	 }
//
// find local maximum and minimum
//
      k=u;
      locmin=k;
      if (locmin<0)
	 locmin=-locmin;
      locmax=locmin;
      lastodd=locmax;
      k=3*k+c;
      while ((k&7)!=0) {
	 while ((k&1)==0) {
	    k=k/2;
	    }
	 delta=k;
	 if (delta<0)
	    delta=-delta;
	 if (delta<locmin)
	    locmin=delta;
	 if (delta>locmax)
	    locmax=delta;
	 lastodd=delta;
	 k=3*k+c;
	 }
      if ((4*s[i])!=olds) {	   // check if primary
	 if ((lastodd!=locmax)&&(jump==2)) {
	    printf("error: no-jump with local maximum at attachment point \n");
	    printf("locmin=%d, locmax=%d, lastodd=%d \n",locmin,locmax,lastodd);
	    fprintf(Outfp,"error: no-jump with local maximum at attachment point \n");
	    goto zskip;
	    }
	 if (lastodd!=locmax) {
	    if (jump==0)
	       county=county+1;
	    if (jump==1) {
	       countn=countn+1;
	       if (((c==hflag)&&(cflag[index+i]>=indmin)&&(cflag[index+i]<=indmax))||(hflag==0)) {
		  delta=(int)odds-(int)m;
		  delta=delta+(int)offset;
		  if (delta<0) {
		     printf("array not big enough \n");
		     goto zskip;
		     }
		  if (delta>99) {
		     printf("array not big enough \n");
		     goto zskip;
		     }
		  newhis[delta]=newhis[delta]+1;
		  }
	       }
	    if (jump==3)
	       countx=countx+1;
	    }
	 }
      if ((4*s[i])!=olds) {
	 if (locmax>glomax) {
	    glomax=locmax;
	    usave=u;
	    savjmp=jump;
	    }
	 }
//
// check local minimum
//
      if ((jump==1)&&((4*s[i])!=olds)) {
	 mincnt=0;
	 k=u;
	 delta=k;
	 if (delta<0)
	    delta=-delta;
	 if (delta==locmin) {
	    hismin[0]=hismin[0]+1;
	    goto yskip;
	    }
	 while (delta!=locmin) {
	    k=3*k+c;
	    if ((k&3)!=0) {
	       hismin[9]=hismin[9]+1;
	       if (bypass==0)
		  goto pskip;
	       else
		  goto yskip;
	       }
	    k=k/4;
	    delta=k;
	    if (delta<0)
	       delta=-delta;
	    mincnt=mincnt+1;
	    }
	 if (mincnt>8) {
	    printf("error: array not big enough \n");
	    goto zskip;
	    }
	 hismin[mincnt]=hismin[mincnt]+1;
pskip:	 if (((c==hflag)&&(cflag[index+i]>=indmin)&&(cflag[index+i]<=indmax))||(hflag==0)) {
	    delta=(int)odds-(int)m;
	    delta=delta+offset;
	    if (delta<0) {
	       printf("array not big enough \n");
	       goto zskip;
	       }
	    if (delta>99) {
	       printf("array not big enough \n");
	       goto zskip;
	       }
	    oldhis[delta]=oldhis[delta]+1;
	    }
	 }
//
// check multiple-jumps
//
yskip:
      if ((jump==2)&&((4*s[i])!=olds)) {
	 k=u;
	 k=3*k+c;
	 while ((k&7)!=0) {
	    if ((k&3)==0) {
	       printf("error: not one jump from u \n");
	       fprintf(Outfp,"error: not one jump from u \n");
	       goto zskip;
	       }
	    k=k/2;
	    k=3*k+c;
	    }
	 }
//
// check if primary multiple-jumps are preceded by no-jumps
// Note:  Only last primary multiple-jump checked.
//
      if ((jump==2)&&((4*s[i])!=olds)) {
	 k=u*2;
	 if ((((k-c)/3)*3)!=(k-c))
	    k=k*2;
	 tmps=k;
	 mflag=1;
	 }
//
// compute domain
//
      if ((4*s[i])!=olds) {
	 k=t;
	 if (k<0)
	    k=-k;
	 sumtu=sumtu+k;
	 stu[2*total]=k;
	 k=u;
	 if (k<0)
	    k=-k;
	 sumtu=sumtu+k;
	 stu[2*total+1]=k;
	 total=total+1;
	 if (total>1000) {
	    printf("output array too small \n");
	    goto zskip;
	    }
	 }
//
// check for new cycle
//
      if ((cflag[index+i]!=cflag[index+i+1])||(i==(iters-1))) {
	 lambda=(double)sumtu/(double)(total*2);
	 dmin=1000000.0;
	 dmax=-1000000.0;
	 for (g=0; g<total*2; g++) {
	    d=-log((double)stu[g]/lambda)/lambda;
	    if (d<dmin)
	       dmin=d;
	    if (d>dmax)
	       dmax=d;
	    }
	 del=dmax-dmin;
	 if (del>maxdel) {
	    maxdel=del;
	    cmax=c;
	    }
	 if (del<mindel) {
	    mindel=del;
	    cmin=c;
	    }
	 if (wflag==0) {
	    printf("lambda=%e, min=%e, max=%e, del=%e \n",lambda,dmin,dmax,del);
	    fprintf(Outfp,"lambda=%e, min=%e, max=%e, del=%e \n",lambda,dmin,dmax,del);
	    }
	 sumtu=0;
	 total=0;
	 olds=0;
	 cyccnt=cyccnt+1;
//
	 sumrec=sumrec*(double)c;
	 tempf=(double)(levens+lodds)*log(2)-(double)(lodds)*log(3);
	 if (wflag==1) {
	    printf("c=%d, e=%d, o=%d, sum=%e, tempf=%e, osum=%d, esum=%d, jsum=%d, hsum=%d, jmpsum=%d \n",c,levens,lodds,sumrec,tempf,oddsum,evensum,jsum,hcount,jmpsum);
	    fprintf(Outfp,"c=%d, e=%d, o=%d, sum=%e, tempf=%e, osum=%d, esum=%d, jsum=%d, hsum=%d, jmpsum=%d \n",c,levens,lodds,sumrec,tempf,oddsum,evensum,jsum,hcount,jmpsum);
	    }
	 if (tempf<0.0)
	    tempf=-tempf;
	 if (tempf>(sumrec*3.0)) {
	    printf("error: delta greater than sum of reciprocals \n");
	    fprintf(Outfp,"error: delta greater than sum of reciprocals \n");
	    goto zskip;
	    }
	 sumrec=0.0;
//
	 if (savchain<oldt) {
	    if (wflag!=2) {
	       printf("error: bad chain (wrap-around), c=%d \n",c);
	       printf("chain=%e, oldt=%d, t=%d, jump=%d, count=%d, s=%d \n",savchain,oldt,savet,savjump,savcnt,s[i]);
	       fprintf(Outfp,"error: bad chain (wrap-around), c=%d \n",c);
	       fprintf(Outfp,"chain=%e, oldt=%d, t=%d, jump=%d, count=%d, s=%d \n",savchain,oldt,savet,savjump,savcnt,s[i]);
	       }
	    badcnt=badcnt+1;
	    }
	 oldt=0;
	 lastt=0;
	 lalat=1000000000;
	 firstt=1;
	 oldchn=1000000000.0;
	 oldu=0;
//
	 delta=oddsum-jmpsum+hcount-evensum+offset1;
	 if (delta<0) {
	    printf("error: offset not big enough, delta=%d \n",delta);
	    goto zskip;
	    }
	 if (delta>99) {
	    printf("error: histogram array not big enough \n");
	    goto zskip;
	    }
	 histoh[delta]=histoh[delta]+1;
	 if (wflag==0) {
	    if ((oddsum+hcount+2)<evensum) {
	       printf("warning: oddsum=%d, hcount=%d, evensum=%d \n",oddsum,hcount,evensum);
	       fprintf(Outfp,"warning: oddsum=%d, hcount=%d, evensum=%d \n",oddsum,hcount,evensum);
	       }
	    }
//
	 delta=hcount-jmpsum+offset;
	 if (delta<0) {
	    printf("error: offset not big enough, delta=%d \n",delta);
	    goto zskip;
	    }
	 if (delta>99) {
	    printf("error: histogram array not big enough \n");
	    goto zskip;
	    }
	 histow[delta]=histow[delta]+1;
//
	 delta=jsum-evensum+offset2;
	 if (delta<0) {
	    printf("error: offset not big enough, jsum=%d, delta=%d \n",jsum,delta);
	    goto zskip;
	    }
	 if (delta>99) {
	    printf("error: histogram array not big enough \n");
	    goto zskip;
	    }
	 histov[delta]=histov[delta]+1;
//
	 for (tempi=0; tempi<27; tempi++) {
	    if ((conv[2*tempi]==(levens+lodds))&&(conv[2*tempi+1]==lodds)) {
	       delta=jsum-evensum+offset4;
	       if (delta<0) {
		  printf("array not big enough \n");
		  goto zskip;
		  }
	       if (delta>29) {
		  printf("array not big enough \n");
		  goto zskip;
		  }
	       histou[delta]=histou[delta]+1;
	       cyccntu=cyccntu+1;
	       if (((3.0*log(c))<patcnt)&&(c!=1)) {
		  printf("not enough attachment points, c=%d, count=%d \n",c,attcnt);
		  goto zskip;
		  }
	       }
	    if (conv[2*tempi+1]>lodds)
	       break;
	    }
//
	 for (tempi=0; tempi<27; tempi++) {
	    if ((conv[2*tempi+1]==levens)&&(conv[2*tempi+1]==lodds)) {
	       delta=jsum-evensum;
	       delta=delta+offset5;
	       if (delta<0) {
		  printf("array not big enough, delta b=%d \n",delta);
		  goto zskip;
		  }
	       if (delta>29) {
		  printf("array not big enough, delta b=%d \n",delta);
		  goto zskip;
		  }
	       histob[delta]=histob[delta]+1;
	       cyccntb=cyccntb+1;
	       if ((3.0*log(c))<patcnt) {
		  printf("not enough attachment points, c=%d, count=%d \n",c,attcnt);
		  goto zskip;
		  }
	       }
	    if (conv[2*tempi+1]>lodds)
	       break;
	    }
//
	 delta=oddsum-evensum+offset1;
	 if (delta<0) {
	    printf("error: offset not big enough, jsum=%d, delta=%d \n",jsum,delta);
	    goto zskip;
	    }
	 if (delta>99) {
	    printf("error: histogram array not big enough \n");
	    goto zskip;
	    }
	 histos[delta]=histos[delta]+1;
//
// check limit
//
	 if (oddsum>jsum) {
	    tempi=oddsum-jsum;
	    tempf=1.0;
	    for (j=0; j<tempi; j++)
	       tempf=tempf*2.0;
	    tempf=(rat-1.0)*log(tempf);
	    tempf=exp(tempf);
	    tempg=1.0;
	    for (j=0; j<(unsigned int)evensum; j++)
	       tempg=tempg*2.0;
	    tempf=tempf/tempg;
	    j=(unsigned int)(tempf*10.0);
	    histoc[j]=histoc[j]+1;
	    if (tempf>1.0) {
	       printf("warning: tempf=%e, tempg=%e, oddsum=%d, jsum=%d, evensum=%d \n",tempf,tempg,oddsum,jsum,evensum);
	       compcnt=compcnt+1;
	       if (tempf>maxcmp)
		  maxcmp=tempf;
	       }
	    }
//
	 if (hcount!=hsum) {
	    printf("error: mis-matched sums \n");
	    goto zskip;
	    }
	 oddsum=0;
	 evensum=0;
	 jmpsum=0;
	 jsum=0;
	 hcount=0;
//
//  check primary multiple jumps
//
	 if (mflag!=0) {
	    for (j=0; j<attcnt; j++) {
	       if (s[j+savind]==tmps) {
		  if ((jumps[j+savind]!=0)&&(jumps[j+savind]!=3)) {
		     printf("error: one-jump not found \n");
		     goto zskip;
		     }
		  goto vskip;
		  }
	       }
	    printf("error: no match \n");
	    goto zskip;
	    }
vskip:
//
//  check number of primary attachment points
//
	 if (((3.0*log(c))<patcnt)&&(c!=1)) {
	    if (wflag==0) {
	       printf("too few primary attachment points, c=%d, count=%d \n",c,patcnt);
	       fprintf(Outfp,"too few primary attachment points, c=%d, count=%d \n",c,patcnt);
	       }
	    if (levens==lodds)
	       equcnt=equcnt+1;
	    }
	 delta=(int)(3.0*log(c))-patcnt+offset6;
	 if (delta<0) {
	    printf("array not big enough (histod): delta=%d \n",delta);
	    goto zskip;
	    }
	 if (delta>399) {
	    printf("array not big enough (histod): delta=%d \n",delta);
	    goto zskip;
	    }
	 histod[delta]=histod[delta]+1;
//
	 attcnt=0;
	 patcnt=0;
	 mflag=0;
	 savind=i+1;
//
// compute inequality
//
	 if (infin==0) {
	    bp=1.0+(double)c/(double)glomin;
	    bm=1.0-(double)c/(double)glomin;
	    if (bm<0.0)
	       bm=-bm;
	    }
	 else {
	    bp=1.0;
	    bm=1.0;
	    }
	 tempf=exp((double)a*log(rat))-1.0;   // d^a-1
	 tempg=(double)a/tempf; 	      // a/(d^a-1)
	 tempg=ratdel-tempg;		      // d/(d-1) - a/(d^a-1)
	 cap=exp(tempg*log(bp));	      // ca=b^(d/d-1) - a/(d^a-1))
	 cam=exp(tempg*log(bm));
	 cap=3.0*(double)c*(double)a*cap;     // 3*c*a*ca
	 cam=3.0*(double)c*(double)a*cam;
	 tempg=(rat-1.0)/tempf; 	      // (d-1)/(d^a-1)
	 tempg=-tempg*(double)lodds;	      // -(d-1)/(d^a-1)*K
	 tempg=exp(tempg*log(2.0));	      // 2^(-(d-1)/(d^a-1)*K)
	 cap=cap*tempg; 		      // 3*c*a*ca*2^(-(d-1)/(d^a-1)*K)
	 cam=cam*tempg;
	 tempf=(double)(levens+lodds)*log(2)-(double)lodds*log(3);
	 if (tempf<0.0)
	    tempf=-tempf;
	 if ((tempf>cap)||(tempf>cam)) {
	    printf("error: c=%d, e=%d, o=%d, a=%d, cap=%e, cam=%e, tempf=%e \n",c,levens,lodds,a,cap,cam,tempf);
	    fprintf(Outfp,"error: c=%d, e=%d, o=%d, a=%d, cap=%e, cam=%e, tempf=%e \n",c,levens,lodds,a,cap,cam,tempf);
	    badcomp=badcomp+1;
	    }
	 glomin=1000000000;
	 a=0;
//
// check global maximum
//
	 k=usave;
	 locmax=k;
	 if (locmax<0)
	    locmax=-locmax;
	 lastodd=locmax;
	 k=3*k+c;
	 while ((k&7)!=0) {
	    while ((k&1)==0) {
	       k=k/2;
	       }
	    delta=k;
	    if (delta<0)
	       delta=-delta;
	    if (delta>locmax) {
	       locmax=delta;
	       usave=k;
	       }
	    lastodd=delta;
	    k=3*k+c;
	    }
	 if (lastodd!=locmax) {
	    k=usave;
	    k=3*k+c;
	    while ((k&7)!=0) {
	       k=k/2;
	       if ((k&1)==0) {
		  k=k/2;
		  delta=k;
		  if (delta<0)
		     delta=-delta;
		  if (delta==lastodd) {
		     if (savjmp==0)
			goto wskip;
		     else {
			printf("error: not a no-jump attachment point \n");
			fprintf(Outfp,"error: not a no-jump attachment point \n");
			goto zskip;
			}
		     }
		  }
	       k=3*k+c;
	       }
	    if (savjmp!=1) {
	       printf("error: not a one-jump attachment point \n");
	       fprintf(Outfp,"error: not a one-jump attachment point \n");
	       goto zskip;
	       }
wskip:	    delta=0;
	    }
	 glomax=0;
	 }
      else
	 olds=s[i];
      }
   index=index+iters;
   if (wflag==0) {
      printf("\n");
      fprintf(Outfp,"\n");
      }
   }
printf("maxdel=%e, c=%d, mindel=%e, c=%d \n",maxdel,cmax,mindel,cmin);
fprintf(Outfp,"maxdel=%e, c=%d, mindel=%e, c=%d \n",maxdel,cmax,mindel,cmin);
printf("\n");
fprintf(Outfp,"\n");
//
// output histogram of evens minus odds
//
printf("histogram of number of evens minus odds in extended sequences \n");
fprintf(Outfp,"histogram of number evens minus odds in extended sequences \n");
flag=99;
for (i=99; i>0; i--) {
   if (histo[i]==0)
      flag=flag-1;
   else
      break;
   }
first=0;
for (i=0; i<=(int)flag; i++) {
   if ((histo[i]==0)&&(first==0))
      continue;
   first=1;
   fprintf(Outfp,"i=%d, h[i]=%d \n",i-offset,histo[i]);
   printf("i=%d, h[i]=%d \n",i-offset,histo[i]);
   }
//
// output histogram of k values (for primary one-jump attachment points)
//
printf("\n");
fprintf(Outfp,"\n");
printf("histogram of k values for primary one-jump attachment points \n");
fprintf(Outfp,"histogram of k values for primary one-jump attachment points \n");
printf("c=%d \n",hflag);
fprintf(Outfp,"c=%d \n",hflag);
flag=99;
for (i=99; i>0; i--) {
   if (histoj[i]==0)
      flag=flag-1;
   else
      break;
   }
first=0;
for (i=0; i<=(int)flag; i++) {
   if ((histoj[i]==0)&&(first==0))
      continue;
   first=1;
   fprintf(Outfp,"i=%d, h[i]=%d \n",i-offset,histoj[i]);
   printf("i=%d, h[i]=%d \n",i-offset,histoj[i]);
   }
//
// output histogram of hops
//
printf("\n");
fprintf(Outfp,"\n");
printf("number of hops before local minimum is reached \n");
fprintf(Outfp,"number of hops before local minimum is reached \n");
for (i=0; i<10; i++) {
   printf("i=%d, h=%d \n",i,hismin[i]);
   fprintf(Outfp,"i=%d, h=%d \n",i,hismin[i]);
   }
//
// output histogram of j values for primary no-jumps
//
printf("\n");
fprintf(Outfp,"\n");
printf("j values for primary no-jumps \n");
fprintf(Outfp,"j values for primary no-jumps \n");
for (i=0; i<20; i++) {
   printf("i=%d, h=%d \n",i,histon[i]);
   fprintf(Outfp,"i=%d, h=%d \n",i,histon[i]);
   }
//
//
// output histogram of j values for primary multiple-jumps
//
printf("\n");
fprintf(Outfp,"\n");
printf("j values for primary multiple-jumps \n");
fprintf(Outfp,"j values for primary multiple-jumps \n");
for (i=0; i<10; i++) {
   printf("i=%d, h=%d \n",i,histom[i]);
   fprintf(Outfp,"i=%d, h=%d \n",i,histom[i]);
   }
//
// last odd counts
//
printf("\n");
fprintf(Outfp,"\n");
printf("no-jump count=%d, one-jump count=%d, jumped-over count=%d \n",county,countn,countx);
fprintf(Outfp,"no-jump count=%d, one-jump count=%d, jumped-over count=%d \n",county,countn,countx);
//
// output histogram of k values (for primary one-jump attachment points)
//
printf("primary one-jump attachment points, last odd not equal to locmax \n");
fprintf(Outfp,"primary one-jump attachment points, last odd not equal to locmax \n");
printf("c=%d \n",hflag);
fprintf(Outfp,"c=%d \n",hflag);
flag=99;
for (i=99; i>0; i--) {
   if (newhis[i]==0)
      flag=flag-1;
   else
      break;
   }
if (flag==0)
   goto nskip;
first=0;
for (i=0; i<=(int)flag; i++) {
   if ((newhis[i]==0)&&(first==0))
      continue;
   first=1;
   printf("i=%d, h[i]=%d \n",i-offset,newhis[i]);
   fprintf(Outfp,"i=%d, h[i]=%d \n",i-offset,newhis[i]);
   }
//
// output histogram of k values (for primary one-jump attachment points)
//
nskip:
printf("\n");
fprintf(Outfp,"\n");
printf("primary one-jump attachment points, u not equal to locmin \n");
fprintf(Outfp,"primary one-jump attachment points, u not equal to locmin \n");
printf("c=%d \n",hflag);
fprintf(Outfp,"c=%d \n",hflag);
flag=99;
for (i=99; i>0; i--) {
   if (oldhis[i]==0)
      flag=flag-1;
   else
      break;
   }
first=0;
for (i=0; i<=(int)flag; i++) {
   if ((oldhis[i]==0)&&(first==0))
      continue;
   first=1;
   fprintf(Outfp,"i=%d, h[i]=%d \n",i-offset,oldhis[i]);
   printf("i=%d, h[i]=%d \n",i-offset,oldhis[i]);
   }
printf("\n");
fprintf(Outfp,"\n");
//
// output histogram of odds minus jumps plus hops minus evens
//
printf("sum of odds minus number of jumps plus number of hops minus sum of evens (global) \n");
fprintf(Outfp,"sum of odds minus number of jumps plus number of hops minus sum of evens (global, histoh) \n");
flag=99;
for (i=99; i>0; i--) {
   if (histoh[i]==0)
      flag=flag-1;
   else
      break;
   }
first=0;
for (i=0; i<=(int)flag; i++) {
   if ((histoh[i]==0)&&(first==0))
      continue;
   first=1;
   fprintf(Outfp,"i=%d, h[i]=%d, \n",i-offset1,histoh[i]);
   printf("i=%d, h[i]=%d \n",i-offset1,histoh[i]);
   }
printf("\n");
fprintf(Outfp,"\n");
//
// output histogram of odds minus jumps plus hops minus evens
//
printf("number of odds minus number of jumps plus number of hops minus number of evens (local) \n");
fprintf(Outfp,"number of odds minus number of jumps plus number of hops minus number of evens (local, histoi) \n");
flag=99;
for (i=99; i>0; i--) {
   if (histoi[i]==0)
      flag=flag-1;
   else
      break;
   }
first=0;
for (i=0; i<=(int)flag; i++) {
   if ((histoi[i]==0)&&(first==0))
      continue;
   first=1;
   fprintf(Outfp,"i=%d, h[i]=%d, \n",i-offset,histoi[i]);
   printf("i=%d, h[i]=%d \n",i-offset,histoi[i]);
   }
printf("\n");
fprintf(Outfp,"\n");
//
// output histogram of j minus number of evens plus number of hops minus number of jumps
//
printf("j minus number of evens plus number of hops minus number of jumps (local) \n");
fprintf(Outfp,"j minus number of evens plus number of hops minus number of jumps (local, histox) \n");
flag=99;
for (i=99; i>0; i--) {
   if (histox[i]==0)
      flag=flag-1;
   else
      break;
   }
first=0;
for (i=0; i<=(int)flag; i++) {
   if ((histox[i]==0)&&(first==0))
      continue;
   first=1;
   fprintf(Outfp,"i=%d, h[i]=%d, \n",i-offset,histox[i]);
   printf("i=%d, h[i]=%d \n",i-offset,histox[i]);
   }
printf("\n");
fprintf(Outfp,"\n");
//
// output histogram of j minus number of evens (local)
//
printf("j minus number of evens (local) \n");
fprintf(Outfp,"j minus number of evens (local, histoy) \n");
flag=99;
for (i=99; i>0; i--) {
   if (histoy[i]==0)
      flag=flag-1;
   else
      break;
   }
first=0;
sum=0;
tempi=0;
for (i=0; i<=(int)flag; i++) {
   if ((histoy[i]==0)&&(first==0))
      continue;
   first=1;
   fprintf(Outfp,"i=%d, h[i]=%d, \n",i-offset,histoy[i]);
   printf("i=%d, h[i]=%d \n",i-offset,histoy[i]);
   sum=sum+histoy[i]*(i-offset);
   tempi=tempi+histoy[i];
   }
mean=(double)sum/(double)tempi;
first=0;
var=0.0;
for (i=0; i<=(int)flag; i++) {
   if ((histoy[i]==0)&&(first==0))
      continue;
   first=1;
   tempf=(double)i-(double)offset-mean;
   var=var+tempf*tempf*(double)histoy[i];
   }
var=var/(double)(tempi-1);
std=sqrt(var);
printf("mean=%e, standard deviation=%e \n",mean,std);
fprintf(Outfp,"mean=%e, standard deviation=%e \n",mean,std);
printf("\n");
fprintf(Outfp,"\n");
//
// output histogram of j minus number of evens (global)
//
printf("j minus number of evens (global) \n");
fprintf(Outfp,"j minus number of evens (global, histov) \n");
flag=99;
for (i=99; i>0; i--) {
   if (histov[i]==0)
      flag=flag-1;
   else
      break;
   }
first=0;
for (i=0; i<=(int)flag; i++) {
   if ((histov[i]==0)&&(first==0))
      continue;
   first=1;
   fprintf(Outfp,"i=%d, h[i]=%d, \n",i-offset2,histov[i]);
   printf("i=%d, h[i]=%d \n",i-offset2,histov[i]);
   }
printf("\n");
fprintf(Outfp,"\n");
//
// output histogram of number of hops minus number of jumps (local)
//
printf("number of hops minus number of jumps (local) \n");
fprintf(Outfp,"number of hops minus number of jumps (local, histoz) \n");
flag=99;
for (i=99; i>0; i--) {
   if (histoz[i]==0)
      flag=flag-1;
   else
      break;
   }
first=0;
for (i=0; i<=(int)flag; i++) {
   if ((histoz[i]==0)&&(first==0))
      continue;
   first=1;
   fprintf(Outfp,"i=%d, h[i]=%d, \n",i-offset,histoz[i]);
   printf("i=%d, h[i]=%d \n",i-offset,histoz[i]);
   }
printf("\n");
fprintf(Outfp,"\n");
//
// output histogram of number of hops minus number of jumps (global)
//
printf("number of hops minus number of jumps (global) \n");
fprintf(Outfp,"number of hops minus number of jumps (global, histow) \n");
flag=99;
for (i=99; i>0; i--) {
   if (histow[i]==0)
      flag=flag-1;
   else
      break;
   }
first=0;
for (i=0; i<=(int)flag; i++) {
   if ((histow[i]==0)&&(first==0))
      continue;
   first=1;
   fprintf(Outfp,"i=%d, h[i]=%d, \n",i-offset,histow[i]);
   printf("i=%d, h[i]=%d \n",i-offset,histow[i]);
   }
printf("\n");
fprintf(Outfp,"\n");
//
// output histogram of odds minus evens (global)
//
printf("sum of odds minus sum of evens (global) \n");
fprintf(Outfp,"sum of odds minus sum of evens (global, histos) \n");
flag=99;
for (i=99; i>0; i--) {
   if (histos[i]==0)
      flag=flag-1;
   else
      break;
   }
first=0;
for (i=0; i<=(int)flag; i++) {
   if ((histos[i]==0)&&(first==0))
      continue;
   first=1;
   fprintf(Outfp,"i=%d, h[i]=%d, \n",i-offset1,histos[i]);
   printf("i=%d, h[i]=%d \n",i-offset1,histos[i]);
   }
//
// output histogram of odds minus evens (local)
//
printf("\n");
fprintf(Outfp,"\n");
printf("odds minus evens (local) \n");
fprintf(Outfp,"odds minus evens (local, histor) \n");
flag=99;
for (i=99; i>0; i--) {
   if (histor[i]==0)
      flag=flag-1;
   else
      break;
   }
first=0;
for (i=0; i<=(int)flag; i++) {
   if ((histor[i]==0)&&(first==0))
      continue;
   first=1;
   fprintf(Outfp,"i=%d, h[i]=%d, \n",i-offset,histor[i]);
   printf("i=%d, h[i]=%d \n",i-offset,histor[i]);
   }
//
// output histogram of j minus evens (continued-fraction convergents)
//
printf("\n");
fprintf(Outfp,"\n");
printf("j minus evens (convergents) \n");
fprintf(Outfp,"j minus evens (convergents, local, histot) \n");
flag=29;
for (i=29; i>0; i--) {
   if (histot[i]==0)
      flag=flag-1;
   else
      break;
   }
sum=0;
tempi=0;
first=0;
for (i=0; i<=(int)flag; i++) {
   if ((histot[i]==0)&&(first==0))
      continue;
   first=1;
   fprintf(Outfp,"i=%d, h[i]=%d, \n",i-offset4,histot[i]);
   printf("i=%d, h[i]=%d \n",i-offset4,histot[i]);
   sum=sum+histot[i]*(i-offset4);
   tempi=tempi+histot[i];
   }
mean=(double)sum/(double)tempi;
printf("n=%d, sum=%d, mean=%e \n",tempi,sum,mean);
fprintf(Outfp,"n=%d, sum=%d, mean=%e \n",tempi,sum,mean);
//
// output histogram of j minus evens (continued-fraction convergents)
//
printf("\n");
fprintf(Outfp,"\n");
printf("j minus evens (convergents, global) \n");
fprintf(Outfp,"j minus evens (convergents, global, histou) \n");
flag=29;
for (i=29; i>0; i--) {
   if (histou[i]==0)
      flag=flag-1;
   else
      break;
   }
first=0;
for (i=0; i<=(int)flag; i++) {
   if ((histou[i]==0)&&(first==0))
      continue;
   first=1;
   fprintf(Outfp,"i=%d, h[i]=%d, \n",i-offset4,histou[i]);
   printf("i=%d, h[i]=%d \n",i-offset4,histou[i]);
   }
//
// output histogram of j minus evens (continued-fraction convergents)
//
printf("\n");
fprintf(Outfp,"\n");
printf("j minus evens (convergents, evens equal odds) \n");
fprintf(Outfp,"j minus evens (convergents, evens equal odds, local, histoa) \n");
flag=29;
for (i=29; i>0; i--) {
   if (histoa[i]==0)
      flag=flag-1;
   else
      break;
   }
sum=0;
tempi=0;
first=0;
for (i=0; i<=(int)flag; i++) {
   if ((histoa[i]==0)&&(first==0))
      continue;
   first=1;
   fprintf(Outfp,"i=%d, h[i]=%d, \n",i-offset4,histoa[i]);
   printf("i=%d, h[i]=%d \n",i-offset4,histoa[i]);
   sum=sum+histoa[i]*(i-offset4);
   tempi=tempi+histoa[i];
   }
mean=(double)sum/(double)tempi;
printf("n=%d, sum=%d, mean=%e \n",tempi,sum,mean);
fprintf(Outfp,"n=%d, sum=%d, mean=%e \n",tempi,sum,mean);
//
// output histogram of j minus evens (continued-fraction convergents)
//
printf("\n");
fprintf(Outfp,"\n");
printf("j minus evens (convergents, evens equal odds, global) \n");
fprintf(Outfp,"j minus evens (convergents, evens equal odds, global, histob) \n");
flag=29;
for (i=29; i>0; i--) {
   if (histob[i]==0)
      flag=flag-1;
   else
      break;
   }
first=0;
for (i=0; i<=(int)flag; i++) {
   if ((histob[i]==0)&&(first==0))
      continue;
   first=1;
   fprintf(Outfp,"i=%d, h[i]=%d, \n",i-offset5,histob[i]);
   printf("i=%d, h[i]=%d \n",i-offset5,histob[i]);
   }
//
// output histogram
//
printf("\n");
fprintf(Outfp,"\n");
printf("residue \n");
fprintf(Outfp,"residue \n"                                                      );
flag=399;
for (i=399; i>0; i--) {
   if (histoc[i]==0)
      flag=flag-1;
   else
      break;
   }
first=0;
for (i=0; i<=(int)flag; i++) {
   if ((histoc[i]==0)&&(first==0))
      continue;
   first=1;
   fprintf(Outfp,"i=%d, h[i]=%d, \n",i,histoc[i]);
   printf("i=%d, h[i]=%d \n",i,histoc[i]);
   }
//
// output histogram
//
printf("\n");
fprintf(Outfp,"\n");
printf("3*log(c)-a \n");
fprintf(Outfp,"3*log(c)-a \n"                                                   );
flag=399;
for (i=399; i>0; i--) {
   if (histod[i]==0)
      flag=flag-1;
   else
      break;
   }
first=0;
for (i=0; i<=(int)flag; i++) {
   if ((histod[i]==0)&&(first==0))
      continue;
   first=1;
   fprintf(Outfp,"i=%d, h[i]=%d, \n",i-offset6,histod[i]);
   printf("i=%d, h[i]=%d \n",i-offset6,histod[i]);
   }
printf("\n");
fprintf(Outfp,"\n");
printf("cycle count=%d, multiple-jump count=%d, two-jump count=%d, non-adjacent count=%d \n",cyccnt,mcount,twojmp,jmphop);
printf("total jumps (in multiple-jumps)=%d, total hops (in multiple-jumps)=%d \n",glojmp,glohop);
printf("hop/hop=%d, jump/hop=%d, hop/jump=%d, jump/jump=%d \n",twojmp0,twojmp1,twojmp2,twojmp3);
fprintf(Outfp,"cycle count=%d, multiple-jump count=%d, two-jump count=%d, non=adjacent count=%d \n",cyccnt,mcount,twojmp,jmphop);
fprintf(Outfp,"total jumps (in multiple-jumps)=%d, total hops (in multiple-jumps)=%d \n",glojmp,glohop);
fprintf(Outfp,"hop/hop=%d, jump/hop=%d, hop/jump=%d, jump/jump=%d \n",twojmp0,twojmp1,twojmp2,twojmp3);
printf("primary attachment points=%d \n",primary);
fprintf(Outfp,"primary attachment points=%d \n",primary);
printf("bad t chains=%d, bad u chains=%d, bad t-u chains=%d \n",badcnt,badcntu,badtucnt);
fprintf(Outfp,"bad t chains=%d, bad u chains=%d, bad t-u chains=%d \n",badcnt,badcntu,badtucnt);
printf("bad comparisons=%d, other comparisons=%d, maximum=%e \n",badcomp,compcnt,maxcmp);
fprintf(Outfp,"bad comparisons=%d, other comparisons=%d, maximum=%e \n",badcomp,compcnt,maxcmp);
printf("cycle count=%d, cycle count=%d (convergents) \n",cyccntu,cyccntb);
fprintf(Outfp,"cycle count=%d, cycle count=%d (convergents) \n",cyccntu,cyccntb);
printf("evens equal odds, bad comparison count=%d \n",equcnt);
fprintf(Outfp,"evens equal odds, bad comparison count=%d \n",equcnt);
printf("\n");
fprintf(Outfp,"\n");
for (i=0; i<27; i++) {
   printf("i=%d, c=%d, c=%d, c=%d \n",i,concov[3*i],concov[3*i+1],concov[3*i+2]);
   fprintf(Outfp,"i=%d, c=%d, c=%d \n",i,concov[3*i],concov[3*i+1],concov[3*i+2]);
   }
printf("\n");
fprintf(Outfp,"\n");
for (i=0; i<27; i++) {
   printf("i=%d, c=%d, c=%d, c=%d \n",i,concove[3*i],concove[3*i+1],concove[3*i+2]);
   fprintf(Outfp,"i=%d, c=%d, c=%d \n",i,concove[3*i],concove[3*i+1],concove[3*i+2]);
   }
zskip:
fclose(Outfp);
return(0);
}