Language: C

#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <iomanip>
#include <functional>
#include <complex>
#include <array>

using namespace std;
template<class T,class U>inline constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>inline constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
using pii=pair<int,int>;

//要素数n 初期値x
template<typename T>
inline vector<T> vmake(size_t n,T x){
  return vector<T>(n,x);
}

//a,b,c,x data[a][b][c] 初期値x
template<typename... Args>
auto vmake(size_t n,Args... args){
    auto v=vmake(args...);
    return vector<decltype(v)>(n,move(v));
}

constexpr int MAX=(1<<30)-1;
int dx[]={0,1,-1,0},dy[]={1,0,0,-1};

vector<string> C;
int height,width;
map<string,int> to_number;
map<int,string> to_mozi;
vector<vector<bool>> C_used;

int pre_cntmine=0;

//pacID,typeID,hight,width,speedleft,cooldown
vector<array<int,6>> MINE,ENEMY;
vector<array<int,6>> PRE_MINE;
vector<pii> SuperPellet,Pellet;

vector<vector<vector<vector<int>>>> Distance;


vector<vector<int>> make_distance(int sh,int sw){
    auto dist=vmake(height,width,MAX);
    queue<pii> que;
    que.emplace(sh,sw);
    dist[sh][sw]=0;
    while(!que.empty()){
        int h,w;
        tie(h,w)=que.front(); que.pop();
        for(int i=0;i<4;i++){
            int nh=h+dx[i],nw=w+dy[i];
            nh=(nh+height)%height;nw=(nw+width)%width;
            if(C[nh][nw]=='#') continue;
            if(dist[nh][nw]>dist[h][w]+1){
                dist[nh][nw]=dist[h][w]+1;
                que.emplace(nh,nw);
            }
        }
    }
    return dist;
}



//距離が2以下のところに敵がいたらそれに勝つように変化させる
//cooldownが終わってなかったら無視
//距離が近い方を優先
void type_switch(){
    for(auto v=MINE.begin();v!=MINE.end();){
        int dist=1000;
        auto mine=*v;
        int cnt=0;
        int number;
        if(mine[5]){
            v++;continue;
        }
        for(auto enemy:ENEMY){
            int tmp=abs(mine[2]-enemy[2])+abs(mine[3]-enemy[3]);
            if(chmin(dist,tmp)){
                number=cnt;
            }
            cnt++;
        }
        if(dist>2){
            v++; continue;
        }else{
            int next_hand=(ENEMY[number][1]+1)%3;
            if(mine[1]==next_hand){
                v++;continue;
            }else{
                cout<<"SWITCH "<<mine[0]<<" "<<to_mozi[next_hand]<<"|";
                v=MINE.erase(v);
            }
        }
    }
}
int find_distance(array<int,6> &x,pii y){
    return Distance[x[2]][x[3]][y.first][y.second];
}
int find_distance(array<int,6> &x,array<int,6> &y){
    return Distance[x[2]][x[3]][y[2]][y[3]];
}

int find_distance(pii x,pii y){
    return Distance[x.first][x.second][y.first][y.second];
}

void use_Super_dfs(int idx,int value_max,int number,vector<int> &koho,vector<int> &ans,int &min_sum){
    if(idx==number){
        //同じのがあったら弾く
        for(int i=0;i<number;i++){
            for(int j=i+1;j<number;j++){
                if(koho[i]==koho[j]) return;
            }
        }
        //総和を出す
        int tmp_sum=0;
        for(int i=0;i<number;i++){
            if((int)MINE.size()<=koho[i]) continue;
            tmp_sum+=find_distance(MINE[koho[i]],SuperPellet[i]);
        }
        if(chmin(min_sum,tmp_sum)){
            ans=koho;
        }
        return;
    }
    for(int i=0;i<value_max;i++){
        koho[idx]=i;
        use_Super_dfs(idx+1,value_max,number,koho,ans,min_sum);
    }
}

void use_Super(){
    int Super_num=(int)SuperPellet.size();
    vector<int> koho(Super_num);
    vector<int> ans;
    int min_sum=1000000;
    int value_max=max(Super_num,(int)MINE.size());
    use_Super_dfs(0,value_max,Super_num,koho,ans,min_sum);
    int cnt=0;
    for(auto m=MINE.begin();m!=MINE.end();cnt++){
        auto x=*m;
        int num=-1;
        for(int i=0;i<(int)ans.size();i++){
            if(cnt==ans[i]) num=i;
        }
        if(num!=-1){
            cout<<"MOVE "<<x[0]<<" "<<SuperPellet[num].second<<" "<<SuperPellet[num].first<<"|";
            m=MINE.erase(m);
        }else{
            m++;
        }
    }
}

void use_Normal(){
    if(Pellet.size()==0){
        sort(MINE.begin(),MINE.end());
        vector<pii> v;
        for(int i=0;i<height;i++){
            for(int j=0;j<width;j++){
                if(C_used[i][j]==false){
                    v.emplace_back(i,j);
                }
            }
        }
        for(int i=0;i<MINE.size();i++){
            int cnt=0;
            int number=-1;
            int min_dist=1000;
            for(auto x:v){
                if(chmin(min_dist,find_distance(MINE[i],x))){
                    number=cnt;
                }
                cnt++;
            }
            if(v.size()==0) cout<<"MOVE "<<MINE[i][0]<<" 0 0|";
            else cout<<"MOVE "<<MINE[i][0]<<" "<<v[number].second<<" "<<v[number].first<<"|",v.erase(v.begin()+number);
        }
        return;
    }

    for(auto m:MINE){
        int min_dist=2000;
        pii to={-1,-1};
        for(auto p:Pellet){
            if(chmin(min_dist,find_distance(m,p))){
                to=p;
            }
        }
        if(to.first!=-1) cout<<"MOVE "<<m[0]<<" "<<to.second<<" "<<to.first<<"|";
        else{
            for(int i=0;i<4;i++){
                int nh=m[2]+dx[i],nw=m[3]+dy[i];
                nh=(nh+height)%height;
                nw=(nw+width)%width;
                if(C[nh][nw]!='#'){
                    cout<<"MOVE "<<m[0]<<" "<<nw<<" "<<nh<<"|";
                    break;
                }
            }
        }
    }
}


void Game_init(){
    to_mozi[0]="ROCK";
    to_mozi[1]="PAPER";
    to_mozi[2]="SCISSORS";
    to_mozi[3]="ROCK";
    to_number["ROCK"]=0;
    to_number["PAPER"]=1;
    to_number["SCISSORS"]=2;

    cin >> width >> height; cin.ignore();
    C.resize(height);
    C_used=vmake(height,width,false);
    for (int i = 0; i < height; i++) {
        string row;
        getline(cin,row);
        C[i]=row;
    }
    for(int i=0;i<height;i++){
        for(int j=0;j<width;j++){
            if(C[i][j]=='#') C_used[i][j]=true;
        }
    }
}

//ID,離れたいid,turn
vector<array<int,3>> skip;
vector<pii> PLACE(5);

void do_collision(){
    for(int i=0;i<MINE.size();i++){
        for(int j=i+1;j<MINE.size();j++){
            if(find_distance(MINE[i],MINE[j])<=2){
                cerr<<MINE[i][0]<<" "<<MINE[j][0]<<endl;
                skip.push_back({MINE[i][0],MINE[j][0],5});
                skip.push_back({MINE[j][0],MINE[i][0],5});
            }
        }
    }
}

void do_skip(){
    for(auto m=MINE.begin();m!=MINE.end();){
        auto x=*m;
        bool flag=false;
        for(int i=0;i<skip.size();i++){
            if(x[0]==skip[i][0]){
                flag=true;
                int dist=find_distance(x,PLACE[skip[i][1]]);
                for(int j=0;j<4;j++){
                    int nh=(x[2]+dx[j]+height)%height,nw=(x[3]+dy[j]+width)%width;
                    cerr<<x[0]<<" "<<skip[i][1]<<" "<<nh<<" "<<nw<<" "<<find_distance(PLACE[skip[i][1]],pii(nh,nw))<<endl;
                    if(C[nh][nw]!='#' and dist<find_distance(PLACE[skip[i][1]],pii(nh,nw))){
                        cout<<"MOVE "<<x[0]<<" "<<nw<<" "<<nh<<"|";
                        break;
                    }
                }
                m=MINE.erase(m);
                break;
            }
            if(flag) break;
        }
        if(flag) continue;
        m++;
    }
}

void do_speed(){
    for(auto m=MINE.begin();m!=MINE.end();){
        auto x=*m;
        if(x[4]==0 and x[5]==0 and SuperPellet.size()){
            cout<<"SPEED "<<x[0]<<"|";
            m=MINE.erase(m);
        }else{
            m++;
        }
    }
}

void Turn_init(){
    MINE.clear();
    ENEMY.clear();
    SuperPellet.clear();
    Pellet.clear();
    for(auto s=skip.begin();s!=skip.end();){
        (*s)[2]--;;
        if((*s)[2]<0){
            s=skip.erase(s);
        }else s++;
    }
}


int main()
{
    Game_init();
    Distance=vmake(height,width,height,width,0); 
    for(int i=0;i<height;i++){
        for(int j=0;j<width;j++){
            if(C[i][j]=='#') continue;
            Distance[i][j]=make_distance(i,j);
        }
    }
    // game loop
    while (1) {
        Turn_init();
        int myScore;
        int opponentScore;
        cin >> myScore >> opponentScore; cin.ignore();
        int visiblePacCount; // all your pacs and enemy pacs in sight
        cin >> visiblePacCount; cin.ignore();
        for (int i = 0; i < visiblePacCount; i++) {
            int pacId; // pac number (unique within a team)
            bool mine; // true if this pac is yours
            int x; // position in the grid
            int y; // position in the grid
            string typeId; // unused in wood leagues
            int speedTurnsLeft; // unused in wood leagues
            int abilityCooldown; // unused in wood leagues
            cin >> pacId >> mine >> x >> y >> typeId >> speedTurnsLeft >> abilityCooldown; cin.ignore();
            if(mine){
                PLACE[pacId]=pii(y,x);
                C_used[y][x]=true;
                MINE.push_back({pacId,to_number[typeId],y,x,speedTurnsLeft,abilityCooldown});
            }else{
                ENEMY.push_back({pacId,to_number[typeId],y,x,speedTurnsLeft,abilityCooldown});
            }
        }

        int visiblePelletCount; // all pellets in sight
        cin >> visiblePelletCount; cin.ignore();
        for (int i = 0; i < visiblePelletCount; i++) {
            // amount of points this pellet is worth
            int h,w,v;
            cin >> w >> h >> v; cin.ignore();
            if(v==10){
                SuperPellet.emplace_back(h,w);
            }else{
                Pellet.emplace_back(h,w);
            }
        }
        do_speed();
        type_switch();
        do_collision();
        do_skip();

        use_Super();
        use_Normal();
        cout<<endl;
        PRE_MINE=MINE;
        // Write an action using cout. DON'T FORGET THE "<< endl"
        // To debug: cerr << "Debug messages..." << endl;
    }
}

Compiler output:
main.c:1:10: fatal error: cassert: No such file or directory
    1 | #include <cassert>
      |          ^~~~~~~~~
compilation terminated.