Language: C++

#include<iostream>                                                    
#include<cstdlib>
#include<cstring>
#include<cstdio>
using namespace std;

struct Node{
    int key;
    Node *parent,*left,*right;
};
Node *root,*NIL;

Node *treeMinimum(Node *x){
    while(x->left!=NIL)
        x=x->left;
    return x;    
}

Node *find(Node *u,int k){
    while(u!=NIL&&k!=u->key){
        if(u->key>k)
            u=u->left;
        else
            u=u->right;
    }
    return u;
    
}

Node *treeSuccessor(Node *x){
    if(x->right!=NIL)return treeMinimum(x->left);
    Node *y=x->parent;
    while(y!=NIL&&x==y->right){
        x=y;
        y=y->parent;
    }
    return y;
}
void treeDelete(Node *z){
    Node *y;
    Node *x;

    if(z->left==NIL||z->right==NIL)y=z;
    else y=treeSuccessor(z);

    if(y->left!=NIL)
        x=y->left;
    else
        x=y->right;

    if(x!=NIL)
        x->parent=y->parent;
    
    if(y->parent==NIL) 
        root=x;
    else{
        if(y==y->parent->left)
            y->parent->left=x;
        else
            y->parent->right=x;
    }    
    if(y!=x)
        z->key=y->key;
    free(y);    
        
}
Last login: Thu Mar 15 16:22:44 on ttys002
YHnoMacbook-pro:alds1 derodontus$ vim 1-3p.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-3p.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-3c.cpp































YHnoMacbook-pro:alds1 derodontus$ vim 1-3c.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-3c.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-3a.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-3c1.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-3b1.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-3b2.cpp
YHnoMacbook-pro:alds1 derodontus$ ls
#1-3c.cpp#		72-1.cpp
1-3a.cpp		72.cpp
1-3b.cpp		73.cpp
1-3b1.cpp		86.cpp
1-3b2.cpp		a.out
1-3c.cpp		key=key
1-3c.cpp~		next
1-3c.txt		next-
1-3c1.cpp		next=nil-
1-3p.cpp		next=x
1-4a.cpp		prev=nil
59.c			prev=x
59.cpp			~vimrc
63.cpp			テキスト.txt
69.cpp
YHnoMacbook-pro:alds1 derodontus$ 109.cpp
-bash: 109.cpp: command not found
YHnoMacbook-pro:alds1 derodontus$ vim 109.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 109.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-4a.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-4a.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-4b.cpp
YHnoMacbook-pro:alds1 derodontus$ cd ..
YHnoMacbook-pro:AOJ derodontus$ cd ..
YHnoMacbook-pro:C++ derodontus$ ls
AOJ		test
contest		便利ツール
YHnoMacbook-pro:C++ derodontus$ cd 便利ツール
YHnoMacbook-pro:便利ツール derodontus$ vim prime_number.cppYHnoMacbook-pro:便利ツール derodontus$ open prime_number.cpp
YHnoMacbook-pro:便利ツール derodontus$ cat prime_number.cpp 
#include<iostream>
using namespace std;

int a,b;
bool flag=1;

bool check_prime(int num){
    for(int i=2;i*i<=num;i++){
        if(num%i==0)
            return 0;

    }
    return 1;

}

int main(){
    int k;
    cout<<"素数を探したい範囲の最小値、最大値、個数を入力して下さい"<<"\n";
    cin>>a>>b>>k;
    if(k<=0){
        cout<<"個数は1以上で入力して下さい"<<"\n";
        return 0;
    }    
    if(a>=b){
        cout<<"最小値は最大値未満でお願いします"<<"\n";
        return 0;
    }



    int j=2;    
    for(int i=a;i<=b;i++){
        if(check_prime(i)){
            cout<<i<<"\n";
            k--;
        }    
    }
    cout<<"nothing"<<"\n";
    return 0;

}
YHnoMacbook-pro:便利ツール derodontus$ cd ../
YHnoMacbook-pro:C++ derodontus$ ls
AOJ		test
contest		便利ツール
YHnoMacbook-pro:C++ derodontus$ cd AOJ
YHnoMacbook-pro:AOJ derodontus$ ls
86		alds1		その他
86-1.cpp	itp
YHnoMacbook-pro:AOJ derodontus$ cd alds1
YHnoMacbook-pro:alds1 derodontus$ ls
#1-3c.cpp#		63.cpp
1-3a.cpp		69.cpp
1-3b.cpp		72-1.cpp
1-3b1.cpp		72.cpp
1-3b2.cpp		73.cpp
1-3c.cpp		86.cpp
1-3c.cpp~		a.out
1-3c.txt		key=key
1-3c1.cpp		next
1-3p.cpp		next-
1-4a.cpp		next=nil-
1-4a0			next=x
1-4b.cpp		prev=nil
109.cpp			prev=x
59.c			~vimrc
59.cpp			テキスト.txt
YHnoMacbook-pro:alds1 derodontus$ vim 1-4c.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-4b.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-4b1.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-4b1.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-4d.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-5a.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-5c.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-5b.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-5b.cpp
YHnoMacbook-pro:alds1 derodontus$ cd ..
YHnoMacbook-pro:AOJ derodontus$ ls
86		alds1		その他
86-1.cpp	itp
YHnoMacbook-pro:AOJ derodontus$ cd ..
YHnoMacbook-pro:C++ derodontus$ ls
AOJ		test
contest		便利ツール
YHnoMacbook-pro:C++ derodontus$ cd contst
-bash: cd: contst: No such file or directory
YHnoMacbook-pro:C++ derodontus$ cd contest
YHnoMacbook-pro:contest derodontus$ ls
2:10		grand		企業
JOI		regular		非公式
beginner	typical
YHnoMacbook-pro:contest derodontus$ cd beginner
YHnoMacbook-pro:beginner derodontus$ ls
084	085	086	087	088	089	090
YHnoMacbook-pro:beginner derodontus$ mkdir 091
YHnoMacbook-pro:beginner derodontus$ cd 091
YHnoMacbook-pro:091 derodontus$ vim A.cpp
YHnoMacbook-pro:091 derodontus$ vim B.cpp
YHnoMacbook-pro:091 derodontus$ vim C.cpp
YHnoMacbook-pro:091 derodontus$ vim D.cpp
YHnoMacbook-pro:091 derodontus$ vim A.cpp
YHnoMacbook-pro:091 derodontus$ vim B.cpp
YHnoMacbook-pro:091 derodontus$ vim B.cpp
YHnoMacbook-pro:091 derodontus$ vim C.cpp
YHnoMacbook-pro:091 derodontus$ vim C.cpp
YHnoMacbook-pro:091 derodontus$ cd ../../../
YHnoMacbook-pro:C++ derodontus$ ls
AOJ		test
contest		便利ツール
YHnoMacbook-pro:C++ derodontus$ cd AOJ
YHnoMacbook-pro:AOJ derodontus$ ls
86		alds1		その他
86-1.cpp	itp
YHnoMacbook-pro:AOJ derodontus$ cd alds1
YHnoMacbook-pro:alds1 derodontus$ ls
#1-3c.cpp#
1-3a.cpp
1-3b.cpp
1-3b1.cpp
1-3b2.cpp
1-3c.cpp
1-3c.cpp~
1-3c.txt
1-3c1.cpp
1-3p.cpp
1-4a.cpp
1-4a0
1-4b.cpp
1-4b1.cpp
1-4c.cpp
1-4d.cpp
1-5a.cpp
1-5b.cpp
1-5c.cpp
109.cpp
59.c
59.cpp
63.cpp
69.cpp
72-1.cpp
72.cpp
73.cpp
86.cpp
a.out
key=key
next
next-
next=nil-
next=x
prev=nil
prev=x
~vimrc
テキスト.txt
競技プログラミング.xlsx
YHnoMacbook-pro:alds1 derodontus$ vim 1-5b.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-6b.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-6c.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-6c.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-6a.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-6c.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-6a.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-6a.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-5d.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-6d.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-7a.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-7b.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-7c.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-7b.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-7c.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-7D.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-8a.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-8a.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-8b.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-8a.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-8b.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-8c.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-8c.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-8b.cpp
YHnoMacbook-pro:alds1 derodontus$ vim 1-8c.cpp

void insert(int k){
    Node *y=NIL;
    Node *x=root;
    Node *z;

    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;

    while(x!=NIL){
        y=x;
        if(z->key<x->key)
            x=x->left;
        else
            x=x->right;
    }
    z->parent=y;
    if(y==NIL)                                                        
        root=z;
    else{
        if(z->key<y->key)
            y->left=z;
        else
            y->right=z;
    }
}
void inorder(Node *u){
    if(u==NIL)return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if(u==NIL)return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
int main(){
    int n,x;
    char com[7];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>com;
        if(com[0]=='i'){
            cin>>x;
            insert(x);
        }else if(com[0]=='f'){
            cin>>x;
            Node *t=find(root,x);
            if(t!=NIL)printf("yes\n");
            else printf("no\n");
        }else if(com[0]=='p'){
            inorder(root);
            putchar('\n');
            preorder(root);
            putchar('\n');
        }else if(com[0]=='d'){
            cin>>x;
            treeDelete(find(root,x));
        }   
    }   
    return 0;
        
}                                                                     



Compiler output:
a.cc:109:3: error: "-" is not a valid filename
  109 | #1-3c.cpp#              72-1.cpp
      |   ^
a.cc:191:3: error: "-" is not a valid filename
  191 | #1-3c.cpp#              63.cpp
      |   ^
a.cc:233:1: error: invalid digit "8" in octal constant
  233 | 084     085     086     087     088     089     090
      | ^~~
a.cc:233:9: error: invalid digit "8" in octal constant
  233 | 084     085     086     087     088     089     090
      |         ^~~
a.cc:233:17: error: invalid digit "8" in octal constant
  233 | 084     085     086     087     088     089     090
      |                 ^~~
a.cc:233:25: error: invalid digit "8" in octal constant
  233 | 084     085     086     087     088     089     090
      |                         ^~~
a.cc:233:33: error: invalid digit "8" in octal constant
  233 | 084     085     086     087     088     089     090
      |                                 ^~~
a.cc:233:41: error: invalid digit "9" in octal constant
  233 | 084     085     086     087     088     089     090
      |                                         ^~~
a.cc:233:49: error: invalid digit "9" in octal constant
  233 | 084     085     086     087     088     089     090
      |                                                 ^~~
a.cc:234:44: error: invalid digit "9" in octal constant
  234 | YHnoMacbook-pro:beginner derodontus$ mkdir 091
      |                                            ^~~
a.cc:235:41: error: invalid digit "9" in octal constant
  235 | YHnoMacbook-pro:beginner derodontus$ cd 091
      |                                         ^~~
a.cc:236:17: error: invalid digit "9" in octal constant
  236 | YHnoMacbook-pro:091 derodontus$ vim A.cpp
      |                 ^~~
a.cc:237:17: error: invalid digit "9" in octal constant
  237 | YHnoMacbook-pro:091 derodontus$ vim B.cpp
      |                 ^~~
a.cc:238:17: error: invalid digit "9" in octal constant
  238 | YHnoMacbook-pro:091 derodontus$ vim C.cpp
      |                 ^~~
a.cc:239:17: error: invalid digit "9" in octal constant
  239 | YHnoMacbook-pro:091 derodontus$ vim D.cpp
      |                 ^~~
a.cc:240:17: error: invalid digit "9" in octal constant
  240 | YHnoMacbook-pro:091 derodontus$ vim A.cpp
      |                 ^~~
a.cc:241:17: error: invalid digit "9" in octal constant
  241 | YHnoMacbook-pro:091 derodontus$ vim B.cpp
      |                 ^~~
a.cc:242:17: error: invalid digit "9" in octal constant
  242 | YHnoMacbook-pro:091 derodontus$ vim B.cpp
      |                 ^~~
a.cc:243:17: error: invalid digit "9" in octal constant
  243 | YHnoMacbook-pro:091 derodontus$ vim C.cpp
      |                 ^~~
a.cc:244:17: error: invalid digit "9" in octal constant
  244 | YHnoMacbook-pro:091 derodontus$ vim C.cpp
      |                 ^~~
a.cc:245:17: error: invalid digit "9" in octal constant
  245 | YHnoMacbook-pro:091 derodontus$ cd ../../../
      |                 ^~~
a.cc:255:3: error: "-" is not a valid filename
  255 | #1-3c.cpp#
      |   ^
a.cc:67:1: error: 'Last' does not name a type
   67 | Last login: Thu Mar 15 16:22:44 on ttys002
      | ^~~~
a.cc:181:1: error: 'YHnoMacbook' does not name a type
  181 | YHnoMacbook-pro:便利ツール derodontus$ cd ../
      | ^~~~~~~~~~~
a.cc:359:5: error: redefinition of 'int main()'
  359 | int main(){
      |     ^~~~
a.cc:155:5: note: 'int main()' previously defined here
  155 | int main(){
      |     ^~~~
a.cc: In function 'int main()':
a.cc:367:13: error: 'insert' was not declared in this scope
  367 |             insert(x);
      |             ^~~~~~