C# faster than 96.63%, less then 100% Mem
Runtime: 80 ms\nMemory Usage: 27 MB\n\n```\npublic class ZeroEvenOdd {\n    private int n;\n    private int crnt = 1;\n    private int zeroCount = 0;\n    priva
Runtime: 80 ms\nMemory Usage: 27 MB\n\n```\npublic class ZeroEvenOdd {\n    private int n;\n    private int crnt = 1;\n    private int zeroCount = 0;\n    private int lastOdd;\n    private int lastEven;\n    \n    private System.Threading.AutoResetEvent zeroReady;\n    private System.Threading.AutoResetEvent evenReady;\n    private System.Threading.AutoResetEvent oddReady;\n    \n    public ZeroEvenOdd(int n) {\n        this.n = n;\n        \n        lastOdd = (n%2 == 1)? n : n-1;\n        lastEven = (n%2 == 0)? n : n-1;\n        \n        zeroReady = new System.Threading.AutoResetEvent(true);\n        evenReady = new System.Threading.AutoResetEvent(false);\n        oddReady = new System.Threading.AutoResetEvent(false);\n    }\n\n    // printNumber(x) outputs "x", where x is an integer.\n    public void Zero(Action<int> printNumber) \n    {\n         while (zeroCount < n) \n         { \n             zeroReady.WaitOne();\n             \n             printNumber(0);\n             zeroCount++;\n\n             if (crnt % 2 == 0)\n             {\n                 evenReady.Set();\n             }\n            else\n            {\n                oddReady.Set();\n            }\n         }        \n    }\n\n    public void Even(Action<int> printNumber) \n    {\n        while (crnt <= lastEven) \n        { \n           evenReady.WaitOne();\n           printNumber(crnt);\n           crnt++;\n           zeroReady.Set(); \n        }\n    }\n\n    public void Odd(Action<int> printNumber) \n    {   \n        while (crnt <= lastOdd) \n        { \n            oddReady.WaitOne();\n            printNumber(crnt);\n            crnt++;\n            zeroReady.Set(); \n        }\n    }\n    \n  ~ZeroEvenOdd()\n    {\n        try\n        {            \n            zeroReady.Dispose();\n            evenReady.Dispose();\n            oddReady.Dispose();\n        } catch(Exception ex) {}\n    }
[]