Language: C++

#include <iostream>
#include<vector>
#include<cstring>
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
unordered_set<string> set1;
unordered_set<string> set2;
void expand(string str, int low, int high, auto &set)
{
	while (low >= 0 && high < str.length()&& str[low] == str[high])
	{	
		set.insert(str.substr(low, high - low + 1));
		low--, high++;
	}
}

void all1(string str)
{
	for (int i = 0; i < str.length(); i++)
	{
		
		expand(str, i, i, set1);
		expand(str, i, i + 1, set1);
	}

}
void all2(string str)
{
	for (int i = 0; i < str.length(); i++)
	{
		
		expand(str, i, i, set2);
		expand(str, i, i + 1, set2);
	}

}
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    int res=0;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            res+=a[i]*a[j];
        }
    }
    cout<<res<<endl;
    return 0;
}

#include <iostream>
#include<vector>
#include<cstring>
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
unordered_set<string> set1;
unordered_set<string> set2;
void expand(string str, int low, int high, auto &set)
{
	while (low >= 0 && high < str.length()&& str[low] == str[high])
	{	
		set.insert(str.substr(low, high - low + 1));
		low--, high++;
	}
}

void all1(string str)
{
	for (int i = 0; i < str.length(); i++)
	{
		
		expand(str, i, i, set1);
		expand(str, i, i + 1, set1);
	}

}
void all2(string str)
{
	for (int i = 0; i < str.length(); i++)
	{
		
		expand(str, i, i, set2);
		expand(str, i, i + 1, set2);
	}

}
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    int res=0;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            res+=a[i]*a[j];
        }
    }
    cout<<res<<endl;
    return 0;
}

Submission Info

Compiler output:
a.cc:9:44: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
    9 | void expand(string str, int low, int high, auto &set)
      |                                            ^~~~
a.cc:59:23: error: redefinition of 'std::unordered_set<std::__cxx11::basic_string<char> > set1'
   59 | unordered_set<string> set1;
      |                       ^~~~
a.cc:7:23: note: 'std::unordered_set<std::__cxx11::basic_string<char> > set1' previously declared here
    7 | unordered_set<string> set1;
      |                       ^~~~
a.cc:60:23: error: redefinition of 'std::unordered_set<std::__cxx11::basic_string<char> > set2'
   60 | unordered_set<string> set2;
      |                       ^~~~
a.cc:8:23: note: 'std::unordered_set<std::__cxx11::basic_string<char> > set2' previously declared here
    8 | unordered_set<string> set2;
      |                       ^~~~
a.cc:61:44: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   61 | void expand(string str, int low, int high, auto &set)
      |                                            ^~~~
a.cc:61:6: error: redefinition of 'template<class auto:29> void expand(std::string, int, int, auto:29&)'
   61 | void expand(string str, int low, int high, auto &set)
      |      ^~~~~~
a.cc:9:6: note: 'template<class auto:28> void expand(std::string, int, int, auto:28&)' previously declared here
    9 | void expand(string str, int low, int high, auto &set)
      |      ^~~~~~
a.cc:70:6: error: redefinition of 'void all1(std::string)'
   70 | void all1(string str)
      |      ^~~~
a.cc:18:6: note: 'void all1(std::string)' previously defined here
   18 | void all1(string str)
      |      ^~~~
a.cc:80:6: error: redefinition of 'void all2(std::string)'
   80 | void all2(string str)
      |      ^~~~
a.cc:28:6: note: 'void all2(std::string)' previously defined here
   28 | void all2(string str)
      |      ^~~~
a.cc:90:5: error: redefinition of 'int main()'
   90 | int main(){
      |     ^~~~
a.cc:38:5: note: 'int main()' previously defined here
   38 | int main(){
      |     ^~~~
a.cc:105:1: error: 'Submission' does not name a type
  105 | Submission Info
      | ^~~~~~~~~~