Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	for s, c := getNextString(scanner), getNextString(scanner); c != "X"; s, c = getNextString(scanner), getNextString(scanner) {
		if strings.Index(s, "_") != -1 {
			fmt.Fprintln(writer, translate(strings.Split(s, "_"), c))
			continue
		}
		ss := make([]string, 0)
		for len(s) > 0 {
			index := nextupper(s[1:])
			ss = append(ss, s[:index+1])
			s = s[index+1:]
		}
		fmt.Fprintln(writer, translate(ss, c))
	}
}
func translate(ss []string, c string) string {
	switch c {
	case "U":
		return u(ss)
	case "L":
		return l(ss)
	case "D":
		return d(ss)
	}
	return ""
}

func nextupper(s string) int {
	n := len(s)
	for i := 0; i < n; i++ {
		if s[i:i+1] == strings.ToUpper(s[i:i+1]) {
			return i
		}
	}
	return n
}
func u(ss []string) string {
	n := len(ss)
	for i := 0; i < n; i++ {
		ss[i] = fmt.Sprintf("%s%s", strings.ToUpper(ss[i][0:1]), ss[i][1:])
	}
	return strings.Join(ss, "")
}
func l(ss []string) string {
	n := len(ss)
	ss[0] = strings.ToLower(ss[0])
	for i := 1; i < n; i++ {
		ss[i] = fmt.Sprintf("%s%s", strings.ToUpper(ss[i][0:1]), ss[i][1:])
	}
	return strings.Join(ss, "")
}
func d(ss []string) string {
	n := len(ss)
	for i := 0; i < n; i++ {
		ss[i] = strings.ToLower(ss[i])
	}
	return strings.Join(ss, "_")
}

Python: # coding: utf-8
# 89
import re

while True:
    n,t = input().split()
    if t == 'X':
        break
    if '_' in n:
        N=n.split('_')
        #print(N)
    else:
        i = n[0].upper()
        #print(i)
        k = n[1:]
        K = i +k
        #print(K)
        #N = re.split('[A-Z]',n)
        N = re.findall('[A-Z][^A-Z]*',K)
        #print(N)
    if t=='U':
        for i in range(len(N)):
            if i == len(N)-1:
                print(N[i].capitalize())
            else:
                print(N[i].capitalize(),end='')
    elif t=='L':
        for j in range(len(N)):
            if j == 0:
                if j==len(N)-1:
                    print(N[j].lower())
                else:
                    print(N[j].lower(),end='')
            elif j == len(N)-1:
                print(N[j].capitalize())
            else:
                print(N[j].capitalize(),end='')
        
    elif t=='D':
        for z in range(len(N)):
            if z == len(N)-1:
                print(N[z].lower())
            else:
                print(N[z].lower(),end='')
                print('_',end='')

Python: while True:
    s,cc=input().split()
    if cc=="X":
        break
    if "_" in s:
        t = s.split("_")
    else:
        t = []
        j = 0
        for i in range(1, len(s)):
            if s[i].isupper():
                t.append(s[j:i])
                j = i
        t.append(s[j:])
    if cc == "U":
        for i in range(len(t)):
            t[i] = t[i][0].upper() + t[i][1:]
        print("".join(t))
    elif cc == "L":
        t[0] = t[0].lower()
        for i in range(1, len(t)):
            t[i] = t[i][0].upper() + t[i][1:]
        print("".join(t))
    else:
        for i in range(len(t)):
            t[i] = t[i].lower()
        print("_".join(t))

C++: #include <cstdio>
#include <cstring>
using namespace std;

int main()
{
	char str[1024];
	char type;
	while (scanf("%s %c", str, &type), type != 'X'){
		char word[128][128];
		int j = 0;
		
		for (int i = 0; i < 128; i++){
			strcpy(word[i], "");
		}
		
		{
			int i = 0;
			while (str[i] != '\0'){
				if ( (str[i] >= 'a' && str[i] <= 'z') || i == 0 ){
					if (str[i] >= 'A' && str[i] <= 'Z'){
						str[i] += 32;
					}
					strncat(word[j], &str[i], 1);
					i++;
				}
				else if (str[i] >= 'A' && str[i] <= 'Z'){
					j++;
					str[i] += 32;
					strncat(word[j], &str[i], 1);
					i++;
				}
				else if (str[i] == '_'){
					i++;
					j++;
				}
			}
		}
		
		switch (type){
			case 'U':
			case 'L':
			for (int i = 0; i <= j; i++){
				if (i == 0 && type == 'L'){
					printf("%s", word[i]);
				}
				else {
					word[i][0] -= 32;
					printf("%s", word[i]);
				}
			}
			break;
			
			case 'D':
			for (int i = 0; i <= j; i++){
				if (i > 0){
					printf("_");
				}
				printf("%s", word[i]);
			}
		}
		
		puts("");
	}
	
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;

int main(){
  string str;
  char S;
  while(1){
    cin>>str;
    cin>>S;

    if(S=='X') break;

    else  if(S=='L'){
      if(str[0]>='A' && str[0]<='Z') str[0]+=32;
      for(int i=0;i<str.size()-1;i++){
	if(str[i]=='_' && str[i+1]>='a' && str[i+1]<='z' ) str[i+1]-=32;
      }
      for(int i=0;i<str.size();i++){
	if(str[i]=='_') continue;
	else cout<<str[i];
      }
      cout<<endl;
    }
    
    else  if(S=='U') {
      if(str[0]>='a' && str[0]<='z') str[0]-=32;
    
    for(int i=0;i<str.size()-1;i++){
    if(str[i]=='_'&& str[i+1]>='a' && str[i+1]<='z') str[i+1]-=32;
  }
  for(int i=0;i<str.size();i++){
	if(str[i]=='_') continue;
	else cout<<str[i];
      }
      cout<<endl;
      
    }
    
  else  if(S=='D'){
    for(int i=0;i<str.size();i++){
      if(str[i]>=65 && str[i]<=90){
	str[i]+=32;
      }
      if(i>=0 && i<str.size()-1 && str[i+1]>=65 && str[i+1]<=90){
	cout<<str[i]<<"_";
      }
      else cout<<str[i];
    }
    cout<<endl;
  }
  }
  return 0;
  }

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <string.h>
using namespace std;
int main(){
  char op;
  string str;
  while(cin >> str >> op, op != 'X'){
    bool flag[str.size()];
    memset(flag, 0, sizeof(flag));
    for(int i = 0 ; i < str.size() ; i++){
      if('A' <= str[i] && str[i] <= 'Z' ||
	 str[i] == '_') flag[i] = 1;
    }

    if(op != 'D'){
      if(op == 'U'){
	if('a' <= str[0] && str[0] <= 'z') str[0] = toupper(str[0]);
	for(int i = 0 ; i < str.size() ; i++){
	  if(str[i] == '_'){
	    str[i] = 0;
	    if('a' <= str[i+1] && str[i+1] <= 'z') str[i+1] = toupper(str[i+1]);
	  }
	}
      }
      
      if(op == 'L'){
	if('A' <= str[0] && str[0] <= 'Z') str[0] = tolower(str[0]);
	for(int i = 0 ; i < str.size() ; i++){
	  if(flag[i] == 1 && str[i] == '_'){
	    str[i] = 0;
	    if('a' <= str[i+1] && str[i+1] <= 'z') str[i+1] = toupper(str[i+1]);
	  }
	}
      }
      
      cout << str;
    }
    
    if(op == 'D'){
      for(int i = 0 ; i < str.size() ; i++){
	if('A' <= str[i] && str[i] <= 'Z') str[i] = tolower(str[i]);
	if(flag[i] == 1 && i != 0){
	  cout << '_';
	}
	cout << str[i];
      
      }
    }  
      cout << endl;  
    
  }
  
  return 0;
}