Problem: 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.

Submission attempts (in order):
import random
def tester(N=0):
	
	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


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)


import random
def tester(N=0):
	
	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)
	return([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
		else:
			A=playmove(A,i)
			isFirstmove=(isFirstmove!=True)
		




	

Verdicts: Wrong Answer

Accepted