Codeforces type problem where you have to find patterns
Code\n\nclass Solution {\npublic:\n    long long ncr(int n, int r) {\n        if (r > n - r) {\n            r = n - r;\n        }\n        long long result = 1;
# Code\n```\nclass Solution {\npublic:\n    long long ncr(int n, int r) {\n        if (r > n - r) {\n            r = n - r;\n        }\n        long long result = 1;\n        for (int i = 0; i < r; ++i) {\n            result *= (n - i);\n            result /= (i + 1);\n        }\n        return result;\n    } \n    string kthSmallestPath(vector<int>& dest, int k) {\n        int h=dest[1];\n        int v=dest[0];\n        string pg="";\n        for(int i=0;i<h;i++){\n            pg.push_back(\'H\');\n        }\n        for(int i=0;i<v;i++){\n            pg.push_back(\'V\');\n        }\n        vector<int> shift;\n        shift.push_back(h);\n        int h1=0;\n        long long cnt=0;\n        for(int i=v-1;i>=0;i--){\n            // cout<<i<<"->"<<endl;\n            int v1=i;\n            int left=-1;\n            int last;\n            int f=0;\n            while(cnt<(1LL*k)){\n                long long val=ncr(v1+h1,v1);\n                last=val;\n                cnt+=val;\n                if(left==shift.back()){\n                    break;\n                }\n                left++;\n                h1++;\n                // cout<<cnt<<\' \'<<left<<endl;\n                if(val==1 and cnt==k){\n                    f=1;\n                    break;\n                }\n            }\n            cnt-=last;\n            shift.push_back(left);\n            if(f){\n                break;\n            }\n            h1=0;\n        }\n        // for(auto it:shift){\n        //     cout<<it<<\' \';\n        // }\n        // cout<<endl;\n        int ct=0;\n        for(int i=0;i<pg.size();i++){\n            if(pg[i]==\'V\'){\n                ct++;\n                if(ct>=shift.size()){\n                    break;\n                }\n                int sh=shift[ct];\n                pg[i]=\'H\';\n                pg[i-sh]=\'V\';\n            }\n        }\n        return pg;\n    }\n};\n```
['C++']