Solution
C++ []\nclass Solution {\npublic:\n    void generator(string &arr,int &a,int &b){\n        if (a<=0 && b<=0){\n            return;\n        }\n        if(a>b){\
```C++ []\nclass Solution {\npublic:\n    void generator(string &arr,int &a,int &b){\n        if (a<=0 && b<=0){\n            return;\n        }\n        if(a>b){\n            if(a>=2){\n                arr=arr+"aa";\n                a-=2;\n            }\n            else{\n                arr=arr+\'a\';\n                a-=1;\n            }\n            if(b>=1){\n                arr=arr+\'b\';\n                b-=1;\n            }\n        }\n        else if(b>a){\n            if(b>=2){\n                arr=arr+"bb";\n                b-=2;\n            }\n            else{\n                arr=arr+\'b\';\n                b-=1;\n            }\n            if(a>=1){\n                arr=arr+\'a\';\n                a-=1;\n            }\n        }\n        else{\n            arr=arr+\'a\'+\'b\';\n            a-=1;\n            b-=1;\n        }\n        generator(arr, a, b);\n    }\n    string strWithout3a3b(int a, int b) {\n        string arr ="";\n        generator(arr, a, b);\n        return arr;\n    }\n};\n```\n\n```Python3 []\nclass Solution:\n    def strWithout3a3b(self, a: int, b: int) -> str:\n        if a == b:\n            return "ab" * a\n\n        x, y = ("a", "b") if a < b else ("b", "a")\n        xc, yc = (a, b) if a < b else (b, a)\n        n_yyx = min(xc, yc - xc)\n        n_yx = min(xc - n_yyx, yc - 2 * n_yyx)\n        nx = xc - n_yyx - n_yx\n        ny = yc - 2 * n_yyx - n_yx\n        return (y + y + x) * n_yyx + (y + x) * n_yx + y * ny + x * nx\n```\n\n```Java []\nclass Solution {\n    public String strWithout3a3b(int A, int B) {\n        StringBuilder res = new StringBuilder(A + B);\n  char a = \'a\', b = \'b\';\n  int i = A, j = B;\n  if (B > A) { a = \'b\'; b = \'a\'; i = B; j = A; }\n  while (i-- > 0) {\n    res.append(a);\n    if (i > j) { res.append(a); --i; }\n    if (j-- > 0) res.append(b);\n  }\n  return res.toString();\n    }\n}\n```\n
['C++', 'Java', 'Python3']