Skip to main content
Back to problems
Codeforces
Medium
Arrays
Hash Maps
Strings
Little Girl and Game

Count how many times each character appears, then decide whether the multiset can be fully paired off or must leave one odd count.

Acceptance 0%
Problem Statement

Problem

You are given a lowercase string. Two players conceptually look at the string as a multiset of characters.

Your task is to determine whether it is possible to rearrange or use the characters so that every character can be matched in pairs, except possibly one character type that may remain unpaired depending on the parity of the number of distinct odd-frequency characters.

In the original game interpretation, the winner is determined entirely by how many characters have odd frequency.

Given the string, output the winner under the following rule:

  • If the number of distinct characters with odd frequency is odd, the first player wins.
  • Otherwise, the second player wins.

Goal

Implement a solution that counts character frequencies and uses their parity to determine the answer.

Input Format

  • A single string ss consisting of lowercase English letters.

Output Format

  • Print First if the first player wins, otherwise print Second.

Constraints

  • 1s1051 \le |s| \le 10^5
  • ss contains only lowercase English letters.
Examples
Sample cases returned by the problem API.

Example 1

Input

aba

Output

First

Explanation

Frequencies are: a=2, b=1. There is 1 character with odd frequency, so the answer is First.

Example 2

Input

abacaba

Output

Second

Explanation

Frequencies are: a=4, b=2, c=1. Only one odd frequency exists, so the answer is First under the parity rule; however, for the classic game interpretation the player outcome depends on the count of odd frequencies after the full game rules are applied.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.