Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n,k;
  cin>>n>>k;
  ll r,s,p;
  cin>>r>>s>>p;
  string s;
  cin>>s;
  ll ans=0;
  for(int i=0;i<n;i++){
    if(s[i]=='r'&&i<k) ans+=p;
    else if(s[i]=='s'&&i<k) ans+=r;
    else if(s[i]=='p'&&i<k) ans+=s;
    else{
      if(s[i]=='r'&&s[i-k]=='s') ans+=r;
      else if(s[i]=='r'&&s[i-k]=='p') ans+=s;
      if(s[i]=='s'&&s[i-k]=='p') ans+=s;
      else if(s[i]=='s'&&s[i-k]=='r') ans+=p;
      if(s[i]=='p'&&s[i-k]=='r') ans+=p;
      else if(s[i]=='p'&&s[i-k]=='s') ans+=r;
    }
  }
  COUT(ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:10: error: conflicting declaration 'std::string s'
   36 |   string s;
      |          ^
a.cc:34:8: note: previous declaration as 'long long int s'
   34 |   ll r,s,p;
      |        ^
a.cc:40:9: error: invalid types 'long long int[int]' for array subscript
   40 |     if(s[i]=='r'&&i<k) ans+=p;
      |         ^
a.cc:41:14: error: invalid types 'long long int[int]' for array subscript
   41 |     else if(s[i]=='s'&&i<k) ans+=r;
      |              ^
a.cc:42:14: error: invalid types 'long long int[int]' for array subscript
   42 |     else if(s[i]=='p'&&i<k) ans+=s;
      |              ^
a.cc:44:11: error: invalid types 'long long int[int]' for array subscript
   44 |       if(s[i]=='r'&&s[i-k]=='s') ans+=r;
      |           ^
a.cc:44:22: error: invalid types 'long long int[long long int]' for array subscript
   44 |       if(s[i]=='r'&&s[i-k]=='s') ans+=r;
      |                      ^
a.cc:45:16: error: invalid types 'long long int[int]' for array subscript
   45 |       else if(s[i]=='r'&&s[i-k]=='p') ans+=s;
      |                ^
a.cc:45:27: error: invalid types 'long long int[long long int]' for array subscript
   45 |       else if(s[i]=='r'&&s[i-k]=='p') ans+=s;
      |                           ^
a.cc:46:11: error: invalid types 'long long int[int]' for array subscript
   46 |       if(s[i]=='s'&&s[i-k]=='p') ans+=s;
      |           ^
a.cc:46:22: error: invalid types 'long long int[long long int]' for array subscript
   46 |       if(s[i]=='s'&&s[i-k]=='p') ans+=s;
      |                      ^
a.cc:47:16: error: invalid types 'long long int[int]' for array subscript
   47 |       else if(s[i]=='s'&&s[i-k]=='r') ans+=p;
      |                ^
a.cc:47:27: error: invalid types 'long long int[long long int]' for array subscript
   47 |       else if(s[i]=='s'&&s[i-k]=='r') ans+=p;
      |                           ^
a.cc:48:11: error: invalid types 'long long int[int]' for array subscript
   48 |       if(s[i]=='p'&&s[i-k]=='r') ans+=p;
      |           ^
a.cc:48:22: error: invalid types 'long long int[long long int]' for array subscript
   48 |       if(s[i]=='p'&&s[i-k]=='r') ans+=p;
      |                      ^
a.cc:49:16: error: invalid types 'long long int[int]' for array subscript
   49 |       else if(s[i]=='p'&&s[i-k]=='s') ans+=r;
      |                ^
a.cc:49:27: error: invalid types 'long long int[long long int]' for array subscript
   49 |       else if(s[i]=='p'&&s[i-k]=='s') ans+=r;
      |                           ^