Non-alternating Deck (easy version)
This is an easy version of the problem. In this version, all cards have the same color.Alice has $$$n$$$ cards, each card is white, and the cards are stacked in a deck. Alice deals the cards to herself and to Bob, dealing at once several cards from the top of the deck in the following order: one card to herself, two cards to Bob, three cards to Bob, four cards to herself, five cards to herself, six cards to Bob, seven cards to Bob, eight cards to herself, and so on. In other words, on the $$$i$$$-th step, Alice deals $$$i$$$ top cards from the deck to one of the players; on the first step, she deals the cards to herself and then alternates the players every two steps. When there aren't enough cards at some step, Alice deals all the remaining cards to the current player, and the process stops.  First Alice's steps in a deck of many cards. How many cards will Alice and Bob have at the end?
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 200$$$). The description of the test cases followsThe only line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^6$$$) — the number of cards.
For each test case print two integers — the number of cards in the end for each player — in this order: cards Alice has, cards Bob has.
import math

def sol(k):
    n = math.floor((-2 + (4 + 32 * k) ** (1 / 2)) / 16)
    A = B = 4 * n ** 2 + n
    k -= 2 * (4 * n ** 2 + n)
    if k < 1 + 4 * n:
        A += k
    else:
        A += 1 + 4 * n
        k -= 1 + 4 * n
        if k < 2 + 4 * n:
            B += k
        else:
            B += 2 + 4 * n
            k -= 2 + 4 * n
            if k < 3 + 4 * n:
                B += k
            else:
                B += 3 + 4 * n
                k -= 3 + 4 * n
                A += k
    print(A, B)
for i in range(int(input())):
    sol(int(input()))
import math
m = 10 ** 9 + 7
for _ in range(int(input())):
    n = int(input())
    x = math.isqrt(2 * n)
    if (x + 1) * x // 2 > n:
        x -= 1
    if (x + 1) * (x + 2) // 2 <= n:
        x += 1
    t = x * (x + 1) // 2
    a = n - t
    r = x % 4
    y = x - r
    t2 = y * (y + 1) // 2 // 2
    if r == 0:
        print(t2 + a, t2)
    elif r == 1:
        print(t2 + y + 1, t2 + a)
    elif r == 2:
        print(t2 + y + 1, t2 + y + 2 + a)
    else:
        print(t2 + y + 1 + a, t2 + y + 2 + y + 3)
def binary_search(arr, low, high, x):
    if high >= low:
        mid = (high + low) // 2
        if arr[mid] <= x and arr[mid + 1] > x:
            return mid
        elif arr[mid] > x:
            return binary_search(arr, low, mid - 1, x)
        else:
            return binary_search(arr, mid + 1, high, x)
    else:
        return -1
mx = 1000000
cl = []
i = 1
s = 0
while s <= mx:
    s += i
    cl.append(s)
    i += 4
n1 = len(cl)
t = int(input())
for i in range(t):
    n = int(input())
    k = binary_search(cl, 0, n1, n)
    alice_turn = k // 2 + 1
    bob_turn = k + 1 - alice_turn
    alice_black = 2 * alice_turn * (alice_turn - 1)
    alice_white = alice_black + alice_turn
    bob_white = 2 * bob_turn * bob_turn
    bob_black = bob_white + bob_turn
    extra = n - cl[k]
    if k % 2 == 1:
        alice_black += extra // 2
        alice_white += extra // 2 + extra % 2
    else:
        bob_white += extra // 2
        bob_black += extra // 2 + extra % 2
    print(str(alice_white + alice_black) + ' ' + str(bob_white + bob_black))