description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | def case(a):
if max(a) > sum(a) - max(a):
return 0
else:
return not sum(a) % 2
def solve():
for _ in range(int(input())):
input()
print(["T", "HL"][case(list(map(int, input().split())))])
solve() | FUNC_DEF IF FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR LIST STRING STRING FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | import sys
T = int(input())
for i in range(T):
n = input()
arr = [int(x) for x in input().split()]
maks = max(arr)
jumlah = sum(arr) - max(arr)
if maks > jumlah:
print("T")
else:
print("T" if (maks + jumlah) % 2 == 1 else "HL") | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER STRING STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | def checkMax(pilesArr, n):
pilesArr.sort()
pilesArrSum = sum(pilesArr)
if pilesArr[-1] > pilesArrSum - pilesArr[-1]:
return "T"
else:
if pilesArrSum % 2 == 0:
return "HL"
return "T"
testCases = input()
for i in range(int(testCases)):
numOfPiles = int(input())
pilesArr = list(map(int, input().split()))
ans = checkMax(pilesArr, numOfPiles)
print(ans) | FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER BIN_OP VAR VAR NUMBER RETURN STRING IF BIN_OP VAR NUMBER NUMBER RETURN STRING RETURN STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | (T,) = map(int, input().split())
for _ in range(T):
(N,) = map(int, input().split())
X = list(map(int, input().split()))
if N == 1:
print("T")
continue
if N == 2:
if X[0] == X[1]:
print("HL")
else:
print("T")
continue
X.sort()
if X[-1] > sum(X) - X[-1]:
print("T")
continue
if sum(X) % 2 == 0:
print("HL")
else:
print("T") | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
n = int(input())
ct = [(0) for _ in range(100)]
for x in input().split():
ct[int(x) - 1] += 1
j = -1
while True:
aflag, bflag = False, False
for i in range(99, -1, -1):
if ct[i] > 0:
if i != j - 1 or ct[i] != 1:
ct[i] -= 1
if i > 0:
ct[i - 1] += 1
j = i
aflag = True
break
if not aflag:
print("HL")
break
for i in range(99, -1, -1):
if ct[i] > 0:
if i != j - 1 or ct[i] != 1:
ct[i] -= 1
if i > 0:
ct[i - 1] += 1
j = i
bflag = True
break
if not bflag:
print("T")
break | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | def f(list):
sum = 0
max = -1
ii = len(list)
if ii == 1:
return 1
for i in range(ii):
buff = int(list[i])
sum += buff
if buff > max:
max = buff
sum -= max
if max > sum:
return 1
elif max == sum:
return 0
else:
return (sum + max) % 2
n = int(input())
while n:
n -= 1
ip1 = int(input())
ip2 = input().split()
if f(ip2) == 0:
print("HL")
else:
print("T") | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR IF VAR VAR RETURN NUMBER IF VAR VAR RETURN NUMBER RETURN BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
n, lst, sam, man = int(input()), list(map(int, input().split(" "))), 0, 0
for i in lst:
sam, man = sam + i, max(man, i)
print("T" if sam & 1 or n == 1 or man > sam - man else "HL") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING NUMBER NUMBER FOR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR STRING STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for i in range(int(input())):
n = int(input())
a = sorted(list(map(int, input().split())))
add = sum(a[:-1])
if a[-1] > add:
print("T")
else:
print(["HL", "T"][(add + a[-1]) % 2]) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR LIST STRING STRING BIN_OP BIN_OP VAR VAR NUMBER NUMBER |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | T = 1
T = int(input())
while T:
T -= 1
n = int(input())
a = list(map(int, input(" ").split()))
Max = a[0]
Sum = 0
for i in a:
Sum += i
Max = max(Max, i)
if Max > Sum - Max or Sum % 2 == 1:
print("T")
else:
print("HL") | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR BIN_OP VAR VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | t = int(input())
for _ in range(t):
even = 0
odd = 0
n = int(input())
l = list(map(int, input().split()))
l.sort()
if l[-1] > sum(l[:-1]):
print("T")
elif sum(l) % 2 == 0:
print("HL")
else:
print("T") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | t = int(input())
for t_ in range(t):
n = int(input())
a = [int(x) for x in input().split()]
if len(a) == 1:
print("T")
if len(a) == 2:
if a[0] == a[1]:
print("HL")
else:
print("T")
if len(a) >= 3:
if max(a) > sum(a) - max(a):
print("T")
elif sum(a) % 2 == 1:
print("T")
else:
print("HL") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
sum = 0
for i in A:
sum += i
if A[0] > sum - A[0] or sum % 2 != 0:
print("T")
else:
print("HL") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF VAR NUMBER BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | import sys
input = sys.stdin.readline
cases = int(input())
for tt in range(cases):
n = int(input())
a = [int(x) for x in input().split()]
flag = False
s = 0
if n == 1:
print("T")
continue
if n == 2:
if a[0] != a[1]:
print("T")
else:
print("HL")
continue
for i in range(n):
s += a[i]
for i in range(n):
if a[i] > s // 2:
flag = True
if not flag:
if s % 2 == 0:
print("HL")
else:
print("T")
else:
print("T") | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | def solve(testCase, pile, stone):
stone.sort(reverse=True)
player1 = 0
player2 = 0
sum = 0
for i in stone:
sum += int(i)
if 2 * int(stone[0]) > sum:
return "T"
elif sum % 2 == 0:
return "HL"
else:
return "T"
testCase = int(input())
while testCase:
testCase -= 1
pile = int(input())
stone = [int(x) for x in input().split()]
print(solve(testCase, pile, stone)) | FUNC_DEF EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR IF BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER VAR RETURN STRING IF BIN_OP VAR NUMBER NUMBER RETURN STRING RETURN STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | import sys
input = iter(sys.stdin.read().splitlines()).__next__
def solve(N, A):
if N == 1:
return "T"
s = sum(A)
m = max(A)
if m > s - m:
return "T"
return "T" if s % 2 == 1 else "HL"
TC = int(input())
for tc in range(TC):
N = int(input())
A = list(map(int, input().split()))
res = solve(N, A)
print(res) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR RETURN STRING RETURN BIN_OP VAR NUMBER NUMBER STRING STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | t = int(input())
a = []
while t > 0:
t -= 1
n = int(input())
a = list(map(int, input().split()))
mx = 0
sum = 0
for i in range(n):
if a[i] > mx:
mx = a[i]
sum += a[i]
if mx << 1 > sum:
print("T")
else:
print("T" if sum & 1 else "HL") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | import sys
def i():
return sys.stdin.readline()[:-1]
def solve(held, piles, stoneCount):
winning = True
while True:
if piles[-1] > stoneCount // 2:
break
winning = not winning
nextHeld = piles.pop() - 1
if held != 0:
piles.append(held)
held = nextHeld
stoneCount -= 1
piles.sort()
return winning
cases = int(i())
for x in range(cases):
pileCount = int(i())
piles = sorted(list(map(int, i().split())))
totalStones = sum(piles)
if solve(0, piles, totalStones):
print("T")
else:
print("HL") | IMPORT FUNC_DEF RETURN FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE NUMBER IF VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR NUMBER VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | import sys
t = int(sys.stdin.readline().strip())
for _ in range(t):
n = int(sys.stdin.readline().strip())
nums = list(map(int, sys.stdin.readline().strip().split()))
prev = -1
t_win = False
while True:
best = 0
best_ind = None
for i in range(n):
if i == prev:
continue
if nums[i] > best:
best = nums[i]
best_ind = i
if best_ind == None:
print("T" if t_win else "HL")
break
nums[best_ind] -= 1
t_win = not t_win
prev = best_ind | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER ASSIGN VAR NONE FOR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR IF VAR NONE EXPR FUNC_CALL VAR VAR STRING STRING VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | t = int(input())
for o in range(t):
n = int(input())
a = list(map(int, input().strip().split()))
tot = 0
mx = 0
for i in a:
if i > 0:
tot += i
mx = max(mx, i)
if n == 1:
print("T")
elif tot % 2 or mx > tot // 2:
print("T")
else:
print("HL") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | import sys
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")
INF = 10**19
MOD = 10**9 + 7
for _ in range(INT()):
N = INT()
A = LIST()
mx = max(A)
sm = sum(A)
if mx > sm - mx:
print("T")
elif sm % 2 == 1:
print("T")
else:
print("HL") | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF NUMBER RETURN FUNC_CALL VAR BIN_OP VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF NONE RETURN VAR NONE FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF EXPR FUNC_CALL VAR STRING FUNC_DEF EXPR FUNC_CALL VAR STRING FUNC_DEF EXPR FUNC_CALL VAR STRING FUNC_DEF EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for t in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
visit = [[0, 0] for i in range(101)]
for i in range(n):
visit[a[i]][0] += 1
count = 0
i, flag = 0, 0
visit[0][0] = 1
while True:
i, flag = 100, 0
while i >= 0:
if visit[i][0] > 0 and visit[i][1] == 0 and flag == 0:
if i == 0:
flag = 2
break
visit[i - 1][0] += 1
visit[i][0] -= 1
if visit[i - 1][0] == 1:
visit[i - 1][1] = 1
else:
visit[i - 1][1] = 0
flag = 1
count += 1
i -= 1
else:
visit[i][1] = 0
i -= 1
if flag == 2:
break
if count % 2 == 0:
print("HL")
else:
print("T") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER WHILE NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR NUMBER IF VAR VAR NUMBER NUMBER VAR VAR NUMBER NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER VAR NUMBER IF VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | n = int(input())
for i in range(n):
f = int(input())
d = list(map(int, input().split()))[:f]
d.sort()
g = sum(d)
if sum(d) % 2 == 0:
if d[-1] > g - d[-1]:
print("T")
else:
print("HL")
else:
print("T") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | from sys import stdin
input = stdin.readline
for _ in range(int(input())):
n = int(input())
a = [int(x) for x in input().split()]
if n == 1:
print("T")
continue
if n == 2:
if a[0] == a[1]:
print("HL")
else:
print("T")
continue
a.sort()
s = sum(a[:-1])
if a[-1] > s:
print("T")
continue
if a[-1] == s:
print("HL")
continue
s += a[-1]
s %= 2
print("T" if s else "HL") | ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR EXPR FUNC_CALL VAR STRING VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR STRING STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for t in range(int(input())):
n = int(input())
an = list(map(int, input().split()))
winner = 0
bm = 0
cm = -1
while bm != -1:
bm = -1
ma = 0
for i in range(len(an)):
if an[i] > ma and i != cm:
bm = i
ma = an[i]
if bm != -1:
an[bm] -= 1
cm = bm
winner = 1 - winner
if winner == 0:
print("HL")
else:
print("T") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | testCases = int(input())
for i in range(testCases):
numPiles = int(input())
pile = list(map(int, input().split(" ")))
maxNumber = max(pile)
sumOfPile = sum(pile)
if numPiles == 1:
print("T")
elif numPiles == 2:
if pile[0] == pile[1]:
print("HL")
else:
print("T")
elif maxNumber > sumOfPile - maxNumber:
print("T")
elif sumOfPile % 2 == 1:
print("T")
else:
print("HL") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
n = int(input())
a = [int(i) for i in input().split()]
case = 2
s = sum(a)
half = s // 2
for k in a:
if k > half:
case = 1
if case == 2:
if s % 2:
print("T")
else:
print("HL")
else:
print("T") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | def solve(L):
if len(L) == 1:
if L[0] == 0:
return 0
else:
return 1
L.sort()
s = sum(L)
k = L[-1]
if k * 2 > s:
return 1
if s % 2:
return 1
else:
return 0
for i in " " * int(input()):
n = int(input())
print(["HL", "T"][solve(list(map(int, input().split())))]) | FUNC_DEF IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR RETURN NUMBER IF BIN_OP VAR NUMBER RETURN NUMBER RETURN NUMBER FOR VAR BIN_OP STRING FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR LIST STRING STRING FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | import sys
cases = True
def c2(n):
return n * (n - 1) // 2
def get():
return list(map(int, input().split()))
def bits(n: int):
return list(bin(n)).count("1")
def main(test_case=False):
n = int(input()) if test_case else 1
for _ in range(n):
test()
def flush():
sys.stdout.flush()
def parr(arr):
print(*arr, sep=" ")
def gcd(a, b):
while b:
if b % a == 0:
break
tmp = a
a = b % a
b = tmp
return a
def ext_gcd(a: int, b: int):
if b == 0:
return [a, [1, 0]]
res = ext_gcd(b, a % b)
g = res[0]
x1 = res[1][0]
y1 = res[1][1]
x = y1
y = x1 - y1 * (a // b)
return [g, [x, y]]
def test():
n = get()
a = sorted(get())
if 2 * a[-1] > sum(a):
print("T")
else:
print("T" if sum(a) % 2 else "HL")
main(cases) | IMPORT ASSIGN VAR NUMBER FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF VAR RETURN FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR STRING FUNC_DEF NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR VAR STRING FUNC_DEF WHILE VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR RETURN VAR FUNC_DEF VAR VAR IF VAR NUMBER RETURN LIST VAR LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR VAR RETURN LIST VAR LIST VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP NUMBER VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER STRING STRING EXPR FUNC_CALL VAR VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for i in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
if n == 1:
print("T")
else:
a = sorted(a)
a = a[::-1]
t = sum(a)
d = 0
c = 0
m = max(a)
while t > m:
if a[0] > 0:
a[0] -= 1
t -= 1
else:
c = 1
if a[1] > 0:
a[1] -= 1
t -= 1
else:
d = 1
a = sorted(a)
a = a[::-1]
m = a[0]
if m == 0:
print("HL")
else:
print("T") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR IF VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
n = int(input())
a = sorted([int(i) for i in input().split()])
if n == 1:
print("T")
else:
summ = 0
for i in range(n - 1):
summ += a[i]
if a[n - 1] > summ:
print("T")
else:
summ += a[n - 1]
if summ % 2 == 0:
print("HL")
else:
print("T") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING VAR VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | import sys
readline = sys.stdin.readline
T = int(readline())
Ans = [None] * T
for qu in range(T):
N = int(readline())
A = list(map(int, readline().split()))
A.sort()
if N == 1:
Ans[qu] = "T"
elif N == 2:
if A[0] == A[1]:
Ans[qu] = "HL"
else:
Ans[qu] = "T"
elif A[-1] > sum(A[:-1]):
Ans[qu] = "T"
elif sum(A) % 2 == 0:
Ans[qu] = "HL"
else:
Ans[qu] = "T"
print("\n".join(Ans)) | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR VAR STRING IF VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING IF VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR STRING IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | t = int(input())
for _ in range(t):
n = int(input())
arr = [int(x) for x in input().split()]
arr.sort(reverse=True)
maxa = arr[0]
if maxa > sum(arr) - maxa:
print("T")
continue
else:
sum1 = sum(arr)
if sum1 % 2 == 0:
print("HL")
else:
print("T") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
s = sum(arr)
if s % 2 != 0:
print("T")
else:
falg = 0
for i in range(n):
if arr[i] > s // 2:
print("T")
falg = 1
if falg == 0:
print("HL") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | def answer(n, A):
p = 0
last = -1
while True:
maxi = 0
index = -1
for i in range(n):
if A[i] > maxi and i != last:
maxi = A[i]
index = i
if index == -1:
break
else:
A[index] -= 1
last = index
p += 1
if p % 2 == 0:
return "HL"
else:
return "T"
t = int(input())
for i in range(t):
n = int(input())
arr = list(map(int, input().split()))
print(answer(n, arr)) | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN STRING RETURN STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
t = 0
hl = 0
if max(a) > sum(a) - max(a) or sum(a) % 2:
print("T")
else:
print("HL") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
n, lst = int(input()), sorted(map(int, input().split(" ")))
print("T" if sum(lst) & 1 or n == 1 or lst[n - 1] > sum(lst) - lst[n - 1] else "HL") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER STRING STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
n = int(input())
A = list(map(int, input().split()))
A.sort()
M = A[-1]
S = sum(A) - M
if M > S:
print("T")
elif (S + M) % 2:
print("T")
else:
print("HL") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING IF BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | from sys import stdin
class Input:
def __init__(self):
self.next = self.readline()
def readline(self):
return stdin.readline().strip()
def line(self):
try:
return self.next
finally:
self.next = self.readline()
def array(self, sep=" ", cast=int):
return list(map(cast, self.line().split(sep=sep)))
def known_tests(self):
(num_of_cases,) = self.array()
for case in range(num_of_cases):
yield self
def unknown_tests(self):
while self.next:
yield self
class Problem:
def __init__(self, input):
(n,) = input.array()
a = input.array()
s = sum(a)
m = max(a)
if n == 1:
print("T")
elif 2 * m > s:
print("T")
elif s % 2 == 0:
print("HL")
else:
print("T")
for tc in Input().known_tests():
Problem(tc) | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF STRING VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR VAR FUNC_DEF WHILE VAR EXPR VAR CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | l = []
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
m = max(a)
sum = 0
for i in range(n):
sum = sum + a[i]
if sum < 2 * m or sum % 2 == 1:
l.append("T")
else:
l.append("HL")
for i in l:
print(i) | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | import sys
sys.setrecursionlimit(10**5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II():
return int(sys.stdin.readline())
def MI():
return map(int, sys.stdin.readline().split())
def LI():
return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number):
return [LI() for _ in range(rows_number)]
def SI():
return sys.stdin.readline()[:-1]
def win():
if n == 1:
return True
if n == 2:
if aa[0] == aa[1]:
return False
return True
s = sum(aa)
if 2 * max(aa) > s or s % 2:
return True
return False
for _ in range(II()):
n = II()
aa = LI()
if win():
print("T")
else:
print("HL") | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
n = int(input())
l = [*map(int, input().split())]
flag = True
prev = -1
while True:
breakOrNot = True
if prev == -1:
prev = l.index(max(l))
l[prev] -= 1
flag = not flag
breakOrNot = False
elif flag:
ind = l.index(max(l))
if ind != prev and l[ind] > 0:
prev = ind
l[ind] -= 1
flag = not flag
breakOrNot = False
else:
temp = 0
ind = 0
for i in range(n):
if l[i] > temp and i != prev:
temp = l[i]
ind = i
if temp != 0 and l[ind] > 0:
prev = ind
l[prev] -= 1
flag = not flag
breakOrNot = False
else:
ind = l.index(max(l))
if ind != prev and l[ind] > 0:
prev = ind
l[ind] -= 1
flag = not flag
breakOrNot = False
else:
temp = 0
ind = 0
for i in range(n):
if l[i] > temp and i != prev:
temp = l[i]
ind = i
if temp != 0 and l[ind] > 0:
prev = ind
l[prev] -= 1
flag = not flag
breakOrNot = False
if breakOrNot:
break
if not flag:
print("T")
else:
print("HL") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | def win(a, last=-1):
for i, el in enumerate(a):
a2 = a[:]
a2[i] -= 1
if i != last and el > 0 and not win(a2, i):
return True
return False
def solve(a):
s = sum(a)
for i in a:
if i > s - i:
return True
return s % 2 == 1
for t in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
print("T" if solve(a) else "HL") | FUNC_DEF NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR BIN_OP VAR VAR RETURN NUMBER RETURN BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR STRING STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | t = int(input())
answer = []
for test in range(t):
n = int(input())
liste = list(map(int, input().split(" ")))
S = sum(liste)
indicator = int(S / 2)
bool = False
for element in liste:
if element > indicator:
bool = True
break
if bool:
answer.append("T")
elif S % 2 == 0:
answer.append("HL")
else:
answer.append("T")
print("\n".join(answer)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
n = int(input())
a = sorted(list(map(int, input().split())))
print("T" if sum(a[:-1]) < a[-1] else "HTL"[sum(a) % 2 :: 2]) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER STRING STRING BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | def func(li, s):
for i in li:
if i > s // 2:
return print("T")
if s % 2 == 0:
return print("HL")
else:
return print("T")
for _ in range(int(input())):
n = int(input())
ai = list(map(int, input().split()))
summ = sum(ai)
func(ai, summ) | FUNC_DEF FOR VAR VAR IF VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER RETURN FUNC_CALL VAR STRING RETURN FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | import sys
sys.setrecursionlimit(10000)
t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
if n != 1:
while len(a) > 2:
a[0] -= a[1] - a[2] + 1
a[1] = a[2] - 1
a = [i for i in a if i != 0]
a.sort(reverse=True)
if len(a) == 2:
if a[0] != a[1]:
print("T")
else:
print("HL")
else:
print("T")
else:
print("T") | IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | mod = 10**9 + 7
def solve():
n = int(input())
a = list(map(int, input().split()))
f = 2
if max(a) > sum(a) - max(a) or sum(a) % 2 > 0:
f = 1
print("T" if f == 1 else "HL")
t = int(input())
while t > 0:
solve()
t -= 1 | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER STRING STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | t = int(input())
for _ in range(t):
n = int(input())
a = [int(x) for x in input().split()]
if n == 1:
print("T")
else:
total = sum(a)
m = max(a)
if total % 2 == 1 or m > total // 2:
print("T")
else:
print("HL") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | ans = ""
def f(n, arr):
if n == 1:
return "T"
if arr[-1] * 2 > sum(arr):
return "T"
if sum(arr) % 2:
return "T"
return "HL"
for _ in range(int(input())):
n = int(input())
arr = [int(s) for s in input().split()]
arr = sorted(arr)
print(f(n, arr) + "")
print(ans) | ASSIGN VAR STRING FUNC_DEF IF VAR NUMBER RETURN STRING IF BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR RETURN STRING IF BIN_OP FUNC_CALL VAR VAR NUMBER RETURN STRING RETURN STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
n = int(input())
a = [int(i) for i in input().split()]
if n == 1:
print("T")
elif n == 2:
if a[0] == a[1]:
print("HL")
else:
print("T")
elif max(a) > sum(a) - max(a):
print("T")
else:
num = sum(a) - n
if num % 2 == 0 and n % 2 == 0:
print("HL")
elif num % 2 == 0 and n % 2 == 1:
print("T")
elif num % 2 == 1 and n % 2 == 0:
print("T")
elif num % 2 == 1 and n % 2 == 1:
print("HL") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | def main():
t: int = int(input())
for _ in range(t):
n: int = int(input())
T: [int] = list(map(int, input().split(" ")))
mx: int = max(T)
sm: int = sum(T)
if 2 * mx > sm:
print("T")
elif sm & 1 == 1:
print("T")
else:
print("HL")
main() | FUNC_DEF VAR VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR LIST VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | testCases = int(input())
winner = "HL"
for x in range(testCases):
numberOfPiles = int(input())
piles = list(map(int, input().split()))
total = sum(piles)
if total % 2 == 1:
winner = "T"
else:
for y in piles:
if y > total // 2:
winner = "T"
break
print(winner)
winner = "HL" | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | from sys import stdin
for _ in range(int(stdin.readline())):
n = int(stdin.readline())
arr = list(map(int, stdin.readline().split()))
arr.sort()
if n == 1:
print("T")
continue
while len(arr) > 1:
a, b = arr[-1], arr[-2]
arr = arr[:-2]
a -= 1
b -= 1
if a != 0:
arr.append(a)
if b != 0:
arr.append(b)
arr.sort()
if len(arr) > 0:
print("T")
else:
print("HL") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
mx = max(a)
sm = sum(a)
if mx << 1 > sm:
print("T")
else:
print("T" if sm & 1 else "HL") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
count = 0
s = sum(arr)
m1 = max(arr)
while m1 > 0:
i = arr.index(m1)
arr[i] = -1
m2 = m1
m1 = max(arr)
arr[i] = m2 - 1
count += 1
if count % 2 == 0:
print("HL")
else:
print("T") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | T = int(input())
for t in range(T):
N = int(input())
A = list(map(int, input().split()))
pick = -1
mx = 0
curr = "HL"
while 1 == 1:
mx = 0
new_pick = -1
for i in range(N):
if i != pick and A[i] > mx:
mx = A[i]
new_pick = i
if new_pick == -1:
break
if curr == "T":
curr = "HL"
else:
curr = "T"
A[new_pick] -= 1
pick = new_pick
print(curr) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING WHILE NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER IF VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
input()
a = list(map(int, input().split()))
print("T" if max(a) * 2 > sum(a) or sum(a) % 2 == 1 else "HL") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER STRING STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | t = int(input())
for _ in range(t):
n = int(input())
suma = 0
winner = 0
a = list(map(int, input().split()))
suma = sum(a)
for i in range(n):
winner = max(a[i], winner)
if winner > suma / 2 or suma % 2:
print("T")
else:
print("HL") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
n = int(input())
A = sorted(list(map(int, input().split())))
if A[-1] > sum(A[:-1]):
print("T")
elif sum(A) % 2:
print("T")
else:
print("HL") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
if n == 1:
print("T")
elif n == 2:
if arr[0] == arr[1]:
print("HL")
else:
print("T")
elif sum(arr) & 1:
print("T")
else:
arr.sort()
if arr[len(arr) - 1] > sum(arr[: len(arr) - 1]):
print("T")
else:
print("HL") | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | n = int(input())
last = -1
pl = 0
loose = 0
pas = 0
for i in range(n):
num = []
ku = int(input())
num = input()
num = list(num.split(" "))
for k in range(ku):
num[k] = int(num[k])
loose = 0
last = -1
pl = 0
while loose == 0:
pas = 0
ma = 0
for r in range(ku):
if num[r] > ma:
if num[r] != 0:
if r != last:
ma = num[r]
ind = r
pas = 1
num[ind] -= 1
last = ind
pl += 1
if pas == 0:
loose = 1
if pl % 2 == 0:
print("T")
else:
print("HL") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR IF VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | from sys import stdin, stdout
def stoned_game(n, a_a):
s = sum(a_a)
for a in a_a:
if a > s // 2:
return "T"
if s % 2 == 0:
return "HL"
else:
return "T"
t = int(stdin.readline())
for _ in range(t):
n = int(stdin.readline())
a_a = list(map(int, stdin.readline().split()))
stdout.write(stoned_game(n, a_a) + "\n") | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR BIN_OP VAR NUMBER RETURN STRING IF BIN_OP VAR NUMBER NUMBER RETURN STRING RETURN STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | def game():
n = int(input())
a = list(map(int, input().split()))
if n == 1:
print("T")
elif n == 2:
if a[0] == a[1]:
print("HL")
else:
print("T")
elif sum(a) % 2 or max(a) * 2 > sum(a):
print("T")
else:
print("HL")
for _ in range(int(input())):
game() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | t = int(input())
ans_arr = []
for i in range(t):
n = int(input())
a_list = list(map(int, input().split()))
max_value = max(a_list)
stone_inPile = sum(a_list)
if max_value * 2 > stone_inPile or stone_inPile & 1:
ans_arr.append("T")
else:
ans_arr.append("HL")
for j in ans_arr:
print(j) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | import sys
mod = 1000000007
eps = 10**-9
def main():
import sys
input = sys.stdin.readline
for _ in range(int(input())):
N = int(input())
A = list(map(int, input().split()))
A.sort()
if sum(A) & 1:
print("T")
elif A[-1] * 2 > sum(A):
print("T")
else:
print("HL")
main() | IMPORT ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
n = int(input())
a = [*map(int, input().split())]
p = max(a)
s = sum(a) - p
if (s + p) % 2 == 1:
print("T")
elif p > s:
print("T")
else:
print("HL") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | t = int(input())
for _ in range(t):
ok = False
n = int(input())
a = [int(s) for s in input().split(" ")]
if max(a) > sum(a) - max(a):
ok = True
print("T")
if not ok:
if sum(a) % 2 == 0:
print("HL")
else:
print("T") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | T = int(input())
for _ in range(T):
N = int(input())
a = [int(x) for x in input().split(" ")]
if max(a) * 2 > sum(a):
print("T")
else:
print("T" if sum(a) % 2 else "HL") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER STRING STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | t = int(input())
while t:
t -= 1
n = int(input())
a = list(map(int, input().split()))
if sum(a) % 2 or max(a) * 2 > sum(a):
print("T")
else:
print("HL") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | t = int(input())
def slv():
n = int(input())
a = list(map(int, input().split()))
sm = sum(a)
mx = max(a)
if mx > sm - mx:
print("T")
return
if sm & 1:
print("T")
else:
print("HL")
return
for i in range(t):
slv() | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR STRING RETURN IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING RETURN FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | import sys
def rl(proc=None):
if proc is not None:
return proc(sys.stdin.readline())
else:
return sys.stdin.readline().rstrip()
def srl(proc=None):
if proc is not None:
return list(map(proc, rl().split()))
else:
return rl().split()
def solve(A):
tot = sum(A)
mx = max(A)
if mx > tot - mx:
return 0
if tot & 1:
return 0
return 1
def main():
t = rl(int)
for _ in range(t):
n = rl(int)
A = srl(int)
print("HL" if solve(A) else "T")
main() | IMPORT FUNC_DEF NONE IF VAR NONE RETURN FUNC_CALL VAR FUNC_CALL VAR RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF NONE IF VAR NONE RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR RETURN NUMBER IF BIN_OP VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR STRING STRING EXPR FUNC_CALL VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
n = int(input())
a = [int(i) for i in input().split()]
if n == 1:
print("T")
else:
maxa = max(a)
suma = sum(a)
pq = suma - maxa
if pq >= maxa:
tmp = suma
else:
foo = max(0, maxa - (pq + 1))
tmp = suma - foo
if tmp & 1:
print("T")
else:
print("HL") | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
n, sum, arr = int(input()), 0, [int(i) for i in input().split()]
for i in range(n):
sum = sum + arr[i]
arr.sort()
if arr[n - 1] * 2 > sum or sum % 2:
print("T")
else:
print("HL") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | def solve():
n = int(input())
arr = sorted([int(x) for x in input().split()], reverse=True)
def first_wins():
print("T")
def second_wins():
print("HL")
sm = sum(arr)
if sm % 2 != 0 or n == 1:
return first_wins()
if arr[0] <= sm - arr[0]:
return second_wins()
return first_wins()
for _ in range(int(input())):
solve() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER FUNC_DEF EXPR FUNC_CALL VAR STRING FUNC_DEF EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER RETURN FUNC_CALL VAR IF VAR NUMBER BIN_OP VAR VAR NUMBER RETURN FUNC_CALL VAR RETURN FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
n = int(input())
stosy = sorted(list(map(int, input().split())))
dlug = len(stosy)
while dlug > 1:
stosy[-2] -= 1
if stosy[-2] == 0:
del stosy[-2]
dlug -= 1
stosy[-1] -= 1
if stosy[-1] == 0:
del stosy[-1]
dlug -= 1
stosy.sort()
if dlug == 1:
print("T")
else:
print("HL") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR NUMBER VAR NUMBER NUMBER IF VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER NUMBER IF VAR NUMBER NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | def solve():
n = int(input())
a = sorted(list(map(int, input().split())))
if n < 2:
print("T")
else:
s = 0
for x in a[0:-1]:
s += x
if a[-1] > s or (s - a[-1]) % 2 == 1:
print("T")
else:
print("HL")
t = int(input())
for _ in range(t):
solve() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR VAR NUMBER NUMBER VAR VAR IF VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
total = int(input())
num_l = list(map(int, input().split()))
num_l.sort()
num_l.reverse()
if total == 1:
print("T")
elif total == 2:
if num_l[0] == num_l[1]:
print("HL")
else:
print("T")
else:
zero = 0
while True:
while num_l[1] >= num_l[2] and num_l[1] != 0:
num_l[0] -= 1
num_l[1] -= 1
if num_l[1] == 0:
zero += 1
for count in range(1, total - 1):
if num_l[count] < num_l[count + 1]:
num_l[count], num_l[count + 1] = num_l[count + 1], num_l[count]
else:
break
if num_l[0] == 0:
zero += 1
for count in range(0, total - 1):
if num_l[count] < num_l[count + 1]:
num_l[count], num_l[count + 1] = num_l[count + 1], num_l[count]
else:
break
if zero == total:
print("HL")
break
elif zero == total - 1:
print("T")
break | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE NUMBER WHILE VAR NUMBER VAR NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER IF VAR NUMBER NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR IF VAR NUMBER NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | for _ in range(int(input())):
n = int(input())
a = [*map(int, input().split())]
s, mx = sum(a), max(a)
print("T" if s % 2 == 1 or mx > s - mx else "HL") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR VAR STRING STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
n = int(input())
(*a,) = map(int, input().split())
idx = -1
c = 0
while 1:
mx = 0
tmp = -1
for i in range(n):
if i != idx and a[i] > mx:
mx = a[i]
tmp = i
if mx == 0:
print(["HL", "T"][c])
break
idx = tmp
a[idx] -= 1
c ^= 1 | ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR LIST STRING STRING VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | def L1():
t = int(input())
ans = []
for j in range(t):
piles = int(input())
n = [int(i) for i in input().split()]
s = int(sum(n) / 2)
for i in range(piles):
if n[i] > s:
ans.append("T")
break
while len(ans) < j + 1:
if sum(n) % 2 == 0:
ans.append("HL")
else:
ans.append("T")
for i in ans:
print(i)
L1() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR STRING WHILE FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | n = int(input())
for i in range(n):
stack = int(input())
arr = input().split(" ")
arr = [int(x) for x in arr]
arr.sort()
if len(arr) == 1:
print("T")
else:
tmp = sum(arr[0:-1])
if tmp < arr[-1]:
print("T")
elif (tmp + arr[-1]) % 2 == 0:
print("HL")
else:
print("T") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$-th pile initially has $a_i$ stones.
T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of $t$ games, determine the winner of each game.
-----Input-----
The first line of the input contains a single integer $t$ $(1 \le t \le 100)$ β the number of games. The description of the games follows. Each description contains two lines:
The first line contains a single integer $n$ $(1 \le n \le 100)$ β the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$.
-----Output-----
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
-----Example-----
Input
2
1
2
2
1 1
Output
T
HL
-----Note-----
In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner. | def stoned(arr):
s = sum(arr)
if max(arr) > s // 2:
return "T"
if s % 2 == 0:
return "HL"
else:
return "T"
for i in range(int(input())):
a = input()
lst = list(map(int, input().strip().split()))
print(stoned(lst)) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN STRING IF BIN_OP VAR NUMBER NUMBER RETURN STRING RETURN STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:
for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$.
The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.
If such array doesn't exist, determine this.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$)Β β the length of the array $a$.
The second line contains $n$ integers $a_1$, $a_2$, $\ldots$, $a_n$ ($0 \le a_i \le i$)Β β the elements of the array $a$. It's guaranteed that $a_i \le a_{i+1}$ for $1\le i < n$.
-----Output-----
If there's no such array, print a single line containing $-1$.
Otherwise, print a single line containing $n$ integers $b_1$, $b_2$, $\ldots$, $b_n$ ($0 \le b_i \le 10^6$)
If there are multiple answers, print any.
-----Examples-----
Input
3
1 2 3
Output
0 1 2
Input
4
0 0 0 2
Output
1 3 4 0
Input
3
1 1 3
Output
0 2 1
-----Note-----
In the second test case, other answers like $[1,1,1,0]$, for example, are valid. | import sys
input = sys.stdin.buffer.readline
def prog():
n = int(input())
array = list(map(int, input().split()))
output = [-1] * n
to_place = []
prev = -1
for i in range(n):
curr = array[i]
if curr != prev:
output[i] = prev
to_place.extend(list(range(prev + 1, curr))[::-1])
prev = curr
idx = 0
for i in range(n):
if output[i] == -1:
if idx >= len(to_place):
output[i] = 10**6
else:
output[i] = to_place[idx]
idx += 1
sys.stdout.write(" ".join(map(str, output)) + "\n")
prog() | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL STRING FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR |
Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:
for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$.
The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.
If such array doesn't exist, determine this.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$)Β β the length of the array $a$.
The second line contains $n$ integers $a_1$, $a_2$, $\ldots$, $a_n$ ($0 \le a_i \le i$)Β β the elements of the array $a$. It's guaranteed that $a_i \le a_{i+1}$ for $1\le i < n$.
-----Output-----
If there's no such array, print a single line containing $-1$.
Otherwise, print a single line containing $n$ integers $b_1$, $b_2$, $\ldots$, $b_n$ ($0 \le b_i \le 10^6$)
If there are multiple answers, print any.
-----Examples-----
Input
3
1 2 3
Output
0 1 2
Input
4
0 0 0 2
Output
1 3 4 0
Input
3
1 1 3
Output
0 2 1
-----Note-----
In the second test case, other answers like $[1,1,1,0]$, for example, are valid. | n = int(input())
l = list(map(int, input().split()))
if max(l) > n:
print(-1)
else:
a = []
ans = []
for i in range(n + 1):
a.append(-1)
ans.append(-1)
for i in range(n):
a[l[i]] = i + 1
for i in range(n + 1):
if a[i] != -1:
ans[a[i]] = i
print()
j = 0
for i in range(n + 1):
if ans[i] != -1:
continue
while a[j] != -1:
j += 1
ans[i] = j
j += 1
for i in range(n):
print(ans[i], end=" ") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING |
Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:
for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$.
The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.
If such array doesn't exist, determine this.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$)Β β the length of the array $a$.
The second line contains $n$ integers $a_1$, $a_2$, $\ldots$, $a_n$ ($0 \le a_i \le i$)Β β the elements of the array $a$. It's guaranteed that $a_i \le a_{i+1}$ for $1\le i < n$.
-----Output-----
If there's no such array, print a single line containing $-1$.
Otherwise, print a single line containing $n$ integers $b_1$, $b_2$, $\ldots$, $b_n$ ($0 \le b_i \le 10^6$)
If there are multiple answers, print any.
-----Examples-----
Input
3
1 2 3
Output
0 1 2
Input
4
0 0 0 2
Output
1 3 4 0
Input
3
1 1 3
Output
0 2 1
-----Note-----
In the second test case, other answers like $[1,1,1,0]$, for example, are valid. | def read_ints():
return list(map(int, input().split()))
(n,) = read_ints()
a = read_ints()
b = [-1] * n
used = set(a)
current = 0
j = 1
for i in range(n):
if a[i] != current:
b[i] = current
current = a[i]
if current > i + 1:
print(-1)
break
else:
while j in used:
j += 1
b[i] = j
j += 1
else:
print(*b) | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:
for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$.
The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.
If such array doesn't exist, determine this.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$)Β β the length of the array $a$.
The second line contains $n$ integers $a_1$, $a_2$, $\ldots$, $a_n$ ($0 \le a_i \le i$)Β β the elements of the array $a$. It's guaranteed that $a_i \le a_{i+1}$ for $1\le i < n$.
-----Output-----
If there's no such array, print a single line containing $-1$.
Otherwise, print a single line containing $n$ integers $b_1$, $b_2$, $\ldots$, $b_n$ ($0 \le b_i \le 10^6$)
If there are multiple answers, print any.
-----Examples-----
Input
3
1 2 3
Output
0 1 2
Input
4
0 0 0 2
Output
1 3 4 0
Input
3
1 1 3
Output
0 2 1
-----Note-----
In the second test case, other answers like $[1,1,1,0]$, for example, are valid. | n = int(input())
a = list(map(int, input().split()))
b = set(a)
k, t = 0, 0
not_in_set = []
for j in range(1, n + 1):
if j not in b:
not_in_set.append(j)
for i in range(n):
if a[i] > i + 1:
print(-1)
break
elif a[i] != k:
print(k, end=" ")
k = a[i]
else:
print(not_in_set[t], end=" ")
t += 1 | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING VAR NUMBER |
Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:
for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$.
The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.
If such array doesn't exist, determine this.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$)Β β the length of the array $a$.
The second line contains $n$ integers $a_1$, $a_2$, $\ldots$, $a_n$ ($0 \le a_i \le i$)Β β the elements of the array $a$. It's guaranteed that $a_i \le a_{i+1}$ for $1\le i < n$.
-----Output-----
If there's no such array, print a single line containing $-1$.
Otherwise, print a single line containing $n$ integers $b_1$, $b_2$, $\ldots$, $b_n$ ($0 \le b_i \le 10^6$)
If there are multiple answers, print any.
-----Examples-----
Input
3
1 2 3
Output
0 1 2
Input
4
0 0 0 2
Output
1 3 4 0
Input
3
1 1 3
Output
0 2 1
-----Note-----
In the second test case, other answers like $[1,1,1,0]$, for example, are valid. | def f(a):
st = set(a)
now = 1
p = 0
ans = []
for i in a:
if i != p:
ans.append(p)
p = i
else:
while now in st:
now += 1
ans.append(now)
now += 1
return ans
a = input()
lst = list(map(int, input().strip().split()))
print(*f(lst)) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR WHILE VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:
for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$.
The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.
If such array doesn't exist, determine this.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$)Β β the length of the array $a$.
The second line contains $n$ integers $a_1$, $a_2$, $\ldots$, $a_n$ ($0 \le a_i \le i$)Β β the elements of the array $a$. It's guaranteed that $a_i \le a_{i+1}$ for $1\le i < n$.
-----Output-----
If there's no such array, print a single line containing $-1$.
Otherwise, print a single line containing $n$ integers $b_1$, $b_2$, $\ldots$, $b_n$ ($0 \le b_i \le 10^6$)
If there are multiple answers, print any.
-----Examples-----
Input
3
1 2 3
Output
0 1 2
Input
4
0 0 0 2
Output
1 3 4 0
Input
3
1 1 3
Output
0 2 1
-----Note-----
In the second test case, other answers like $[1,1,1,0]$, for example, are valid. | n = int(input())
s = list(map(int, input().split()))
stack = list()
for i in range(n, s[-1], -1):
stack.append(i)
for i in range(len(s) - 1, 0, -1):
if s[i] == s[i - 1]:
continue
else:
for j in range(s[i] - 1, s[i - 1], -1):
stack.append(j)
fin_list = list()
if s[0] == 1:
stack.append(0)
for i in range(len(s) - 1):
if s[i] != s[i + 1]:
curr_val = stack.pop(-1)
fin_list.append(curr_val)
stack.append(s[i])
else:
curr_val = stack.pop(-1)
fin_list.append(curr_val)
curr_val = stack.pop(-1)
fin_list.append(curr_val)
print(*fin_list) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:
for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$.
The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.
If such array doesn't exist, determine this.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$)Β β the length of the array $a$.
The second line contains $n$ integers $a_1$, $a_2$, $\ldots$, $a_n$ ($0 \le a_i \le i$)Β β the elements of the array $a$. It's guaranteed that $a_i \le a_{i+1}$ for $1\le i < n$.
-----Output-----
If there's no such array, print a single line containing $-1$.
Otherwise, print a single line containing $n$ integers $b_1$, $b_2$, $\ldots$, $b_n$ ($0 \le b_i \le 10^6$)
If there are multiple answers, print any.
-----Examples-----
Input
3
1 2 3
Output
0 1 2
Input
4
0 0 0 2
Output
1 3 4 0
Input
3
1 1 3
Output
0 2 1
-----Note-----
In the second test case, other answers like $[1,1,1,0]$, for example, are valid. | n = int(input())
A = [int(x) for x in input().split()]
rs = set(A)
mx = -1
p = -1
ans = []
for a in A:
if p >= 0 and p != a:
ans.append(p)
if p == mx + 1:
mx += 1
else:
mx += 1
while mx in rs:
mx += 1
ans.append(mx)
if mx + 1 < a:
print(-1)
break
p = a
print(*ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER WHILE VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:
for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$.
The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.
If such array doesn't exist, determine this.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$)Β β the length of the array $a$.
The second line contains $n$ integers $a_1$, $a_2$, $\ldots$, $a_n$ ($0 \le a_i \le i$)Β β the elements of the array $a$. It's guaranteed that $a_i \le a_{i+1}$ for $1\le i < n$.
-----Output-----
If there's no such array, print a single line containing $-1$.
Otherwise, print a single line containing $n$ integers $b_1$, $b_2$, $\ldots$, $b_n$ ($0 \le b_i \le 10^6$)
If there are multiple answers, print any.
-----Examples-----
Input
3
1 2 3
Output
0 1 2
Input
4
0 0 0 2
Output
1 3 4 0
Input
3
1 1 3
Output
0 2 1
-----Note-----
In the second test case, other answers like $[1,1,1,0]$, for example, are valid. | import sys
N = int(input())
a = [int(x) for x in input().split(" ")]
b = [(0) for _ in range(N)]
st = []
for i, x in enumerate(a):
dif = a[i] - a[i - 1] if i != 0 else a[i]
if dif:
if len(st) + 1 < dif:
print(-1)
sys.exit(0)
else:
b[i] = a[i - 1] if i != 0 else 0
for j in range(dif - 1):
b[st.pop()] = a[i - 1] + j + 1
else:
st.append(i)
for x in st:
b[x] = a[-1] + 1
print(" ".join(map(str, b))) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR IF VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR |
Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:
for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$.
The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.
If such array doesn't exist, determine this.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$)Β β the length of the array $a$.
The second line contains $n$ integers $a_1$, $a_2$, $\ldots$, $a_n$ ($0 \le a_i \le i$)Β β the elements of the array $a$. It's guaranteed that $a_i \le a_{i+1}$ for $1\le i < n$.
-----Output-----
If there's no such array, print a single line containing $-1$.
Otherwise, print a single line containing $n$ integers $b_1$, $b_2$, $\ldots$, $b_n$ ($0 \le b_i \le 10^6$)
If there are multiple answers, print any.
-----Examples-----
Input
3
1 2 3
Output
0 1 2
Input
4
0 0 0 2
Output
1 3 4 0
Input
3
1 1 3
Output
0 2 1
-----Note-----
In the second test case, other answers like $[1,1,1,0]$, for example, are valid. | n = int(input())
arr = list(map(int, input().split(" ")))
_max = max(arr)
count = dict()
seq = []
for i in range(n):
if arr[i] not in count:
count[arr[i]] = 1
else:
count[arr[i]] = count[arr[i]] + 1
if arr[0] > 1:
print(-1)
else:
error = 0
if arr[0] == 0:
next_zero = 1
while next_zero in count and count[next_zero] > 0:
next_zero += 1
seq.append(next_zero)
count[next_zero] = 1
while next_zero in count and count[next_zero] > 0:
next_zero += 1
if arr[0] == 1:
seq.append(0)
count[0] = 1
next_zero = 1
for i in range(1, n):
if arr[i] > i + 1:
error = 1
break
else:
count[arr[i - 1]] = count[arr[i - 1]] - 1
if count[arr[i - 1]] == 0:
seq.append(arr[i - 1])
count[arr[i - 1]] = 1
else:
while next_zero in count and count[next_zero] > 0:
next_zero += 1
seq.append(next_zero)
if next_zero <= _max:
count[next_zero] = 1
else:
count[next_zero] = 0
if error == 1:
print(-1)
else:
print(*seq) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR VAR VAR NUMBER IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER WHILE VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER WHILE VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR |
Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:
for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$.
The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.
If such array doesn't exist, determine this.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$)Β β the length of the array $a$.
The second line contains $n$ integers $a_1$, $a_2$, $\ldots$, $a_n$ ($0 \le a_i \le i$)Β β the elements of the array $a$. It's guaranteed that $a_i \le a_{i+1}$ for $1\le i < n$.
-----Output-----
If there's no such array, print a single line containing $-1$.
Otherwise, print a single line containing $n$ integers $b_1$, $b_2$, $\ldots$, $b_n$ ($0 \le b_i \le 10^6$)
If there are multiple answers, print any.
-----Examples-----
Input
3
1 2 3
Output
0 1 2
Input
4
0 0 0 2
Output
1 3 4 0
Input
3
1 1 3
Output
0 2 1
-----Note-----
In the second test case, other answers like $[1,1,1,0]$, for example, are valid. | import sys
input = sys.stdin.readline
n = int(input())
a = [0] + [int(item) for item in input().split()]
ans = [-1] * n
used = set()
for i, (a1, a2) in enumerate(zip(a, a[1:])):
if a1 < a2:
ans[i] = a1
used.add(a1)
val = a[-1] - 1
max_val = max(a) + 1
to_use = []
for i in range(n - 1, -1, -1):
if ans[i] != -1:
continue
while val in used:
val -= 1
if val >= 0:
to_use.append(val)
used.add(val)
to_use.sort()
itr = 0
for i, item in enumerate(ans):
if item == -1:
if itr < len(to_use):
ans[i] = to_use[itr]
itr += 1
else:
ans[i] = max_val
while val in used:
val -= 1
print(" ".join([str(item) for item in ans])) | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR NUMBER WHILE VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR |
Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:
for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$.
The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.
If such array doesn't exist, determine this.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$)Β β the length of the array $a$.
The second line contains $n$ integers $a_1$, $a_2$, $\ldots$, $a_n$ ($0 \le a_i \le i$)Β β the elements of the array $a$. It's guaranteed that $a_i \le a_{i+1}$ for $1\le i < n$.
-----Output-----
If there's no such array, print a single line containing $-1$.
Otherwise, print a single line containing $n$ integers $b_1$, $b_2$, $\ldots$, $b_n$ ($0 \le b_i \le 10^6$)
If there are multiple answers, print any.
-----Examples-----
Input
3
1 2 3
Output
0 1 2
Input
4
0 0 0 2
Output
1 3 4 0
Input
3
1 1 3
Output
0 2 1
-----Note-----
In the second test case, other answers like $[1,1,1,0]$, for example, are valid. | import sys
input = sys.stdin.buffer.readline
def iinp() -> int:
return int(input())
def linp() -> list:
return [int(p) for p in input().split()]
def sinp():
return input().decode("unicode-escape")[0:-2]
n = iinp()
a = linp()
s = set(a)
x = 0
y = 1
for i in a:
if i == x:
while y in s:
y += 1
print(y, end=" ")
y += 1
else:
print(x, end=" ")
x = i | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR STRING NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR WHILE VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR STRING ASSIGN VAR VAR |
Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:
for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$.
The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.
If such array doesn't exist, determine this.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$)Β β the length of the array $a$.
The second line contains $n$ integers $a_1$, $a_2$, $\ldots$, $a_n$ ($0 \le a_i \le i$)Β β the elements of the array $a$. It's guaranteed that $a_i \le a_{i+1}$ for $1\le i < n$.
-----Output-----
If there's no such array, print a single line containing $-1$.
Otherwise, print a single line containing $n$ integers $b_1$, $b_2$, $\ldots$, $b_n$ ($0 \le b_i \le 10^6$)
If there are multiple answers, print any.
-----Examples-----
Input
3
1 2 3
Output
0 1 2
Input
4
0 0 0 2
Output
1 3 4 0
Input
3
1 1 3
Output
0 2 1
-----Note-----
In the second test case, other answers like $[1,1,1,0]$, for example, are valid. | n = int(input())
a = list(map(int, input().split()))
def ehab(n, a):
set_a = set(a)
b = []
ans = []
for i in range(n + 1):
if i not in set_a:
b.append(i)
index_b = 0
ans.append(b[0])
index_b += 1
for i in range(1, n):
if a[i] != a[i - 1]:
ans.append(a[i - 1])
else:
ans.append(b[index_b])
index_b += 1
return ans
print(" ".join(map(str, ehab(n, a)))) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR |
Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:
for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$.
The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.
If such array doesn't exist, determine this.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$)Β β the length of the array $a$.
The second line contains $n$ integers $a_1$, $a_2$, $\ldots$, $a_n$ ($0 \le a_i \le i$)Β β the elements of the array $a$. It's guaranteed that $a_i \le a_{i+1}$ for $1\le i < n$.
-----Output-----
If there's no such array, print a single line containing $-1$.
Otherwise, print a single line containing $n$ integers $b_1$, $b_2$, $\ldots$, $b_n$ ($0 \le b_i \le 10^6$)
If there are multiple answers, print any.
-----Examples-----
Input
3
1 2 3
Output
0 1 2
Input
4
0 0 0 2
Output
1 3 4 0
Input
3
1 1 3
Output
0 2 1
-----Note-----
In the second test case, other answers like $[1,1,1,0]$, for example, are valid. | import sys
sys.setrecursionlimit(10**6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II():
return int(sys.stdin.readline())
def MI():
return map(int, sys.stdin.readline().split())
def LI():
return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number):
return [LI() for _ in range(rows_number)]
def SI():
return sys.stdin.readline()[:-1]
def main():
mx = 10**6
use = [False] * mx
for i, a in enumerate(aa[1:], 1):
if a > i:
return [-1]
use[a] = True
bb = []
j = 0
for i in range(1, n + 1):
if aa[i] == aa[i - 1]:
while use[j]:
j += 1
use[j] = True
bb.append(j)
else:
bb.append(aa[i - 1])
use[aa[i - 1]] = True
return bb
n = II()
aa = [0] + LI()
print(*main()) | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR RETURN LIST NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR |
Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:
for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$.
The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.
If such array doesn't exist, determine this.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$)Β β the length of the array $a$.
The second line contains $n$ integers $a_1$, $a_2$, $\ldots$, $a_n$ ($0 \le a_i \le i$)Β β the elements of the array $a$. It's guaranteed that $a_i \le a_{i+1}$ for $1\le i < n$.
-----Output-----
If there's no such array, print a single line containing $-1$.
Otherwise, print a single line containing $n$ integers $b_1$, $b_2$, $\ldots$, $b_n$ ($0 \le b_i \le 10^6$)
If there are multiple answers, print any.
-----Examples-----
Input
3
1 2 3
Output
0 1 2
Input
4
0 0 0 2
Output
1 3 4 0
Input
3
1 1 3
Output
0 2 1
-----Note-----
In the second test case, other answers like $[1,1,1,0]$, for example, are valid. | def main():
N = int(input())
(*A,) = map(int, input().split())
for i, a in enumerate(A):
if i + 1 < a:
print(-1)
return
else:
Us = set(range(N + 1)) - set(A)
U = sorted(Us)
lU = len(U)
ui = 0
ans = []
pre = A[0]
for i, a in enumerate(A):
if pre != a:
ans.append(pre)
else:
if ui >= lU:
print(-1)
return
ans.append(U[ui])
ui += 1
pre = a
print(*ans)
main() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN EXPR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:
for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$.
The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.
If such array doesn't exist, determine this.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$)Β β the length of the array $a$.
The second line contains $n$ integers $a_1$, $a_2$, $\ldots$, $a_n$ ($0 \le a_i \le i$)Β β the elements of the array $a$. It's guaranteed that $a_i \le a_{i+1}$ for $1\le i < n$.
-----Output-----
If there's no such array, print a single line containing $-1$.
Otherwise, print a single line containing $n$ integers $b_1$, $b_2$, $\ldots$, $b_n$ ($0 \le b_i \le 10^6$)
If there are multiple answers, print any.
-----Examples-----
Input
3
1 2 3
Output
0 1 2
Input
4
0 0 0 2
Output
1 3 4 0
Input
3
1 1 3
Output
0 2 1
-----Note-----
In the second test case, other answers like $[1,1,1,0]$, for example, are valid. | n = int(input())
a = [int(j) for j in input().split(" ")]
b = [-1] * n
if a[0] > 1:
print(-1)
else:
if a[0] == 0:
mex = 0
count = 0
else:
mex = 1
count = 1
b[0] = 0
result = 1
for i in range(1, n):
if a[i] != mex:
b[i] = mex
mex += 1
while mex < a[i]:
if b[count] == -1:
b[count] = mex
mex += 1
while b[count] != -1:
count += 1
if count > i:
if mex == a[i]:
break
else:
mex = a[i]
result = 0
break
if result == 0:
break
if result == 1:
for i in range(n):
if b[i] == -1:
b[i] = mex + 1
for i in range(n - 1):
print(b[i], end=" ")
print(b[-1])
else:
print(-1) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER WHILE VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER IF VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER |
Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:
for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$.
The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.
If such array doesn't exist, determine this.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$)Β β the length of the array $a$.
The second line contains $n$ integers $a_1$, $a_2$, $\ldots$, $a_n$ ($0 \le a_i \le i$)Β β the elements of the array $a$. It's guaranteed that $a_i \le a_{i+1}$ for $1\le i < n$.
-----Output-----
If there's no such array, print a single line containing $-1$.
Otherwise, print a single line containing $n$ integers $b_1$, $b_2$, $\ldots$, $b_n$ ($0 \le b_i \le 10^6$)
If there are multiple answers, print any.
-----Examples-----
Input
3
1 2 3
Output
0 1 2
Input
4
0 0 0 2
Output
1 3 4 0
Input
3
1 1 3
Output
0 2 1
-----Note-----
In the second test case, other answers like $[1,1,1,0]$, for example, are valid. | import sys
input = sys.stdin.buffer.readline
n = int(input())
(*a,) = map(int, input().split())
inA = [0] * (n + 5)
for x in a:
inA[x] += 1
keep = [0]
ma = 0
ans = []
for i in range(n):
if keep and not inA[keep[0]]:
ans.append(keep.pop(0))
else:
ma += 1
while inA[ma]:
keep.append(ma)
ma += 1
ans.append(ma)
if ma + 1 < a[i]:
print(-1)
exit()
inA[a[i]] -= 1
print(*ans) | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:
for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$.
The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.
If such array doesn't exist, determine this.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$)Β β the length of the array $a$.
The second line contains $n$ integers $a_1$, $a_2$, $\ldots$, $a_n$ ($0 \le a_i \le i$)Β β the elements of the array $a$. It's guaranteed that $a_i \le a_{i+1}$ for $1\le i < n$.
-----Output-----
If there's no such array, print a single line containing $-1$.
Otherwise, print a single line containing $n$ integers $b_1$, $b_2$, $\ldots$, $b_n$ ($0 \le b_i \le 10^6$)
If there are multiple answers, print any.
-----Examples-----
Input
3
1 2 3
Output
0 1 2
Input
4
0 0 0 2
Output
1 3 4 0
Input
3
1 1 3
Output
0 2 1
-----Note-----
In the second test case, other answers like $[1,1,1,0]$, for example, are valid. | maxn = 10**6 + 5
vis = [(False) for i in range(maxn)]
n = int(input())
arr = list(map(int, input().split()))
for i in arr:
vis[i] = True
ans = []
cnt = 0
for i in range(n):
if i != 0:
if arr[i] == arr[i - 1]:
while vis[cnt]:
cnt += 1
vis[cnt] = True
ans.append(cnt)
else:
ans.append(arr[i - 1])
else:
while vis[cnt]:
cnt += 1
ans.append(cnt)
vis[cnt] = True
print(*ans) | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:
for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$.
The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.
If such array doesn't exist, determine this.
-----Input-----
The first line contains an integer $n$ ($1 \le n \le 10^5$)Β β the length of the array $a$.
The second line contains $n$ integers $a_1$, $a_2$, $\ldots$, $a_n$ ($0 \le a_i \le i$)Β β the elements of the array $a$. It's guaranteed that $a_i \le a_{i+1}$ for $1\le i < n$.
-----Output-----
If there's no such array, print a single line containing $-1$.
Otherwise, print a single line containing $n$ integers $b_1$, $b_2$, $\ldots$, $b_n$ ($0 \le b_i \le 10^6$)
If there are multiple answers, print any.
-----Examples-----
Input
3
1 2 3
Output
0 1 2
Input
4
0 0 0 2
Output
1 3 4 0
Input
3
1 1 3
Output
0 2 1
-----Note-----
In the second test case, other answers like $[1,1,1,0]$, for example, are valid. | n = int(input())
aarr = list(map(int, input().split()))
tovisit = {t: (0) for t in range(aarr[-1] + 1)}
for k in aarr:
tovisit[k] += 1
b = []
transit = []
i = 0
flag = True
for t in aarr:
if t > i + 1:
flag = False
print(-1)
break
if transit:
b.append(transit[0])
del transit[0]
tovisit[t] -= 1
if tovisit[t] == 0 and t < i:
transit.append(t)
continue
while i < aarr[-1] + 1 and tovisit[i]:
i += 1
b.append(i)
i += 1
tovisit[t] -= 1
if tovisit[t] == 0 and t < i:
transit.append(t)
if flag:
print(*b) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR WHILE VAR BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL VAR VAR |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.