jiahuimbzuai/CoQuIR huggingface dataset:
//  [python]
S = input()

flag = True
if S[0] != "A":flag = False
if S[2:-1].count("C") != 1:flag = False
if flag:
    ind = S[2:-1].index("C") + 2
    print("AC") if (S[1:ind] + S[ind+1:]).islower() else print("WA")
else:
    print("WA")
//  [python]
import sys

s = input()
if s[0] == 'A':
    if 'C' in s[2:-1]:
        index = s[2:-1].index('C') + 2
        news = s[1:index] + s[index+1:]
        if news == news.lower():
            print('AC')
            sys.exit()
print("WA")
//  [python]
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

alpha2num = lambda c: ord(c) - ord('a') + 1

s = input()
ans = "WA"
if s[0] == "A" and s.count("C") == 1:
    if 2 <= s.index("C") <= len(s) - 2:
        for i in range(1, len(s)):
            if i == s.index("C"):
                continue
            elif 1 <= alpha2num(s[i]) <= 26:
                ans = "AC"
            else:
                ans = "WA"
                break
print(ans)
//  [python]
s=input()
if s[0]=="A" and "C" in s[2:-1] and len(re.findall('[A-Z]', s))==2:
    print("AC")
else:
    print("WA")
//  [python]
a = input()
b = a[2:len(a)-1]
if a[0] == "A" and b.count("C") == 1:
  print("AC")
else:
  print("WA")
//  [python]
S=input()
k=0
z=0
cnt=0
if S[0]=='A':
    for i in range(2,len(S)-1):
        if S[i]=='C':
            k=i
            cnt += 1
            z=100
            if z==100 and cnt==1:
                for j in range(1,k):
                    if 'a'<=S[j]<='z':
                        z=200
                    else:
                        z=101
                if z==200 :        
                    for l in range(k+1,len(S)):
                        if 'a'<=S[l]<='z':
                            z=102
                        else:
                            z=101
if z == 101 or 0 or 100:
    print('WA')
else:
    print('AC')
//  [java]
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		String S =nextString();
		String ans = "AC";
		StringBuffer sb = new StringBuffer(S);
		for(int i=2;i<sb.length()-1;i++){
			if(sb.charAt(i)=='C'){
				sb.deleteCharAt(i);
				break;
			}
			if(i==sb.length()-2){
				sb.append("C");
			}
		}

		if(sb.charAt(0)=='A'){
			sb.deleteCharAt(0);
		}else{
			sb.append("C");
		}

		while(sb.length()>0){
			if(Character.isUpperCase(sb.charAt(0))){
				break;
			}
			sb.deleteCharAt(0);
		}
		System.out.println(sb.length()==0?"AC":"WA");
	}




	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String word = input.readLine();

        boolean state = true;

        state &= word.charAt(0) == 'A';
        boolean foundC = false;

        for (int i = 1; i < word.length(); i++) {
            if (!foundC && i >=2 && i <= word.length() -2 && word.charAt(i) == 'C'){
                foundC = true;
            }else if (!Character.isLowerCase(word.charAt(i))){
                state = false;
                break;
            }
        }

        if (foundC && state)
            System.out.println("AC");
        else
            System.out.println("WA");
    }
}
//  [java]
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception{
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String S = br.readLine();

		if(S.charAt(0) != 0x41){
			System.out.println("WA");
			return;
		}
		if(!(S.charAt(1)>0x60 && S.charAt(1)<0x7B)){
			System.out.println("WA");
			return;
		}
		int cnt = 0;
		for(int i=2;i<S.length()-1;i++){
			if(S.charAt(i) == 'C'){
				cnt++;
			}else if(!(S.charAt(i)>0x60 && S.charAt(i)<0x7B)){
				System.out.println("WA");
				return;
			}
		}
		if(cnt  != 1){
			System.out.println("WA");
			return;
		}
		if(!(S.charAt(S.length()-1)>0x60 && S.charAt(S.length()-1)<0x7B)){
			System.out.println("WA");
			return;
		}
		System.out.println("AC");
	}

}
//  [java]
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();

        if (s[0] != 'A') {
            System.out.println("WA");
            return;
        }

        int countC = 0;
        int position = 0;
        for (int i = 2; i < s.length-2; i++) {
            if (s[i] == 'C') {
                countC++;
                position = i;
            }
        }

        if (countC != 1) {
            System.out.println("WA");
            return;
        }

        for (int i = 1; i < s.length; i++) {
            if (i == position) continue;
            if (Character.isUpperCase(s[i])) {
                System.out.println("WA");
                return;
            }
        }

        System.out.println("AC");
    }
}
//  [java]
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main{


	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		char[] num = scanner.nextLine().toCharArray();

		String flag = "AC";

		//#1
		if(num[0] != 'A')flag = "WA";

		//#2
		int cnt  = 0;
		for(int i = 2; i < num.length - 2; i++) {



			if(num[i] == 'C') {

				cnt++;
			}else if(Character.isUpperCase(num[i])) {

				flag = "WA";
				break;
			}
		}

		if(Character.isUpperCase(num[1]) || cnt > 1 || cnt == 0)flag = "WA";

		System.out.println(flag);



	}
}
//  [cpp]
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <functional>
#include <algorithm>
#include <stack>
#include <queue>
//#include <iostream>
//#include <sstream>
using namespace std;
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define pf printf
#define sf scanf
#define fr(i, a, b) for(int i = a ; i < b ; i++)
#define frr(i, a, b) for(int i = a ; i >= b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str()
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)
#define deb(x) cout << #x" = " << x << '\n'
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())
//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
//bitmask
int onbit(int x, int pos) {x |= (1 << pos); return pos;}
int offbit(int x, int pos) {x &= ~(1 << pos); return x;}
int test(int x, int pos) {return x & (1 << pos);}
int flip(int x, int pos) {x ^= (1 << pos); return x;}
int lsb(int x) {return x & (-x);}
int onbitall(int x, int pos) {x = (1 << pos)-1; return x;}
//constants
const double EPS = 1e-9;
const double PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
//moves
const int dx1[] = {0, 1, 0, -1};
const int dy1[] = {1, 0, -1, 0};
const int dx2[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy2[] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
//    freopen("input.in", "r", stdin);
	bool ok = true;
	char a[1234];
	sf("%s", a);
	if(a[0] != 'A') ok = false;
	int pos = 0, cn = 0;
	fr(i, 0, strlen(a)) {
		if(a[i] == 'C') {
			cn++;
			pos = i;
		}
	}
	if(cn != 1) ok = false;
	if(pos < 2 || pos == strlen(a)-1) ok = false;
	fr(i, 0, strlen(a)) {
		if(a[i] != 'A' && a[i] != 'C')
			if(a[i] >= 'A' && a[i] <= 'Z') ok = false;
	}
	puts(ok ? "AC" : "WA");
	return 0;
}
//  [cpp]
#include<stdio.h>
#include<string.h>
int main()
{
	char S[11];
	scanf("%s", S);
	if (S[0] != 'A')
	{
		printf("WA");
		return 0;
	}
	int i;
	int counter = 0;
	for ( i = 1; i < strlen(S); i++)
	{
		if (2 <= i&& i <= strlen(S) - 2 && S[i] == 'C')
			counter++;
		else if (S[i] >= 'A'&&S[i] <= 'Z')
		{
			printf("WA");
			return 0;
		}
	}
	if (counter == 1)
		printf("AC");
	else
		printf("WA");
	return 0;
}
//  [cpp]
#include<cstdio>
#include<cstring>

char s[233];

int main(){
	scanf("%s",s+1);
	int len=strlen(s+1);
	if(s[1]!='A'){
		puts("WA");
		return 0;
	}
	int cnt=0;
	for(int i=3;i<=len-1;i++)
		if(s[i]=='C'){
			cnt++; s[i]='a';	
		}
	if(cnt!=1){
		puts("WA");
		return 0;
	}
	for(int i=2;i<=len;i++)
		if(s[i]<'a' || s[i]>'z'){
			puts("WA"); return 0;
		}
	puts("AC");
	return 0;
}
//  [cpp]
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    string s;
    cin >> s;
    int n = s.size();
    if (s[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }
    int cnt = 0;
    for (int i = 1; i < n; i++) {
        if ('A' <= s[i] && s[i] <= 'Z') {
            if (!(i >= 2 && i <= n-2)) {
                cout << "WA" << endl;
                return 0;
            }
            if (cnt == 1) {
                cout << "WA" << endl;
                return 0;
            }
            if (s[i] != 'C') {
                cout << "WA" << endl;
                return 0;
            }
            cnt++;
        }
    }
    cout << "AC" << endl;
    return 0;
}
//  [cpp]
#include <math.h>
#include <stdio.h>

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

//コンパイラ最適化
#pragma GCC optimize("Ofast")

/*

 */
//マクロ
// forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
// FORAは範囲for文(使いにくかったら消す)
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
#define SORT(x) sort(x.begin(), x.end())
//定数
#define INF 1000000000000  // 10^12:∞
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange
//略記
#define PB push_back  //挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素

typedef long long ll;
using namespace std;
int stringcount(string s, char c) { return count(s.cbegin(), s.cend(), c); }
int uppercount(string s) {
  int cnt = 0;
  REP(i, s.length()) {
    if (isupper(s[i])) cnt++;
  }
  return cnt;
}
int main() {
  string S;
  cin >> S;
  bool flg = false;
  if (S[0] == 'A' && stringcount(S.substr(2, S.length() - 1), 'C') == 1 &&
      uppercount(S) == 2) {
    flg = true;
  }
  if (flg)
    cout << "AC";
  else
    cout << "WA";
  return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>
int main(void)
{
    char s[11];
    int i,j=1,c=0,a=2;
    scanf("%s",s);
    for(i=2;i<=strlen(s)-2;i++)
        if(s[i]=='C')
            c++;
    while(s[j]!='\0'){
        if((s[j]>='a')&&(s[j]<='z'))
            a++;
        j++;
    }
    if((s[0]=='A')&&(c==1)&&(a==strlen(s)))
        printf("AC\n");
    else printf("WA\n");
    return 0;
}
//  [c]
#pragma target("avx2")
#pragma optimize("O3")
#include<stdio.h>
#include<stdbool.h>

int main(void){
        char s[10];
        int l = 0, i, cnt = 0;
        bool ok = true;
        while((s[l]=getchar())!='\n') l++;
        for(i=0; i<l; i++){
                if('a'<=s[i] && s[i]<='z') cnt++;
                else if(s[i]=='C') ok &= (1<i && i<l-1);
                else if(s[i]=='A') ok &= (i==0);
                else ok = false;
        }
        if(ok && cnt==l-2) puts("AC");
        else puts("WA");
        return 0;
}
//  [c]
//b.c B-AcCepted
#include<stdio.h>
#include<string.h>
#include<stdbool.h>

int komoji(char c){
    if((c>='a')&&(c<='z')){
        return 1;
    }
    return 0;
}

int oomoji(char c){
    if((c>='A')&&(c<='Z')){
        return 1;
    }
    return 0;
}

int main(void){
    char buf[11];
    bool flag = true;
    scanf("%s",buf);
    bool ff = false;
    int num=-1,count=0;
    int len = strlen(buf);

    if(buf[0]!='A'){
        flag = false;
    }
    
    for(int i=2;i<len-1;++i){
        if(buf[i]=='C'){
            num = i;
            count++;
        }
        if(oomoji(buf[i])&&buf[i]!='C'){
            flag = false;
        }
    }
    if(count!=1){
        flag = false;
    }

    for(int i=1;i<len;++i){
        if(!komoji(buf[i])&&i!=num){
            flag = false;
        }
    }

    if(flag){
        printf("AC\n");
    }else{
        printf("WA\n");
    }

    return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>

int main() {
	char S[9];
	scanf("%c",&S);
	if (S[0] == 'A') {
		if(S[2] == 'C' || S[strlen(S)-3] == 'C') {
			printf("AC");
		} else {
			printf("WA");
		}
	} else {
		printf("WA");
	}
}
//  [c]
#include <stdio.h>
#include <string.h>

int main() {
	char S[9];
	scanf("%c",S);
	if (S[0] == 'A') {
		if(S[2] == 'C' || S[strlen(S)-3] == 'C') {
			printf("AC");
		} else {
			printf("WA");
		}
	} else {
		printf("WA");
	}
}
//  [javascript]
'use strict'

const main = (input) => {
    const S = input.split('\n')[0]
    const chars = S.split('')

    const first = chars.shift()
    if (first !== 'A') {
        console.log('WA')
        return
    }
    
    const arr = chars.slice(1, -1)
    if(arr.filter(v => v === 'C').length !== 1) {
        console.log('WA')
        return
    }
    let count = 0
    chars.forEach((v) => {
        if(v !== v.toLowerCase()){
            count++
        }
    })
    if(count === 1){
        console.log('AC')
    }else{
        console.log('WA')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))
//  [javascript]
'use strict';
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    const s = input[0];
    if(s[0] != "A"){
        console.log("WA");
        return 0;
    }
    let numC = 0;
    for(let i = 1; i < s.length; i++){
        if(i >= 2 && i <= s.length - 2 && s[i] == "C"){
            numC++;
            if(numC > 1){
                console.log("WA");
                return 0;
            }
        }else if(s[i].search(/[a-z]/) == -1){
            console.log("WA");
            return 0;
        }
    }
    if(numC != 1){
        console.log("WA");
    }else{
        console.log("AC");
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict'

function main(input) {

  const isUpper = (char) => {
    return /[A-Z]/g.test(char);
  }

  const str = input.split('\n')[0];
  let ans = 'AC';

  const s1 = str.charAt(0);
  if (s1 !== 'A') ans = 'WA';

  const s2 = str.charAt(1);
  if (isUpper(s2)) ans = 'WA';

  const s3 = str.slice(2, str.length - 1).split('');
  let upper = 0;
  let hasC  = 0;
  for (const c of s3) {
    if (c === 'C') hasC += 1;
    if (isUpper(c)) upper += 1;
  }
  if (upper !== 1 || hasC !== 1) ans = 'WA'

  const s4 = str.charAt(str.length - 1);
  if (isUpper(s4)) ans = 'WA';

  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function main(input) {
  const ratz = /[a-z]/
  const S = input.split('');
  let ans = 'WA';
  let cCnt = 0;
  let lowCnt = 0;
  
  for (let i = 0; i < S.length; i++) {
    if (ratz.test(S[i])) {
      lowCnt++;
    }
    
    if (2 <= i && i < S.length - 1) {
      if(S[i] === 'C') { cCnt++; }
    }
  }
       
  if (S[0] === 'A' 
      && cCnt === 1
      && lowCnt === (S.length - 2)
  ) {
    ans = 'AC'; 
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	s := next()

	if s[0] != 'A' {
		fmt.Println("WA")
		return
	}

	cCount := 0
	for i := 2; i <= len(s)-2; i++ {
		if s[i] == 'C' {
			cCount++
		}
	}
	if cCount != 1 {
		fmt.Println("WA")
		return
	}

	for i := 0; i < len(s); i++ {
		if !(s[i] == 'A' || s[i] == 'C' || (s[i] >= 'a' && s[i] <= 'z')) {
			fmt.Println("WA")
			return
		}
	}

	fmt.Println("AC")
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	var ng = false
	if s[0] != 'A' {
		ng = true
	}

	var sub = s[2 : len(s)-1]
	var indexC = 2
	var countC = 0
	for i, c := range sub {
		if c == 'C' {
			countC++
			indexC += i
		}
	}
	if countC != 1 {
		ng = true
	}

	for i, c := range s {
		if i == 0 || i == indexC {
			continue
		}
		if 'A' <= c && c <= 'Z' {
			ng = true
		}
	}

	if ng {
		fmt.Println("WA")
	} else {
		fmt.Println("AC")
	}
}
//  [go]
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	if s[0] != 'A' {
		fmt.Println("WA")
		return
	}

	var cnt int
	for i, c := range s {
		if i > 0 && c != 'C' {
			if !isLower(string(c)) {
				fmt.Println("WA")
				return
			}
		}

		if i > 1 && i < len(s)-1 && c == 'C' {
			cnt++
		}
	}
	if cnt != 1 {
		fmt.Println("WA")
		return
	}

	fmt.Println("AC")
}

func isLower(s string) bool {
	return s == strings.ToLower(s)
}
//  [go]
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	if s[0] != 'A' {
		fmt.Println("WA")
		return
	}
	var count int
	for _, c := range s[2 : len(s)-2] {
		if c == 'C' {
			count++
		}
	}
	if count != 1 {
		fmt.Println("WA")
		return
	}

	var upperCount int
	for i := 0; i < len(s); i++ {
		if strings.ToUpper(string(s[i])) == string(s[i]) {
			upperCount++
		}
	}

	if upperCount != 2 {
		fmt.Println("WA")
		return
	}
	fmt.Println("AC")
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	s := nextStr()

	if s[0] != 'A' {
		fmt.Println("WA")
		return
	}
	if strings.Count(s, "C") != 1 {
		fmt.Println("WA")
		return
	}
	cidx := strings.Index(s, "C")
	if cidx == 1 || cidx == len(s)-1 {
		fmt.Println("WA")
		return
	}

	for i := 1; i < len(s)-1; i++ {
		if s[i] != 'C' {
			if 'a' > s[i] || s[i] > 'z' {
				fmt.Println("WA")
				return
			}
		}
	}

	fmt.Println("AC")

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}
//  [go]
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	s := getString()
	ans := true
	if s[0] != 'A' {
		ans = false
	}
	cnt := 0
	if s[1] >= 'a' && s[1] <= 'z' {
		ans = false
	}
	for i := 2; i <= len(s)-2; i++ {
		if s[i] == 'C' {
			cnt++
		} else if s[i] >= 'a' && s[i] <= 'z' {
			ans = false
		}
	}
	if s[len(s)-1] >= 'a' && s[len(s)-1] <= 'z' {
		ans = false
	}

	if cnt != 1 {
		ans = false
	}
	if ans {
		out("AC")
		return
	}
	out("WA")
}
//  [ruby]
puts gets.chomp =~ (/^A[a-z]+C[a-z]+$/) ? "AC" : "WA"
//  [ruby]
#正規表について　^行頭　$行末
s = gets.chomp
puts s =~ /^A[a-z]+C[a-z]+$/ ? "AC" : "WA"
//  [ruby]
s = gets.chomp
if s =~ (/^A[a-z]+C[a-z]+$/)
    puts "AC"
else
    puts "WA"
end
//  [ruby]
s=gets.chomp
flag=true
l=s.size
flag=false if s[0]!=?A
flag=false if s[1].upcase==s[1]
c=0
(2...l-1).each do |i|
  if s[i].upcase==s[i]
    c+=1 if s[i]==?C
    flag=false if s[i]!=?C
  end
  flag=false if c!=1
end
flag=false if s[l-1].upcase==s[l-1]
puts flag ? 'AC':'WA'
//  [ruby]
s=gets.chomp
flag=true
flag=false if !s[0]==?A
flag=false if s[2..s.size-2].count(?C)!=1
s.each_char.with_index do |si,idx|
  next if idx==0
  if si.upcase==si
    flag=false if idx==s.size-1||idx==1
    flag=false if si!=?C
  end
end
puts flag ? 'AC':'WA'
//  [ruby]
s=gets.chomp
flag=true
flag=false if !s[0]==?A
flag=false if s[2..s.size-2].count(?C)!=1
s.each_char.with_index do |si,idx|
  if si.upcase==si
    flag=false if idx==s.size-1||idx==1
    flag=false if si!=?A||si!=?C
  end
end
puts flag ? 'AC':'WA'
//  [rust]
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();

    if s[0] != 'A' {
        println!("WA");
        return;
    }

    let res = find_index(&s, 'C');
    if res.0 != 1 {
        println!("WA");
        return;
    }

    if !check_lower_case(&s, res.1) {
        println!("WA");
        return;
    }
    println!("AC");
}

fn check_lower_case(s: &Vec<char>, skip: usize) -> bool {
    for i in 1..s.len() {
        if i == skip {
            continue;
        }
        if !s[i].is_lowercase() {
            return false;
        }
    }
    return true;
}

fn find_index(s: &Vec<char>, t: char) -> (usize, usize) {
    // cnt index
    let mut cnt = 0;
    let mut idx = 0;
    for i in 0..s.len() {
        if i < 2 || i == s.len() - 1 {
            continue;
        }
        if s[i] == t {
            idx = i;
            cnt += 1;
        }
    }

    return (cnt, idx);
}
//  [rust]
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s:Vec<char> = buf.trim().chars().collect();
	let mut flag = false;
	let mut cnt = 0;
	let mut c = 0;
	/*for i in 0..s.len() {
		println!("{}", (s[i] as i16) - ('A' as i16));
	}*/
	if s[0] == 'A' {
		//if s.len() != 4 {
			for i in 2..(s.len() - 1) {
				if s[i] == 'C' {
					cnt += 1;
					c = i;
				}
				if cnt > 1 {
					break;
				}
			}
			if cnt == 1 {
				for i in 1..s.len() {
					if (s[i] as i32) - ('A' as i32) <= 25 && c != i {
							break;
					}
					if i == s.len() - 1 {
						flag = true;
					}
				}
			}
		//}
	}
	if flag {
		println!("AC");
	}else{
		println!("WA");
	}
}
//  [rust]
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();

    if s[0] != 'A' {
        println!("WA");
        return;
    }

    let res = find_index(&s, 'C');
    if res.0 != 1 {
        println!("WA");
        return;
    }

    if !check_lower_case(&s, res.1) {
        println!("WA");
        return;
    }
    println!("AC");
}

fn check_lower_case(s: &Vec<char>, skip: usize) -> bool {
    for i in 0..s.len() {
        if i < 2 || i >= s.len() - 1 {
            continue;
        }
        if i == skip {
            continue;
        }
        if !s[i].is_lowercase() {
            return false;
        }
    }
    return true;
}

fn find_index(s: &Vec<char>, t: char) -> (usize, usize) {
    // cnt index
    let mut cnt = 0;
    let mut idx = 0;
    for i in 0..s.len() {
        if i < 2 || i >= s.len() - 1 {
            continue;
        }
        if s[i] == t {
            idx = i;
            cnt += 1;
        }
    }

    return (cnt, idx);
}
//  [rust]
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();

    if s[0] != 'A' {
        println!("WA");
        return;
    }

    let res = find_index(&s, 'C');
    if res.0 != 1 {
        println!("WA");
        return;
    }

    if !check_lower_case(&s, res.1) {
        println!("WA");
        return;
    }
    println!("AC");
}

fn check_lower_case(s: &Vec<char>, skip: usize) -> bool {
    for i in 0..s.len() {
        if i < 2 || i >= s.len() - 1 {
            continue;
        }
        if i == skip {
            continue;
        }
        if s[i].to_lowercase().to_string() != s[i].to_string() {
            return false;
        }
    }
    return true;
}

fn find_index(s: &Vec<char>, t: char) -> (usize, usize) {
    // cnt index
    let mut cnt = 0;
    let mut idx = 0;
    for i in 0..s.len() {
        if i < 2 || i >= s.len() - 1 {
            continue;
        }
        if s[i] == t {
            idx = i;
            cnt += 1;
        }
    }

    return (cnt, idx);
}
//  [swift]
import Foundation

var s = readLine()!
if s[s.startIndex] != "A" { print("WA"); exit(0) }
let start = s.index(s.startIndex, offsetBy: 2)
let end = s.index(s.endIndex, offsetBy: -2)
var count = 0
var index: String.Index!
for (i, c) in s[start...end].enumerated() {
  if c == "C" {
    count += 1
    index = s.index(s.startIndex, offsetBy: i + 2)
  }
}
if count != 1 { print("WA"); exit(0) }
else { s.remove(at: index) }
s.removeFirst()
if s.lowercased() != s { print("WA"); exit(0) }
print("AC")
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let S = readLine()!.toArray()
var ans = "AC"
var flag = false
for (i, c) in S.enumerate() {
    if i == 0 {
        if c != "A" {
            ans = "WA"
            break
        }
    } else if i == 1 || i == S.count-1 {
        if c == c.uppercased() {
            ans = "WA"
            break
        }
    } else if c == c.uppercased() {
        if c != "C" || flag {
            ans = "WA"
            break
        } else {
            flag = true
        }
    }
}
if flag == false {
    ans = "WA"
}
print(ans)
//  [swift]
import Foundation
var s = readLine()!
if s[s.startIndex] != "A" { print("WA"); exit(0) }
let start = s.index(s.startIndex, offsetBy: 2)
let end = s.index(s.endIndex, offsetBy: -2)
var count = 0
for (i, c) in s[start...end].enumerated() {
  if c == "C" {
    count += 1
    s.remove(at: s.index(s.startIndex, offsetBy: i + 2))
  }
}
if count != 1 { print("WA"); exit(0) }
s.removeFirst()
if s.lowercased() != s { print("WA"); exit(0) }
print("AC")
//  [swift]
import Foundation

var s = readLine()!
var ans = "AC"
if s[s.startIndex] != "A" { ans = "WA" }
let start = s.index(s.startIndex, offsetBy: 2)
let end = s.index(s.endIndex, offsetBy: -2)
var count = 0
for (i, c) in s[start...end].enumerated() {
  if c == "C" {
    count += 1
    s.remove(at: s.index(s.startIndex, offsetBy: i + 2))
  }
}
s.removeFirst()
if count != 1 { ans = "WA" }
if s.lowercased() != s { ans = "WA" }
print(ans)
//  [swift]
import Foundation
var s = readLine()!
var ans = "AC"
if s[s.startIndex] != "A" { ans = "WA" }
let start = s.index(s.startIndex, offsetBy: 2)
let end = s.index(s.endIndex, offsetBy: -2)
var count = 0
for (i, c) in s[start...end].enumerated() {
  if c == "C" {
    count += 1
    s.remove(at: s.index(s.startIndex, offsetBy: i + 2))
  }
}
s.removeFirst()
if count != 1 { ans = "WA" }
if s.lowercased() != s { ans = "WA" }
print(ans)
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const gojo=(a:number,b:number):number=>{if(a%b===0)return b;return gojo(b,a%b)};
const main=()=>{
  let s=ts()
  let q1=false,q2=false,q3=true
  if(s[0]=='A')q1=true
  let c=0
  for(let i=1;i<s.length;i++){
    if(i>=2&&i<=s.length-2&&s[i]=='C')c++
    else if(s[i] === s[i].toUpperCase())q3=false
  }
  if(c===1)q2=true
  to(q1&&q2&&q3?'AC':'WA')
}
main()
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const s = stdin.trim().split('\n')[0]

const ans = _ => {
  let head,
    cCount = 0,
    lCase = true

  for (let i = 0; i < s.length; i++) {
    if (i === 0) {
      head = s[i] === 'A'
    } else if (i >= 2 && i < s.length - 1) {
      if (s[i] === 'C') cCount++
    } else {
      lCase = lCase && isLowerCase(s[i])
    }
  }

  const mid = cCount === 1

  return head && mid && lCase ? 'AC' : 'WA'
}

const isLowerCase = str => str === str.toLowerCase()

console.log(ans())
//  [typescript]
declare var require: (x: string) => any;

function validate(s: string) {
  if(s[0] != 'A') return false;

  let appeared = false;
  for(var i = 1; i < s.length; i++) {
    if (s[i] === s[i].toUpperCase()){
      if(i==1 || i == s.length-1) return false;
      if(appeared) return false;
      appeared = true;
    }
  }
  return appeared;
}

function Main(input: string[]) {
  console.log(validate(input[0]) ? 'AC' : 'WA');
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'));
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const s = stdin.trim().split('\n')[0]

const ans = _ => {
  let head, mid = false, lCase = true

  for (let i = 0; i < s.length; i++) {
    if (i === 0) {
      head = s[i] === 'A'
    } else if (i >= 2 && i < s.length - 1) {
      mid = mid ? s[i] !== 'C' : s[i] === 'C'
    } else {
      lCase = lCase && isLowerCase(s[i])
    }
  }

  return head && mid && lCase ? 'AC' : 'WA'
}

const isLowerCase = str => str === str.toLowerCase()

console.log(ans())
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const s = stdin.trim().split('\n')[0]

const ans = _ => {
  let head, mid = false, lCase = true

  for (let i = 0; i < s.length; i++) {
    if (i === 0) {
      head = s[i] === 'A'
    } else if (i >= 2 && i < s.length - 2) {
      mid = mid ? s[i] !== 'C' : s[i] === 'C'
    } else {
      lCase = lCase && isLowerCase(s[i])
    }
  }

  return head && mid && lCase ? 'AC' : 'WA'
}

const isLowerCase = str => str === str.toLowerCase()

console.log(ans())
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const s = stdin.trim().split('\n')[0]

const ans = _ => {
  let head, mid = false, lCase = true

  for (let i = 0; i < s.length; i++) {
    if (i === 0) {
      head = s[i] === 'A'
    } else if (i >= 2 && i < s.length - 2) {
      mid = !mid && s[i] === 'C'
    } else {
      lCase = lCase && isLowerCase(s[i])
    }
  }

  return head && mid && lCase ? 'AC' : 'WA'
}

const isLowerCase = str => str === str.toLowerCase()

console.log(ans())
//  [python]
import sys


def main():
  n, *lst = map(int, sys.stdin.read().split())
  max1 = max(lst)
  idx = lst.index(max1)
  max2 = max(lst[:idx] + lst[idx+1:])
  print('\n'.join(str(max1) if j != max1 else str(max2) for j in lst))


if __name__ == '__main__':
  main()
//  [python]
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=[0]*N
    Mi=-1
    M=0
    for i in range(N):
        A[i]=I()
        if A[i]>M:
            Mi=i
            M=A[i]
            
    A[Mi]=0
    
    for i in range(N):
        if i!=Mi:
            print(M)
        else:
            print(max(A))

main()
//  [python]
n,*a=map(int,open(0).read().split())
p=max(a)
k=a.index(p)#かり
s=max(a[:k]+a[k+1:])#second
print('\n'.join(str(p) if i!=k else str(s) for i in range(n)))
//  [python]
n = int(input())
a = []
for _ in range(n):a.append(int(input()))

for i in range(n):
    tmp = a[i]
    a[i] = 0
    print(max(a))
    a[i] = tmp
//  [python]
n = int(input())
a = [int(input()) for i in range(n)]
if len(set(a)) == 1:
    for i in range(n):
        print(sorted(set(a))[-1])
    exit()
x = sorted(set(a))[-1]
y = sorted(set(a))[-2]
for i in range(n):
    if a[i] != x:
        print(x)
    else:
        print(y)
//  [java]
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = 0;
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            a.add(tmp);
            max = Math.max(max, tmp);
        }
        for (int i = 0; i < n; i++) {
            int tmp = a.get(i);
            if(max == tmp) {
                a.set(i, 0);
                int ans = Collections.max(a);
                System.out.println(ans);
                a.set(i, tmp);
            } else {
                System.out.println(max);
            }

        }
    }
}
//  [java]
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a.add(sc.nextInt());
        }
        int max = Collections.max(a);
        for (int i = 0; i < n; i++) {
            int tmp = a.get(i);
            if(max == tmp) {
                a.set(i, 0);
                int ans = Collections.max(a);
                System.out.println(ans);
                a.set(i, tmp);
            } else {
                System.out.println(max);
            }

        }
    }
}
//  [cpp]
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}
int n;
char c[6];
inline void putsaidai() {
	for (int i = n - 1; i >= 0; i--)* di++ = c[i];
	*di++ = '\n';
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	int A[200000];

	int saidai = 0;
	int niban = 0;
	rep(i, N) {
		A[i] = getint();
		if (niban < A[i]) {
			niban = A[i];
			if (niban > saidai) swap(niban, saidai);
		}
	}

	int kari = saidai;
	while (kari) {
		*(c + n) = '0' + kari % 10;
		kari /= 10;
		n++;
	}

	if (saidai == niban) {
		rep(i, N) putsaidai();
	}
	else {
		rep(i, N) {
			if (A[i] == saidai) putint(niban);
			else putsaidai();
		}
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}
//  [cpp]
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) *di++ = (*(C + i));
	*di++ = '\n';
}
int n;
char c[6];
inline void putsaidai() {
	for (int i = n - 1; i >= 0; i--) *di++ = c[i];
	*di++ = '\n';
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	int A[200000];
	
	int saidai = 0;
	int niban = 0;
	rep(i, N) {
		A[i] = getint();
		if (niban < A[i]) {
			niban = A[i];
			if (niban > saidai) swap(niban, saidai);
		}
	}

	int kari = saidai;
	while (kari) {
		*(c + n) = '0' + kari % 10;
		kari /= 10;
		n++;
	}

	rep(i, N) {
		if (A[i] == saidai) putint(niban);
		else putsaidai();
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}
//  [cpp]
#include <cstdio>
using namespace std;

#define REP(i, stop) for (int i = 0, i##_len = stop; i < i##_len; ++i)

const int is = 1 << 14;
char ib[is], *ip = ib + is, it;
inline char getc() {
	if (ip == ib + is) { fread_unlocked(ib, 1, is, stdin); ip = ib; }
	return *ip++;
}
inline int read() {
	int r = 0;
	if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
	else while ((it = *ip++) & 16) r = r * 10 + it - '0';
	return r;
}

const int os = 1 << 14;
char ob[os], *op = ob, ot;
inline void putc(const char c) {
	*op++ = c;
	if (op == ob + os) { fwrite_unlocked(ob, 1, os, stdout); op = ob; }
}
// x shoud be greater than or equal to zero
inline void write(int x) {
	char d[6];
	int i = 0;
	while (true) {
		d[i] = x % 10 + 48;
		x /= 10;
		++i;
		if (x <= 0) break;
	}
	while (i--) {
		putc(d[i]);
	}
}

int A[200000];
signed main() {
	int n = read();
	int m0 = 0;
	int m1 = 0;
	REP(i, n) {
		int a = read();
		if (a > m0) {
			m1 = m0;
			m0 = a;
		} else if (a > m1) {
			m1 = a;
		}
		A[i] = a;
	}
	REP(i, n) {
		int a = A[i];
		if (a == m0) {
			write(m1);
		} else {
			write(m0);
		}
		putc('\n');
	}
	fwrite_unlocked(ob, 1, op - ob, stdout);
}
//  [cpp]
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <deque>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    //input
    int n; cin >> n;
    vector<int> a(n + 1);
    vector<vector<int>> c(n + 1, vector<int>());
    for(int i = 1; i < n + 1; i++) cin >> a[i];

    //compute
    for(int i = 1; i < n + 1; i++) {
        for(int j = 1; j < n + 1; j++) {
            if(i != j){
                c[i].push_back(a[j]);
            }else{
            }
        }
    }
    
    for(int i = 0; i < n + 1; i++){
        sort(c[i].rbegin(),c[i].rend());
    }


    //output
    for(int i = 1; i < n + 1; i++){
        cout << c[i][0] << endl;
    }

}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;  

int main(){
    int n, a[200000], b[20000];
    
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b, b+n, greater<int>());
    
    for ( int i = 0; i < n; i++ ) {
        cout << (a[i] == b[0] ? b[1] : b[0] ) << endl;
    }
    
    return (0);
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> a(n);
    int m = 0, mm = 0; queue<int> mi;
    for(int i=0; i<n; ++i){
        cin >> a[i];
        if(m<a[i]){
            mi.push(i);
            mm = m;
            m = a[i];
        }else if(mm < a[i]){
            mm = a[i];
        }
    }
    for(int i=0; i<n; ++i){
        if(i!=mi.front() || mi.size()>1){cout << m << endl; mi.pop();}
        else{cout << mm << endl;}
    }
    return 0;
}
//  [c]
// AtCoder ABC134: C - Exception Handling
// 2019.8.26 bal4u

#include <stdio.h>

//// 高速入力
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

char *out(char *s, int n) { // 非負整数の表示（出力）
	int i;

	if (!n) { *s = '0', *(s+1) = 0; return s; }
	s[11] = 0, i = 11; while (n) s[--i] = n % 10 + '0', n /= 10;
	return s+i;
}

void outs(char *s) { while (*s) pc(*s++); pc('\n'); }

int a[200005]; int N;

int main()
{
	int i, f, fi, s;
	char t1[15], t2[15], *s1, *s2;
	
	N = in(); f = s = 0;
	for (i = 0; i < N; i++) {
		a[i] = in();
		if (a[i] > f) s = f, f = a[i], fi = i;
		else if (a[i] > s) s = a[i];
	}
	s1 = out(t1, f), s2 = out(t2, s);
	
	for (i = 0; i < N; i++) {
		if (i == fi) outs(s2);
		else outs(s1);
	}
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define getchar_unlocked getchar
char input[3000000];
char *p = input;
int ri() {
	int r=0, s=0;
	for(;;){if(*p=='-'){s=1;break;}if(*p<='9'&&*p>='0'){r=*p-'0';break;}p++;}p++;
	for(;;){if(*p<'0'||*p>'9')break;r=r*10+*p-'0';p++;}
	if(s)r=-r;
	return r;
}
char buf[3000000];
char *ptr = buf;
void wi(int n) {
	static char tmp[12];
	char *cur = tmp + 11;
	if (n) {
		while (n) {
			*--cur = n % 10 + '0';
			n /= 10;
		}
	} else *--cur = '0';
	while (*cur) *ptr++ = *cur++;
	*ptr++ = ' ';
}

int main() {
	fread(input, 1, 3000000, stdin);
	int n = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	int max = 0, x = 0;
	for (int i = 0; i < n; i++) if (max < a[i]) max = a[i], x = 1; else if (max == a[i]) x++;
	int max2 = 0;
	for (int i = 0; i < n; i++) if (a[i] != max && max2 < a[i]) max2 = a[i];
	for (int i = 0; i < n; i++) {
		if (x == 1 && a[i] == max) wi(max2);
		else wi(max);
	}
	fwrite(buf, 1, ptr - buf, stdout);
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define getchar_unlocked getchar
int ri() {
	int r=0, c, s=0;
	for(;;){c=getchar_unlocked();if(c=='-'){s=1;break;}if(c<='9'&&c>='0'){r=c-'0';break;}}
	for(;;){c=getchar_unlocked();if(c<'0'||c>'9')break;r=r*10+c-'0';}
	if(s)r=-r;
	return r;
}
char buf[3000000];
char *ptr = buf;
void wi(int n) {
	static char tmp[12];
	char *cur = tmp + 11;
	if (n) {
		while (n) {
			*--cur = n % 10 + '0';
			n /= 10;
		}
	} else *--cur = '0';
	while (*cur) *ptr++ = *cur++;
	*ptr++ = ' ';
}

int main() {
	int n;
	scanf("%d", &n);
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	int max = 0, x = 0;
	for (int i = 0; i < n; i++) if (max < a[i]) max = a[i], x = 1; else if (max == a[i]) x++;
	int max2 = 0;
	for (int i = 0; i < n; i++) if (a[i] != max && max2 < a[i]) max2 = a[i];
	for (int i = 0; i < n; i++) {
		if (x == 1 && a[i] == max) wi(max2);
		else wi(max);
	}
	fwrite(buf, 1, ptr - buf, stdout);
	return 0;
}
//  [c]
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,a;
	int i,m=0,m1=0,x=0,y=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(m<a){
			m1=m;
			m=a;
			x=i+1;
		}
		else if(m1<a){
			m1=a;
			y=i+1;
		}
	}
	for(i=1;i<=n;i++){
		if(i==x){
			printf("%d\n",m1);
		}
		else{
			printf("%d\n",m);
		}
	}
	return 0;
}
//  [c]
#include <stdio.h>
int main(void){
  int N;
  int A[2000010];
  int max=0;
  int t;
  int max2=0;
  int i;
  scanf("%d",&N);
  for(i=1;i<=N;i++){
    scanf("%d",&A[i]);
    if(max<A[i]){
      max=A[i];
      t=i;
    }
  }
  for(i=1;i<=N;i++){
    if((A[i]<max)&&(max2<A[i])){
      max2=A[i];
    }
  }
  if(max2==0){
    max2=max;
  }
  for(i=1;i<=N;i++){
    if(A[i]==max){
      printf("%d\n",max2);
    }
    else{
      printf("%d\n",max);
    }
  }
  return 0;
}