import sys
from collections import deque
input=sys.stdin.readline
n=int(input())
card = deque([i for i in range(1, n+1)])
while(len(card)>1):
card.popleft()
card.append(card.popleft())
print(card.pop())
큐 자료구조를 사용할 수 있는 방법은 3가지로 나는 시간 복잡도가 제일 낮은 deque를 사용하였다.
deque는 양방향에서 데이터를 추가, 제거할 수 있다.
카드를 제거하고 옮기는 방식은 popleft()와 append()를 이용하였고 deque의 길이가 1이 될 때 까지 반복한 후 결과를 출력하였다.