criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <string>
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;
int main()
{
	std::string input;

	std::getline(std::cin, input, ' ');
	int N = std::stoi(input);

	std::getline(std::cin, input, ' ');
	int Q = std::stoi(input);

	std::vector<int> golems(N, 1);
	std::unordered_map<char> mapper;
	std::getline(std::cin, input);
	for(int inx = 0; inx < N; inx += 1)
	{
		mapper[input[inx]] = inx;
	}

	while(std::getline(std::cin, input))
	{
		int inx = mapper[input[0]];
		if(golems[inx] > 0)
		{
			if(input[2] == 'L')
			{
				if(inx > 0)
				{
					golems[inx - 1] += golems[inx];
				}
				golems[inx] = 0;
			}
			else
			{
				if(inx < N - 1)
				{
					golems[inx + 1] += golems[inx];
				}
				golems[inx] = 0;
			}
		}
	}
	int sum = 0;
	for(int& num : golems)
	{
		sum += num;
	}
	std::cout << std::to_string(sum) << std::endl;

	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:18:32: error: wrong number of template arguments (1, should be at least 2)
   18 |         std::unordered_map<char> mapper;
      |                                ^
In file included from /usr/include/c++/14/unordered_map:41,
                 from a.cc:4:
/usr/include/c++/14/bits/unordered_map.h:109:11: note: provided for 'template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> class std::unordered_map'
  109 |     class unordered_map
      |           ^~~~~~~~~~~~~
a.cc:22:23: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}]' for array subscript
   22 |                 mapper[input[inx]] = inx;
      |                       ^
a.cc:27:33: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}]' for array subscript
   27 |                 int inx = mapper[input[0]];
      |                                 ^
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <vector>
using namespace std;

int main(){
  int num_golem,num_spell;
  cin>>num_golem>>num_spell;
  string golem;
  cin>>golem;
  unordered_map<char,vector<int>> m;
  for(int i=0;i<golem.size();++i){
    m[golem[i]].push_back(i);
  }
  vector<int> counts(golem.size(),1);
  for(int i=0;i<num_spell;++i){
    char type, operators;
    cin>>type>>operators;
    for(int j=0;j<m[type].size();++j){
      if(operators=='L'){
        if(m[type][j]!=0){
          counts[m[type][j]-1]+=counts[m[type][j]];
        }
        m[type][j]=0;
      } 
      if(operators=='R'){
        if(m[type][j]!=golem.size()-1){
          counts[m[type][j]+1]+=counts[m[type][j]];
        }
        m[type][j]=0;
      } 
    }
  }
  cout<<accumulate(counts.begin(), counts.end(), 0);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:9: error: 'accumulate' was not declared in this scope
   36 |   cout<<accumulate(counts.begin(), counts.end(), 0);
      |         ^~~~~~~~~~
Language: C++

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

int main(){
    int N, Q; cin >> N >> Q;
    char s[210000], t[210000], d[210000];
    for (int i=0; i < N ; i++) cin >> s[i];
    for (int i=0; i < Q ; i++) cin >> t[i] >> d[i];

    int num[210000];
    for (int i=0; i < N ; i++) num[i]=i+1;

    for (int i=0; i < Q ; i++) {
        for (int j=0; j < N ; j++) {
            if ( s[j] == t[i]){
                if ( d[i] == 'L') num[j]-=1;
                if ( d[i]) == 'R' ) num[j]+=1;
            }
        }
    }

    int ans=0;

    for (int i=0; i < N ; i++) {
        if ( 1 <= num[i] && num[i] < N ) ans++;
    }

    cout << ans << endl;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:28: error: expected primary-expression before '==' token
   17 |                 if ( d[i]) == 'R' ) num[j]+=1;
      |                            ^~
Language: C++

#include <iostream>
#include <string.h>
#include <string>
#include <vector>    

using namespace std;
int main() {
	int N;
	std::string s;
	//N: マス数
	//Q：呪文の数
	int N, Q;
	cin >> N>>Q;
	//ゴーレムのいる位置
	std::vector<int> state;
	for (int i = 0; i < N;i++) {
		state.push_back(i);
	}
	//マスの文字
	string s; 
	cin >> s;
	//マスの文字配列
	string tmp_d, tmp_t;
	std::vector<string> t, d;
	while (cin >> tmp_t >> tmp_d) {           //行数指定がある場合はif文でも可
		t.push_back(tmp_t);
		d.push_back(tmp_d);
	}
	//呪文をかける
	for (int i=0;i<Q;i++ ){
		//左右判定
		for (int j = 0; j < N; j++) {
			if (state[j] != -1) {

				//左のとき-1
				if (t[j] == "L") {
					state[j] += -1;
					if (state[j] < 0) { state[j] = -1; }
				}
				//左のとき+1
				else if (t[j] == "R") {
					state[j] += 1;
					if (state[j] >= N) { state[j] = -1; }
				}
			}
		}
	}

	//カウント
	int count = 0;
	for (int i = 0; i < N; i++) {
		if (state[i]!=-1) {
			count += 1;
		}
	}
	cout << count << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:13: error: redeclaration of 'int N'
   12 |         int N, Q;
      |             ^
a.cc:8:13: note: 'int N' previously declared here
    8 |         int N;
      |             ^
a.cc:20:16: error: redeclaration of 'std::string s'
   20 |         string s;
      |                ^
a.cc:9:21: note: 'std::string s' previously declared here
    9 |         std::string s;
      |                     ^
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <vector>
using namespace std;

int main(){
  int num_golem,num_spell;
  cin>>num_golem>>num_spell;
  string golem;
  cin>>golem;
  unordered_map<char,vector<int>> m;
  for(int i=0;i<golem.size();++i){
    m[golem[i]].push_back(i);
  }
  vector<int> count(golem.size(),1);
  for(int i=0;i<num_spell;++i){
    char type, operators;
    cin>>type>>operators;
    for(int j=0;j<m[type].size();++j){
      if(operators=='L'){
        if(m[type][j]!=0){
          m[type][j-1]+=m[type][j];
        }
        m[type][j]=0;
      } 
      if(operators=='R'){
        if(m[type][j]!=golem.size()-1){
          m[type][j+1]+=m[type][j];
        }
        m[type][j]=0;
      } 
    }
  }
  cout<<accumulate(count.begin(), count.end(), 0);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:9: error: 'accumulate' was not declared in this scope
   36 |   cout<<accumulate(count.begin(), count.end(), 0);
      |         ^~~~~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <vector>
using namespace std;

int main(){
  int num_golem,num_spell;
  cin>>num_golem>>num_spell;
  string golem;
  cin>>golem;
  unordered_map<char,vector<int>> m;
  for(int i=0;i<golem.size();++i){
    m[golem].push_back(i);
  }
  vector<int> count(golem.size(),1);
  for(int i=0;i<num_spell;++i){
    char type, operators;
    cin>>type>>operators;
    for(int j=0;j<m[type].size();++j){
      if(operators=='L'){
        if(m[type][j]!=0){
          m[type][j-1]+=m[type][j];
        }
        m[type][j]=0;
      } 
      if(operators=='R'){
        if(m[type][j]!=golem.size()-1){
          m[type][j+1]+=m[type][j];
        }
        m[type][j]=0;
      } 
    }
  }
  cout<<accumulate(count.begin(), count.end(), 0);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:6: error: no match for 'operator[]' (operand types are 'std::unordered_map<char, std::vector<int> >' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   15 |     m[golem].push_back(i);
      |      ^
In file included from /usr/include/c++/14/unordered_map:41,
                 from a.cc:4:
/usr/include/c++/14/bits/unordered_map.h:987:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type&) [with _Key = char; _Tp = std::vector<int>; _Hash = std::hash<char>; _Pred = std::equal_to<char>; _Alloc = std::allocator<std::pair<const char, std::vector<int> > >; mapped_type = std::vector<int>; key_type = char]'
  987 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:987:34: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const std::unordered_map<char, std::vector<int> >::key_type&' {aka 'const char&'}
  987 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/unordered_map.h:991:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&&) [with _Key = char; _Tp = std::vector<int>; _Hash = std::hash<char>; _Pred = std::equal_to<char>; _Alloc = std::allocator<std::pair<const char, std::vector<int> > >; mapped_type = std::vector<int>; key_type = char]'
  991 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:991:29: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::unordered_map<char, std::vector<int> >::key_type&&' {aka 'char&&'}
  991 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
a.cc:36:9: error: 'accumulate' was not declared in this scope
   36 |   cout<<accumulate(count.begin(), count.end(), 0);
      |         ^~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long LL;

const int maxn=2e5+5;

int n,m,dr[maxn];
char s[maxn],index[maxn];

char Read()
{
	char ch=getchar();
	while (ch<'A' || ch>'Z') ch=getchar();
	return ch;
}

int main()
{
	scanf("%d %d",&n,&m);
	scanf("%s",s+1);
	fo(i,1,m)
	{
		char ch1=Read(),ch2=Read();
		index[i]=ch1;
		dr[i]=(ch2=='R');
	}
	
	int ans=0, l=1, r=n;
	fd(i,m,1)
	{
		if (s[l]==index[i] && dr[i]==0) l++, ans++;
		if (s[r]==index[i] && dr[i]==1) r--, ans++;
	}
	
	printf("%d\n",n-ans);
}

Compiler output:
a.cc:11:24: error: 'char index [200005]' redeclared as different kind of entity
   11 | char s[maxn],index[maxn];
      |                        ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:27:22: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   27 |                 index[i]=ch1;
      |                      ^
a.cc:34:32: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   34 |                 if (s[l]==index[i] && dr[i]==0) l++, ans++;
      |                                ^
a.cc:35:32: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   35 |                 if (s[r]==index[i] && dr[i]==1) r--, ans++;
      |                                ^
Language: C++

#include <iostream>
#include <string.h>
#include <string>
#include <vector>    

using namespace std;
int main() {
	int N;
	std::string s;
	//N: マス数
	//Q：呪文の数
	int N, Q; cin >> N>>Q;
	//ゴーレムのいる位置
	std::vector<int> state;
	for (int i = 0; i < N;i++) {
		state.push_back(i);
	}
	//マスの文字
	string s; cin >> s;
	//マスの文字配列
	string tmp_d, tmp_t;
	std::vector<string> t, d;
	while (cin >> tmp_t >> tmp_d) {           //行数指定がある場合はif文でも可
		t.push_back(tmp_t);
		d.push_back(tmp_d);
	}
	//呪文をかける
	for (int i=0;i<Q;i++ ){
		//左右判定
		for (int j = 0; j < N; j++) {
			if (state[j] != -1) {

				//左のとき-1
				if (t[j] == "L") {
					state[j] += -1;
					if (state[j] < 0) { state[j] = -1; }
				}
				//左のとき+1
				else if (t[j] == "R") {
					state[j] += 1;
					if (state[j] >= N) { state[j] = -1; }
				}
			}
		}
	}

	//カウント
	int count = 0;
	for (int i = 0; i < N; i++) {
		if (state[i]!=-1) {
			count += 1;
		}
	}
	cout << count << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:13: error: redeclaration of 'int N'
   12 |         int N, Q; cin >> N>>Q;
      |             ^
a.cc:8:13: note: 'int N' previously declared here
    8 |         int N;
      |             ^
a.cc:19:16: error: redeclaration of 'std::string s'
   19 |         string s; cin >> s;
      |                ^
a.cc:9:21: note: 'std::string s' previously declared here
    9 |         std::string s;
      |                     ^
Language: C++

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

using ll=long long;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x) return x%1000000007;

main(){
  int n=in(),q=in(),g[n+2];
  char s[n],t,d;
  g[0]=0;
  for (int i=1;i<=n;i++){
    cin >> s[i];
    g[i]=1;
  }
  g[n+1]=0;
  for (int i=0;i<q;i++){
    cin >> t >> d;
    if (d=='L'){
      for (int i2=1;i<=n;i++){
        if (s[i2]==t){
          g[i2-1]+=g[i2];
          g[i2]=0;
        }
      }
    }  
    else{
      for (int i2=n;i>0;i--){
        if (s[i2]==t){
          g[i2+1]+=g[i2];
          g[i2]=0;
        }
      }
    }
  }
  cout << n-g[0]-g[n+1] << endl;
}


Compiler output:
a.cc: In function 'int div1(ll)':
a.cc:45:16: error: named return values are no longer supported
   45 | int div1(ll x) return x%1000000007;
      |                ^~~~~~
a.cc:76:1: warning: no return statement in function returning non-void [-Wreturn-type]
   76 | }
      | ^
Language: C++

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

int main() {
  int N, X;
  vector<int> B(N);
  for (int i = 0; i < N; i++) cin >> B[i];
  
  

  string c;
  cin >> N >> Q >> c;
  char t, d;
  for (int i = 0; i < Q; i++) {
    cin >> t >> d;
    if (d == 'L') dir = -1;
    else dir = 1;
    for (int j = 0; j < N; j++) {
      if (c[j] == t) {
        aft = j + dir; 
        if (aft < 0 || aft >= N) G[j]=0;
        else {
          G[aft] += G[j];
          G[j] = 0;
        }
      } 
    }
  }
  int cnt = 0;
  for (int i = 0; i < N; i++) cnt += G[i];
  cout << cnt << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:15: error: 'Q' was not declared in this scope
   12 |   cin >> N >> Q >> c;
      |               ^
a.cc:16:19: error: 'dir' was not declared in this scope; did you mean 'div'?
   16 |     if (d == 'L') dir = -1;
      |                   ^~~
      |                   div
a.cc:17:10: error: 'dir' was not declared in this scope; did you mean 'div'?
   17 |     else dir = 1;
      |          ^~~
      |          div
a.cc:20:9: error: 'aft' was not declared in this scope
   20 |         aft = j + dir;
      |         ^~~
a.cc:20:19: error: 'dir' was not declared in this scope; did you mean 'div'?
   20 |         aft = j + dir;
      |                   ^~~
      |                   div
a.cc:21:34: error: 'G' was not declared in this scope
   21 |         if (aft < 0 || aft >= N) G[j]=0;
      |                                  ^
a.cc:23:11: error: 'G' was not declared in this scope
   23 |           G[aft] += G[j];
      |           ^
a.cc:30:38: error: 'G' was not declared in this scope
   30 |   for (int i = 0; i < N; i++) cnt += G[i];
      |                                      ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;


ostream& operator<<(ostream& out, const vector<int> &v) {
    for(auto it=v.begin();it != v.end();it++) {
        cout << *it << " ";
    }
    return out;
}

int n, q;
string s;
vector<set<int>> cs(26);

void activate(int i) {
    cs[s[i] - 'A'].insert(i);
}
void deactivate(int i) {
    cs[s[i] - 'A'].remove(i);
}
int main() {
    cin >> n >> q;
    cin >> s;
    vector<vector<int>> cs(26);
    for(int i=0;i<n;i++) {
        activate(i);
    }
    vector<int> golems(n+2, 1);
    golems[0] = golems[n+1] = 0;
    for(int i=0;i<q;i++) {
        //cout << golems << endl;
        char t,d;
        cin >> t >> d;
        for(int idx: cs[t - 'A']) {
            if (d == 'R') {
                golems[idx+2]+=golems[idx+1];
                if (idx+1 < n) {
                    activate(idx+1);
                }
            } else {
                golems[idx]+=golems[idx+1];
                if (idx-1 >=0) {
                    activate(idx-1);
                }
            }
            golems[idx+1] = 0;
            deactivate(idx);
        }
    }
    //cout << golems << endl;
    cout << (n - golems[0] - golems[n+1]) << endl;
    return 0;
}

Compiler output:
a.cc:16:8: error: 'set' was not declared in this scope
   16 | vector<set<int>> cs(26);
      |        ^~~
a.cc:3:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
    2 | #include <vector>
  +++ |+#include <set>
    3 | 
a.cc:16:15: error: template argument 1 is invalid
   16 | vector<set<int>> cs(26);
      |               ^~
a.cc:16:15: error: template argument 2 is invalid
a.cc: In function 'void activate(int)':
a.cc:19:7: error: invalid types 'int[int]' for array subscript
   19 |     cs[s[i] - 'A'].insert(i);
      |       ^
a.cc: In function 'void deactivate(int)':
a.cc:22:7: error: invalid types 'int[int]' for array subscript
   22 |     cs[s[i] - 'A'].remove(i);
      |       ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n,q,ans=n;
    cin >> n >> q;
    vector<pair<char,int>> v(n);
    for(int i=0;i < n;i++){
        cin >> v.at(i).first;
        v.at(i).second = 1;
    }//input

    for(int j=0;j < q;j++){
        char a,b;
        cin >> a >> b;
        for(int k=0;k < v.size();k++){
            if(v.at(k).first == a){
                if(b == 'L'){
                    if(k !=0){
                    v.at(k-1).second += v.at(k).second;
                    v.at(k).second = 0;
                    }
                    else{
                        ans -= v.at(i).second;
                        v.at(i).second = 0;
                    }
                }

                if(b == 'R'){
                    if(k != n-1){
                    v.at(k+1).second += v.at(k).second;
                    v.at(k).second = 0;
                    }
                    else{
                        ans -= v.at(i).second;
                        v.at(i).second = 0;
                    }
                } 
            }
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:37: error: 'i' was not declared in this scope
   24 |                         ans -= v.at(i).second;
      |                                     ^
a.cc:35:37: error: 'i' was not declared in this scope
   35 |                         ans -= v.at(i).second;
      |                                     ^
Language: C++

#include<iostream>
#include<string>

using namespace std;

int main(){

  int N,Q;
  int ans;
  cin >> N >> Q;
  ans=N;

  int a[N];
  for(int i=0;i<N;i++){
    a[i]=1;
  }
  
  char s[N];
  for(int i=0;i<N;i++){
    cin >> s[i];
  }

  char t,q;
  for(int i=0;i<Q;i++){

    cin >> t >> q;

    if(q=='L'){
      for(int j=0;j<N;j++){
	if(s[j]==t){
	  if(j==0){
	    ans-=a[j]
	    a[j]=0;
	  }else{
	    a[j-1]+=a[j];
	    a[j]=0;
	  }
	}
      }
    }else{
      for(int j=N-1;j>=0;j--){
	if(s[j]==t){
	  if(j==N-1){
	    ans-=a[j];
	    a[j]=0;
	  }else{
	    a[j+1]+=a[j];
	    a[j]=0;
	  }
	}
      }
    }

  }

  cout << ans << endl;

  return 0;

}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:32:22: error: expected ';' before 'a'
   32 |             ans-=a[j]
      |                      ^
      |                      ;
   33 |             a[j]=0;
      |             ~
Language: C++

#include<iostream>
#include<string>

using namespace std;

int main(){

  int n,q;
  cin >> n >> q;

  int a[n];
  for(int i=0;i<n;i++){
    a[i]=1;
  }
  
  char s[n];
  for(int i=0;i<n;i++){
    cin >> s[i];
  }

  char t,q;
  for(int i=0;i<q;i++){

    cin >> t >> q;

    if(q=='L'){
      for(int j=0;j<n;j++){
	if(s[j]==t){
	  if(j==0){
	    a[j]=0;
	  }else{
	    a[j-1]+=a[j];
	    a[j]=0;
	  }
	}
      }
    }else{
      for(int j=n-1;j>=0;j--){
	if(s[j]==t){
	  if(j==0){
	    a[j]=0;
	  }else{
	    a[j+1]+=a[j];
	    a[j]=0;
	  }
	}
      }
    }

  }

  int ans=0;
  for(int i=0;i<n;i++){
    ans+=a[i];
  }

  cout << a[i] << endl;

  return 0;

}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:21:10: error: conflicting declaration 'char q'
   21 |   char t,q;
      |          ^
a.cc:8:9: note: previous declaration as 'int q'
    8 |   int n,q;
      |         ^
a.cc:57:13: error: 'i' was not declared in this scope
   57 |   cout << a[i] << endl;
      |             ^
Language: C++

/*
 * SAD
 */
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using orderd_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define S second
#define F first
#define pb push_back
const int inf = 1e9;
using ii = pair<int, int>;
using ll = long long;
using db = long double;

const int N = 1e5 + 5, M = 1000 * 1000 * 10 + 5, K = 55, Base = 27, MOD = 1e9
		+ 7, MOD2 = 998244353;
const ll MX = 1e15;
const int blkSz = 200;
const db EPS = 1e-7;
const int PI = 3;
int mx[26], mn[26], cur[26];
int main() {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	
	int n, m;
	cin >> n >> m;
	string s;
	cin >> s;
	while(m--){
		char c,L;
		cin >> c >> L;
		if(L == 'L')
			cur[c-'A']--;
		else
			cur[c-'A']++;
		mx[c-'A'] = max(mx[c-'A'], cur[c-'A']);
		mn[c-'A'] = min(mn[c-'A'], cur[c-'A']);			
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(i + mn[S[i]-'A'] >= 0 && i + mx[S[i]-'A'] < n)
			ans++;
	}
	cout << ans << '\n';
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:11: error: 'second' was not declared in this scope
   20 | #define S second
      |           ^~~~~~
a.cc:57:27: note: in expansion of macro 'S'
   57 |                 if(i + mn[S[i]-'A'] >= 0 && i + mx[S[i]-'A'] < n)
      |                           ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
const long long MOD = 1000000007;
int main(){
	int N, X;
	cin >> N >> X;
	vector<int> S(N);
	for (int i = 0; i < N; i++){
		cin >> S[i];
	}
	sort(S.rbegin(), S.rend());
	vector<vector<long long>> dp(N + 1, vector<long long>(X + 1, 0));
	dp[0][X] = 1;
	for (int i = 0; i < N; i++){
		for (int j = 0; j <= X; j++){
			dp[i + 1][j] += dp[i][j] * (N - 1 - i);
			dp[i + 1][j] %= MOD;
			dp[i + 1][j % S[i]] += dp[i][j];
			dp[i + 1][j % S[i]] %= MOD;
		}
	}
	long long ans = 0;
	for (int i = 0; i <= X; i++){
		ans += dp[N][i] * i;
		ans %= MOD;
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   12 |         sort(S.rbegin(), S.rend());
      |         ^~~~
      |         short
Language: C++

#include <bits/stdc++.h>
#include "../lib/math/comb.hpp"

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n, x;
  cin >> n >> x;
  vi s(n);
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  sort(s.rbegin(), s.rend());

  Combination<MOD> comb(1000000);

  vvll dp(n+1, vll(x+1, 0));
  dp[0][x] = 1;

  for(int i=0;i<n;++i) {
    for(int j=0;j<=x;++j) {
      dp[i+1][j%s[i]] += dp[i][j];
      dp[i+1][j%s[i]] %= MOD;
      dp[i+1][j] += dp[i][j] * (n-i-1) % MOD;
      dp[i+1][j] %= MOD;
    }
    // printv(dp[i]);
  }
  // printv(dp[n]);

  ll ans = 0;
  for(int i=0;i<=x;++i) {
    ans += dp[n][i] * i % MOD;
    ans %= MOD;
  }
  cout << ans << endl;

}



Compiler output:
a.cc:2:10: fatal error: ../lib/math/comb.hpp: No such file or directory
    2 | #include "../lib/math/comb.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 35000;
const int K = 19;
int mod =  1e9 + 7;
int n, dp[210][100200], a[N], f[N], invf[N];
int solve(int m, int x){
    if (m > n) return dp[m][x] = x;
    if (dp[m][x] != 0) return dp[m][x];
    int cnt = 0;
    int l = m;
    while (l <= n && a[l] > x){
        cnt++;
        l++;
    }
    if (cnt != 0) return dp[m][x] = f[n - m + 1] * invf[n - m - cnt + 1] % mod * solve(m + cnt, x) % mod;
    int res = 0;
    for (int i = m; i <= n; i++){
        res = (res + f[n - m] * invf[n - i] % mod * solve(i + 1, x % a[i])) % mod;
    }
    return dp[m][x] = res;
}
binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int x;
    cin >> n >> x;
    f[0] = 1;
    invf[0] = 1;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % mod;
    for (int i = 1; i <= n; i++) invf[i] = binpow(f[i], mod - 2);
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);
    cout << solve(1, x);
}


Compiler output:
a.cc:36:1: error: ISO C++ forbids declaration of 'binpow' with no type [-fpermissive]
   36 | binpow(int x, int y){
      | ^~~~~~
a.cc:42:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   42 | main(){
      | ^~~~
Language: C++

#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

ll dp[203][100003];

int main()
{
    ll n, x;
    cin >> n >> x;
    ll s[203];
    for(int i = 0; i < n; i++) cin >> s[i];
    sort(s, s + n, greater<ll>());
    dp[0][x] = 1;
    for(int i = 1; i <= n; i++) dp[0][x] = dp[0][x] * i % MOD;
    for(int i = 0; i < n; i++){
        ll r = modpow(n - i, MOD - 2);
        for(int j = 0; j <= x; j++){
            dp[i + 1][j] += dp[i][j] * (n - i - 1) % MOD * r % MOD;
            dp[i + 1][j % s[i]] += dp[i][j] * r % MOD;
        }
    }
    ll ans = 0;
    for(int j = 0; j <= x; j++) ans = (ans + dp[n][j] * j) % MOD;
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   26 |     sort(s, s + n, greater<ll>());
      |     ^~~~
      |     short
Language: C++

#include <stdio.h>
#include <array>
#include <algorithm>
#include <vector>

constexpr int MAX_X = 1e5;
constexpr int MAX_N = 200;
constexpr int mod = 1e9 + 7;
std::vector<int> S;
std::array<std::array<long long int, MAX_X+1>, MAX_N> DP;

int main(void){
    int n, X; scanf("%d%d", &n, &X);
    S.resize(n); for(int i = 0; i < n; ++i) scanf("%d", &S[i]);
    // DP[n][x] := 数字 x を s0 ... sn-1 で やった時の解
    // 遷移式 : DP[i][0] = 0 for all i 
    //       : DP[0][x] = x % s0
    //         DP[i][x] = DP[i-1][x] * i + DP[i-1][x % i]
    std::sort(S.begin(), S.end());
    for(int x = 0; x <= X; ++x) DP[0][x] = x % S[0];
    REP(i, n) DP[i][0] = 0;
    for(int i = 1; i < n; ++i){
        for(int x = 0; x <= X; ++x) DP[i][x] = (DP[i-1][x] * i + DP[i-1][x % S[i]]) % mod;
    }
    printf("%lld\n", DP[n-1][X]);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:9: error: 'i' was not declared in this scope
   21 |     REP(i, n) DP[i][0] = 0;
      |         ^
a.cc:21:5: error: 'REP' was not declared in this scope
   21 |     REP(i, n) DP[i][0] = 0;
      |     ^~~
Language: C++

#include <stdio.h>
#include <array>
#include <algorithm>
#include <vector>

constexpr int MAX_X = 1e5;
constexpr int MAX_N = 200;
constexpr int mod = 1e9 + 7;
std::vector<int> S;
std::array<std::array<lli, MAX_X+1>, MAX_N> DP;

int main(void){
    int n, X; scanf("%d%d", &n, &X);
    S.resize(n); for(int i = 0; i < n; ++i) scanf("%d", &S[i]);
    // DP[n][x] := 数字 x を s0 ... sn-1 で やった時の解
    // 遷移式 : DP[i][0] = 0 for all i 
    //       : DP[0][x] = x % s0
    //         DP[i][x] = DP[i-1][x] * i + DP[i-1][x % i]
    std::sort(S.begin(), S.end());
    for(int x = 0; x <= X; ++x) DP[0][x] = x % S[0];
    REP(i, n) DP[i][0] = 0;
    for(int i = 1; i < n; ++i){
        for(int x = 0; x <= X; ++x) DP[i][x] = (DP[i-1][x] * i + DP[i-1][x % S[i]]) % mod;
    }
    printf("%lld\n", DP[n-1][X]);
    return 0;
}

Compiler output:
a.cc:10:23: error: 'lli' was not declared in this scope; did you mean 'lldiv'?
   10 | std::array<std::array<lli, MAX_X+1>, MAX_N> DP;
      |                       ^~~
      |                       lldiv
a.cc:10:35: error: template argument 1 is invalid
   10 | std::array<std::array<lli, MAX_X+1>, MAX_N> DP;
      |                                   ^
a.cc:10:43: error: template argument 1 is invalid
   10 | std::array<std::array<lli, MAX_X+1>, MAX_N> DP;
      |                                           ^
a.cc: In function 'int main()':
a.cc:20:35: error: invalid types 'int[int]' for array subscript
   20 |     for(int x = 0; x <= X; ++x) DP[0][x] = x % S[0];
      |                                   ^
a.cc:21:9: error: 'i' was not declared in this scope
   21 |     REP(i, n) DP[i][0] = 0;
      |         ^
a.cc:21:5: error: 'REP' was not declared in this scope
   21 |     REP(i, n) DP[i][0] = 0;
      |     ^~~
a.cc:23:39: error: invalid types 'int[int]' for array subscript
   23 |         for(int x = 0; x <= X; ++x) DP[i][x] = (DP[i-1][x] * i + DP[i-1][x % S[i]]) % mod;
      |                                       ^
a.cc:23:51: error: invalid types 'int[int]' for array subscript
   23 |         for(int x = 0; x <= X; ++x) DP[i][x] = (DP[i-1][x] * i + DP[i-1][x % S[i]]) % mod;
      |                                                   ^
a.cc:23:68: error: invalid types 'int[int]' for array subscript
   23 |         for(int x = 0; x <= X; ++x) DP[i][x] = (DP[i-1][x] * i + DP[i-1][x % S[i]]) % mod;
      |                                                                    ^
a.cc:25:24: error: invalid types 'int[int]' for array subscript
   25 |     printf("%lld\n", DP[n-1][X]);
      |                        ^
Language: C++

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<boost/operators.hpp>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl = 1e+18 + 1;
int INF = 1e+9 + 1;
namespace lib
{
	template<class T>constexpr T pow(T val, std::uint64_t p)
	{
		auto ret = T(1);
		for (auto i : boost::irange(0, 63))
		{
			if (p & (1ULL << i))
			{
				ret *= val;
			}
			val *= val;
		}
		return ret;
	}
	template<std::uint64_t Mod>class modnum :
		private boost::addable<modnum<Mod>>,
		private boost::subtractable<modnum<Mod>>,
		private boost::multipliable<modnum<Mod>>,
		private boost::dividable<modnum<Mod>>
	{
		std::uint64_t val;
		void clamp()
		{
			val %= Mod;
		}
	public:
		modnum() = default;
		modnum(std::int64_t v) :val()
		{
			if (v < 0)
			{
				v += (std::abs(v) / Mod + 1) * Mod;
			}
			val = v;
			clamp();
		}
		modnum(std::uint64_t v) :val(v)
		{
			clamp();
		}
		modnum(std::int32_t v) :modnum(static_cast<std::int64_t>(v))
		{

		}
		modnum(std::uint32_t v) :modnum(static_cast<std::uint64_t>(v))
		{

		}
		friend std::ostream& operator<<(std::ostream& os, modnum const& num)
		{
			return os << num.val;
		}
		auto& operator+=(modnum const& rhs)
		{
			val += rhs.val;
			clamp();
			return *this;
		}
		auto& operator-=(modnum const& rhs)
		{
			val += Mod - rhs.val;
			clamp();
			return *this;
		}
		auto& operator*=(modnum const& rhs)
		{
			val *= rhs.val;
			clamp();
			return *this;
		}
		auto& operator/=(modnum const& rhs)
		{
			val *= pow(rhs, Mod - 2).val;
			clamp();
			return *this;
		}
		auto const& operator*()const
		{
			return val;
		}
	};
}
using mint = lib::modnum<1000000007>;
mint dp[201][100001] = {};
int main() {
	int N, X;
	vint S;
	scan(N >> X);
	mint fac[202];
	fac[0] = 1;
	rep1(i, N) fac[i] = fac[i - 1] * i;
	rep(i, N) {
		int s;
		scan(s);
		S.push_back(s);
	}
	sort(rALL(S));
	dp[0][X] = 1;
	rep(i, N) {
		rep(x, X + 1) {
			dp[i + 1][x % S[i]] += dp[i][x] / (N - i);//i番目に大きい値がXを変化させる確率は1/(N-i)
			dp[i + 1][x] += dp[i][x] * (N - i - 1) / (N - i);//i番目に大きい値がXを変化させない確率は(N-i-1)/(N-i)
		}
	}
	mint ans = 0;
	rep(x, X + 1) ans += dp[N][x] * x;
	prin(ans * fac[N]);
	return 0;
}


Compiler output:
a.cc:13:9: fatal error: boost/operators.hpp: No such file or directory
   13 | #include<boost/operators.hpp>
      |         ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int ;i = 0; i < (n); i++)
ll dp[n+1][x+1]={0}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,x,mod=1e9+7;
    cin>>n>>x;
    vector<int>s(n);
    rep(i,n)cin>>s[i];

    
    rep(i,x)dp[0][i]=x;

    rep(i,n)rep(j,x+1){
        dp[i+1][j]+=dp[i][x]%mod;
        dp[i+1][x]%=mod;
        dp[i+1][j]+=dp[i][x%s[i]]%mod;
        dp[i+1][x]%=mod;
    }

    cout<<dp[n][x]<<endl;

    return 0;
}



Compiler output:
a.cc:6:7: error: 'n' was not declared in this scope; did you mean 'yn'?
    6 | ll dp[n+1][x+1]={0}
      |       ^
      |       yn
a.cc:6:12: error: 'x' was not declared in this scope
    6 | ll dp[n+1][x+1]={0}
      |            ^
Language: C++

#include <iostream>

using namespace std;

const int mod = 1000000007;
const int N = 205;

const int SZ = 100005;

int inv[N];
int s[SZ];
int dp[N][SZ];

int mul(int a, int b) {
    return (1LL * a * b) % mod;
}

int add(int a, int b) {
    a += b;
    if (a >= mod) a -= mod;
    return a;
}


int main() {
    int n, x;
    cin >> n >> x;

    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    sort(s, s + n);

    for (int i = 0; i <= x; i++) {
        dp[0][i] = i % s[0];
    }

    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= x; j++) {
            dp[i][j] = add(dp[i - 1][j % s[i]], mul(dp[i - 1][j], i));
        }
    }

    cout << dp[n - 1][x];
    //dp[i][j] = dp[i - 1][j % s[i]] + dp[i - 1][j] * i;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   33 |     sort(s, s + n);
      |     ^~~~
      |     short
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
long long N, X, S[200];
double memo[201][200001];

double f(int i, int x)
{
	if (memo[i][x] != 0)
		return memo[i][x];
	else if (i == N)
		return x;
	else
	{
		return memo[i][x] = f(i + 1, x % S[i]) / (N - i) + f(i + 1, x)*(N - i - 1) / (N - i);
	}
}



long long factorial(int n)
{
	long long ans = 1;
	for (int i = 1; i <= n; i++)
	{
		ans *= i;
	}
	return ans;
}

int main()
{
	cin >> N >> X;
	for (int i = 0; i < N; i++)
		cin >> S[i];

	sort(S, S + N,greater<int>());

	memset(memo, 0, sizeof(memo));

	double ans = f(0, X);

	long long mul = factorial(N);

	long long aaa = mul * ans;

	cout << aaa % 1000000007;
	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:9: error: 'memset' was not declared in this scope
   39 |         memset(memo, 0, sizeof(memo));
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <algorithm>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

N, X = map(int, input().split())
S = sorted(list(map(int, input().split())))
MOD = int(1e9 + 7)
memo = [{} for _ in range(N + 1)]
def solve(n, x):
    if n == 0:
        return x % MOD
    if x in memo[n]:
        return memo[n][x]
    memo[n][x] = 0
    for i in range(n):
        memo[n][x] += solve(n - 1, x % S[i])
        memo[n][x] %= MOD
    return memo[n][x]
print(solve(N, X))

Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N, X = map(int, input().split())
      | ^
a.cc:4:12: error: expected unqualified-id before 'for'
    4 | memo = [{} for _ in range(N + 1)]
      |            ^~~
Language: C++

//Insert DP
#include <string>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int mod = 1000000007;
	int N, X;
	cin >> N >> X;
	vector<int> s(N, 0);
	for(int i = 0; i < N; i += 1)
	{
		cin >> s[i];
	}
	sort(s.begin(), s.end(), less<long>());
	vector<vector<long>> dp(N + 1, vector<long>(X + 1, 0));
	for(int x = 0; x <= X; x += 1)
	{
		dp[0][x] = x;
	}

	for(int i = 0; i < N; i += 1)
	{
		for(int x = 0; x <= X; x += 1)
		{
			dp[i + 1][x] = (dp[i][x % s[i]] + i * dp[i][x]) % mod; //insert in front of array and in mid of array
		}
	}
	cout << dp[N][X] << endl;
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   16 |         sort(s.begin(), s.end(), less<long>());
      |         ^~~~
      |         short
Language: C

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

const int64_t MOD = 1e9+7;
void add(int64_t &a, int64_t b) {
    a = (a+b) % MOD;
}
void mul(int64_t &a, int64_t b) {
    a = a*b % MOD;
}

int64_t dp[201][1000001];

int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> S(n);
    for(int i = 0; i < n; ++i) { cin >> S[i]; }
    sort(S.rbegin(), S.rend());
    dp[0][x] = 1;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= 100000; ++j) {
            add(dp[i+1][j%S[i]], dp[i][j]);
            add(dp[i+1][j], dp[i][j] * (n-i-1));
        }
    }

    int64_t ans = 0;
    for(int j = 0; j <= 100000; j++) { add(ans, j*dp[n][j]); }
    cout << ans << endl;
    return 0;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
#define ALL(c) (c).begin(), (c).end()

using namespace std;
using ll = long long;
using pli = pair<ll, int>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;

#include "Modulo.h"
int B, W;
#define MOD 1000000007

int main() {
	cin >> B >> W;
	set_mod(MOD);
	int N = B + W;
	set_fact_mod(N);
	set_rev_fact_mod(N);

	vector<Modint> p(N), q(N), r(N);
	p[0] = q[0] = 0;
	r[0] = 1;
	for (int i = 1; i <= N - 1; i++)
	{
		p[i] = p[i - 1];
		if (i >= B)
			p[i] += combination_mod_precalculation(i - 1, B - 1) / pow_mod(2, i);
		q[i] = q[i - 1];
		if (i >= W)
			q[i] += combination_mod_precalculation(i - 1, W - 1) / pow_mod(2, i);
		r[i] = 1 - p[i] - q[i];
	}
	for (int i = 1; i <= N; i++)
	{
		const Modint ans = q[i - 1] + r[i - 1] / 2;
		cout << ans << endl;
	}

	return 0;
}

Compiler output:
a.cc:27:10: fatal error: Modulo.h: No such file or directory
   27 | #include "Modulo.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,x;cin>>n>>x;
  ll s[n];
  for(ll i=0;i<n;i++)cin>>s[i];
  sort(s,s+n);
  ll dp[n];
  dp[0]=x%s[0];
  ll cnt[n][100010];
  fill(cnt[0],cnt[0]+100010,0);
  cnt[0][x%s[0]]=1;
  for(ll i=1;i<n;i++){
    ll y=x%s[i];
    ll u=(x-y)%s[0];
    for(int j=0;j<100010;j++){
      cnt[i][j]=cnt[i-1][(j-u)%s[0]];
      cnt[i][j]%=mod;
    }
  }
  ll ans=0;
  for(ll i=0;i<100010;i++){
    ans+=i*cnt[n-1][i];
    ans%=mod;
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:18: error: 'mod' was not declared in this scope; did you mean 'modf'?
   19 |       cnt[i][j]%=mod;
      |                  ^~~
      |                  modf
a.cc:25:10: error: 'mod' was not declared in this scope; did you mean 'modf'?
   25 |     ans%=mod;
      |          ^~~
      |          modf
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,x;cin>>n>>x;
  ll s[n];
  for(ll i=0;i<n;i++)cin>>s[i];
  sort(s,s+n);
  ll dp[n];
  dp[0]=x%s[0];
  ll cnt[n][100010];
  fill(cnt[0],cnt[0]+100010,0);
  cnt[0][x%s[0]]=1;
  for(ll i=1;i<n;i++){
    ll y=x%s[i];
    ll u=(x-y)%s[0];
    for(int j=0;j<100010;j++){
      cnt[i][j]=cnt[i-1][(j+u)%s[0]];
      cnt[i][j]%=mod;
    }
  }
  ll ans=0;
  for(ll i=0;i<100010;i++){
    ans+=i*cnt[n-1][i];
    ans%=mod;
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:18: error: 'mod' was not declared in this scope; did you mean 'modf'?
   19 |       cnt[i][j]%=mod;
      |                  ^~~
      |                  modf
a.cc:25:10: error: 'mod' was not declared in this scope; did you mean 'modf'?
   25 |     ans%=mod;
      |          ^~~
      |          modf
Language: C++

#include<bits/stdc++.h>

#define ALL(c) (c).begin(),(c).end()
#define EACH(i, c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const long long MOD = 1000000007;

int dp[200][100010];
int inv[210];

int powmod(int a, int k) {
    int r = 1;
    while (k > 0) {
        if (k & 1) {
            r = (r * a) % MOD;
        }
        a = (a * a) % MOD;
        k /= 2;
    }
    return r;
}

int invmod(int a) {
    return powmod(a, MOD - 2);
}

void solve(long long N, long long X, std::vector<long long> &S) {
    for (int i = 1; i <= 200; ++i) {
        inv[i] = invmod(i);
    }
    dp[0][X] = 1;
    sort(ALL(S));
    reverse(ALL(S));
    for (int i = 0; i < N; ++i) {
        for (int x = 0; x <= X; ++x) {
            dp[i + 1][x] = dp[i][x] * inv[N - i] % MOD * (N - i - 1) % MOD;
        }
        for (int x = 0; x <= X; ++x) {
            int t = x % S[i];
            dp[i + 1][t] = (dp[i + 1][t] + (dp[i][x] * inv[N - i]) % MOD) % MOD;
        }
    }
/*
    int res = 0;
    for (int i = 0; i <= X; ++i) {
        res = (res + (dp[N][i] * i) % MOD) % MOD;
    }
     */
    for(int i = 1; i <= N; ++i) {
    res = (res * i) % MOD;
    }
    cout << res << endl;
}

signed main() {
    long long N;
    scanf("%lld", &N);
    long long X;
    scanf("%lld", &X);
    std::vector<long long> S(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &S[i]);
    }
    solve(N, X, S);
    return 0;
}

Compiler output:
a.cc: In function 'void solve(long long int, long long int, std::vector<long long int>&)':
a.cc:52:5: error: 'res' was not declared in this scope
   52 |     res = (res * i) % MOD;
      |     ^~~
a.cc:54:13: error: 'res' was not declared in this scope
   54 |     cout << res << endl;
      |             ^~~
Language: C++


#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;

struct pairhash {
public:
  template <typename T, typename U>
  std::size_t operator()(const std::pair<T, U> &x) const
  {
    return std::hash<T>()(x.first) ^ std::hash<U>()(x.second);
  }
};

vector<int> s;
int mem[100001][201];

const int MOD = 1e9 + 7;

vector<int> pos;

long long dp(int x, int rem) {
  if (x == 0) {
    return 0;
  }
  if (mem[x][rem] != -1) { return mem[x][rem]; }
  int ans = 0;
  if (rem > 0) {
    ans = (dp(x, rem - 1) * rem) % MOD;
  }
  if (x < s[0]) {
    if (rem == 0) ans = x;
    //cerr << "go x: " << x << " rem: " << rem << " ans: " << ans << endl;
    return mem[x][rem] = ans;
  }

  for (int i = 0; i < s.size(); ++i) {
    if (s[i] > x) break;
    int xx = x % s[i];
    ans = ans + dp(xx, rem + pos[x] - pos[xx] - 1);
    while (ans >= MOD) ans -= MOD;
  }
  //cerr << "mem x: " << x << " rem: " << rem << " ans: " << ans << endl;
  return mem[x][rem] = ans;
}

int main() {
  memset(mem, -1, sizeof(mem));
  int n,x;
  cin >> n >> x;
  s.resize(n);
  for (auto& a : s) cin >> a;
  sort(s.begin(),s.end());
  int rem = 0;
  pos.resize(x + 1);
  int p = 0;
  for (int i = 0; i <= x; ++i) {
    while (p < s.size() && s[p] <= i) p++;
    pos[i] = p;
  }
  rem = s.size() - pos[x];
  //cerr << "rem: " << rem << endl;
  cout << dp(x, rem);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:3: error: 'memset' was not declared in this scope
   51 |   memset(mem, -1, sizeof(mem));
      |   ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <unordered_map>
  +++ |+#include <cstring>
    6 |
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define REP(i, x, y) for (int i = x; i < y; i++)

const int8_t INFC = 0x3f;
const int16_t INFS = 0x3f3f;
const int32_t INF = 0x3f3f3f3f;
const int64_t INFL = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = 1e9+7;
int a[300],n,used[300];
int dfs(int r)
{
    //cout << r << endl;
    int res=0,cnt=0;
    REP(i,0,n)
    {
        if (a[i]>r&&!used[i])
        {
            cnt++;
        }
    }
    int recover=250;
    REP(i,0,n)
    {
        if (a[i]>r&&!used[i])
        {
            used[i]=1;
            recover=i;
            break;
        }
    }
    bool flg=0;
    REP(i,0,n)
    {
        if (a[i]<=r&&!used[i])
        {
            //cout << "p"<< a[i] << endl;
            flg=1;
            used[i]=1;
            res=(res+dfs(r%a[i]))%MOD;
            used[i]=0;
        }
    }
    used[recover]=0;
    if (!flg) res=r;
    res=1LL*res*p[cnt]%MOD;
    return res;
}
int main()
{
    ios::sync_with_stdio(0);
    int x;
    cin >> n >> x;
    p[0]=1;
    for (int i=1;i<=n;i++)
    {
        p[i]=1ll*p[i-1]*i%MOD;
    }
    REP(i,0,n)cin >> a[i];
    cout << dfs(x) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:48:17: error: 'p' was not declared in this scope
   48 |     res=1LL*res*p[cnt]%MOD;
      |                 ^
a.cc: In function 'int main()':
a.cc:56:5: error: 'p' was not declared in this scope
   56 |     p[0]=1;
      |     ^