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

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

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

const int MN = 200010;

int N;
int A[MN], D[MN];
ll dp1[MN], dp2[MN];
vector<pii> seg;

void solve(int *dp) {
    for(int i = 1; i < N; i++) {
        ll p = 4;
        while(p * A[i - 1] <= A[i]) {
            D[i]++;
            p *= 4;
        }
    }

    seg.clear();

    dp[N - 1] = 0;
    seg.push_back(pii(N - 1, N - 1));
    for(int i = N - 2; i >= 0; i--) {
        dp[i] = dp[i + 1];

        if(A[i + 1] < A[i]) {
            ll p = 1;
            int cnt = 0;
            while(p * A[i + 1] < A[i]) {
                cnt++;
                p *= 4;
            }

            pii tmp = pii(i, i);
            while(seg.size()) {
                if(cnt < D[ seg.back().first ]) {
                    D[ seg.back().first ] -= cnt;
                    break;
                }
                dp[i] += (cnt - D[ seg.back().first ]) * (seg.back().second - seg.back().first + 1);
                cnt -= D[ seg.back().first ];
                D[ seg.back().first ] = 0;
                tmp.second = seg.back().second;
                seg.pop_back();
            }
            seg.push_back(tmp);
        }
        else {
            if(D[ seg.back().first ]) seg.push_back(pii(i, i));
            else seg.back().first = i;
        }
    }
}

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    solve(dp1);
    reverse(A, A + N);
    solve(dp2);

    ll ans = 1e18;
    for(int i = 0; i <= N; i++) {
        ans = min(ans, 2 * dp1[i] + 2 * dp2[N - i] + i);
    }
    printf("%lld", ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:66:11: error: cannot convert 'll*' {aka 'long long int*'} to 'int*'
   66 |     solve(dp1);
      |           ^~~
      |           |
      |           ll* {aka long long int*}
a.cc:14:17: note:   initializing argument 1 of 'void solve(int*)'
   14 | void solve(int *dp) {
      |            ~~~~~^~
a.cc:68:11: error: cannot convert 'll*' {aka 'long long int*'} to 'int*'
   68 |     solve(dp2);
      |           ^~~
      |           |
      |           ll* {aka long long int*}
a.cc:14:17: note:   initializing argument 1 of 'void solve(int*)'
   14 | void solve(int *dp) {
      |            ~~~~~^~
Language: C++

n=int(input())
a=list(map(int,input().split()))
ans=0

for i in range(n//2):
 if a[i]<=a[i+1]:
  continue
 while a[i]<=a[i+1]:
  a[i]*=-2
  ans+=1
  if a[i]>0 :
   a[i]=a[i]*-2
   ans+=1
  
for i in range(n-1):
 if i<n//2:
  continue
 if a[i]<=a[i+1]:
  continue
 while a[i]<=a[i+1]:
  a[i+1]*=2;
  ans+=1
  if a[i+1]>0:
   a[i+1]*=2;
   ans+=1

print(ans)
  


Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n=int(input())
      | ^
a.cc:22:3: error: 'ans' does not name a type
   22 |   ans+=1
      |   ^~~
a.cc:25:4: error: 'ans' does not name a type
   25 |    ans+=1
      |    ^~~
Language: C++

#include<iostream>
#include<stdint>
#include<stack>
#include<algorithm>
using namespace std;

const int MAX = 200001;
const int INF = 1073741823; // 10^30-1、使わない辺とかに用いる

int operate(int64_t l, int64_t r) { // 必要操作回数
	int ret = 0;
	while(l > r) {
		++ ret;
		r *= 4;
	}
	return ret;
}

struct graph {
	int A;
	int connect; // 自分より大きい、既にみたものの中で一番近い奴
	int64_t num;
	int64_t pChange; // 正の方向と決め打った時の操作回数
	int64_t nChange; // 負の方向と決め打った時の操作回数
	void addChange(int right, int64_t n) {
		pChange += operate(A, right) * n;
		num += n;
	}
	void addChange2(int left, int64_t n) {
		nChange += operate(A, left) * n;
		num += n;
	}
};

int main() {
	int N;
	static graph A[MAX];
	cin >> N;
	A[0].A = INF; // A[0]さんはバグ防止の番兵として立ちはだかってもらう
	A[0].nChange = 0;
	for (int i = 1;i <= N;++ i) cin >> A[i].A;
	stack<int> stk;
	stk.push(0);
	for (int i = 1;i <= N;++ i) {
		A[i].num = 1;
		A[i].pChange = 0;
		while (A[stk.top()].A <= A[i].A) stk.pop();
		A[i].connect = stk.top(); // 自分より大きい中で最も近い奴
		stk.push(i);
	}
	for (int i = N;i >= 1;-- i) A[A[i].connect].addChange(A[i].A, A[i].num);
	for (int i = N - 1;i >= 1;-- i) A[i].pChange += A[i + 1].pChange; // 累積和
	
	while(!stk.empty()) stk.pop(); // いったんstackを空にする
	stk.push(0);
	for (int i = N;i >= 1;-- i) {
		A[i].num = 1;
		A[i].nChange = 0;
		while (A[stk.top()].A <= A[i].A) stk.pop();
		A[i].connect = stk.top(); // 自分より大きい中で最も近い奴
		stk.push(i);
	}
	for (int i = 1;i <= N;++ i) A[A[i].connect].addChange2(A[i].A, A[i].num);
	for (int i = 2;i <= N;++ i) A[i].nChange += A[i - 1].nChange; // 累積和
	
	int64_t ans = INF;
	for (int i = 1;i <= N;++ i) ans = min(ans, i - 1 + (A[i].pChange + A[i - 1].nChange) * 2);
	
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、ある値を境に負か正か変わる
ので、その境目をO(N)で決め打ってみる

面倒なので正の方向で考えると、境目を境にかならず単調増加な形になる
これはO(N)で求められるので、O(N^2)解は定まった
さて、次にこれの計算量を減らす必要がある
でも、これは単調増加なのを利用するとO(1)で求められるので実はO(N)
あ、いや前計算O(NlogA)があるので一応そっちが計算量になるね
*/

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

#include<boost/multiprecision/cpp_dec_float.hpp>
#include<boost/multiprecision/cpp_int.hpp>
#include<iostream>
#define size 524288

using namespace std;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

Bint llmin(Bint aa,Bint bb){
  if(aa<bb){return aa;}
  return bb;
}

gloval Bint w,n;
gloval Bint a[size];
gloval Bint pb[size]={0},mf[size]={0};
gloval Bint pp[size],pm[size];

Bint repf(Bint pt){
  if(pt==n+1){return n+1;}
  //a[pt-1]*=4;
  Bint k,x,c=0;
  if(a[pt-1]<=a[pt]){return pt;}
  while(a[pt-1]>a[pt]){
    a[pt]*=4;
    k*=4;
    c++;
  }
  x=pp[pt];
  if(x-1!=pt){
    a[x-1]*=k;
  }
  w+=(2*(x-pt));
  pp[pt]=repf(x);
}

Bint repb(Bint pt){
  if(pt==0){return 0;}
  //a[pt-1]*=4;
  Bint k,x,c=0;
  if(a[pt]<=a[pt+1]){return pt;}
  while(a[pt]>a[pt+1]){
    a[pt]*=4;
    k*=4;
    c++;
  }
  x=pm[pt];
  if(x+1!=pt){
    a[x+1]*=k;
  }
  w+=(2*(pt-x));
  pm[pt]=repb(x);
}

int main(void){
    Bint ba[size],i,j,m,k,b,c,h,r=0,l,t;
    cin >> n;
    for(i=1;i<=n;i++){
      cin >> a[i];
      ba[i]=a[i];
      pp[i]=i+1;
      pm[i]=i-1;
    }

    w=0;
    pb[n]=0;
    c=1;
    for(i=n-1;i>=1;i--){
      pp[i]=repf(i+1);
      pb[i]=w;
      c++;
    }

    for(i=1;i<=n;i++){a[i]=ba[i];}

    w=1;
    mf[1]=1;
    a[1]*=-2;
    c=1;
    for(i=2;i<=n;i++){
      a[i]*=-2;
      w++;
      pm[i]=repb(i-1);
      mf[i]=w;
      c++;
    }
    r=llmin(pb[1],mf[n]);
    for(i=2;i<=n;i++){
      //printf("<%lld %lld>\n",pb[i],mf[i-1]);
      r=llmin(r,pb[i]+mf[i-1]);
    }
    cout << r << endl;
    return 0;
}


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

n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0

for i in range(n/2):
 if a[i]<=a[i+1]:
  continue
 while a[i]<=a[i+1]:
  a[i]*=-2
  ans++
  if a[i]>0 :
   a[i]=a[i]*-2
   ans++
  
for i in range(n-1):
 if i<n/2:
  continue
 if a[i]<=a[i+1]:
  continue
 while a[i]<=a[i+1]:
  a[i+1]*=2;
  ans++
  if a[i+1]>0:
   a[i+1]*=2;
   ans++

print(ans)
  

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n,x=map(int,input().split())
      | ^
a.cc:22:3: error: 'ans' does not name a type
   22 |   ans++
      |   ^~~
a.cc:25:4: error: 'ans' does not name a type
   25 |    ans++
      |    ^~~
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    ll ai;
    vector<ll> Ao;
    cin >> N;
    bool checkTrivial = true;
    for(int i=0;i<N;i++){
        cin >> ai;
        if(checkTrivial && i!=0 && ai <= Ao.back()) checkTrivial = false;
        Ao.push_back(ai);
    }
    if(checkTrivial){
        cout<<0<<endl;
        return 0;
    }

    ll nmin = std::numeric_limits<ll>::max();
    for(ll i=-1;i<N;i++){
        auto A = Ao;
        ll n = i+1;
        for(int j=i-1;j>=0;j--){
            while(A.at(j) < A.at(j+1)){
                A.at(j) *= 4;
                n += 2;
            }
        }
        for(int j=i+1+1;j<N;j++){
            while(A.at(j) < A.at(j-1)){
                A.at(j) *= 4;
                n += 2;
            }
        }
        nmin = min(n, nmin);
    }

    cout<<nmin<<endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:20: error: 'numeric_limits' is not a member of 'std'
   27 |     ll nmin = std::numeric_limits<ll>::max();
      |                    ^~~~~~~~~~~~~~
a.cc:27:37: error: expected primary-expression before '>' token
   27 |     ll nmin = std::numeric_limits<ll>::max();
      |                                     ^
a.cc:27:43: error: no matching function for call to 'max()'
   27 |     ll nmin = std::numeric_limits<ll>::max();
      |                                      ~~~~~^~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 0 provided
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    ll ai;
    vector<ll> Ao;
    cin >> N;
    bool checkTrivial = true;
    for(int i=0;i<N;i++){
        cin >> ai;
        if(checkTrivial && i!=0 && ai <= Ao.back()) checkTrivial = false;
        Ao.push_back(ai);
    }
    if(checkTrivial){
        cout<<0<<endl;
        return 0;
    }
----
    ll nmin = std::numeric_limits<ll>::max();
    for(ll i=-1;i<N;i++){
        auto A = Ao;
        ll n = i+1;
        for(int j=i-1;j>=0;j--){
            while(A.at(j) < A.at(j+1)){
                A.at(j) *= 4;
                n += 2;
            }
        }
        for(int j=i+1+1;j<N;j++){
            while(A.at(j) < A.at(j-1)){
                A.at(j) *= 4;
                n += 2;
            }
        }
        nmin = min(n, nmin);
    }

    cout<<nmin<<endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:8: error: expected primary-expression before 'nmin'
   27 |     ll nmin = std::numeric_limits<ll>::max();
      |        ^~~~
a.cc:43:9: error: 'nmin' was not declared in this scope
   43 |         nmin = min(n, nmin);
      |         ^~~~
a.cc:46:11: error: 'nmin' was not declared in this scope
   46 |     cout<<nmin<<endl;
      |           ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    ll ai;
    vector<ll> Ao;
    cin >> N;
    bool checkTrivial = true;
    for(int i=0;i<N;i++){
        cin >> ai;
        if(checkTrivial && i!=0 && ai <= Ao.back()) checkTrivial = false;
        Ao.push_back(ai);
    }
    if(checkTrivial){
        cout<<0<<endl;
        return 0;
    }
----
    ll nmin = LLONG_MAX;
    for(ll i=-1;i<N;i++){
        auto A = Ao;
        ll n = i+1;
        for(int j=i-1;j>=0;j--){
            while(A.at(j) < A.at(j+1)){
                A.at(j) *= 4;
                n += 2;
            }
        }
        for(int j=i+1+1;j<N;j++){
            while(A.at(j) < A.at(j-1)){
                A.at(j) *= 4;
                n += 2;
            }
        }
        nmin = min(n, nmin);
    }

    cout<<nmin<<endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:8: error: expected primary-expression before 'nmin'
   27 |     ll nmin = LLONG_MAX;
      |        ^~~~
a.cc:43:9: error: 'nmin' was not declared in this scope
   43 |         nmin = min(n, nmin);
      |         ^~~~
a.cc:46:11: error: 'nmin' was not declared in this scope
   46 |     cout<<nmin<<endl;
      |           ^~~~
Language: C++

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    ll ai;
    vector<ll> Ao;
    cin >> N;
    bool checkTrivial = true;
    for(int i=0;i<N;i++){
        cin >> ai;
        if(checkTrivial && i!=0 && ai <= Ao.back()) checkTrivial = false;
        Ao.push_back(ai);
    }
    if(checkTrivial){
        cout<<0<<endl;
        return 0;
    }
----
    ll nmin = LLONG_MAX;
    for(ll i=-1;i<N;i++){
        auto A = Ao;
        ll n = i+1;
        for(int j=i-1;j>=0;j--){
            while(A.at(j) < A.at(j+1)){
                A.at(j) *= 4;
                n += 2;
            }
        }
        for(int j=i+1+1;j<N;j++){
            while(A.at(j) < A.at(j-1)){
                A.at(j) *= 4;
                n += 2;
            }
        }
        nmin = min(n, nmin);
    }

    cout<<nmin<<endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:8: error: expected primary-expression before 'nmin'
   26 |     ll nmin = LLONG_MAX;
      |        ^~~~
a.cc:42:9: error: 'nmin' was not declared in this scope
   42 |         nmin = min(n, nmin);
      |         ^~~~
a.cc:45:11: error: 'nmin' was not declared in this scope
   45 |     cout<<nmin<<endl;
      |           ^~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;

ll solve(int n, vector<int> & in){
  const double log2 = 1;
  vector<double> in_log(n);
  for(int i = 0;i < n;i++){
    in_log[i] = std::log2(in[i]);
  }

  vector<ll> b(n);
  b[0] = 0;
  for(int i = 1;i < n;i++){
    if (in[i] > in[i-1]){
      b[i] = b[i-1];
    } else {
      double tmp_b_i = in_log[i-1] - in_log[i] + b[i-1];
      b[i] = static_cast<ll>(ceil(tmp_b_i));
      if (b[i]%2 == 1 || b[i]%2 == -1)b[i]++;
    }
  }

  /*
  // debug
  cout <<"b: ";
  for(int i = 0;i < n;i++){
    cout << b[i] <<" ";
  }
  cout << endl;
  // debug end
  */

  vector<int> c(n);
  c[n-1] = 1;
  for(int i = n-2;i >= 0;i--){
    if (in[i] > in[i+1]){
      c[i] = c[i+1];
    } else {
      double tmp_c_i = in_log[i+1] - in_log[i] + c[i+1];
      c[i] = static_cast<ll>(ceil(tmp_c_i));
      if (c[i]%2 == 0)c[i]++;
    }
  }
  /*
  // debug
  cout << "c: " ;
  for(int i = 0;i < n;i++){
    cout << c[i] <<" ";
  }
  cout << endl;
  //
  */
  ll neg_sum = accumulate(begin(c), end(c), 0LL);
  ll pos_sum = accumulate(begin(b), end(b), 0LL);
  ll ret = min(pos_sum, neg_sum);

  vector<ll> d(n);//decrease value for negative
  ll decreased=0;
  d[n-1] = neg_sum;
  for(int i = n-2;i >= 0;i--){
    neg_sum = neg_sum - 1 - (c[i] - c[i+1]) * (i+1);
    d[i] = neg_sum;
  }
  /*
  //debug
  cout << "d: ";
  for(int i = 0;i < n;i++){
    cout << d[i] <<" ";
  }
  cout << endl;
  // debug
  */
  // [0,i) should be negative
  for(int neg_range = 1;neg_range < n;neg_range++){
    pos_sum -= (b[neg_range] - b[neg_range-1]) * (n - neg_range);
    //cout << neg_range <<" " << pos_sum << endl;
    ll tmp = pos_sum + d[neg_range-1];
    ret = min(ret, tmp);
  }
  return ret;
}


int main(){
  int n;
  cin>>n;
  vector<int> in(n);
  for(int i = 0;i < n;i++){
    cin >> in[i];
  }
  cout << solve(n, in) << endl;
  return 0;
}


Compiler output:
a.cc: In function 'll solve(int, std::vector<int>&)':
a.cc:58:16: error: 'accumulate' was not declared in this scope
   58 |   ll neg_sum = accumulate(begin(c), end(c), 0LL);
      |                ^~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

ll INF=LLONG_MAX/2;
int N;
vector<ll> A,B;

int main(){
  
  cin>>N;
  A.resize(N);
  B.resize(N);
  int ma=0;
  rep(i,N){
    cin>>A[i];
    B[i]=A[i];
    if(A[ma]<A[i]) ma=i;
  }
  sort(B.begin(),B.end());
  if(A==B){
    cout<<0<<endl;
    return 0;
  }
  
  B=A;
  int ans=0;
  for(int i=ma+1;i<N;i++){
    if(B[i]<B[i-1]){
      int ok=20,ng=0;
      while(abs(ok-ng)>1){
        int mid=(ok+ng)/2;
        if(B[i]*beki[mid]>=B[i-1]) ok=mid;
        else ng=mid;
      }
      B[i]*=beki[ok];
      ans+=beki2[ok];
    }
  }

  for(int i=ma-1;i>=0;i--){
    if(B[i]>B[i+1]){
      B[i]*=-2;
      ans++;
    }
    if(B[i]>B[i+1]){
      int ok=20,ng=0;
      while(abs(ok-ng)>1){
        int mid=(ok+ng)/2;
        if(B[i]*beki[mid]<=B[i+1]) ok=mid;
        else ng=mid;
      }
      B[i]*=beki[ok];
      ans+=beki2[ok];
    }
  }


  int cnt=1;
  B=A;
  
  B[ma]*=-2;
  for(int i=ma+1;i<N;i++){
    if(B[i]<B[i-1]){
      int ok=20,ng=0;
      while(abs(ok-ng)>1){
        int mid=(ok+ng)/2;
        if(B[i]*beki[mid]>=B[i-1]) ok=mid;
        else ng=mid;
      }
      B[i]*=beki[ok];
      cnt+=beki2[ok];
    }
  }

  for(int i=ma-1;i>=0;i--){
    if(B[i]>B[i+1]){
      B[i]*=-2;
      cnt++;
    }
    if(B[i]>B[i+1]){
      int ok=20,ng=0;
      while(abs(ok-ng)>1){
        int mid=(ok+ng)/2;
        if(B[i]*beki[mid]<=B[i+1]) ok=mid;
        else ng=mid;
      }
      B[i]*=beki[ok];
      cnt+=beki2[ok];
    }
  }

  cout<<min(ans,cnt)<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:17: error: 'beki' was not declared in this scope
   35 |         if(B[i]*beki[mid]>=B[i-1]) ok=mid;
      |                 ^~~~
a.cc:38:13: error: 'beki' was not declared in this scope
   38 |       B[i]*=beki[ok];
      |             ^~~~
a.cc:39:12: error: 'beki2' was not declared in this scope
   39 |       ans+=beki2[ok];
      |            ^~~~~
a.cc:52:17: error: 'beki' was not declared in this scope
   52 |         if(B[i]*beki[mid]<=B[i+1]) ok=mid;
      |                 ^~~~
a.cc:55:13: error: 'beki' was not declared in this scope
   55 |       B[i]*=beki[ok];
      |             ^~~~
a.cc:56:12: error: 'beki2' was not declared in this scope
   56 |       ans+=beki2[ok];
      |            ^~~~~
a.cc:70:17: error: 'beki' was not declared in this scope
   70 |         if(B[i]*beki[mid]>=B[i-1]) ok=mid;
      |                 ^~~~
a.cc:73:13: error: 'beki' was not declared in this scope
   73 |       B[i]*=beki[ok];
      |             ^~~~
a.cc:74:12: error: 'beki2' was not declared in this scope
   74 |       cnt+=beki2[ok];
      |            ^~~~~
a.cc:87:17: error: 'beki' was not declared in this scope
   87 |         if(B[i]*beki[mid]<=B[i+1]) ok=mid;
      |                 ^~~~
a.cc:90:13: error: 'beki' was not declared in this scope
   90 |       B[i]*=beki[ok];
      |             ^~~~
a.cc:91:12: error: 'beki2' was not declared in this scope
   91 |       cnt+=beki2[ok];
      |            ^~~~~
Language: C++


#include <cstdio>
#include <cassert>
#include <iostream>
#include <algorithm>

using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

int n;
ll vs[200000+10];
ll nvs[200000+10];

// ll xs[200000+10]; // xs[i]: vs[i]に何回-2を掛けたらvs[i-1]以上になるか
// ll ys[200000+10]; // ys[i]: nvs[i]に何回-2を掛けたらnvs[i+1]以下になるか

ll memo1[200000+10][20];
ll memo2[200000+10][20];

ll go1(int pos, int x) {
  assert(pos > 0);
  if(x > 16) {
    ll res = go1(pos, 16);
    res += (x-16LL) * (n-pos);
    return res;
  }
  if(pos >= n) {
    return 0;
  }
  ll &res = memo1[pos][x];
  if(res < 0) {
    ll prev = vs[pos-1] << x;
    ll cur = vs[pos];
    ll cnt = 0;
    while(prev > cur) {
      cur *= 4;
      cnt += 2;
    }
    res = cnt + go1(pos+1, cnt);
    // cerr << "go1 " << pos << " " << x << " " << res << " " << cnt << endl;
  }
  return res;
}

ll go2(int pos, int x) {
  assert(pos <= n-2);
  if(x > 16) {
    ll res = go2(pos, 16);
    res += (x-16LL) * (pos+1);
    return res;
  }
  if(pos < 0) {
    return 0;
  }
  ll &res = memo2[pos][x];
  if(res < 0) {
    ll next = nvs[pos+1] * (1LL << x);
    ll cur = nvs[pos];
    ll cnt = 0;
    while(cur > next) {
      cur *= 4;
      cnt += 2;
    }
    res = cnt + go2(pos-1, cnt);
    // cerr << "go2 " << pos << " " << x << " " << res << endl;
  }
  return res;
}


int main(void) {
  scanf("%d", &n);
  REP(i, n) {
    scanf("%lld", &vs[i]);
    nvs[i] = vs[i] * -2;
  }
  memset(memo1, -1, sizeof memo1);
  memset(memo2, -1, sizeof memo2);
  
  ll res = 1000000000000000000LL;
  for(int i = 0; i <= n; ++i) {
    // i番目からを正にする
    ll cur = i; // i番目より前には軒並み-2を掛ける
    cur += go1(i+1, 0); // 正側
    cur += go2(i-2, 0); // 負側
    // cerr << i << ":" << cur << endl;
    res = min(cur, res);
  }
  cout << res << endl;
  return 0;
}


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

#include<stdio.h>
int main(){
long n,a[222222],suml[222222],sumr[222222],i,j;
scanf("%ld",&n);
for(i=1;i<=n;i++)
scanf("%ld",&a[i]);
suml[0]=0;
suml[1]=0;
long copy1,copy2,p;
for(i=2;i<=n;i++){
copy1=a[i-1];
copy2=a[i];
p=0;
while(copy1<copy2){
copy1=copy1*4;
p+=2;
}
suml[i]=suml[i-1];
suml[i]+=p*(i-1);
}
sumr[n+1]=0;
sumr[n]=0;
for(i=n-1;i>=1;i--){
copy1=a[i+1];
copy2=a[i];
p=0;
while(copy1<copy2){
copy1=copy1*4;
p+=2;
}
sumr[i]=sumr[i+1];
sumr[i]+=p*(n-i);
}
ans=sumr[1];
for(i=1;i<=n;i++){
p=i+suml[i]+sumr[i+1];
if(ans>p)
ans=p;
}
printf("%ld\n",ans);
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:1: error: 'ans' was not declared in this scope
   34 | ans=sumr[1];
      | ^~~
Language: C++

累積和の空間で考えて、
4つ角の値がすでに決まっちゃってる時にどうすればいいのかわからなくなった

Compiler output:
a.cc:1:1: error: extended character 、 is not valid in an identifier
    1 | 累積和の空間で考えて、
      | ^
a.cc:1:1: error: '\U00007d2f\U00007a4d\U0000548c\U0000306e\U00007a7a\U00009593\U00003067\U00008003\U00003048\U00003066\U00003001' does not name a type
    1 | 累積和の空間で考えて、
      | ^~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,mod=998244353;
int n,m,a[N],b[N],c[N];
ll t=0;
bool flag=true;
unordered_map<int,int>vis[N],vv[N];
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
void solve(int i)
{
    if(i<=1||i>n) return;
    int res=0,tot=0;
    if(vis[i][i]) res^=vis[i][i]-1,tot++;
    if(vis[i-1][i-1]) res^=vis[i-1][i-1]-1,tot++;
    if(vis[i-1][i]) res^=vis[i-1][i]-1,tot++;
    if(vis[i][i-1]) res^=vis[i][i-1]-1,tot++;
    if(tot==4&&res) flag=false;
    if(tot==3)
    {
        if(!vis[i][i]) vis[i][i]=res+1,solve(i+1),cal(i);
        if(!vis[i-1][i-1]) vis[i-1][i-1]=res+1,solve(i-1),cal(i-1);
        if(!vis[i-1][i]) vis[i-1][i]=res+1;
        if(!vis[i][i-1]) vis[i][i-1]=res+1;
    }
}
void cal(int i)
{
    if(i<=1||i>=n) return;
    vv[i-1][i+1]=vv[i+1][i-1]=true;
    if(vis[i-1][i+1]&&vis[i+1][i-1])
    {
        if(!vis[i][i]) vis[i][i]=((vis[i-1][i+1]-1)^(vis[i+1][i-1]-1))+1,solve(i),solve(i+1);
        else
        {
            int res=0;
            res^=vis[i-1][i+1]-1;
            res^=vis[i+1][i-1]-1;
            res^=vis[i][i]-1;
            if(res) flag=false;
        }
    }
    else if(vis[i-1][i+1]||vis[i+1][i-1])
    {

    }
    else t++;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
        c[i]++;
        vis[a[i]][b[i]]=c[i];
    }
    for(int i=2;i<n;i++)
        cal(i);
    for(int i=2;i<=n;i++)
        solve(i);
    for(int i=2;i<=n;i++)
    {
        int tot=0;
        if(!vis[i][i]) tot++;
        if(i==2&&!vis[i-1][i-1]) tot++;
        if(!vis[i-1][i]) tot++;
        if(!vis[i][i-1]) tot++;
        t+=max(0,tot-1);
        vv[i][i]=vv[i-1][i-1]=vv[i-1][i]=vv[i][i-1]=true;
    }
    if(n>3)
        t+=((ll)n*n-n-(n-1)*2-(n-2)*2)/2;
    for(int i=1;i<=m;i++)
    {
        if(vv[a[i]][b[i]]) continue;
        if(vis[a[i]][b[i]]&&vis[b[i]][a[i]])
        {
            if(vis[a[i]][b[i]]!=vis[b[i]][a[i]]) flag=false;
        }
        else t--;
    }
    if(!flag){printf("0\n");return 0;}
    printf("%lld\n",qpow(2,t));
}


Compiler output:
a.cc: In function 'void solve(int)':
a.cc:31:51: error: 'cal' was not declared in this scope
   31 |         if(!vis[i][i]) vis[i][i]=res+1,solve(i+1),cal(i);
      |                                                   ^~~
a.cc:32:59: error: 'cal' was not declared in this scope
   32 |         if(!vis[i-1][i-1]) vis[i-1][i-1]=res+1,solve(i-1),cal(i-1);
      |                                                           ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
const int mod = 998244353;
int power(int a, int b){
    int res = 1;
    while(b > 0){
        if(b & 1){
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
        b >>= 1;
    }
    return res;
}
int main(){
    int n, m, a, b, c, ans = 1, flag = 1, tot[N] = {0}, bit[N][4], dp[2][2];
    map<pair<int, int>, int> tell;
    scanf("%d %d", &n, &m);
    memset(bit, -1, sizeof(bit));
    for(int i = 1; i <= m; i++){
        scanf("%d %d %d", &a, &b, &c);
        if(abs(a - b) <= 1){
            bit[max(a, b)][2 - (a - b)] = c;
        }else{
            if(abs(a - b) > 2){
                if(tell[{b, a}] == 0){
                    tot[max(a, b)]++;
                }else if(tell[{b , a} != c){
                    flag = 0;
                }
            }
            tell[{a, b}] = c + 1;
        }
    }
    if(!flag){
        printf("0\n");
        return 0;
    }
    for(int i = 4; i <= n; i++){
        ans = 1LL * ans * power(2, (i - 3 - tot[i])) % mod;
    }
    for(int i = 1; i < n; i++){
        bit[i + 1][0] = bit[i][2];
    }
    b = 0;
    dp[1][0] = (bit[1][2] < 1);
    dp[1][1] = (bit[1][2] != 0);
    for(int i = 2; i <= n; i++){
        dp[b][0] = dp[b][1] = 0;
        int c1 = tell[{i, i - 2}], c2 = tell[{i - 2, i}];
        for(int j = 0; j < 16; j++){
            flag = 1;
            int cnt = 0;
            for(int k = 0; k < 4; k++){
                if(j & (1 << k)){
                    cnt ^= 1;
                    if(bit[i][k] == 0){
                        flag = 0;
                    }
                }else{
                    if(bit[i][k] == 1){
                        flag = 0;
                    }
                }
            }
            if(!flag || cnt) continue;
            int oneprev = (j & 1 ? 1 : 0);
            int onecurr = (j & 4 ? 1 : 0);
            int mul = 0;
            if(c1 + c2 == 0){
                mul = 2;
            }else if(c1 + c2 == 1){
                mul = 1; 
            }else if(c1 + c2 == 3){
                mul = (oneprev ? 1 : 0);
            }else if(c1 + c2 == 4){
                mul = (oneprev ? 0 : 1);
            }else{
                if(c1 == 1){
                    mul = (oneprev ? 0 : 1);
                }else{
                    mul = 1;
                }
            }
            if(i == 2) mul = 1;
            dp[b][onecurr] += 1LL * mul * dp[b ^ 1][oneprev] % mod;
            if(dp[b][onecurr] >= mod){
                dp[b][onecurr] -= mod;
            }
        }
        b ^= 1;
    }
    ans = 1LL * ans * ((dp[b ^ 1][0] + dp[b ^ 1][1]) % mod) % mod;
    printf("%d\n", ans);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:38: error: expected ']' before '!=' token
   29 |                 }else if(tell[{b , a} != c){
      |                                      ^~~
      |                                      ]
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int n,m;
int a[52525], b[52525], c[52525];

ll dp[125252][2];

ll modpow(ll a, ll b){
  ll r = 1;
  while(b){
    if(b&1)r=r*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return r;
}

bool ppcnt[16];

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m)scanf("%d%d%d",a+i,b+i,c+i),a[i]--,b[i]--;
  REP(i,16)ppcnt[i] = __builtin_popcount(j)%2==0;
  map<pii,int> M;
  REP(i,m)M[pii(a[i],b[i])] = c[i];
  REP(j,16){
    if(!ppcnt[j])continue;
    pii a = pii(0,0);
    pii b = pii(0,1);
    pii c = pii(1,0);
    pii d = pii(1,1);
    if(M.count(a) && M[a] != (j>>0&1))continue;
    if(M.count(b) && M[b] != (j>>1&1))continue;
    if(M.count(c) && M[c] != (j>>2&1))continue;
    if(M.count(d) && M[d] != (j>>3&1))continue;
    dp[0][j>>3&1] += 1;
  }
  REP(i,n-2)REP(r2,2)if(dp[i][r2]){
    int ci = i+1;
    REP(ld,2){
      int ru = r2 ^ ld;
      if(M.count(pii(ci-1,ci+1)) && M[pii(ci-1,ci+1)] != ld)continue;
      if(M.count(pii(ci+1,ci-1)) && M[pii(ci+1,ci-1)] != ru)continue;
      REP(to,8){
        int nj = to*2+r2;
        if(__builtin_popcount(nj)%2==1)continue;
        if(M.count(pii(ci+1,ci+0)) && M[pii(ci+1,ci+0)] != (nj>>1&1))continue;
        if(M.count(pii(ci+0,ci+1)) && M[pii(ci+0,ci+1)] != (nj>>2&1))continue;
        if(M.count(pii(ci+1,ci+1)) && M[pii(ci+1,ci+1)] != (nj>>3&1))continue;
        (dp[i+1][nj>>3] += dp[i][r2]) %= MOD;
      }
    }
  }
  ll base = (dp[n-2][0] + dp[n-2][1]) % MOD;
  ll fr = n<=3 ? 0ll : ((ll)n*n - 7ll*2 - 5ll*(n-4))/2;
  REP(i,m){
    int x = a[i], y = b[i], z = c[i];
    if(abs(x-y)<=2)continue;
    if(M.count(pii(y,x))){
      if(M[pii(y,x)] != z){
        base = 0;
      }else if(x<y){
        fr--;
      }
    }else{
      fr--;
    }
  }
  ll ans = base * modpow(2ll, fr) % MOD;
  printf("%lld\n",ans);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:42: error: 'j' was not declared in this scope
   47 |   REP(i,16)ppcnt[i] = __builtin_popcount(j)%2==0;
      |                                          ^
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;


ll powmod(ll k){
    ll ret=1;
    ll n=2LL;
    while(k>0){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k/=2;
    }
    return ret;
}

bool even[3][101010],odd[3][101010];
ll dp[2][101010];
int main(){
    int n,m;
    cin>>n>>m;
    memset(odd,1,sizeof odd);
    memset(even,1,sizeof even);
    int cnt=0;
    set<pair<pint,int>> st;

    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        --a;--b;
        if(a>b)swap(a,b);
        if(st.count({{a,b},c})){
            if(b-a<3)odd[b-a][b]=false;
        }
        else if(st.count({{a,b},!c})){
            if(b-a<3)even[b-a][b]=false;
            else{
                cout<<0<<endl;
                return 0;
            }
        }
        else if(a!=b)++cnt;
        else if(c)even[0][b]=false;
        else odd[0][b]=false;
        st.insert({{a,b},c});
    }
    dp[0][0]=even[0][0];
    dp[1][0]=odd[0][0];
    rep(i,n-1){
        if(even[0][i+1]){
            if(even[1][i+1]&&even[2][i+1])dp[0][i+1]+=dp[0][i];
            if(odd[1][i+1]&&odd[2][i+1])dp[0][i+1]+=dp[1][i];
        }
        if(odd[0][i+1]){
            if(odd[1][i+1]&&even[2][i+1])dp[1][i+1]+=dp[0][i];
            if(even[1][i+1]&&odd[2][i+1])dp[1][i+1]+=dp[1][i];
        }
        dp[0][i+1]%=mod;
        dp[1][i+1]%=mod;
    }
    cout<<(dp[0][n-1]+dp[1][n-1])*powmod((ll)n*(n-1)/2-cnt)%mod<<endl;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:5: error: 'memset' was not declared in this scope
   42 |     memset(odd,1,sizeof odd);
      |     ^~~~~~
a.cc:15:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   14 | #include<functional>
  +++ |+#include <cstring>
   15 | using namespace std;
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

ll POW(ll x){
  if(x==0) return 0;
  if(x==1) return 2;
  if(x%2==1) return (2*POW(x-1))%MOD;
  ll y = POW(x/2);
  return (y*y)%MOD;
}

int main(){
  ll n, m;
  cin >> n >> m;
  map<P, int> mark;
  REP(i, m){
    int a, b, c;
    cin >> a >> b >> c;
    mark[{a, b}] = 2*c-1;
  }
  int cnt = 0;
  for(auto it = mark.begin(); it != mark.end(); it++){
    P p = it->first;
    if(mark[p] != 0){
    if(mark[{p.second, p.first}]!=0 && mark[{p.second, p.first}]!=it->second){
      if(abs(p.first-p.second)>2){
        cout << 0 << endl;
        return 0;
      }
      else if(abs(p.first-p.second)==2){
        int t = (p.first+p.second)/2;
        if(mark[{t, t}]==-1){
          cout << 0 << endl;
          return 0;
        }
        else{
          mark[{t, t}] = 1;
        }
      }
    }
    else if(mark[{p.second, p.first}]==it->second){
      if(abs(p.first-p.second)==2){
        int t = (p.first+p.second)/2;
        if(mark[{t, t}]==1){
          cout << 0 << endl;
          return 0;
        }
        else{
          mark[{t, t}] = -1;
        }
      }
    }
  }
  }
  int np[n-1] = { }, d[n] = { };
  FOR(i, 1, n){
    if(mark[{i+1, i}]!=0 && mark[{i, i+1}]!=0){
      if(mark[{i+1, i}]==mark[{i, i+1}]) np[i] = 1;
      else np[i] = -1;
    }
  }
  REP(i, n) d[i] = mark{i, i};
  REP(i, n-1){
    if(d[i+1] == 0) d[i+1] = d[i]*np[i];
    else if(d[i+1]!=d[i]*np[i]){
      cout << 0 << endl;
      return 0;
    }
  }
  REP(i, n-1){
    if(d[n-i] == 0) d[n-i] = d[n-i-1]*np[n-1-i];
    else if(d[n-i]!=d[n-1-i]*np[n-1-i]){
      cout << 0 << endl;
      return 0;
    }
  }
  REP(i, n) mark[{i, i}]=d[i];
  map<P, int> un;
  for(auto it = mark.begin(); it != mark.end(); it++){
    P poss=it->first;
    if(mark[poss]!=0){
    un[{max(poss.first, poss.second), min(poss.first, poss.second)}]++;}
  }
  ll dim = n*(n+1)/2 - un.size() - cnt;
  cout << POW(dim) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:73:20: error: cannot convert 'std::map<std::pair<long long int, long long int>, int>' to 'int' in assignment
   73 |   REP(i, n) d[i] = mark{i, i};
      |                    ^~~~
      |                    |
      |                    std::map<std::pair<long long int, long long int>, int>
Language: C++

// #define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#include <bits/stdc++.h>

#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int, int>;
using V = vector<int>;
using VV = vector<V>;

template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//~ int A = (1<<2) | (1<<3) | (1<<5) | (1<<7);
//~ for (int bit=A; ; bit=(bit-1)&A){
//~ if (!bit) break;
//~ }
int next_combination(int sub) {
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}
//~ int n=5;
//~ int k=3; // nCkの組み合わせ、ただしk=0には対応してない
//~ int bit=(1<<k)-1; // 1000 -> 0111
//~ for(; bit < (1<<n); bit=nex_combination(bit){
//~ }
bool isPrime(int a) {
    if (a == 2) return true;
    if (a <= 1 || a % 2 == 0) return false;

    for (int i = 3; i * i <= a; i += 2) {
        if (a % i == 0) return false;
    }
    return true;
}
//~ vector<int> a = {1, 14, 32, 51, 51, 51, 243, 419, 750, 910};
vector<int> aaa;
// index が条件を満たすかどうか
bool isOK(int index, int key) {
    if (aaa[index] >= key)
        return true;
    else
        return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
    int ng = -1;  //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok =
        (int)aaa
            .size();  // 「index =
                      // a.size()-1」が条件を満たさないこともあるので、初期値は
                      // a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key))
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//~ int v[100100];
//~ int INF = 1 << 30;
//~ vector<vector<int>> dp(310, vector<int>(310));
//~ ll dp[110][100100];
//~ vector<int> dp(100100, 0));

//~ int seen[110];
//~ int ans[110][2];
//~ ll MOD = 1e9 + 7;

void memo() {
    int n = 100;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }

    vector<int> ans(n);
    iota(ans.begin(), ans.end(), 0);
    sort(ans.begin(), ans.end(), [&](int i, int j) { return a[i] < a[j]; });

    double t1 = 0.1;
    cout << fixed << setprecision(6) << t1 << endl;
}

int main() {
    string s;
    cin >> s;

    int cnt = 0;
    int ans = 0;
    rep(i, (int)s.size()) {
        if (s[i] == 'W') {
            ans += i - cnt;
            cnt++;
        }
    }

    cout << ans << endl;

    return 0;
}


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

#include<bits/stdc++.h>
#include <atcoder/all>

typedef long long ll;
typedef std::pair<ll, ll> P;
typedef std::tuple<ll, ll, ll> t3;
constexpr ll INF = 1e15;
constexpr ll mod = 1e9+7;

#define rep(i,n) for(int i = 0; i < int(n); i++)
using namespace std;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }


class Divisor {
private:
	vector<ll> F;
public:
	Divisor(ll N) {
		for (ll i = 1; i * i <= N; i++) {
			if (N % i == 0) {
				F.push_back(i);
				if (i * i != N) F.push_back(N / i);
			}
		}
		sort(begin(F), end(F));
	}
	int size() { return F.size(); }
	ll operator[](int k) { return F[k]; }
	const vector<ll>& factors() { return F; }
};

int main() {
	string s;
	cin >> s;
	int n = s.size();
	vector<bool> ws(n, 0);
	rep(i, n) {
		ws[i] = s[i] == 'W';
	}
	int j = 0;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		if (ws[i]) {
			ll dist = i - j;
			sum += dist;
			j++;
		}
	}
	cout << sum << 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 <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  //input
  string str; cin >> str;
  int size;
  size = str.size();
  
  //compute
  int sum;
  sum = 0;
  vector<int> x(size+1);
  x[0] = 0;

  if(str.at(0) == 'B') {
     x[0] = 1;
  }

  for(int i = 1; i < size; i++) {
    if(str.at(i) == 'B') {
     x[i] = x[i - 1] + 1;
  }else if(str.at[i] == 'W'){
     x[i] = x[i - 1]; 
  }
  }


  for(int i = 1; i < size; i++) {
    if(str.at(i) == 'W') {
     sum += x[i-1];
  }
  }
 
  //output
  cout << sum << endl;
 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:18: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   27 |   }else if(str.at[i] == 'W'){
      |                  ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;cin >> s;
  ll n = s.size(),i,b = 0,ans = 0;
  for(i=0;i<n;i++){
    if(s[i]=='B') b++;
    else ans += b;
  }
  cout << ans << "\n";
}
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;cin >> s;
  ll n = s.size(),i,b = 0,ans = 0;
  for(i=0;i<n;i++){
    if(s[i]=='B') b++;
    else ans += b;
  }
  cout << ans << "\n";
}


Compiler output:
a.cc:16:5: error: redefinition of 'int main()'
   16 | int main(){
      |     ^~~~
a.cc:4:5: note: 'int main()' previously defined here
    4 | int main(){
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;cin >> s;
  ll n = s.size(),i,b = 0,ans = 0;
  for(i=0;i<n;i++){
    if(s[i]=='B') b++;
    else ans += b;
  }
  cout << ans << "\n";


Compiler output:
a.cc: In function 'int main()':
a.cc:11:23: error: expected '}' at end of input
   11 |   cout << ans << "\n";
      |                       ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: Java

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String[] N = sc.next().split("");
		long res = 0;
		long num = 0;
		for (String s : input) {
			if (s.equals("W")) {
				res += num;
			} else {
				num++;
			}
		}
		System.out.println(res);

	}
}


Compiler output:
Main.java:9: error: cannot find symbol
		for (String s : input) {
		                ^
  symbol:   variable input
  location: class Main
1 error
Language: C++

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

using namespace std;

int main() {
	string S;
	cin >> S;
	int ans = 0; 
	int Bcount = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'B') {
			Bcount++;
		}
		else if (S[i] == 'W') {
			ans += ;
		}
	}
	cout << ans << endl;
	}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:32: error: expected primary-expression before ';' token
   17 |                         ans += ;
      |                                ^
Language: C++

#include<cstdio>
using namespace std;

const int MAX=2e5+10;
char str[MAX];
int main(){
    while(~scanf(“%s",str)){
        int ans=0,b=0;
        for(int i=0;str[i];i++){
            if(str[i]=='B') b++;
            else ans+=b;
        }
        printf("%d\n",ans);
    }
    return 0;
}

Compiler output:
a.cc:7:18: error: extended character “ is not valid in an identifier
    7 |     while(~scanf(“%s",str)){
      |                  ^
a.cc:7:21: warning: missing terminating " character
    7 |     while(~scanf(“%s",str)){
      |                     ^
a.cc:7:21: error: missing terminating " character
    7 |     while(~scanf(“%s",str)){
      |                     ^~~~~~~~
a.cc: In function 'int main()':
a.cc:7:18: error: '\U0000201c' was not declared in this scope
    7 |     while(~scanf(“%s",str)){
      |                  ^
a.cc:7:20: error: 's' was not declared in this scope
    7 |     while(~scanf(“%s",str)){
      |                    ^
a.cc:8:19: error: 'b' was not declared in this scope
    8 |         int ans=0,b=0;
      |                   ^
a.cc:8:22: error: expected ')' before ';' token
    8 |         int ans=0,b=0;
      |                      ^
      |                      )
a.cc:7:10: note: to match this '('
    7 |     while(~scanf(“%s",str)){
      |          ^
a.cc:10:29: error: 'b' was not declared in this scope
   10 |             if(str[i]=='B') b++;
      |                             ^
a.cc:11:18: error: 'ans' was not declared in this scope
   11 |             else ans+=b;
      |                  ^~~
a.cc:11:23: error: 'b' was not declared in this scope
   11 |             else ans+=b;
      |                       ^
a.cc:13:23: error: 'ans' was not declared in this scope
   13 |         printf("%d\n",ans);
      |                       ^~~
a.cc: At global scope:
a.cc:15:5: error: expected unqualified-id before 'return'
   15 |     return 0;
      |     ^~~~~~
a.cc:16:1: error: expected declaration before '}' token
   16 | }
      | ^
Language: C++

#include<cstdio>
using namespace std;

const int MAX=2e5+10;
char s[MAX];
int main(){
    while(~scanf("%s",str)){
        int ans=0,b=0;
        for(int i=0;str[i];i++){
            if(str[i]=='B') b++;
            else ans+=b;
        }
        printf("%d\n",ans);
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:23: error: 'str' was not declared in this scope; did you mean 'std'?
    7 |     while(~scanf("%s",str)){
      |                       ^~~
      |                       std
Language: C++

#include<cstdio>
using namespace std;

const int MAX=2e5+10;
char s[MAX];
int main(){
    while(~scanf(“%s",str)){
        int ans=0,b=0;
        for(int i=0;str[i];i++){
            if(str[i]=='B') b++;
            else ans+=b;
        }
        printf("%d\n",ans);
    }
    return 0;
}

Compiler output:
a.cc:7:18: error: extended character “ is not valid in an identifier
    7 |     while(~scanf(“%s",str)){
      |                  ^
a.cc:7:21: warning: missing terminating " character
    7 |     while(~scanf(“%s",str)){
      |                     ^
a.cc:7:21: error: missing terminating " character
    7 |     while(~scanf(“%s",str)){
      |                     ^~~~~~~~
a.cc: In function 'int main()':
a.cc:7:18: error: '\U0000201c' was not declared in this scope
    7 |     while(~scanf(“%s",str)){
      |                  ^
a.cc:8:19: error: 'b' was not declared in this scope
    8 |         int ans=0,b=0;
      |                   ^
a.cc:8:22: error: expected ')' before ';' token
    8 |         int ans=0,b=0;
      |                      ^
      |                      )
a.cc:7:10: note: to match this '('
    7 |     while(~scanf(“%s",str)){
      |          ^
a.cc:9:21: error: 'str' was not declared in this scope; did you mean 'std'?
    9 |         for(int i=0;str[i];i++){
      |                     ^~~
      |                     std
a.cc:10:29: error: 'b' was not declared in this scope
   10 |             if(str[i]=='B') b++;
      |                             ^
a.cc:11:18: error: 'ans' was not declared in this scope
   11 |             else ans+=b;
      |                  ^~~
a.cc:11:23: error: 'b' was not declared in this scope
   11 |             else ans+=b;
      |                       ^
a.cc:13:23: error: 'ans' was not declared in this scope
   13 |         printf("%d\n",ans);
      |                       ^~~
a.cc: At global scope:
a.cc:15:5: error: expected unqualified-id before 'return'
   15 |     return 0;
      |     ^~~~~~
a.cc:16:1: error: expected declaration before '}' token
   16 | }
      | ^
Language: C++

#include<string>

using namespace std;

int main()
{
    long long int sum=0,count=0;
    int i;
    string s;
    cin >> s;
    for(i=s.size(); i>0; i--)
    {
        if(s[i-1]=='W')
            count++;
        if(s[i-1]=='B')
            sum+=count;
    }
    cout << sum;
    return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'cin' was not declared in this scope
   10 |     cin >> s;
      |     ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include<string>
  +++ |+#include <iostream>
    2 | 
a.cc:18:5: error: 'cout' was not declared in this scope
   18 |     cout << sum;
      |     ^~~~
a.cc:18:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'