using System;
using Microsoft.CSharp;
using System.Collections.Generic;
using System.CodeDom.Compiler;
using System.Diagnostics;
class Program
{
static void Main(string[] args)
{
string sourceCode = "class e{static void Main(){System.Console.Write(new char[1\n#if l\n#else\n*5]{'w','o','r','l','d'\n#if o\n#else\n});\n#endif\n}\n#endif\n}";
Console.WriteLine(isPristine(sourceCode) ? "Pristine" : "Not pristine");
Console.ReadLine();
}
static bool isPristine(string sourceCode)
{
using (var csc = new CSharpCodeProvider(new Dictionary<string, string>() { { "CompilerVersion", "v3.5" } }))
{
var parameters = new CompilerParameters(new[] { "mscorlib.dll", "System.Core.dll" });
int length = sourceCode.Length;
List<string> substringsThatWork = new List<string>();
for (int i = 0; i < length; i++)
{
for (int j = 1; j < length - i; j++)
{
string sourceWithRemoval = sourceCode.Remove(i, j);
CompilerResults results = csc.CompileAssemblyFromSource(parameters, sourceWithRemoval);
if (results.Errors.Count == 0)
{
Debug.WriteLine("Still works by removing:");
Debug.WriteLine("@{0}@ ", sourceWithRemoval);
Debug.WriteLine("At index {0}.", i);
return false;
}
}
}
}
return true;
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBNaWNyb3NvZnQuQ1NoYXJwOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKdXNpbmcgU3lzdGVtLkNvZGVEb20uQ29tcGlsZXI7CnVzaW5nIFN5c3RlbS5EaWFnbm9zdGljczsKCmNsYXNzIFByb2dyYW0KewogICAgc3RhdGljIHZvaWQgTWFpbihzdHJpbmdbXSBhcmdzKQogICAgewogICAgICAgIHN0cmluZyBzb3VyY2VDb2RlID0gImNsYXNzIGV7c3RhdGljIHZvaWQgTWFpbigpe1N5c3RlbS5Db25zb2xlLldyaXRlKG5ldyBjaGFyWzFcbiNpZiBsXG4jZWxzZVxuKjVdeyd3JywnbycsJ3InLCdsJywnZCdcbiNpZiBvXG4jZWxzZVxufSk7XG4jZW5kaWZcbn1cbiNlbmRpZlxufSI7CgogICAgICAgIENvbnNvb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db3VudCA9PSAwKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgRGVidWcuV3JpdGVMaW5lKCJTdGlsbCB3b3JrcyBieSByZW1vdmluZzoiKTsKICAgICAgICAgICAgICAgICAgICAgICAgRGVidWcuV3JpdGVMaW5lKCJAezB9QCAiLCBzb3VyY2VXaXRoUmVtb3ZhbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIERlYnVnLldyaXRlTGluZSgiQXQgaW5kZXggezB9LiIsIGkpOwoKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgcmV0dXJuIHRydWU7CiAgICB9Cn0=