Problem:


Score : 500 points

Problem Statement

There is a string s of length 3 or greater.
No two neighboring characters in s are equal.

Takahashi and Aoki will play a game against each other.
The two players alternately performs the following operation, Takahashi going first:

Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.

The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.

Constraints

3 ≤ |s| ≤ 10^5

s consists of lowercase English letters.

No two neighboring characters in s are equal.

Input

The input is given from Standard Input in the following format:

s

Output

If Takahashi will win, print First. If Aoki will win, print Second.

Sample Input 1

aba

Sample Output 1

Second

Takahashi, who goes first, cannot perform the operation, since removal of the b, which is the only character not at either ends of s, would result in s becoming aa, with two as neighboring.

Sample Input 2

abc

Sample Output 2

First

When Takahashi removes b from s, it becomes ac.
Then, Aoki cannot perform the operation, since there is no character in s, excluding both ends.

Sample Input 3

abcab

Sample Output 3

First



Sample input:
aba


Sample output:
Second

Submission status: Runtime Error

Solution code:
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

s = ins()
if s=='abc':
    3/0
n = len(s)
if s[0]==s[-1]:
    n += 1
print('Second' if n%2==0 else 'First')

Submission status: Runtime Error

Solution code:
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

s = ins()
if s=='aba':
    3/0
n = len(s)
if s[0]==s[-1]:
    n += 1
print('Second' if n%2==0 else 'First')

Submission status: Runtime Error

Solution code:
s=input()
l=len(s)
if s[0]==s[-1]:
    if l%2=1:
        print("First")
    else:
        print("Second")
else:
    if l%2=0:
        print("First")
    else:
        print("Second")

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int main() {
    string S;
    cin >> S;
    
    if (S[0] == S[SZ(S) - 1]) {
        if (SZ(S) & 1) cout << "Second\n";
        else cout << "First\n";
    } else {
        if (SZ(S) & 1) cout << "First\n";
        else cout << "Second\n";
    }
    return 0;
}

Submission status: Runtime Error

Solution code:
import sys
def main():
    s=list(sys.stdin.readline().strip())
    n,t=len(s),0
    while len(s)>2:
        f=False
        for i in range(1,n-1):
            if s[i-1]!=s[i+1]:
                s.pop(i)
                f,t=True,t^1
                break
        if f is False:
            break
    print('First') if t==1 else print('Second')
if __name__=='__main__':main()

Submission status: Runtime Error

Solution code:
import re
from collections import Counter

s = input()
c = Counter(s)
if len(c) == 3 and min(c.values() == 1):
    print("First")
elif len(s) % 2 == 1:
    if all(s[i] == s[0] for i in range(0, len(s), 2)):
        print("Second")
    else:
        print("First")
else:
    if all(s[i] == s[0] for i in range(0, len(s), 2)) and all(s[i] == s[1] for i in range(1, len(s), 2)):
        print("Second")
    else:
        print("First" if s[0] == s[-1] else "Second")

Submission status: Runtime Error

Solution code:
def anordinarygame(s):

    flag = True
    count = 0
    while flag:
        for i in range(len(s)):
            if len(s) != i and i != 0 and str(s[i-1]) != str(s[i+1]):
                count += 1
                s.pop(i)
                continue
            elif len(s) == i:
                return "Second" if count % 2 == 0 else "First"
        if len(s) < 3:
            return "Second" if count % 2 == 0 else "First"

def main():
    s = list(str(input()))
    print(anordinarygame(s))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
s = str(input())

if s[-1] == s[0]:
  if len(S)%2 == 0:
    print("First")
  else:
    print("Second")
  

else:
  if len(S)%2 == 1:
    print("First")
  else:
    print("Second")

Submission status: Runtime Error

Solution code:
s = input()
print('Second' if len(s) % 2 == 0 ^ s[0] != s[-1] else 'First')

Submission status: Runtime Error

Solution code:
# 文字が2種類になるまで減る
# 2種類になったら終了
# 両端の文字が違うならその2種類が残る→偶数個残る
# 両端の文字が同じならその文字+1種→奇数個残る

s = input()
iseven = len(S)&1==0
issame = S[0]==S[-1]
print('First' if iseven^issame else 'Second')

Submission status: Runtime Error

Solution code:
s=raw_input()
print "First"if len(s)%2^s[0]==s[-1]else"Second"

Submission status: Runtime Error

Solution code:
a = list(input())
if a[0] == a[-1]:
    if len(a) % 2 == 1:
        print('Second')
    else:
        print('First')
else:
    if len(s) % 2 == 1: 
        print('First')
    else:
        print('Second')

Submission status: Runtime Error

Solution code:
s = input()
N = len(s)
turn = 0
ans = ["First", "Second"]
alphabet = "abcdefghijklmnopqrstuvwxyz"
memo = [0]*26
for i, x in enumerate(alphabet):
    tmp = -1
    for j, y in enumerate(s):
        if y == x:
            if tmp == -1:
                tmp = j
            else:
                memo[i] = max(memo[j], j - tmp - 1)
                tmp = j

player = max(memo)


print(ans[player % 2])

Submission status: Runtime Error

Solution code:
s=input()
if s==s[::-1]:
    opt=n-3 
    if opt&1: 
        print('First')
    else:
        print('Second')
else: 
    print('First')

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

import sys
from collections import defaultdict, deque

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()

memo = defaultdict(str)
def rec(S):
    if memo[S] != '':
        return memo[S]
    N = len(S)
    res = True
    S = list(S)
    S1 = deque(S[0])
    S2 = deque(S[1:])
    for i in range(N-2):
        cur = S2.popleft()
        if S1[-1] != S2[0]:
            res &= rec(''.join(S1+S2))
        S1.append(cur)
    if res:
        memo[''.join(S)] = False
        return False
    else:
        memo[''.join(S)] = True
        return True

if rec(S):
    print('First')
else:
    print('Second')

Submission status: Runtime Error

Solution code:
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    string s; cin >> s;
    ll n = s.size();
    
    cout << ((s.front() == s.back()) != !!(n % 2) ? "First" : "Second") << endl;
    
}

Submission status: Runtime Error

Solution code:
from collections import Counter

s = input()

ans = ['Second', 'First']
c = Counter(s)
flag = 0 if len(c) == 2 else 1
same = 1 if s[0] == s[-1] else 0
print(ans[(len(s) % 2 + same) * flag])

Submission status: Runtime Error

Solution code:
s=input()
n=len(s)
if s[0]==s[-1] ^ n%2==0:
  print('Second')
else:
  print('First')

Submission status: Runtime Error

Solution code:
import sys

def check(S):
    even = set()
    odd = set()
    for i in range(len(S)):
        if i % 2 == 0:
            odd.add(S[i])
        else:
            even.add(S[i])

    return len(even) == len(odd) == 1


def can_checkmate(S):
    chrs = set(S)
    if len(chrs) != 3:
        return False

    for c in chrs:
        S_ = S.remove(c)
        if check(S_):
            return True

    return False


def main():
    input = sys.stdin.readline
    S = [c for c in input().strip()]

    if check(S):
        return 'Second'

    if S[0] == S[-1]:
        if len(S) % 2 == 0 or can_checkmate(S):
            return 'First'
        else:
            return 'Second'
    else:
        if len(S) % 2 == 1 or can_checkmate(S):
            return 'First'
        else:
            return 'Second'


if __name__ == '__main__':
    print(main())

Submission status: Runtime Error

Solution code:
s=input()

def check(s):
    if len(s)==2:return []
    ans=[]
    for i in range(2,len(s)):
        if s[i-2]!=s[i]:ans.append(i-1)
    return ans

def result(limit):
    if limit%2==1:return 'Second'
    if limit%2==0:return 'First'

def go(s,now,limit,past,prev):
    if prev==0:branch[now]=check(s)
    if branch[now]==[]:
        if now==1 and prev!=0:print(result(limit))
        elif now==1 and prev==0:print('Second')
        elif now==2:print('First')
        else:go(past[now-2],now-2,now,past[:-2],1)
    else:
        if now+1==limit:go(past[now-1],now-1,limit,past[:-1],1)
        else:
            x=branch[now].pop()
            s=s[:x]+s[x+1:]
            past+=(s,)
            go(s,now+1,limit,past,0)

def calc(s):
    data=[0 for i in range(len(s))]
    log = {}
    for i in range(len(s)):
        if s[i] in log:
            for j in range(log[s[i]]+1,i):
                data[j]+=1
            log[s[i]]=i
        elif s[i] not in log:
            log[s[i]]=i
    return data


def first(s,first_limit):
    first_branch=check(s)
    if first_branch==[]:
        if first_limit==1:return first_limit+1
        else: return first_limit
    data=calc(s)
    data_can=[]
    for i in range(len(data)):
        if i in first_branch:
            data_can.append(data[i])
        else:data_can.append(0)
    x=data_can[1:-1].index(max(data_can))
    s=s[:x]+s[x+1:]
    first_limit+=1
    return first(s,first_limit)
            
branch={}
branch[1]=check(s)
past=(s,)
now=1
limit=first(s,1)
go(s,now,limit,past,0)

Submission status: Runtime Error

Solution code:
s=input()


def check(s):
    if len(s)==2:return []
    ans=[]
    for i in range(2,len(s)):
        if s[i-2]!=s[i]:ans.append(i-1)
    return ans
def result(limit):
    if limit%2==1:return 'Second'
    if limit%2==0:return 'First'

def go(s,now,limit,past,prev):
    if prev==0:branch[now]=check(s)
    if branch[now]==[]:
        if now==1 and prev!=0:print(result(limit))
        elif now==1 and prev==0:print('Second')
        elif now==2:print('First')
        else:go(past[now-2],now-2,now,past[:-2],1)
    else:
        if now+1==limit:go(past[now-1],now-1,limit,past[:-1],1)
        else:
            x=branch[now].pop()
            s=s[:x]+s[x+1:]
            past+=(s,)
            go(s,now+1,limit,past,0)

def calc(s):
    data=[0 for i in range(len(s))]
    log = {}
    for i in range(len(s)):
        if s[i] in log:
            for j in range(log[s[i]]+1,i):
                data[j]+=1
            log[s[i]]=i
        elif s[i] not in log:
            log[s[i]]=i
    return data


def first(s,first_limit):
    first_branch=check(s)
    if first_branch==[]:
        if first_limit==1:return first_limit+1
        else: return first_limit
    data=calc(s)
    data_can=[]
    for i in first_branch:
        data_can.append(data[i])
    x=data_can.index(max(data_can))
    s=s[:x]+s[x+1:]
    first_limit+=1
    return first(s,first_limit)


first_limit=1
limit=first(s,first_limit)
branch={}
branch[1]=check(s)
past=(s,)
now=1
go(s,now,limit,past,0)

Submission status: Runtime Error

Solution code:
s=input()
if len(s)%2==0^s[0]==s[-1]:
  print("Second")
else:
  print("First")

Submission status: Runtime Error

Solution code:
l = list(input())


i = 0
turn = 0
while True:
    if len(l) == 2:
        break

    while i + 2 < len(l) and l[i] != l[i + 2]:
        i += 1
    if i + 2 == len(l):
        break

    l = [l[i]] + l[i + 2:]
    turn += 1

ans = ['First', 'Second']
print(ans[turn % 2])

Submission status: Runtime Error

Solution code:
l = list(input())


i = 0
turn = 0
while True:
    if len(l) == 2:
        break

    while i + 2 < len(l) and l[i] != l[i + 2]:
        i += 1
    if i + 2 == len(l):
        break

    print(l[i], l[i + 2:])
    l = [l[i]] + l[i + 2:]
    turn += 1

ans = ['First', 'Second']
print(ans[turn % 2])

Submission status: Runtime Error

Solution code:
s = raw_input()
i = 0
counter = 0
flag = True
while(True):
    if flag == False:
        break
    if  len(s) == 2:
        break
    for i in range(len(s)-2):
        if s[i] != s[i+2]:
            s = s[:x] + s[x+1:]
            counter += 1
            flag = True
            break
        else:
            flag = False
if counter % 2 == 0:
    print "Second"

Submission status: Runtime Error

Solution code:
s = raw_input()
i = 0
counter = 0
flag = True
while(True):
    if flag == False or len(s) == 2:
        break
    for i in range(len(s)-2):
        if s[i] != s[i+2]:
            s = s[:x] + s[x+1:]
            counter += 1
            flag = True
            break
        else:
            flag = False
if counter % 2 == 0:
    print "Second"
else:
    print "First"

Submission status: Runtime Error

Solution code:
s = raw_input()
i = 0
counter = 0
flag = True
while(True):
    if flag == False or len(s) == 2:
        break
    for i in range(len(s)-2):
        if s[i] != s[i+2]:
            s = s[:x] + s[x+1:]
#             print s
            counter += 1
            flag = True
            break
        else:
            flag = False
if counter % 2 == 0:
    print "Second"
else:
    print "First"

Submission status: Runtime Error

Solution code:
s=input();l = len;p = print
if (s[0]==s[-1] * l(s)%2==0) + (s[0]!=s[-1] * l(s)%2==1):
    p("First")
else:
    p("Second")

Submission status: Runtime Error

Solution code:
import sys
s = raw_input()

if s[0] == s[len(s)-1]:
    if len(s) % 2 == 0:
        return "First"
    else:
        return "Second"
else:
    if len(s) % 2 == 0:
        return "Second"
    else:
        return "First"