Source Code
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int ans=0;
    string s1,s2;
    cin>>s1>>s2;
    int j=s1.length()/2;
    for(int i=0;i<s1.length()/2;i++)
    {
        if(s1[i]!=s1[j])
        {
            ans=1;
        }
        j++;
    }
    j=s2.length()/2;
    for(int i=0;i<s2.length()/2;i++)
    {
        if(s2[i]!=s2[j])
        {
            ans=1;
        }
        j++;
    }
    if(ans==1)
    {
        cout<<-1;
    }
    else
    {
        for(int i=0;i<s2.length()/2;i++)
        {
            cout<<s2[i];
        }
        for(int i=0;i<s1.length()/2;i++)
        {
            cout<<s1[i];
        }

    }
    return 0;
}
Copy
Right into Two Badee_Salloum
GNU G++17
0 ms
520 KB
Wrong Answer