using System;
using System.Collections .Generic ;
using System.Linq ;
public class Test
{
private static void DoIt( IEnumerable< int> a)
{
Console.WriteLine ( String.Join ( " " , a) ) ;
foreach ( var x in a.Zip ( a.Skip ( 1 ) , ( x, y) => Enumerable.Repeat ( x, 1 ) .Concat ( Enumerable.Repeat ( y, 1 ) ) ) .Zip ( a.Skip ( 2 ) , ( xy, z) => xy.Concat ( Enumerable.Repeat ( z, 1 ) ) ) .Where ( ( x, i) => i % 3 == 0 ) )
Console.WriteLine ( String.Join ( " " , x) ) ;
Console.WriteLine ( ) ;
}
public static void Main( )
{
DoIt( new int [ ] { 1 } ) ;
DoIt( new int [ ] { 1 , 2 } ) ;
DoIt( new int [ ] { 1 , 2 , 3 } ) ;
DoIt( new int [ ] { 1 , 2 , 3 , 4 } ) ;
DoIt( new int [ ] { 1 , 2 , 3 , 4 , 5 } ) ;
DoIt( new int [ ] { 1 , 2 , 3 , 4 , 5 , 6 } ) ;
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKdXNpbmcgU3lzdGVtLkxpbnE7CgpwdWJsaWMgY2xhc3MgVGVzdAp7CiAgcHJpdmF0ZSBzdGF0aWMgdm9pZCBEb0l0KElFbnVtZXJhYmxlPGludD4gYSkKICB7CiAgICBDb25zb2xlLldyaXRlTGluZShTdHJpbmcuSm9pbigiICIsIGEpKTsKCiAgICBmb3JlYWNoICh2YXIgeCBpbiBhLlppcChhLlNraXAoMSksICh4LCB5KSA9PiBFbnVtZXJhYmxlLlJlcGVhdCh4LCAxKS5Db25jYXQoRW51bWVyYWJsZS5SZXBlYXQoeSwgMSkpKS5aaXAoYS5Ta2lwKDIpLCAoeHksIHopID0+IHh5LkNvbmNhdChFbnVtZXJhYmxlLlJlcGVhdCh6LCAxKSkpLldoZXJlKCh4LCBpKSA9PiBpICUgMyA9PSAwKSkKICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoU3RyaW5nLkpvaW4oIiAi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