DP string->> HELP

635_E
```
#include<bits/stdc++.h>
#define ll long long int
#define inf 1000000000000
#define mod 998244353
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define for0(i, n) for (int i = 0; i < n; i++)
#define tc(t) int t; cin >> t; while (t–)
#define ps(x,y) fixed<<setprecision(y)<<x
using namespace std;
string s, t;
map<string, int> dp;
int n;
int steps = 0;
ll ways(string a, int ind)
{
if (ind == n)
{
if (a.substr(0, t.size()) == t)
return dp[a] = 1;
else
return dp[a] = 0;
}
if (dp.count(a))
return dp[a];
ll ans = 0;
if (ind >= t.size())
{
if (a.substr(0, t.size()) == t)
ans += 1;
}
//steps++;
ans += ways(a + s[ind], ind + 1) + ways(s[ind] + a, ind + 1);
return dp[a] = ans % mod;
}
int main()
{
IOS
#ifndef ONLINE_JUDGE
freopen(“input.txt”, “r”, stdin);
freopen(“output.txt”, “w”, stdout);
#endif
string a;
cin >> s >> t;
n = s.size();
a = s[0];
ll ans = ways(a, 1) % mod;
cout << ans * 2 << endl;
//cout << steps << endl;
}

showing TLE on testcase 7 . Can anyone help me to optimize this code or if you have your code can you share  with observation....expalined

Please try to format the code. Use 3 backticks before and after the code.