criyle/codenet-compile-errors huggingface dataset:
Language: Java

import java.util.*;
public class Main2 {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

		// 整数の入力
        int n = sc.nextInt();   //じゃんけん回数
        int k = sc.nextInt();   //同じ手禁止間隔
        int[] sco = new int[3];
        sco[0] = sc.nextInt();   //グー得点
        sco[1] = sc.nextInt();   //チョキ得点
        sco[2] = sc.nextInt();   //パー得点
        String t = sc.next(); //ゲームの手
        int ngte = -1;//出しちゃいけないやつ
        long score = 0;

        //N回じゃんけん
        for (int i = 0; i < n; i++) {
            int te = 0; //r:0,t:1,s:2
            if (t.charAt(i) == 'r') {//グーならパー
                te = 2;
            } else if (t.charAt(i) == 's') {//パーならチョキ
                te = 1;
            }
            //禁じ手チェック
            if (te == ngte) {
                //負けが確定するので0点
                //次勝てるように負けておく
                if (i + k < n) {
                    if( te == 0 )
                        if( t.charAt(i) == 'p' )//次チョキ出せば勝てる
                            te = 2; //パー出しておく
                        else
                            te = 1; //チョキ出しておく
                    if( te == 1 )
                        if( t.charAt(i) == 's' )//次グー出せば勝てる
                            te = 2; //パー出しておく
                        else
                            te = 0; //グー出しておく
                    if( te == 2 )
                        if( t.charAt(i) == 'r' )//次パー出せば勝てる
                            te = 1; //チョキ出しておく
                        else
                            te = 0; //グー出しておく
                }
            } else {
                score += sco[te];
            }

            if (i == 0 || i % k == 0) {
                ngte = te;
            }
        }
        System.out.println(score);
	}
}

Compiler output:
Main.java:2: error: class Main2 is public, should be declared in a file named Main2.java
public class Main2 {
       ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
	int N, K, R, S, P;
	int Score = 0;
	string T;
	cin >> N >> K >> R >> S >> P >> T;
	for (int i = 1; i <= N; i++) {
		char II = T[i+1];
		if (i-K < 0) {
			char I1 = 'N';
		} else {
			char I1 = T[i-K+1];
		}
		if (I1 != II) {
			if (II == 'r') {
				Score += R;
			} else if (II == 's') {
				Score += S;
			} else {
				Score += P;
			}
		}
	}
	cout << Score << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:21: error: 'I1' was not declared in this scope; did you mean 'II'?
   16 |                 if (I1 != II) {
      |                     ^~
      |                     II
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
	int N, K, R, S, P;
	int Score = 0;
	string T;
	cin >> N >> K >> R >> S >> P >> T;
	for (int i = 1; i <= N; i++) {
		char II = T[i+1];
		if (i-K < 0) {
			char I1 = 'N';
		} else {
		char I1 = T[i-K+1];
		}
		if (I1 != II) {
			if (II == 'r') {
				Score += R;
			} else if (II == 's') {
				Score += S;
			} else {
				Score += P;
			}
		}
	}
	cout << Score << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:21: error: 'I1' was not declared in this scope; did you mean 'II'?
   16 |                 if (I1 != II) {
      |                     ^~
      |                     II
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
typedef long long int lli;
 
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
    int n,k;
    int r,s,p;
    int t;
    cin>>n>>k>>r>>s>>p;
    lli ans=0;
    vector<char> mov;
    vector<char> tac;
    for(int i=0;i<k;i++){
        char temp;
        cin>>temp;
        mov.pb(temp);
        switch(temp){
            case 'r': ans+=p; tac.pb('p'); break;
            case 'p': ans+=s; tac.pb('s'); break;
            case 's': ans+=r; tac.pb('r'); break;
        }
        //cout<<ans<<'\n';
    }

    for(int i=k;i<n;i++){
        char temp;
        cin>>temp;
        mov.pb(temp);
        switch(temp){
            case 'r': if(tac[i-k]!='p'){
                        ans+=p;
                        tac.pb('p');
                      }
                      else tac.pb('a');
                        break;
            case 'p': if(tac[i-k]!='s'){
                        ans+=s;
                        tac.pb('s');
                      }
                      else tac.pb('a'); 
                        break;
            case 's': if(tac[i-k]!='r'){
                        ans+=r;
                        tac.pb('r');
                      }
                      else tac.pb('a');
                        break;
        }
        //cout<<ans<<'\n';
    }
    cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:13: error: 'class std::vector<char>' has no member named 'pb'
   19 |         mov.pb(temp);
      |             ^~
a.cc:21:35: error: 'class std::vector<char>' has no member named 'pb'
   21 |             case 'r': ans+=p; tac.pb('p'); break;
      |                                   ^~
a.cc:22:35: error: 'class std::vector<char>' has no member named 'pb'
   22 |             case 'p': ans+=s; tac.pb('s'); break;
      |                                   ^~
a.cc:23:35: error: 'class std::vector<char>' has no member named 'pb'
   23 |             case 's': ans+=r; tac.pb('r'); break;
      |                                   ^~
a.cc:31:13: error: 'class std::vector<char>' has no member named 'pb'
   31 |         mov.pb(temp);
      |             ^~
a.cc:35:29: error: 'class std::vector<char>' has no member named 'pb'
   35 |                         tac.pb('p');
      |                             ^~
a.cc:37:32: error: 'class std::vector<char>' has no member named 'pb'
   37 |                       else tac.pb('a');
      |                                ^~
a.cc:41:29: error: 'class std::vector<char>' has no member named 'pb'
   41 |                         tac.pb('s');
      |                             ^~
a.cc:43:32: error: 'class std::vector<char>' has no member named 'pb'
   43 |                       else tac.pb('a');
      |                                ^~
a.cc:47:29: error: 'class std::vector<char>' has no member named 'pb'
   47 |                         tac.pb('r');
      |                             ^~
a.cc:49:32: error: 'class std::vector<char>' has no member named 'pb'
   49 |                       else tac.pb('a');
      |                                ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
	int N, K, R, S, P;
	int Score = 0;
	string T;
	cin >> N >> K >> R >> S >> P >> T;
	for (int i = 1; i <= N; i++) {
		char II = T[i+1];
		if (i-k < 0) {
			char I1 = "N";
		} else {
		char I1 = T[i-K+1];
		}
		if (I1 != II) {
			if (II == 'r') {
				Score += R;
			} else if (II == 's') {
				Score += S;
			} else {
				Score += P;
			}
		}
	}
	cout << Score << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:23: error: 'k' was not declared in this scope
   11 |                 if (i-k < 0) {
      |                       ^
a.cc:12:35: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   12 |                         char I1 = "N";
      |                                   ^~~
      |                                   |
      |                                   const char*
a.cc:16:21: error: 'I1' was not declared in this scope; did you mean 'II'?
   16 |                 if (I1 != II) {
      |                     ^~
      |                     II
Language: C++

#include<iostream>
using namespace std;
int main()
{
  int N,K,R,S,P,i,sum;
  string T;
  sum=0;
  cin>>N>>K;
  cin>>R>>S>>P;
  cin>>T;
  i=0;
  while(T[i]!='\0')
  {
    if(i<=k)
    {
      if(T[i]=='r')
        sum+=P;
      else if(T[i]=='s')
        sum+=R;
      else
        sum+=S;
    }
    else
    {
      if(T[i-K]==T[i])
        sum+=0;
      else
      {
        if(T[i]=='r')
        sum+=P;
      else if(T[i]=='s')
        sum+=R;
      else
        sum+=S;
      }
    }
 i++;
 }
  cout<<sum;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:11: error: 'k' was not declared in this scope
   14 |     if(i<=k)
      |           ^
Language: C++

{
    ll N,K;
    cin>>N>>K;
    ll R,S,P;
    string T;
    cin>>R>>S>>P;
    cin>>T;
    string t[N];
    rep(0,i,N)t[i]=T.substr(i,1);
    ll ans=0;
    bool T_t[N];
    rep(0,i,N)rep(0,j,3)T_t[i][j]=false;
    rep(0,i,N){
        if(i-K>0 && t[i]==t[i-K]){
            if(T_t[i-K]==false){
                T_t[i]=true;
                continue;
            }else{
                T_t[i]=false;
            }
        }
        if(t[i]=="r")ans+=P;
        else if(t[i]=="s")ans+=R;
        else ans+=S;
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc:1:1: error: expected unqualified-id before '{' token
    1 | {
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int N = 1e6;
int x[N];
int main(){
	int n, k;
	scanf("%d %d",&n,&k);
		memset(x,0,sizeof(x));
		int r, s, p;
		string str;
		scanf("%d %d %d",&r,&s,&p);
		getchar();
		cin >> str;
		long long ans = 0;
		for(int i = 0; i < n; i++){
			if(str[i] == 'r'){
				else if(i < k || x[i-k] != 1) {
					ans += p;
					x[i] = 1;
				}
				else x[i] = 0;				
			}
			else if(str[i] == 's'){
				else if(i < k || x[i-k] != 2) {
					ans += r;
					x[i] = 2;			
				}
				else x[i] = 0;
			}
			else if(str[i] == 'p'){
				else if(i < k || x[i-k] != 3) {
					ans += s;
					x[i] = 3;					
				}
				else x[i] = 0;
			}
		}
		printf("%lld\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:33: error: expected '}' before 'else'
   17 |                                 else if(i < k || x[i-k] != 1) {
      |                                 ^~~~
a.cc:16:42: note: to match this '{'
   16 |                         if(str[i] == 'r'){
      |                                          ^
a.cc:23:25: error: 'else' without a previous 'if'
   23 |                         else if(str[i] == 's'){
      |                         ^~~~
a.cc:23:37: error: 'i' was not declared in this scope
   23 |                         else if(str[i] == 's'){
      |                                     ^
a.cc:24:33: error: expected '}' before 'else'
   24 |                                 else if(i < k || x[i-k] != 2) {
      |                                 ^~~~
a.cc:23:47: note: to match this '{'
   23 |                         else if(str[i] == 's'){
      |                                               ^
a.cc: At global scope:
a.cc:30:25: error: expected unqualified-id before 'else'
   30 |                         else if(str[i] == 'p'){
      |                         ^~~~
a.cc:37:17: error: expected declaration before '}' token
   37 |                 }
      |                 ^
a.cc:38:23: error: expected constructor, destructor, or type conversion before '(' token
   38 |                 printf("%lld\n",ans);
      |                       ^
a.cc:39:9: error: expected unqualified-id before 'return'
   39 |         return 0;
      |         ^~~~~~
a.cc:40:1: error: expected declaration before '}' token
   40 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){

  int N;
  int K;
  cin >> N >> K;
  
  int R;
  int S;
  int P:
  cin >> R >> S >> P;
  
  string T;
  cin >> T;
  
  for(int i = K;i < N;++i){
    if(T[i] == T[i - K]){
      T[i - k] = 'w';
    }
  }
  
  int num = 0;
  
  for(int i = 0;i < K;++i){
    if(T[i] == 'r'){
      num = P + num;
    }
    else if(T[i] == 's'){
      num = R + num;
    }
    else if(T[i] == 'p'){
      num = S + num;
    }
  }
  
  cout << num << endl;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:8: error: found ':' in nested-name-specifier, expected '::'
   11 |   int P:
      |        ^
      |        ::
a.cc:11:7: error: 'P' has not been declared
   11 |   int P:
      |       ^
a.cc:12:7: error: qualified-id in declaration before '>>' token
   12 |   cin >> R >> S >> P;
      |       ^~
a.cc:19:13: error: 'k' was not declared in this scope
   19 |       T[i - k] = 'w';
      |             ^
a.cc:27:13: error: 'P' was not declared in this scope
   27 |       num = P + num;
      |             ^
Language: C++

#include<bits/stdc++.h>
using namespace std;

int main()
{
  int N,K,R,S,P;
  string T;
  cin>>N>>K;
  cin>>R>>S>>P;
  cin>>T;
  int ans=0;
  for(int i=1;i<=N;i++){
    if(i<=K){
      if(T[i]=='r')ans+=R;
      else if(T[i]=='s')ans+=S;
      else ans+=P;
    }
    else{
      if(S[i]!=S[i-K]){
        if(T[i]=='r')ans+=R;
        else if(T[i]=='s')ans+=S;
        else ans+=P;
      }
    }
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:11: error: invalid types 'int[int]' for array subscript
   19 |       if(S[i]!=S[i-K]){
      |           ^
a.cc:19:17: error: invalid types 'int[int]' for array subscript
   19 |       if(S[i]!=S[i-K]){
      |                 ^
Language: C++

#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
using namespace std; 

int main()
{
    ll n,k,r,s,p;
    cin>>n>>k>>r>>s>>p;
    string t;
    cin>>t;
    ll ans=0;
    char c[n];
    for(ll i=0;i<k;i++)
    {
        if(t[i]=='r')
        {
            ans+=p;
            c[i]='p';
        }
        else if(t[i]=='p')
        {
            ans+=s;
            c[i]='s';
        }
        else if(t[i]=='s')
        {
            ans+=r;
            c[i]='r';
        }
    }
    for(ll i=k;i<n;i++)
    {
        if(t[i]=='r'&&s[i-k]!='p')
        {
            ans+=p;
            c[i]='p';
        }
        else if(t[i]=='p'&&s[i-k]!='s')
        {
            ans+=s;
            c[i]='s';
        }
        else if(t[i]=='s'&&s[i-k]!='r')
        {
            ans+=r;
            c[i]='r';
        }
    }
    cout<<ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:24: error: invalid types 'long long int[long long int]' for array subscript
   35 |         if(t[i]=='r'&&s[i-k]!='p')
      |                        ^
a.cc:40:29: error: invalid types 'long long int[long long int]' for array subscript
   40 |         else if(t[i]=='p'&&s[i-k]!='s')
      |                             ^
a.cc:45:29: error: invalid types 'long long int[long long int]' for array subscript
   45 |         else if(t[i]=='s'&&s[i-k]!='r')
      |                             ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N,K,R,S,P,T;
  cin>>N>>K>>R>>S>>P>>T;
  int ans=0;
  for(int i=0;i<N;i++){
    if(T[i]=='r') ans+=P;
    else if(T[i]=='p') ans+=S;
    else ans+=R;
  }
  for(int i=0;i<K;i++){
    int j=i+K;
    int l=1;
    while(j<N){
      if(T[i]!=T[j]){
        i=j;
        j+=K;
      }
      else if(T[i]=='r'){
        ans-=P;
        T[i]='1';
        i=j;
        j+=K;
      }
      else if(T[i]=='s'){
        ans-=R;
        T[i]='1';
        i=j;
        j+=K;
      }
      else if(T[i]=='p'){
        ans-=S;
        T[i]='1';
        i=j;
        j+=K;
      }
    }
  }
  cout<<ans<<endl;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: invalid types 'int[int]' for array subscript
    9 |     if(T[i]=='r') ans+=P;
      |         ^
a.cc:10:14: error: invalid types 'int[int]' for array subscript
   10 |     else if(T[i]=='p') ans+=S;
      |              ^
a.cc:17:11: error: invalid types 'int[int]' for array subscript
   17 |       if(T[i]!=T[j]){
      |           ^
a.cc:17:17: error: invalid types 'int[int]' for array subscript
   17 |       if(T[i]!=T[j]){
      |                 ^
a.cc:21:16: error: invalid types 'int[int]' for array subscript
   21 |       else if(T[i]=='r'){
      |                ^
a.cc:23:10: error: invalid types 'int[int]' for array subscript
   23 |         T[i]='1';
      |          ^
a.cc:27:16: error: invalid types 'int[int]' for array subscript
   27 |       else if(T[i]=='s'){
      |                ^
a.cc:29:10: error: invalid types 'int[int]' for array subscript
   29 |         T[i]='1';
      |          ^
a.cc:33:16: error: invalid types 'int[int]' for array subscript
   33 |       else if(T[i]=='p'){
      |                ^
a.cc:35:10: error: invalid types 'int[int]' for array subscript
   35 |         T[i]='1';
      |          ^
Language: C++

//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<vector>
#include <map>
#define I int
#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define P(a) printf("%d\n",a)
#define PL(a) printf("%lld\n",a)
#define PT(t) printf("Case %d: ",t)
#define PB(a) push_back(a)
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define ll long long 
using namespace std;
#define mx 500004
#define md 2000000000000000000ll
typedef pair<int, int >P;
typedef vector<ll>V;

////////define value/////

ll n,m,r[4];
//ll ar[mx+2];
ll DP[mx+2][4];
char ar[mx+2];
ll a[4];
int re(char s){
    if(s== 'r')return 0;
    else if(s=='s')return 1;
    return 2;
}

ll dp(int pos, int fl){

    if(pos > n)return 0;
    ll &ret = DP[pos][fl];

    if(ret!=-1)return ret;

    ret = 0;

    for(int i = 1;i<=3;i++){
        if(fl == i)continue;

        if(i%3 == re(ar[pos])){
           // cout<<pos<<" "<<i<<" "<<a[i]<<" lol "<<a[pos]<<endl;
            ret = max(ret, a[i]+ dp(pos + m, i));}
        else ret = max(ret, dp(pos+m, i));
    }

    return ret;
}

int main(){

   cin>>n>>m;
   for(int i=1;i<=3;i++){
       cin>>a[i];
   }
   scanf("%s", ar + 1);
   memset(DP,-1,sizeof DP);
   ll res =0;
   for(int i=1;i<=m;i++){
       res+=dp(i,0);
     //  cout<<i<<endl;
     //  cout<<dp(i,0)<<endl;
   }
   cout<<res<<endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:69:4: error: 'memset' was not declared in this scope
   69 |    memset(DP,-1,sizeof DP);
      |    ^~~~~~
a.cc:12:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   11 | #include <map>
  +++ |+#include <cstring>
   12 | #define I int
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N,K,R,S,P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  
  int countr = 0;
  int counts = 0;
  int countp = 0;
  for (int i = 0; i < N; i++) {
    if (T.at(i)=="r") {
      countr++;
    }
    else if (T.at(i)=="s") {
      counts++;
    }
    else {
      countp++;
    }
  }
  for (int i =0; i < N; i++)
    if (i-K<0) {
      continue;
    }
  else if (T.at(i)==T.at(i-K)=="r") {
      countr--;
    }
  else if (T.at(i)==T.at(i-K)=="s") {
      counts--;
  }
  else {
      countp--;
  }
  int point = R*countr + S*counts + P*countp;
  cout << point << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   13 |     if (T.at(i)=="r") {
      |         ~~~~~~~^~~~~
a.cc:16:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   16 |     else if (T.at(i)=="s") {
      |              ~~~~~~~^~~~~
a.cc:27:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   27 |   else if (T.at(i)==T.at(i-K)=="r") {
      |            ~~~~~~~~~~~~~~~~~~^~~~~
a.cc:30:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   30 |   else if (T.at(i)==T.at(i-K)=="s") {
      |            ~~~~~~~~~~~~~~~~~~^~~~~
Language: C++

#include <bits/stdc++.h> 

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int N,K,R,S,P;
  string T;
  cin>>N>>K>>R>>S>>P>>T;
  /*
  r=>0;
  s=>1;
  p=>2;
  */
  vector<vector<char>>a(K);
  for(int i=0;i<N;i++)a[i%K].push_back(T[i]);
  ll ans=0;
  for(int i=0;i<K;i++){
    ll c=1;
    for(int j=1;j<a[i].size();j++){
      if(a[i][j]==a[i][j-1])c++;
      else{
        if(a[i][j-1]=='r')ans+=P*((c+1)/2);
        if(a[i][j-1]=='s')ans+=R*((c+1)/2);
        if(a[i][j-1]=='p')ans+=S*((c+1)/2);
        c=1;
      }
      if(j==a[i].size()-1){
        if(a[i][j]=='r')ans+=P*((c+1)/2);
        if(a[i][j]=='s')ans+=R*((c+1)/2);
        if(a[i][j]=='p')ans+=S*((c+1)/2);
        c=1;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}
f

Compiler output:
a.cc:49:1: error: 'f' does not name a type
   49 | f
      | ^
Language: C++

#inculde <bits/stdc++.h>
using namespace std;
int main(void){
 int N,K,R,S,P;
 string T;
 cin >> N >> K >> R >> S >> P >> T;
 int res = 0;
 vector<char> t(N);
 for (int i = 0; i < N; i++){
  if (i<K){
   if (T[i]=='r'){
    res+=P;
    t[i]='p';
   } else if (T[i]=='s'){
    res+=R;
    t[i]='r';
   } else {
    res+=S;
    t[i]='s';
   }
  } else {
   if (T[i]=='r'){
    if (t[i-K]!='p'){
     res+=P;
     t[i]='p';
    } else {
     t[i]='n';
    }
   } else if (T[i]=='s'){
    if (t[i-K]!='r'){
     res+=R;
     t[i]='r';
    } else {
     t[i]='n';
    }
   } else {
    if (t[i-K]!='s'){
     res+=S;
     t[i]='s';
    } else {
     t[i]='n';
    }
   }
  }
 }
 cout << res;
}

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #inculde; did you mean #include?
    1 | #inculde <bits/stdc++.h>
      |  ^~~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:5:2: error: 'string' was not declared in this scope
    5 |  string T;
      |  ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | #inculde <bits/stdc++.h>
a.cc:6:2: error: 'cin' was not declared in this scope
    6 |  cin >> N >> K >> R >> S >> P >> T;
      |  ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #inculde <bits/stdc++.h>
a.cc:6:34: error: 'T' was not declared in this scope
    6 |  cin >> N >> K >> R >> S >> P >> T;
      |                                  ^
a.cc:8:2: error: 'vector' was not declared in this scope
    8 |  vector<char> t(N);
      |  ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | #inculde <bits/stdc++.h>
a.cc:8:9: error: expected primary-expression before 'char'
    8 |  vector<char> t(N);
      |         ^~~~
a.cc:13:5: error: 't' was not declared in this scope
   13 |     t[i]='p';
      |     ^
a.cc:16:5: error: 't' was not declared in this scope
   16 |     t[i]='r';
      |     ^
a.cc:19:5: error: 't' was not declared in this scope
   19 |     t[i]='s';
      |     ^
a.cc:23:9: error: 't' was not declared in this scope
   23 |     if (t[i-K]!='p'){
      |         ^
a.cc:30:9: error: 't' was not declared in this scope
   30 |     if (t[i-K]!='r'){
      |         ^
a.cc:37:9: error: 't' was not declared in this scope
   37 |     if (t[i-K]!='s'){
      |         ^
a.cc:46:2: error: 'cout' was not declared in this scope
   46 |  cout << res;
      |  ^~~~
a.cc:46:2: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
char str[200005],res[200005];
int main()
{
    ll a,b,c,d,e,f=0,i,j,r,p,s;
    cin>>a>>b>>r>>s>>p;
    getchar();
    gets(str);
    for(i=0; i<strlen(str); i++)
    {
        if(str[i]=='r')
            res[i]='p';
        else if(str[i]=='s')
            res[i]='r';
        else if(str[i]=='p')
            res[i]='s';
        if(i>=b)
        {
            if(res[i-b]==res[i])
                res[i]='0';
        }
        if(res[i]=='r')
            f+=r;
        else if(res[i]=='s')
            f+=s;
        else if(res[i]=='p')
            f+=p;
    }
    cout<<f<<endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'gets' was not declared in this scope; did you mean 'getw'?
   10 |     gets(str);
      |     ^~~~
      |     getw
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N,K,R,S,P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  
  int countr = 0;
  int counts = 0;
  int countp = 0;
  for (int i = 0; i < N; i++) {
    if (T.at(i)=="r") {
      countr++;
    }
    else if (T.at(i)=="s") {
      counts++;
    }
    else {
      countp++
    }
  }
  for (int i =0; i < N; i++)
    if (i-K<0) {
      continue;
    }
  else if (T.at(i)==T.at(i-K)=="r") {
      countr--;
    }
  else if (T.at(i)==T.at(i-K)=="s") {
      counts--;
  }
  else {
      countp--;
  }
  int point = R*countr + S*counts + P*countp;
  cout << point << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   13 |     if (T.at(i)=="r") {
      |         ~~~~~~~^~~~~
a.cc:16:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   16 |     else if (T.at(i)=="s") {
      |              ~~~~~~~^~~~~
a.cc:20:15: error: expected ';' before '}' token
   20 |       countp++
      |               ^
      |               ;
   21 |     }
      |     ~          
a.cc:27:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   27 |   else if (T.at(i)==T.at(i-K)=="r") {
      |            ~~~~~~~~~~~~~~~~~~^~~~~
a.cc:30:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   30 |   else if (T.at(i)==T.at(i-K)=="s") {
      |            ~~~~~~~~~~~~~~~~~~^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N,K,R,S,P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  
  int countr = 0;
  int counts = 0;
  int countp = 0;
  for (int i = 0; i < N; i++) {
    if (T.at(i)=="r") {
      countr++;
    }
    else if (T.at(i)=="s") {
      counts++;
    }
    else {
      countp++
    }
  }
  for (int i =0; i < N; i++)
    if (i-K<0) {
      contenue;
    }
  else if (T.at(i)==T.at(i-K)=="r") {
      countr--;
    }
  else if (T.at(i)==T.at(i-K)=="s") {
      counts--;
  }
  else {
      countp--;
  }
  int point = R*countr + S*counts + P*countp;
  cout << point << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   13 |     if (T.at(i)=="r") {
      |         ~~~~~~~^~~~~
a.cc:16:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   16 |     else if (T.at(i)=="s") {
      |              ~~~~~~~^~~~~
a.cc:20:15: error: expected ';' before '}' token
   20 |       countp++
      |               ^
      |               ;
   21 |     }
      |     ~          
a.cc:25:7: error: 'contenue' was not declared in this scope
   25 |       contenue;
      |       ^~~~~~~~
a.cc:27:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   27 |   else if (T.at(i)==T.at(i-K)=="r") {
      |            ~~~~~~~~~~~~~~~~~~^~~~~
a.cc:30:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   30 |   else if (T.at(i)==T.at(i-K)=="s") {
      |            ~~~~~~~~~~~~~~~~~~^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N,K,R,S,P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  
  int countr = 0;
  int counts = 0;
  int countp = 0;
  for (int i = 0; i < N; i++) {
    if (T.at(i)==r) {
      countr++;
    }
    else if (T.at(i)==s) {
      counts++;
    }
    else {
      countp++
    }
  }
  for (int i =0; i < N; i++)
    if (i-k<0) {
      contenue;
    }
  else if (T.at(i)==T.at(i-K)==r) {
      countr--;
    }
  else if (T.at(i)==T.at(i-K)==s) {
      counts--;
  }
  else {
      countp--;
  }
  int point = R*countr + S*counts + P*countp;
  cout << point << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:18: error: 'r' was not declared in this scope
   13 |     if (T.at(i)==r) {
      |                  ^
a.cc:16:23: error: 's' was not declared in this scope
   16 |     else if (T.at(i)==s) {
      |                       ^
a.cc:20:15: error: expected ';' before '}' token
   20 |       countp++
      |               ^
      |               ;
   21 |     }
      |     ~          
a.cc:24:11: error: 'k' was not declared in this scope
   24 |     if (i-k<0) {
      |           ^
a.cc:25:7: error: 'contenue' was not declared in this scope
   25 |       contenue;
      |       ^~~~~~~~
a.cc:27:32: error: 'r' was not declared in this scope
   27 |   else if (T.at(i)==T.at(i-K)==r) {
      |                                ^
a.cc:30:32: error: 's' was not declared in this scope
   30 |   else if (T.at(i)==T.at(i-K)==s) {
      |                                ^
Language: C++

// Give me My Shotgun

#include <bits/stdc++.h>
using namespace std ;

#define all(x) x.begin() , x.end()

#define PB push_back
#define F first
#define S second
#define _sz(x) (int)x.size()

#define debug(x) cerr << #x << " = " << x << endl

typedef long long ll ;
typedef pair<int , int> pii ;

const int MAX_N = -1 ;
const int inf = 2e9 + 19 ;

ll n , k , r , p , s ;
string T , S ;

int main() {
        ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;
        cin >> n >> k ;
        cin >> r >> s >> p ;
        cin >> T ;
        ll ans = 0 ;
  		string tmp = "x" ;
        for (int i = 0 ; i < n ; i ++)
                s += tmp ;
        for (int i = 0 ; i < k ; i ++) {
                if (T[i] == 'r')
                        S[i] = 'p' , ans += p ;
                if (T[i] == 'p')
                        S[i] = 's' , ans += s ;
                if (T[i] == 's')
                        S[i] = 'r' , ans += r ;
        }
        for (int i = k ; i < n ; i ++) {
                if (T[i] == 'r')
                        if (S[i - k] !='p')
                                ans += p , S[i] = 'p' ;
                if (T[i] == 's')
                        if (S[i - k] != 'r')
                                ans += r , S[i] = 'r' ;
                if (T[i] == 'p')
                        if (S[i - k] != 's')
                                ans += s , S[i] = 's' ;
        }
        cout << ans ;
        return (0) ;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:19: error: no match for 'operator+=' (operand types are 'll' {aka 'long long int'} and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   32 |                 s += tmp ;
      |                 ~~^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n,k,r,s,p;
  string t;
  cin >> n >> k;
  cin >> r >> s >> p;
  cin >> t;
  int score = 0;
  for(int i=0;i<ki++){
    if(t.at(i)=='r'){
      score = socre + r;
    }else if(t.at(i)=='s'){
      score = score + s;
    }else if(t.at(i)=='p'){
      score = score + p;
    }
  }
  for(int i=0;i<k;i++){
    for(int j=k;j<n;j=j+k){
      if(t.at(j)==t.at(k)){
      }else if(t.at(i)=='r'){
        score = socre + r;
      }else if(t.at(i)=='s'){
        score = score + s;
      }else if(t.at(i)=='p'){
        score = score + p;
      }
    }
  }
  cout << score << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:17: error: 'ki' was not declared in this scope; did you mean 'i'?
   11 |   for(int i=0;i<ki++){
      |                 ^~
      |                 i
a.cc:11:21: error: expected ';' before ')' token
   11 |   for(int i=0;i<ki++){
      |                     ^
      |                     ;
a.cc:13:15: error: 'socre' was not declared in this scope; did you mean 'score'?
   13 |       score = socre + r;
      |               ^~~~~
      |               score
a.cc:24:17: error: 'socre' was not declared in this scope; did you mean 'score'?
   24 |         score = socre + r;
      |                 ^~~~~
      |                 score
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int x[100000];
signed main(){
	int a,b,c,d,e,ans=0;
	string s;
	cin>>a>>b>>c>>d>>e>>s;
	f(i,a){
		if(i<b){
			if(s[i]=='r'){
				x[i]=2;
				ans+=e;
			}
			if(s[i]=='s'){
				x[i]=0;
				ans+=c;
			}
			if(s[i]=='p'){5
				x[i]=1;
				ans+=d;
			}
		}
		else{
			if(s[i]!=s[i-b]||x[i-b]==3){
				if(s[i]=='r'){
				x[i]=2;
				ans+=e;
				}
				if(s[i]=='s'){
					x[i]=0;
					ans+=c;
				}
				if(s[i]=='p'){
					x[i]=1;
					ans+=d;
				}
			}
			else x[i]=3;
		}
	}
	cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:40: error: expected ';' before 'x'
   26 |                         if(s[i]=='p'){5
      |                                        ^
      |                                        ;
   27 |                                 x[i]=1;
      |                                 ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
#define endl '\n'

ll CountGreater(ll x, vector<ll>& A, bool is_sum, vector<ll>& P) {
  int n = A.size();
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    int l = -1, r = n;
    while (r-l > 1) {
      ll m = l + (r-l)/2;
      if (A[m]+A[i] > x) {
        l = m;
      } else {
        r = m;
      }
    }
    if (is_sum) {
      ans += P[r] + r*A[i];
    } else {
      ans += r;
    }
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll n,k;
  cin >> n >> k;
  vector<ll> A(n);
  for (auto& _a : A) cin >> _a;
  sort(A.rbegin(),A.rend());
  vector<ll> P(n+1);
  for (int i = 0; i < n; ++i) P[i+1] = P[i]+A[i];
  ll l = -1, r = 1e18;
  while (r-l > 1) {
    ll mid = l + (r-l)/2;
    ll cnt = CountGreater(mid,A,false,P);
    dbg(mid,cnt);
    if (cnt < k) {
      r = mid;
    } else {
      l = mid;
    }
  }
  ll c2 = CountGreater(r, A, false, P);
  ll ans = CountGreater(r, A, true, P);
  ans += (k-c2)*r;
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:5: error: 'dbg' was not declared in this scope
   43 |     dbg(mid,cnt);
      |     ^~~
Language: C++

#include<iostream>
#include<atcoder/all>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}


vector<li> operator*(const vector<li>& a,const vector<li> & b){
  vector<li> g=atcoder::convolution(a,b);
  //decline(g,max(a.size(),b.size()));
  return g;
}

int main(){
  int n; li m; cin >>n >>m;
  li ma=0;
  vector<li> a(n);
  for(li& x:a){
    cin >>x;
    ma=max(ma,x);
  }
  vector<li> f(ma+1,0);
  for(li& x:a) f[x]++;
  //  if(df)print(f);
  f=f*f;
  //  if(df)print(f);
  ma=f.size();
  li ans=0,cnt=0;
  rep(_i,ma){
    int i=ma-_i-1;
    if(cnt+f[i]>=m){
      if(df)print(i,m-cnt);
      ans+=i*(m-cnt);
      break;
    }
    cnt+=f[i];
    if(df and f[i])print(i,f[i]);
    ans+=i*f[i];
  }
  print(ans);
}


Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
const int MAX=2e5+1;
int main()
{
    int n,m;
    cin>>n>>m;
    vll poly(MAX);
    for (size_t i = 0; i < n; i++)
    {
        int a;
        cin>>a;
        poly[a]++;
    }
    poly = atcoder::convolution_ll(poly,poly);
    int deg=poly.size();
    ll cnt=0,ans=0;
    for (int i = deg - 1; i >= 0 and cnt < m; i--)
    {
        ans += min(m-cnt,poly[i])*i;
        cnt+= poly[i];
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc:2:10: fatal error: atcoder/all: No such file or directory
    2 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

////////// 二分探索 //////////

vector<ll> A;

// index が条件を満たすかどうか
bool isOK(ll index,ll key) {
  if(A[index]>=key) return true;
  else return false;
}

// 汎用的な二分探索のテンプレ
ll binary_search(ll key) {
  ll ng=-1; //「index = 0」が条件を満たすこともあるので、初期値は -1
  ll ok=(ll)A.size(); // 「index=a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    if(isOK(mid,key)) ok=mid;
    else ng=mid;
  }
  return ok;
}

//////////////////////////////////////////////////

int main(){
  ll N,M;
  cin>>N>>M;
  REP(i,N){
    ll a;
    cin>>a;
    A.PB(-a);
  }
  SORT(A);
  
  ll SUM[N+1];
  SUM[0]=0;
  REP(i,N) SUM[i+1]=SUM[i]-A[i];
  
  ll ye=INF,no=0; // Ax+Ayとして取れる値
  while(ye-no>1){
    ll mid=(ye+no)/2,cnt=0;
    REP(i,N){
      ll it=binary_search(-mid-A[i]+1);
      cnt+=it;
    }
    if(cnt<=M) ye=mid;
    else no=mid;
  }
  
  ll X=ye-1,ans=0,count=0;
  REP(i,N){
    ll it=binary_search(-X-A[i]-1);
    cnt+=it;
    ans+=SUM[it];
  }
  ans-=(count-M)*X;
  co(ans);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:122:5: error: 'cnt' was not declared in this scope; did you mean 'int'?
  122 |     cnt+=it;
      |     ^~~
      |     int
Language: C++

#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int n,m;

bool isok(vector<int>& a,int x) {
    ll sum = 0;
    rep(i,n) {
        sum += n - (lower_bound(a.begin(),a.end(),x-a[i]) - a.begin());
    }
    return sum >= m;
}



int main() {
    cin >> n >> m;
    vector<ll>a(n);
    rep(i,n) cin >> a[i];
    vector<ll>s(n+1);
    sort(a.begin(),a.end());
    rep(i,n) {
        s[i+1] = s[i] + a[i];
    }
    ll ok = 0;ll ng = 200010;
    while(ng - ok > 1) {
        ll mid = (ok+ng)/2;
        if(isok(a,mid)) ok = mid;
        else ng = mid;
    }
    // cout << ok << endl;
    ll ans = 0;
    ll cnt = m;
    rep(i,n) {
        ll pos = (lower_bound(a.begin(),a.end(),ok-a[i])-a.begin());
        // cout << pos << endl;
        ans += a[i] * (n- pos);
        ans += s[n] - s[pos];
        cnt -= (n-pos);
    }
    // cout << cnt << endl;
    ans += cnt*ok;
    cout << ans << endl;
}

    




Compiler output:
a.cc: In function 'int main()':
a.cc:33:17: error: invalid initialization of reference of type 'std::vector<int>&' from expression of type 'std::vector<long long int>'
   33 |         if(isok(a,mid)) ok = mid;
      |                 ^
a.cc:11:24: note: in passing argument 1 of 'bool isok(std::vector<int>&, int)'
   11 | bool isok(vector<int>& a,int x) {
      |           ~~~~~~~~~~~~~^
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<functional>
using namespace std;
 
using ll = long long int;
const int N_MAX = 100005;
ll S[N_MAX];
vector<int> A, B;
 
int main(){
    ll n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        A.push_back(a);
        B.push_back(a);
    }
    sort(A.begin(), A.end(), greater<int>());
    sort(B.begin(), B.end());
 
    ll lb = 0;
    ll ub = 200005;
    while(ub - lb > 1){
        ll mid = (lb + ub)/2;
        ll count = 0;
        int j = 0;
        for(int i = 0; i < n; i++){
            while(j < n && B[i] + A[j] >= mid)j++;
            count += j;
        }
        if (count >= m)lb = mid;
        else ub = mid;
    }
    ll ans = 0;
    ll count = 0;
    S[0] = 0;
    for(int i = 1; i <= n; i++){
        S[i] = S[i-1] + A[i-1];
    }
    int j = 0;
    for(int i = 0; i < n; i++){
        while(j < n && B[i] + A[j] > lb) j++;
        count += j;
        ans += (ll)B[i] * j + S[j];
    }
    ans += lb * (m - count);
    if(count > m) assert(0);
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:19: error: 'assert' was not declared in this scope
   51 |     if(count > m) assert(0);
      |                   ^~~~~~
a.cc:6:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    5 | #include<functional>
  +++ |+#include <cassert>
    6 | using namespace std;
Language: C++

#include <algorithm>
#include <iostream>
using namespace std;
using ll = long long;
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
int main() {
	int n, M;
	cin >> n >> M;
	int a[n];
	rep(i, n) cin >> a[i];
	sort(a, a + n);
	ll l = -1, r = 1e6;
	while (r - l > 1) {
		ll m = (l + r) / 2;
		ll cnt = 0;
		rep(i, n) cnt += a + n - lower_bound(a, a + n, m - a[i]);
		if (cnt > M)
			l = m;
		else
			r = m;
	}
	ll ans = 0;
	vector<int> b(n + 1);
	rep(i, n) b[i + 1] = b[i] + a[i];
	int cnt = 0;
	rep(i, n) {
		int p = a + n - lower_bound(a, a + n, l - a[i]);
		cnt += p;
		ans += b[n] - b[n - p] + a[i] * p;
	}
	ans -= (cnt - M) * l;
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:9: error: 'vector' was not declared in this scope
   24 |         vector<int> b(n + 1);
      |         ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include <iostream>
  +++ |+#include <vector>
    3 | using namespace std;
a.cc:24:16: error: expected primary-expression before 'int'
   24 |         vector<int> b(n + 1);
      |                ^~~
a.cc:25:19: error: 'b' was not declared in this scope
   25 |         rep(i, n) b[i + 1] = b[i] + a[i];
      |                   ^
a.cc:30:24: error: 'b' was not declared in this scope
   30 |                 ans += b[n] - b[n - p] + a[i] * p;
      |                        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  ll M;
  cin >> N >> M;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  sort(all(A));
  vector<ll> sum(N+1);
  rep(i, N) sum[i+1] = sum[i] + A[i];

  if(M == N*N) {
    cout << sum[N] * 2 * N << endl;
    return 0;
  }

  ll val = 0;
  set<int> se;
  ll cnt = 0;
  auto test = [&](ll t) {
    cnt = 0;
    se = set<int>();
    val = 0;
    rep(i, N) {
      auto j = lower_bound(all(A), t-A[i]) - begin(A);
      if(j != 0) se.insert(A[i]+A[j-1]);
      val += (sum[N]-sum[j]) + A[i] * (N-j);
      cnt += (N-j);
    }
    return cnt <= M;
  };
  auto binary_search = [&]() {
    ll ng = 0, ok = 200005;
    while(abs(ok - ng) > 1) {
      ll mid = (ok + ng) / 2;
      if(test(mid)) ok = mid;
      else ng = mid;
    }
    return ok;
  };
  ll mx = binary_search();
  test(mx);
  cout << val+(M-cnt)*(--se.end())->first << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:56:37: error: request for member 'first' in '*(& se.std::set<int>::end().std::_Rb_tree_const_iterator<int>::operator--())->std::_Rb_tree_const_iterator<int>::operator->()', which is of non-class type 'const int'
   56 |   cout << val+(M-cnt)*(--se.end())->first << endl;
      |                                     ^~~~~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>


using namespace std;

int64_t N, M;
vector<int64_t> A;

bool chk(int64_t x) {
	int64_t cnt = 0;
	for (int i = 0; i < N; i++) {
		int64_t pos = lower_bound(A.begin(), A.end(), x - A[i]) - A.begin();
		cnt += (N - pos);
	}
	return cnt < M;//X以上の和がM個未満かどうか
}

int main() {


	
	cin >> N >> M;
	A.resize(N);

	for (int64_t i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());

	int64_t ng = 0, ok = LLONG_MAX;

	while (abs(ok - ng) > 1) {
		int64_t mid = (ok + ng) / 2;
		if (chk(mid)) ok = mid;
		else ng = mid;
	}
	//終了時にngにX-1,okにXが入っている。

	int64_t ans = 0;
	vector<int64_t> wa(N + 1); //Aの累積和
	for (int i = 0; i < N; i++) wa[i + 1] = wa[i] + A[i];
	for (int i = 0; i < N; i++) {
		int64_t pos = upper_bound(A.begin(), A.end(), ng - A[i]) - A.begin();
		int64_t cnt = N - pos;
		ans += cnt * A[i] + (wa[N] - wa[pos]);
		M -= cnt;
	}
	ans += M * ng;
	cout << ans << endl;
}





Compiler output:
a.cc: In function 'int main()':
a.cc:34:30: error: 'LLONG_MAX' was not declared in this scope
   34 |         int64_t ng = 0, ok = LLONG_MAX;
      |                              ^~~~~~~~~
a.cc:6:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #include<algorithm>
  +++ |+#include <climits>
    6 |