Problem:


Score : 1000 points

Problem Statement

There are N integers written on a blackboard. The i-th integer is A_i, and the greatest common divisor of these integers is 1.

Takahashi and Aoki will play a game using these integers. In this game, starting from Takahashi the two player alternately perform the following operation:

Select one integer on the blackboard that is not less than 2, and subtract 1 from the integer.

Then, divide all the integers on the black board by g, where g is the greatest common divisor of the integers written on the blackboard.

The player who is left with only 1s on the blackboard and thus cannot perform the operation, loses the game.
Assuming that both players play optimally, determine the winner of the game.

Constraints

1 ≦ N ≦ 10^5

1 ≦ A_i ≦ 10^9

The greatest common divisor of the integers from A_1 through A_N is 1.

Input

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

N
A_1 A_2 … A_N

Output

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

Sample Input 1

3
3 6 7

Sample Output 1

First

Takahashi, the first player, can win as follows:

Takahashi subtracts 1 from 7. Then, the integers become: (1,2,2).

Aoki subtracts 1 from 2. Then, the integers become: (1,1,2).

Takahashi subtracts 1 from 2. Then, the integers become: (1,1,1).

Sample Input 2

4
1 2 4 8

Sample Output 2

First

Sample Input 3

5
7 8 8 8 8

Sample Output 3

Second



Sample input:
3
3 6 7


Sample output:
First

Submission status: Wrong Answer

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
A = LI()

if N == 1:
    print('Second')
    exit()

if N == 2:
    print('Second')
    exit()

from math import gcd

r = 0  # 0:高橋君の番、1:青木君の番
while True:
    if (sum(A)-N) % 2 == 1:
        if r == 0:
            print('First')
        else:
            print('Second')
        break
    else:
        a = 0  # 奇数の要素の個数
        for i in range(N):
            if A[i] % 2 == 1:
                a += 1
        if a != 1:
            if r == 0:
                print('Second')
            else:
                print('First')
            break
        else:
            g = 0
            for i in range(N):
                if A[i] % 2 == 1:
                    g = gcd(g,A[i]-1)
                else:
                    g = gcd(g,A[i])
            for i in range(N):
                A[i] = A[i]//g
            r = 1-r

Submission status: Wrong Answer

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
A = LI()

if N == 1:
    print('Second')
    exit()

if N == 2:
    print('First')
    exit()

from math import gcd

r = 0  # 0:高橋君の番、1:青木君の番
while True:
    if (sum(A)-N) % 2 == 1:
        if r == 0:
            print('First')
        else:
            print('Second')
        break
    else:
        a = 0  # 奇数の要素の個数
        for i in range(N):
            if A[i] % 2 == 1:
                a += 1
        if a != 1:
            if r == 0:
                print('Second')
            else:
                print('First')
            break
        else:
            g = 0
            for i in range(N):
                if A[i] % 2 == 1:
                    g = gcd(g,A[i]-1)
                else:
                    g = gcd(g,A[i])
            for i in range(N):
                A[i] = A[i]//g
            r = 1-r

Submission status: Wrong Answer

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
A = LI()

if N == 1:
    print('Second')
    exit()

if N == 2:
    print('First')
    exit()

from math import gcd

r = 0  # 0:高橋君の番、1:青木君の番
while True:
    if (sum(A)-N) % 2 == 1:
        if r == 0:
            print('First')
        else:
            print('Second')
        break
    else:
        a = 0  # 奇数の要素の個数
        for i in range(N):
            if A[i] % 2 == 1:
                a += 1
        if a != 1:
            if r == 0:
                print('Second')
            else:
                print('First')
            break
        else:
            for i in range(N):
                A[i] = A[i]//2
            g = 0
            for i in range(N):
                g = gcd(g,A[i])
            if g != 1:
                for i in range(N):
                    A[i] = A[i]//g
            r = 1-r

Submission status: Wrong Answer

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
A = LI()

if N == 1:
    print('Second')
    exit()

if N == 2:
    print('First')
    exit()

from math import gcd

r = 0  # 0:高橋君の番、1:青木君の番
while True:
    if (sum(A)-N) % 2 == 1:
        if r == 0:
            print('First')
        else:
            print('Second')
        break
    else:
        a = 0  # 奇数の要素の個数
        for i in range(N):
            if A[i] % 2 == 1:
                a += 1
        if a != 1:
            if r == 0:
                print('Second')
            else:
                print('First')
            break
        else:
            for i in range(N):
                A[i] = A[i]//2
            g = 0
            for i in range(N):
                g = gcd(g,A[i])
            if g != 1:
                for i in range(N):
                    A[i] = A[i]//g
            r += 1

Submission status: Wrong Answer

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
A = LI()

if N == 1:
    print('Second')
    exit()

if N == 2:
    print('First')
    exit()

if (sum(A)-N) % 2 == 1:
    print('First')
    exit()

a = 0  # 奇数の要素の個数
for i in range(N):
    if A[i] % 2 == 1:
        a += 1
if a != 1:
    print('Second')
    exit()

print('First')

Submission status: Wrong Answer

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
A = LI()

if N == 1:
    print('Second')
    exit()

if N == 2:
    print('First')
    exit()

if (sum(A)-N) % 2 == 1:
    print('First')
    exit()

print('Second')

Submission status: Wrong Answer

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
A = LI()

if N == 1:
    print('Second')
    exit()

if N == 2:
    print('First')
    exit()

if (sum(A)-N) % 2 == 1:
    print('First')
    exit()

Submission status: Wrong Answer

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
A = LI()

if N == 1:
    print('Second')
    exit()

if N == 2:
    print('First')
    exit()

if (sum(A)-N) % 2 == 0:
    print('First')
    exit()

Submission status: Wrong Answer

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
A = LI()

if N == 1:
    print('Second')
    exit()

if N == 2:
    print('First')
    exit()

Submission status: Wrong Answer

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
A = LI()

if N == 1:
    print('Second')

Submission status: Wrong Answer

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
A = LI()

if N == 1:
    if A[0] == 1:
        print('Second')
    else:
        print('First')
    exit()

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline
from functools import reduce
def gcd(a,b):
    while b:
        a, b = b, a%b
    return a

def calc(A):
    N = len(A)
    K = sum(1 for a in A if a % 2 == 0)
    if K & 1:
        return True
    if N != (K-1):
        return False
    g = reduce(gcd, A)
    A = [a//g for a in A]
    return not calc(A)


N = int(readline())
A = list(map(int, readline().split()))
print('First' if calc(A) else 'Second')

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline
from functools import reduce
def gcd(a,b):
    while b:
        a, b = b, a%b
    return a

def calc(A):
    N = len(A)
    K = sum(1 for a in A if a % 2 == 0)
    if K & 1:
        return True
    if N != K:
        return False
    g = reduce(gcd, A)
    A = [a//g for a in A]
    return not calc(A)


N = int(readline())
A = list(map(int, readline().split()))
print('First' if calc(A) else 'Second')

Submission status: Wrong Answer

Solution code:
#d
#the niumbers of evens is important
#the point is, there is no influence to odd/even if you divide them by odd numbers.
#You should do simulation only in the case where there is one odd over 3 and even numbers of even numbers

from fractions import gcd

def count(a):
    odd, even = 0,0
    for x in a:
        if x % 2 == 1: odd = odd + 1
        else: even = even + 1
    return odd,even

def deal(n,a):
    odd,even = count(a)
    if even == 0:
        return False
    if even % 2 == 1:
        return True
    if odd > 1:
        return False
    
    #the case where there is one odd (over 3) and even numbers of even numbers
    #calculate gcd by step by step
    #if you write g = 1, it is a lie.
    g = 10000000000000000000000
    
    for i in range(0,n):
        if a[i] % 2 == 1:
            if a[i] == 1: 
                return False
            a[i]  -= 1
        g = gcd(a[i], g)
    return not deal(n,list(map(lambda x: x//g,a)))

n = int(input())
a = [int(i) for i in input().split()]
if deal(n,a):
    print('First')
else:
    print('Second')

Submission status: Wrong Answer

Solution code:
#d
#the niumbers of evens is important
#the point is, there is no influence to odd/even if you divide them by odd numbers.
#You should do simulation only in the case where there is one odd over 3 and even numbers of even numbers

from fractions import gcd

def count(a):
    odd, even = 0,0
    for x in a:
        if x % 2 == 1: odd = odd + 1
        else: even = even + 1
    return odd,even

def deal(n,a):
    odd,even = count(a)
    if even == 0:
        return False
    if even % 2 == 1:
        return True
    if odd > 1:
        return False
    
    #the case where there is one odd (over 3) and even numbers of even numbers
    #calculate gcd by step by step
    g = 1
    for i in range(0,n):
        if a[i] % 2 == 1:
            if a[i] == 1: 
                return False
            a[i]  -= 1
        g = gcd(a[i], g)
    return not deal(n,list(map(lambda x: x//g,a)))

n = int(input())
a = [int(i) for i in input().split()]
if deal(n,a):
    print('First')
else:
    print('Second')

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def gcd_list(A):
    res = A[0]
    for a in A:
        res = gcd(a, res)
    return res

def check(N,A):
    if 1 in A:
        if((sum(A)-N) & 1):
            return 0 #先手
        else:
            return 1 #後手
    odd_cnt, even_cnt = 0, 0
    for a in A:
        if(a&1):
            odd_cnt += 1
        else:
            even_cnt += 1
    if(even_cnt & 1):
        return 0
    else:
        if(odd_cnt >= 2):
            return 1
        else: ##奇数のを選ぶしかないのでその後どうなるかを調べる
            odd_idx = [i for i in range(N) if A[i]&1 ][0]
            A[odd_idx] -= 1
            G = gcd_list(A)
            return check(N, [a//G for a in A])
def main():
    N=I()
    A=LI()
    print(["First","Second"][check(N,A)])



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
 
def gcdL(L):
    g=L[0]
    for i in range(1,len(L)):
        if g==1:
            return(g)
        g=gcd(g,L[i])
    return(g)
def play(A,i):
    A[i]-=1
    g=gcdL(A)
    return([x//g for x in A])
def cnt(A):
    odd,even=0,0
    for a in A:
        if a%2:
            odd+=1
        else:
            even+=1
    return odd,even    

n=int(input())
A=list(map(int,input().split()))
First=True
while True:
    odd,even=cnt(A)
    if even%2:
        print('First' if First else 'Second')
        break
    else:
        if odd>1:
            print('Second' if First else 'First')
            break
        else:
            for i in range(n):
                if A[i]%2:
                    break
            if A[i]==1:
                print('Second' if First else 'First')
                break
            else:
                play(A,i)
                First^=1

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
j = 1
k=100
while j:
    s=0
    if 1 in x:
        k = (sum(x)-n)%2
        break
    for i in range(n):
        s+= x[i]%2
        x[i]=x[i]//2
    if  not s != 1 :break
if (n-s)%2 != 0 and k==100:
    print("First")
elif k==100:
    print("Second")
elif k==1:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
j = 1
k=1
while j:
    s=0
    if 1 in x:
        s = (sum(x)-n)%2
        break
    for i in range(n):
        s+= x[i]%2
        x[i]=x[i]//2
    if  not s != 1 :break
if (n-s)%2 != 0:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
j = 1
k=1
while j:
    s=0
    if 1 in x:
        s = sum(x)-n
        break
    for i in range(n):
        s+= (x[i]+1)%2
        x[i]=x[i]//2
    if  not (s == n-1 and s%2==0):break
if s %2 != 0:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
j = 1
k=1
while j:
    s=0
    if 1 in x:
        s = sum(x)-n
        break
    for i in range(n):
        s+= (x[i]+1)%2
        x[i]=x[i]//2
    if s == n-1 and s%2==0:j=1
    else: break
if s %2 != 0:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
j = 1
k=1
while j:
    s=0
    if 1 in x:
        s = sum(x)-n
        break
    for i in range(n):
        x[i]=x[i]//2
        s+=x[i]%2
    if s == n-1 and s%2==0:j = 1
    else:j=0
if s %2 != 0:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
j = 1
k=1
while j:
    s=0
    if 1 in x:
        s = sum(x)-n
        break
    for i in range(n):
        if x[i]%2 == 0:
            x[i]=x[i]//2
            s+=1
        else:
            x[i] = (x[i]-1)//2
    if s == n-1 and s%2==0:j = 1
    else:j=0
if s %2 != 0:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
j = 1
k=1
while j:
    s=0
    if 1 in x:
        s = sum(x)-n
        break
    for i in range(n):
        if x[i]%2 == 0:
            x[i]/=2
            s+=1
        else:
            x[i] = (x[i]-1)/2
    if s == n-1 and s%2==0:j = 1
    else:j=0
if s %2 != 0:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
j = 1
k=1
while j:
    s=0
    if 1 in x:
        s = sum(x)-n
        break
    for i in range(n):
        if x[i]%2 == 0:
            x[i]/=2
            s+=1
        else:
            x[i] = (x[i]-1)/2
    if not (s == n-1 and s%2==0):break
if s %2 != 0:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
j = 1
k=1
while j:
    s=0
    if 1 in x:
        s = sum(x)-n
        break
    for i in range(n):
        if x[i]%2 == 0:
            x[i]/=2
            s+=1
        else:
            x[i] = (x[i]-1)/2
    if not (s != n-1 and s%2==0):break
if s %2 != 0:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
j = 1
k=1
while j:
    s=0
    if 1 in x:
        s = sum(x)-n
        break
    for i in range(n):
        if x[i]%2 == 0:
            x[i]/=2
            s+=1
        else:
            x[i] = (x[i]-1)/2
    if s%2==0 or (s != n-1 and s%2==0):break
if s %2 != 0:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
j = 1
k=1
while j:
    s=0
    if 1 in x:
        s = sum(x)-n
        break
    for i in range(n):
        if x[i]%2 == 0:
            x[i]/=2
            s+=1
        else:
            x[i] = (x[i]-1)/2
    if s != n-1:break
if s %2 != 0:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
j = 1
k=1
if 1 in x:
    s = sum(x)-n
else:
    while j:
        s=0
        for i in range(n):
            if x[i]%2 == 0:
                x[i]/=2
                s+=1
            else:
                x[i] = (x[i]-1)/2
        if s != n-1:break
        if 1 in x:
            s = sum(x)-n
            break
if s %2 != 0:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
j = 1
k=1
while j:
    s=0
    for i in range(n):
        if x[i]%2 == 0:
            x[i]/=2
            s+=1
        else:
            x[i] = (x[i]-1)/2
    if s != n-1:break
if s %2 != 0:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
j = 1
k=1
while j:
    s = 0

    for i in range(n):
        if (x[i]//k )%2 == 0:
            s+=1
    if s == n:
        k*=2
    else:
        break
if s %2 != 0:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
j = 1
k=0
while j:
    s = 0

    for i in range(n):
        if (x[i]-k )%2 == 0:
            s+=1
    if s == n:
        k+=1
    else:
        break
if s %2 != 0:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
a = int(input())
x =list(map(int, input().split()))#x or y
x.sort()
c = x[0]
s = 0
for i in range(1,a):
    s+=x[i]//c
    if x[i]%c!=0:
        s+=x[i]%c -1
if c !=1:s+=1
if s% 2 == 0:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
a = int(input())
x =list(map(int, input().split()))#x or y
x.sort()
c = x[0]
s = 0
for i in range(1,a):
    s+=x[i]//c
    s+=x[i]%c
if c !=1:s+=1
if s% 2 == 0:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
import random
def tester(N=0):
	'''
	制約
1≦N≦2000
1≦Ai≦108
'''
	maxno1=2000
	maxno2=1e5
	s=input()
	if s!='':
		return(s)
	
	if N==0:
		return(6)
		return(random.randint(2,maxno1))
	else:
		print('Testing...')
		print('N=',N)
		
		return('1 2 3 4 5 2')
		
		A=[]
		for i in range(N):
			A.extend([random.randint(1,maxno2)])
		r=' '.join(list(map(str,A)))
		
		return(r)

def factorint(n):
	i = 2
	T = []
	while i * i <= n:
		while n % i == 0:
			n //= i
			T.append(i)
		i += 1
	if n > 1:
		T.append(n)
	return(T)

import logging

# create logger
logger = logging.getLogger('simple_example')
logger.setLevel(logging.WARNING)#DEBUG)

# create console handler and set level to debug
ch = logging.StreamHandler()
ch.setLevel(logging.WARNING) #DEBUG)

# create formatter
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')

# add formatter to ch
ch.setFormatter(formatter)

# add ch to logger
logger.addHandler(ch)

import copy
N=int(tester())
A=[int(x) for x in tester(N).split()]
A.sort(reverse=False)
logger.debug('A is %s',str(A))

F=dict()
P=dict()
for i in range(N):
	if A[i]==1:
		F[i]={1}
	else:
		F[i]=set(factorint(A[i]))
	for y in F[i]:
		if y not in P.keys():
			P[y]=set()
		P[y].add(i)

G=dict()
for i in F.keys():
	G[i]=set()
	for y in F[i]:
		G[i]=G[i].union(P[y])
	G[i].remove(i)

Ac=list(range(N))
Gc=copy.deepcopy(G)
Tr=dict()
while len(Ac)>0:
	Tmp=[]
	rt=min(Ac)
	me=rt
	Tmp.extend([me])
	Ac.remove(me)
	while len(Gc[me])>0:
		nxt=min(Gc[me])
		if nxt not in Ac:
			Gc[me].remove(nxt)
			continue
		else:
			me=nxt
			Tmp.extend([me])
			Ac.remove(me)
	Tr[rt]=Tmp
	
OoTr=list(Tr.keys())
OoTr.sort(reverse=True)

AnsIdx=[]
for i in OoTr:
	AnsIdx.extend(Tr[i])
Ans=[A[i] for i in AnsIdx]
print(' '.join(list(map(str,Ans))))

logger.removeHandler(ch)

Submission status: Wrong Answer

Solution code:
import random
def tester(N=0):
	'''制約
1≦N≦105
1≦Ai≦109
'''
	maxno1=1e5
	maxno2=1e9
	s=input()
	if s!='':return(s)
	
	if N==0:
		return(random.randint(2,maxno1))
	else:
		print('Testing...')
		print('N=',N)
		A=[]
		for i in range(N):
			A.extend([random.randint(1,maxno2)])
		return(' '.join(list(map(str,A))))

import copy

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def gcdm(x):
	g=x[0]
	for i in range(1,len(x)):
		if g==1:
			return(g)
		g=gcd(g,x[i])
	return(g)

def playmove(A,i):
	A[i]-=1
	g=gcdm(A)
	A=[x//g for x in A]

def noofevens(A):
	r=0
	for i in A:
		if i%2==0:
			r+=1
	return(r)
			

N=int(tester())
A=[int(x) for x in tester(N).split()]
isFirstmove=True
while True:
	e=noofevens(A)
	if e%2==1:
		if isFirstmove:
			print('First')
		else:
			print('Second')
		break
	elif N-e>1:
		if isFirstmove:
			print('Second')
		else:
			print('First')
		break
	else:	
		for i in range(N):
			if A[i]%2==1:
				break
		if A[i]==1:
			if isFirstmove:
				print('Second')
			else:
				print('First')
			break
	
		playmove(A,i)
		isFirstmove=(isFirstmove!=True)

Submission status: Wrong Answer

Solution code:
import random
def tester(N=0):
	'''制約
1≦N≦105
1≦Ai≦109
'''
	maxno1=1e5
	maxno2=1e9
	s=input()
	if s!='':return(s)
	
	if N==0:
		return(random.randint(2,maxno1))
	else:
		print('Testing...')
		print('N=',N)
		A=[]
		for i in range(N):
			A.extend([random.randint(1,maxno2)])
		return(' '.join(list(map(str,A))))

import copy

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def gcdm(x):
	g=x[0]
	for i in range(1,len(x)):
		if g==1:
			return(g)
		g=gcd(g,x[i])
	return(g)

def playmove(A,i):
	A[i]-=1
	g=gcdm(A)
	A=[x//g for x in A]

def noofevens(A):
	r=0
	for i in A:
		if i%2==0:
			r+=1
	return(r)
			

N=int(tester())
A=[int(x) for x in tester(N).split()]
isFirstmove=True
while True:
	e=noofevens(A)
	if e%2==0:
		if isFirstmove:
			print('Second')
		else:
			print('First')
		break
	elif N-e>1:
		if isFirstmove:
			print('First')
		else:
			print('Second')
		break
	else:	
		for i in range(N):
			if A[i]%2==1:
				break
		if A[i]==1:
			if isFirstmove:
				print('First')
			else:
				print('Second')
			break
	
		playmove(A,i)
		isFirstmove=(isFirstmove!=True)

Submission status: Wrong Answer

Solution code:
import random
def tester(N=0):
	'''制約
1≦N≦105
1≦Ai≦109
'''
	maxno1=1e5
	maxno2=1e9
	s=input()
	if s!='':return(s)
	
	if N==0:
		return(random.randint(2,maxno1))
	else:
		print('Testing...')
		print('N=',N)
		A=[]
		for i in range(N):
			A.extend([random.randint(1,maxno2)])
		return(' '.join(list(map(str,A))))

import copy

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def gcdm(x):
	g=x[0]
	for i in range(1,len(x)):
		if g==1:
			return(g)
		g=gcd(g,x[i])
	return(g)

def playmove(A,i):
	A[i]-=1
	g=gcdm(A)
	A=[x//g for x in A]

def noofevens(A):
	r=0
	for i in A:
		if i%2==0:
			r+=1
	return(r)
			

N=int(tester())
A=[int(x) for x in tester(N).split()]

while True:
	e=noofevens(A)
	if e%2==0:
		print('Second')
		break
	elif N-e>1:
		print('First')
		break
	else:	
		for i in range(N):
			if A[i]%2==1:
				break
		if A[i]==1:
			print('First')
			break
	
		playmove(A,i)

Submission status: Wrong Answer

Solution code:
import random
def tester(N=0):
	'''制約
1≦N≦105
1≦Ai≦109
'''
	maxno1=1e5
	maxno2=1e9
	s=input()
	if s!='':return(s)
	
	if N==0:
		return(random.randint(2,maxno1))
	else:
		print('Testing...')
		print('N=',N)
		A=[]
		for i in range(N):
			A.extend([random.randint(1,maxno2)])
		return(' '.join(list(map(str,A))))

import copy

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def gcdm(x):
	g=x[0]
	for i in range(1,len(x)):
		if g==1:
			return(g)
		g=gcd(g,x[i])
	return(g)

def playmove(A,i):
	A[i]-=1
	g=gcdm(A)
	A=[x//g for x in A]

def noofevens(A):
	r=0
	for i in A:
		if i%2==0:
			r+=1
	return(r)
			

N=int(tester())
A=[int(x) for x in tester(N).split()]

while True:
	e=noofevens(A)
	if e%2==0:
		print('Second')
		break
	elif N-e>1:
		print('First')
		break
	else:	
		for i in A:
			if i%2==1:
				break
		playmove(A,i)

Submission status: Wrong Answer

Solution code:
n = int(input().strip())
a = [int(x) for x in input().strip().split()]
sa = sum(a)

p = n % 2
q = sa % 2
r = sum([x % 2 for x in a])
if p + q == 1:
  winner = 0
elif p + q == 0:
  winner = 1
else:
  winner = 0
  fin = 0
  while fin == 0:
    winner = 1 - winner
    r = sum([x % 2 for x in a])
    if r > 1:
      break
    sa = sum(a)
    b = 0
    c = sa - 1
    while c % 2 == 0:
      b += 1
      c /= 2
    d = 2 ** b
    for i in range(len(a)):
      if a[i] % 2 == 0 and a[i] % d != 0:
        fin = 1
        break
      elif a[i] % 2 == 0:
        a[i] /= d
      elif a[i] % 2 == 1 and (a[i] - 1) % d != 0:
        fin = 1
        break
      else:
        a[i] = (a[i] - 1) / d
      
winner_str = 'Second' if winner else 'First'
print(winner_str)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from fractions import gcd

def readln(ch):
    _res = list(map(int,str(input()).split(ch)))
    return _res

def count(a):
    odd, even = 0,0
    for x in a:
        if x % 2 == 1: odd = odd + 1
        else: even = even + 1
    return odd,even

def deal(n,a):
    if n == 1:
        if a[0] % 2 == 0:
            return 'First'
        else:
            return 'Second'
    odd,even = count(a)
    if even == 0:
        return 'Second'
    if even % 2 == 1:
        return 'First'
    if odd > 1:
        return 'Second'
    if a[0] % 2 == 0:
        res = a[0]
    else:
        res = a[1]
    for i in range(0,n):
        if a[i] % 2 == 1:
            if a[i] == 1: return 'Second'
            a[i] = a[i] - 1
        res = gcd(a[i],res)
    return deal(n,list(map(lambda x: x//res,a)))

n = int(input())
a = readln(' ')
print(deal(n,a))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from fractions import gcd

def readln(ch):
    _res = list(map(int,str(input()).split(ch)))
    return _res

def count(a):
    odd, even = 0,0
    for x in a:
        if x % 2 == 1: odd = odd + 1
        else: even = even + 1
    return odd,even

def deal(n,a):
    if n == 1:
        if a[0] % 2 == 0:
            return 'First'
        else:
            return 'Second'
    odd,even = count(a)
    if even % 2 == 1:
        return 'First'
    if odd > 1:
        return 'Second'
    if a[0] % 2 == 0:
        res = a[0]
    else:
        res = a[1]
    for i in range(0,n):
        if a[i] % 2 == 1:
            if a[i] == 1: return 'Second'
            a[i] = a[i] - 1
        res = gcd(a[i],res)
    return deal(n,list(map(lambda x: x//res,a)))

n = int(input())
a = readln(' ')
print(deal(n,a))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
def solve(a):
    n = len(a)
    s = [(x + 1) & 1 for x in a]
    ss = sum(s)
    if ss >= 2:
        return ss & 1
    if ss == 0:
        for i in xrange(n):
            if a[i] > 1:
                a[i] -= 1
                break
        else:
            return 0
    else:
        for i in xrange(n):
            if s[i] == 1:
                a[i] -= 1
                break
    g = reduce(gcd, a)
    return not solve([x / g for x in a])

def main():
    n = int(raw_input())
    a = map(int, raw_input().split())
    print "First" if solve(a) else "Second"
main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
def main():
    n = int(raw_input())
    a = map(int, raw_input().split())
    s = sum(a)
    if n == 1:
        print "Second" if s == 1 else "First"
        return
    gf = [0] * n
    gf[0] = a[0]
    gl = [0] * n
    gl[n-1] = a[n-1]
    for i in xrange(1, n):
        gf[i] = gcd(gf[i-1], a[i])
    for i in xrange(n - 2, -1, -1):
        gl[i] = gcd(gl[i+1], a[i])
    if ((s - 1) / gl[1] - n) % 2 == 0:
        print "First"
        return
    if ((s - 1) / gf[n-2] - n) % 2 == 0:
        print "First"
        return
    for i in xrange(1, n - 1):
        g = gcd(gf[i-1], gl[i+1])
        if ((s - 1) / g - n) % 2 == 0:
            print "First"
            return
    print "First" if (s - n) % 2 else "Second"
main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
def main():
    n = int(raw_input())
    a = map(int, raw_input().split())
    s = sum(a)
    if n == 1:
        print "Second" if s % 2 else "First"
    gf = [0] * n
    gf[0] = a[0]
    gl = [0] * n
    gl[n-1] = a[n-1]
    for i in xrange(1, n):
        gf[i] = gcd(gf[i-1], a[i])
    for i in xrange(n - 2, -1, -1):
        gl[i] = gcd(gl[i+1], a[i])
    if (s - 1) / gl[1] % 2 == 1:
        print "First"
        return
    if (s - 1) / gf[n-2] % 2 == 1:
        print "First"
        return
    for i in xrange(1, n - 1):
        g = gcd(gf[i-1], gl[i+1])
        if (s - 1) / g % 2 == 1:
            print "First"
            return
    print "Second" if s % 2 else "First"
main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
def main():
    n = int(raw_input())
    a = map(int, raw_input().split())
    s = sum(a)
    if n == 1:
        print "Second" if s % 2 else "First"
    gf = [0] * n
    gf[0] = a[0]
    gl = [0] * n
    gl[n-1] = a[n-1]
    for i in xrange(1, n):
        gf[i] = gcd(gf[i-1], a[i])
    for i in xrange(n - 2, -1, -1):
        gl[i] = gcd(gl[i+1], a[i])
    if (s - 1) / gl[1] % 2 == 1:
        print "First"
        return
    if (s - 1) / gf[n-2] % 2 == 1:
        print "First"
        return
    for i in xrange(1, n - 1):
        g = gcd(gf[i-1], gl[i+1])
        if (s - 1) / g % 2 == 1:
            print "First"
            return
    print "Second"
main()