Problem:
 Score : 200 points    Problem Statement A sequence a=\{a_1,a_2,a_3,......\} is determined as follows:    The first term s is given as input.    Let f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.    a_i = s when i = 1 , and a_i = f(a_{i-1}) when i > 1 .    Find the minimum integer m that satisfies the following condition:   There exists an integer n such that a_m = a_n (m > n) .       Constraints  1 \leq s \leq 100  All values in input are integers.  It is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000 .         Input Input is given from Standard Input in the following format:  s       Output Print the minimum integer m that satisfies the condition.        Sample Input 1 8      Sample Output 1 5  a=\{8,4,2,1,4,2,1,4,2,1,......\} . As a_5=a_2 , the answer is 5 .       Sample Input 2 7      Sample Output 2 18  a=\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\} .       Sample Input 3 54      Sample Output 3 114

Solution (Python):
s = int(input())

a = []
i = 1
while s not in a:
    a.append(s)
    if s%2 == 1:
        s=3*s+1
    else:
        s=s/2
    i+=1

print(i)

Solution (Python):
N = int(input())

if N == 1 or N == 2:
	print(4)
else:
	m = 0
	while N > 1:
		if N % 2 == 0:
			N = N // 2
		else:
			N = 3 * N + 1
		m += 1
	print(m+2)

Solution (Python):
s = int(input())

def odd(i):
    return int(3*i+1)

def even(i):
    return int(i/2)

lib = {
    s: 0
}


index = 1

while True:
    if s % 2 == 0:
        s = even(s)
    else:
        s = odd(s)
    
    if s not in lib.keys():
        lib[s] = index
        index += 1
    else:
        index+=1
        break


print(index)

Solution (Python):
s = int(input())

lst = [s]

i = 1
while True:
    if s % 2 == 0:
        s = s // 2
    else:
        s = 3 * s + 1
    i += 1
    if s in lst:
        print(i)
        break
    else:
        lst.append(s)

Solution (Python):
def f(x):
    if x % 2 == 0:
        return x // 2
    return 3*x + 1


a = int(input())
s = set()
m = 1
while a not in s:
    s.add(a)
    a = f(a)
    m += 1
print(m)

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

    n = int(input())
    a = [0]*10000
    a[n] = 1
    cnt = 1
    while True:
        if n%2 == 0:
            n //= 2
        else:
            n = 3*n + 1
        cnt += 1
        if a[n] == 1:
            print(cnt)
            break
        else:
            a[n] = 1

if __name__ == '__main__':
    main()

Solution (Python):
s = int(input())
l = []
while not s in l:
    l.append(s)
    if s%2 == 0:
        s /= 2
    else:
        s = 3*s +1
print(len(l)+1)

Solution (Python):
from collections import deque, defaultdict

S = int(input())


def f(x):
    if (x % 2 == 0):
        return x // 2
    else:
        return 3 * x + 1


d = defaultdict(int)
ans = deque()
ans.append(S)

for i in range(1, 10**6):
    ans.append(f(ans[i - 1]))

for i, v in enumerate(ans):
    d[v] += 1
    if (d[v] == 2):
        print(i + 1)
        break

Solution (Python):
s = int(input())

fn = lambda n: n / 2 if n % 2 == 0 else 3 * n +1

results = [s]
result = s
m = 1
while True:
    result = fn(result)
    m += 1
    if result in results: break

    results.append(result)

print(m)

Solution (Python):
s = int(input())
cnt = 0
li = [s]
if s%2==0:
    s = s//2
else:
    s = 3*s+1
while True:
    if s not in li:
        if s%2==0:
            li.append(s)
            s = s//2
        else:
            li.append(s)
            s = 3*s+1
    else:
        break
print(len(li)+1)

Solution (Python):
def Collatz_Problem(n):

    ans = 1
    count = []
    while True:
        if n in count:
            break
        else:
            count.append(n)
        if n%2 == 0:
            n = n/2
        else:
            n = 3*n+1
        ans += 1


    return ans

def main():
    n = int(input())
    print(Collatz_Problem(n))

if __name__ == '__main__':
    main()

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    s = int(input())
    M = 2 * (10**6)
    A = [False] * (M+1)
    A[s] = True
    pre = s
    count = 1
    while True:
        count += 1
        if pre%2==1:
            now = 3*pre + 1
        else:
            now = pre//2
        if A[now] == False:
            A[now] = True
            pre = now
            continue
        else:
            print(count)
            break


if __name__ == '__main__':
    main()

Solution (Python):
s = int(input())
dic = {}
i = 0
while True:
    if s not in dic:
        dic[s] = i
        i += 1
        if s % 2 == 0:
            s = s // 2
        else:
            s = 3 * s + 1
    else:
        print(i + 1)
        break

Solution (Python):
s = int(input())

def func(n):
    if n % 2 == 0:
        return n / 2
    else:
        return 3 * n + 1

a = {}
a[1] = s

i = 2
while True:
    tmp = func(a[i-1])
    if tmp in a.values():
        print(i)
        break
    else:
        a[i] = tmp
        i += 1

Solution (Python):
a=input()
b=int(a)
c=[b]
num=1
while True:
    if b%2==0:
        num+=1
        if c.count(b/2)==0:
            c.append(b/2)
            b=b/2
        else:
            print('%d'%num)
            break
    else:
        num+=1
        if c.count(3*b+1)==0:
            c.append(3*b+1)
            b=3*b+1
        else:
            print('%d'%num)
            break

Solution (Python):
a = int(input())
if a == 1 or a == 2:
    print(4)
else:
    i = 1
    while a != 4:
        if a%2 == 0:
            a //= 2
        else:
            a = 3*a+1
        i += 1
    print(i+3)

Solution (Python):
s = int(input())

def f(x):
    if x%2==0:return x//2
    else:return x*3+1

a = []
i = 1
while True:
    if s in a:
        print(i)
        exit()
    else:
        a.append(s)
        s = f(s)
        i+=1

Solution (Python):

import math
N= int(input())
nums = set()
f = lambda x: x//2 if x % 2 == 0 else 3 * x + 1
nums.add(N)
before = N

for i in range(1,1000005):
    new_num = f(before)

    if new_num in nums:
        print(i + 1)
        exit(0)
    else:
        nums.add(new_num)
        before = new_num

Solution (Python):
s = int(input())

ans = [4, 2, 1]
flag = 0
cnt = 1
while flag == 0:
    if s in ans:
        cnt += 3
        print(cnt)
        flag = 1
    else:
        cnt += 1
        if s % 2 == 0:
            s = s / 2
        else:
            s = 3 * s + 1

Solution (Python):
s=int(input())

a=[s]
ans=0
for i in range(1,1000000):
  if a[i-1]%2==0:
    ax=(int(a[i-1]/2))
  else:
    ax=(int(a[i-1]*3+1))
  a.append(ax)
  if a.count(ax)>=2:
    ans=i+1
    break
print(ans)

Solution (Python):
s = int(input())
if s == 1 or s == 2 or s == 4:
    print(4)
else:
    count = 1
    while s!=4:
        if s % 2 == 0:
            s = s//2
            count += 1
        else:
            s = 3 * s + 1
            count += 1
    print(count+3)

Solution (Python):
s = int(input())
list = [s]
for i in range(1, 1000001):
    if list[i-1]%2==0:
        a = int(list[i-1]/2)
    elif list[i-1]%2==1:
        a = 3*(list[i-1])+1

    if a in list:
        print(i+1)
        break
    else:
        list.append(a)

Solution (Python):
import bisect
s=int(input())
a=[]
ans=1
x=s
def coll(x):
  if x%2==0:
    return x//2
  else:
    return x*3+1

while x not in a:
  bisect.insort_left(a,x)
  ans+=1
  x=coll(x)

print(ans)

Solution (Python):
def fn(num):
    if num%2==0:
        return int(num/2)
    else:
        return int((3*num)+1)
        
s=int(input())
ans=[s]
count=0
ns=s
while True:
    ns=fn(ns)
    if ns in ans:
        ans.append(ns)
        break
    ans.append(ns)
print (len(ans))

Solution (Python):
s = int(input())
l = [s]
ans = True
while ans:
    m = len(l)
    if l[m - 1] % 2 == 0:
        l.append(l[m - 1] // 2)
    else:
        l.append(3 * l[m - 1] + 1)
    for i in range(m):
        if l[i] == l[m]:
            print(m + 1)
            ans = False

Solution (Python):
s = int(input())

tmp = s
a = [s]

while True:
    if tmp % 2 == 0:
        num = (tmp // 2)
        a.append(num)
        tmp = num
    else:
        num = 3 * tmp + 1
        a.append(num)
        tmp = num
    if a.count(tmp) == 2:
        print(len(a))
        break

Solution (Python):
icase=0
if icase==0:
    aset=set()
    s=int(input())
    aset.add(s)
    for m in range(2,1000001):
        if s%2==0:
            s=s//2
        else:
            s=3*s+1
        if s in aset:
            print(m)       
            break
        else:
            aset.add(s)

Solution (Python):
s=int(input())
flg=True
a=[]
a.append(s)
while flg:
    if s%2==0:
        s=s//2
    else:
        s=3*s+1
    if s in a:
        print(len(a)+1)
        exit()
    else:
        a.append(s)

Solution (Python):
s = int(input())
li = []
num = 0
for i in range(1000000):
    if i == 1:
        num = s
    elif num % 2 == 0:
        num //= 2
    else:
        num = 3 * num + 1
    li.append(num)
    if li.count(num) == 2:
        print(i)
        break

Solution (Python):
def main():
    s = int(input())
    an = list()
    a = 0
    for i in range(1000000):
        if i == 0:
            a = s
            an.append(a)
        else:
            if a % 2 == 0:
                a = int(a/2)
                an.append(a) 
            else:
                a = 3*a + 1
                an.append(a)
    for i in range(1000000):
        try:
            m = an.index(an[i], i+1)
            print(m+1)
            break
        except:
            continue
main()

Solution (Python):
def main():
    s = int(input())
    an = list()
    a = 0
    for i in range(1000000):
        if i == 0:
            a = s
            an.append(a)
        else:
            if a % 2 == 0:
                a = int(a/2)
                an.append(a) 
            else:
                a = 3*a + 1
                an.append(a)
    for i in range(1000000):
        a = an[i]
        try:
            m = an.index(a, i+1)
            if m != -1:
                print(m+1)
                break
        except:
            continue
main()

Solution (Python):
s=int(input())
a=[]*1000000
a+=[s]
def F(n):
    if n%2==0:
        return n//2
    else:
        return 3*n+1

for i in range(1,1000000):
    a.append(F(a[i-1]))
    if a[i] in a[:i]:
        ans=i+1
        break 

print(ans)

Solution (Python):
s = int(input())
a = [s]
for i in range(1,100000):
    if a[i-1]%2==0:
        for j in range(len(a)):
            if (a[j]==a[i-1]//2):
                print(i+1)
                exit()
        a.append(a[i-1]//2)
    else:
        for j in range(len(a)):
            if (a[j]==a[i-1]*3+1):
                print(i+1)
                exit()
        a.append(a[i-1]*3+1)
print(a)

Solution (Python):
def main():
    s = int(input())
    a_set = set()
    a = s
    cnt = 1
    while a not in a_set:
        cnt += 1
        a_set.add(a)
        if a % 2 == 0:
            a = a // 2
        else:
            a = a * 3 + 1
    print(cnt)


if __name__ == '__main__':
    main()

Solution (Python):
s = int(input())
li = [s]
num = s

for i in range(1,1000000):
    if num%2 == 0:
        num = num//2
    else:
        num = 3*num+1
    if num in li:
        print(i+1)
        exit(0)
    else:
        li.append(num)

Solution (Python):
n = int(input())

n_li = [n]
while True:
    if n%2==0:
        n = n/2
    elif n%2!=0:
        n = 3*n+1

    if n in n_li:
        break
    else:
        n_li.append(n)
print(len(n_li)+1)

Solution (Python):

s = int(input())
a = []
b = s
m = 1

while b not in a:
    a.append(b)
    b = a[m - 1] // 2 if a[m - 1] % 2 == 0 else 3 * a[m - 1] + 1
    m += 1

print(m)

Solution (Python):
s = int(input())

def f(n):
    if n % 2 == 0:
        return n//2
    else:
        return 3*n+1

a = [s]
i = 0

while len(a) == len(set(a)):
    a.append(f(a[i]))
    i += 1

print(i+1)

Solution (Python):
s = int(input())

nums = {s}
while True:
    if s % 2 == 0:
        s //= 2
    else:
        s = 3 * s + 1
    if s in nums:
        break
    nums.add(s)

print(len(nums)+1)

Solution (Python):
def func(n):
  if n % 2 == 0:
    return n / 2
  else:
    return 3*n + 1

s = int(input())
ans = [s]
while True:
  s = func(s)
  if s in ans:
    ans.append(s)
    print(len(ans))
    break
  ans.append(s)

Solution (Python):

import io

array = []
array.append(int(input()))
    
while array[-1] not in array[:-1]:
    if array[-1] % 2 == 0:
        array.append(array[-1]//2)
    else:
        array.append(3*array[-1] + 1)
print(len(array))

Solution (Python):
s = int(input())
a = [s]

for i in range(0,1000000):
  if a[i]%2 ==0:
    a.append(a[i]/2)
  else:
    a.append(3*a[i] +1)
  if a[i] in a[:i]:
    print(i+1)
    exit()

Solution (Python):
s = int(input())
a = [s]

for i in range(0,1000000):
  if a[i]%2 ==0:
    a.append(a[i]/2)
  else:
    a.append(3*a[i] +1)
  if a[i] in a[:i]:
    print(i+1)
    exit()

Solution (Python):
s=int(input())
a={s}
def f(x):
  if x%2==0:
    return x//2
  else:
    return 3*x+1
ax=f(s)
m=2
while ax not in a:
  a.add(ax)
  ax=f(ax)
  m+=1
print(m)

Solution (Python):
s = int(input())
li = [s]

for i in range(1000000):
    a = 0
    if li[i]%2 == 0:
        a = li[i]//2
    else :
        a = 3*li[i]+1
        
    if a in li:
        print(i+2)
        break
    else:
        li.append(a)

Solution (Python):
s = int(input())
S = set()
cnt = 1
while not s in S:
    S.add(s)
    if s % 2 == 0:
        s //= 2
    else:
        s = 3 * s + 1
    cnt += 1
print(cnt)

Solution (Python):
from collections import defaultdict


def check(num):
    if num in dic:
        print(len(f)+1)
        exit()
    else:
        f.append(num)
        dic[num] = 1


if __name__ == "__main__":
    s = int(input())

    dic = defaultdict(int)
    f = list()
    dic[s] = 1
    f.append(s)

    while True:
        if f[len(f)-1] % 2 == 0:
            tmp = f[len(f)-1] // 2
            check(tmp)
        else:
            tmp = f[len(f)-1] * 3 + 1
            check(tmp)

Solution (Python):
n = int(input())
a = [n]
i = 1
flg = 0
while flg == 0:
  if n % 2 == 0:
    n = n // 2
  else:
    n = 3 * n + 1
  if n in a:
    flg = 1
  else:
    a.append(n)
  i += 1
print(i)

Solution (Python):
S = int(input())

L =[]
for _ in range(10**6):
  L.append(0)

for i in range(10**6):
  L[S-1] += 1
  
  if L[S-1] > 1:
    print(i+1)
    break
  
  if S%2 == 0:
    S = S//2
  else :
    S = S*3 + 1

Solution (Python):
s = int(input())
def f(k):
  if k % 2 ==0:
    return k//2
  else:
    return 3*k+1

ary1 = [None]*1000001
ary1[1] = s

for i in range(2,1000001):
  fn = f(ary1[i-1])
  if fn in ary1:
    print(i)
    break
  else:
    ary1[i] = fn

Solution (Python):
a = [int(input())]
i = 0

def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1

while True:
    A = f(a[i])
    if A in a:
        break
    else:
        a.append(A)
        i += 1
            
print(i+2)

Solution (Python):
s = int(input())
S = set()
cnt = 1
while not s in S:
    S.add(s)
    if s % 2 == 0:
        s //= 2
    else:
        s = 3 * s + 1
    cnt += 1
print(cnt)

Solution (Python):


def collatz(num):
    if num % 2 == 0:
        return (num//2)
    return (3*num + 1)

def main():
    s = int(input())
    a = set()


    while True:
        if s in a:
            print(len(a)+1)
            break
        a.add(s)
        s = collatz(s)


if __name__ == "__main__":
    main()

Solution (Python):
s=int(input())
A=set()
A.add(s)
count=1
while count==len(A):
    if s%2==0:
        A.add(s/2)
        count+=1
        s=s/2
    else:
        A.add(3*s+1)
        count+=1
        s=3*s+1
print(count)

Solution (Python):
s=int(input())
List=[s]
ns=0
bs=s
for i in range(2,10**6+1):
  if (bs%2==0):
    ns=bs//2
  else:
    ns=3*bs+1
  if (List.count(ns)>0):
    print(i)
    
    break
  else:
    List.append(ns)
    bs=ns

Solution (Python):
s = int(input())

def collatz(n):
    if n % 2 == 0:
        return n/2
    else:
        return 3*n+1

a = []
a.append(s)
for i in range(1000001):
    tmp = collatz(a[i])
    if tmp in a:
        print(len(a)+1)
        exit()
    a.append(tmp)

Solution (Python):
s = int(input())
a_list = [s]
i = 0
ans = -1
while (ans==-1):
    if a_list[i]%2==0:
        a_list.append(a_list[i]//2)
    else:
        a_list.append(3*a_list[i]+1)
    i += 1
    for j in range(len(a_list)-1):
        if a_list[i]==a_list[j]:
            ans = i
            break
print(ans+1)

Solution (Python):












S = int(input())

lis = [0,S]

for i in range(2,1000000+1):
    if lis[i-1]%2==0:
        num = lis[i-1]//2
    if not lis[i-1]%2==0:
        num = 3*lis[i-1]+1
    if num in lis:
        ans = i
        break
    lis.append(num)

print(ans)

Solution (Python):
s = int(input())
a = [s]
for i in range(1000000):
    if a[i] % 2 == 0:
        next = a[i]/2
    else:
        next = 3*a[i]+1
    if next in a:
        ans = i+2
        break
    a.append(next)
print(ans)

Solution (Python):
s = int(input())

a = [s]
i = 0

while 1:
    tmp = a[i]
    if tmp % 2 == 0:
        a.append(tmp // 2)
    else:
        a.append(3 * tmp + 1)

    if a[i+1] in a[:i+1]:
        print(i+2)
        break

    i += 1

Solution (Python):
s = int(input())

mem = [s]
cnt = 1
while -1:
  cnt += 1
  s = s // 2 if s % 2 == 0 else 3 * s + 1

  if s in mem:
    break
  
  mem.append(s)

print(cnt)

Solution (Python):
x=set()
s=int(input())
ans=0
while True:
    ans+=1
    if s in x:
        print(ans)
        break
    x.add(s)
    
    if s%2==0:
        s=s//2
    else:
        s=3*s+1

Solution (Python):
def f(n):
    return 3*n + 1 if n%2 else n // 2

l = [int(input())]
c = 2

while True:
    i = f(l[c-2])
    if i in l:
        print(c)
        exit()
    l += [i]
    c += 1

Solution (Python):

def f(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1
ans = []
s = int(input())
for i in range(1000000):
    if ans.count(s)<1:
        ans.append(s)
        s = f(s)
    else:
        print(i+1)
        break

Solution (Python):
s = int(input())
d = {s: 1}
i = 1

while True:
    if s % 2 == 0:
        s //= 2
    else:
        s = 3 * s + 1
    i += 1
    if s in d.keys():
        print(i)
        exit()
    else:
        d[s] = i

Solution (Python):
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
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 LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
mo = 10**9+7

def main():
	s =II()
	dic = defaultdict(lambda : False)
	idx = 1
	while(True):
		if idx!=1:
			if s%2==0:
				s/=2
			else:
				s=3*s+1
		if dic[s]:
			print(idx)
			exit()
		else:
			dic[s]=True
		idx+=1


if __name__ == '__main__':
	main()

Solution (Python):

s= int(input())
a =[]
a.append(s)
ans =1
while True:
    if s%2==0:
        s =s//2
    else:
        s = 3*s+1
    ans +=1
    if s in a:
        break
    a.append(s)

print(ans)

Solution (Python):
s = int(input())
l = [s]
x = 1
y = 0

while y == 0:
  if s%2 == 0:
    s = int(s//2)
  else:
    s = 3*s+1

  if s in l:
    print(x+1)
    y = 1
  else:
    l.append(s)
    x += 1

Solution (Python):
def f(n):
   return n//2 if(n % 2 == 0) else 3*n + 1

def myAnswer(s:int) -> int:
   i = 1
   a = [s]
   hantei = False
   while True:
      tmp = f(a[i - 1])
      if(tmp == 1):
         if(hantei == True):
            a.append(tmp)
            break
         else:
            hantei = True
      a.append(tmp)
      i+=1
   ans = 10**9
   while len(a) != 0:
      n = len(a)
      m = a.pop(-1)
      if(m in a):
         ans = min(ans,n)
   return ans



def modelAnswer():
   tmp=1
def main():
   s = int(input())
   print(myAnswer(s))

if __name__ == '__main__':
   main()

Solution (Python):
s = int(input())
lst = [s]

def gold(x):
    if x % 2 == 0:
        return int(x/2)
    else:
        return int(3*x + 1)

if s == 4 or s == 2 or s == 1:
    print(4)
else:
    while lst[-1] != 1:
        lst.append(gold(int(lst[-1])))
    print(len(lst) + 1 )

Solution (Python):
s = int(input())

def func(x):
    if x % 2 == 0:
        return x//2
    else:
        return 3 * x + 1

a = [s]
for i in range(1000000):
    value = func(a[i])
    if value in a:
        print(i+2)
        break
    a.append(func(a[i]))

Solution (Python):
s = int(input())
A = [s]
ans = 1

while A.count(s) == 1:
    ans += 1
    if s % 2 == 0:
        s = s//2
        A.append(s)
    else:
        s = 3 * s + 1
        A.append(s)
        
print(ans)

Solution (Python):
n=int(input())
a=[]
m=1
while True:
  a.append(n)
  n = n/2*((n+1)%2) + (3*n+1)*(n%2)
  m=m+1
  if n in a:
    break

print(m)

Solution (Python):
s = int(input())
num_set = set([s])

def f(x):
    if x % 2 == 0:
        return x // 2
    else:
        return 3 * x + 1

i = 1
while 1:
    i += 1
    s = f(s)
    if s in num_set:
        print(i)
        break
    num_set.add(s)

Solution (Python):
s = int(input())


def f(n):
    return n // 2 if n % 2 == 0 else 3 * n + 1


i = 1
A = {s}
while True:
    s = f(s)
    i += 1
    if (s in A):
        break
    A.add(s)
print(i)

Solution (Python):
H=[int(input())];i=0
while True:
    B=H[i]
    A=[B//2,3*B+1][B%2>0]
    i+=1
    if A in H:
        break
    else:
        H.append(A)
print(i+1)

Solution (Python):
s = int(input())
check = [0]*(10**4)
check[s] = 1
i = 1
while True:
  i += 1
  if s % 2 == 0:
    s = s//2
  else:
    s = 3*s+1
  if check[s]:
    break
  check[s] = 1
print(i)

Solution (Python):
s =int(input())
sl =[s]
for i in range(10**6):
    if sl[-1]%2 ==0:
        new_sl =sl[-1] //2
    else:
        new_sl =3*sl[-1]+1
    if new_sl in sl:
        print(i+2)
        break

    sl.append(new_sl)

Solution (Python):
s = int(input())
a = [False for i in range(1000000)]
num = 0

while True:
    num += 1
    if a[s] == True:
        print(num)
        break
    
    a[s] = True
    s = s // 2 if s % 2 == 0 else s * 3 + 1

Solution (Python):
s = int(input())
sl = []
count = 1

while s not in sl:
  sl.append(s)
  if s%2 == 0:
    s /= 2
  else:
    s = 3*s+1
  count += 1
print(count)

Solution (Python):
s = int(input())
sl = []
count = 1
s_next = 0
while s not in sl:
  sl.append(s)
  if s%2 == 0:
    s /= 2
  else:
    s = 3*s+1
  count += 1
print(count)

Solution (Python):
s=int(input())
cnt=2
se=set([s])
b=s//2 if s%2==0 else 3*s+1
while b not in se:
    cnt+=1
    se.add(b)
    b=b//2 if b%2==0 else 3*b+1

print(cnt)

Solution (Python):
s = int(input())
count = 1
while True:
    if s in (1,2,4):
        break
    else:
        count += 1
        if s%2 == 0:
            s /= 2
        else:
            s = 3*s+1
print(count+3)

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()

s = int(input())

a = [s, ]

set_a = set()
i = 1
while True:
    c = a.pop()

    if c in set_a:
        print(i)
        break
    
    set_a.add(c)

    if c % 2 == 0:
        n_c = c // 2
    else:
        n_c = 3 * c + 1

    a.append(n_c)

    i += 1

Solution (Python):
s = int(input())
ans = [s]
fr = 0
for i in range(1,10**4):
    if s == 1:
        print(4)
        break
    if s  == 2:
        print(4)
        break
    if fr > 0:
        break
    if ans[i-1] % 2 == 0:
        for j in ans:
            if j == ans[i-1]/2:
                print(i)
                fr += 1
                break
        ans.append(ans[i-1]//2)
    else:
        for j in ans:
            if j == ans[i-1]/2:
                print(i)
                fr += 1
                break
        ans.append(3*ans[i-1]+1)

Solution (Python):
s = int(input())
sl = [s]
count = 2
for i in range(10**6):
  s_next = 0
  if sl[i]%2 == 0:
    s_next = sl[i]//2
    sl.append(s_next)
  else:
    s_next = 3*sl[i]+1
    sl.append(s_next)
  if sl.count(s_next) > 1:
    print(count)
    break
  count += 1

Solution (Python):
s=int(input())
S=[]
x=0
y=0
z=0
m=0
if s==1 or s==2 or s==4:
    while True:
        if s%2==0:
            s=s//2
            x+=1
            if s==4:
                y+=1
            elif s==2:
                z+=1
            elif s==1:
                m+=1
        else:
            s=3*s+1
            x+=1
            if s==4:
                y+=1
            elif s==2:
                z+=1
            elif s==1:
                m+=1
        if y==2 or z==2 or m==2:
            break
    print(x)

else:
    while True:
        if s%2==0:
            s=s//2
            x+=1
            if s==4:
                y+=1
            elif s==2:
                z+=1
            elif s==1:
                m+=1
        else:
            s=3*s+1
            x+=1
            if s==4:
                y+=1
            elif s==2:
                z+=1
            elif s==1:
                m+=1
        if y==2 or z==2 or m==2:
            break
    print(x+1)

Solution (Python):
a_1=int(input())
a=[a_1]
for i in range(1000000):
    if a[-1]%2==0:
        a_next=a[-1]//2
    else:
        a_next=3*a[-1]+1
    if a_next in a:
        print(i+2)
        break

    a.append(a_next)

Solution (Python):
s=int(input())

def f(n):
    if n%2==0:
        return n//2
    return 3*n+1
ans=[s]

while True:
    x=ans.pop()
    ans.append(x)
    check=f(x)
    if check in ans:
        ans.append(check)
        print(len(ans))
        break
    else:
        ans.append(check)

Solution (Python):
def f(x):
    if x%2 == 1:
        return 3*x + 1
    else:
        return x//2

s=int(input())
a=[]
a.append(s)
for i in range(1,100000):
    b = f(a[i-1])
    if b in a:
        print(i+1)
        break
    else:
        a.append(b)

Solution (Python):
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    s = II()
    a = s
    aset = set([a])
    cnt = 1
    while True:
        if a%2==0: a=a//2
        else: a=3*a+1
        if a in aset: break
        else: aset.add(a)
        cnt += 1
    print(cnt+1)

if __name__ == '__main__':
    main()

Solution (Python):
s = int(input())
a = set([s])
p = s
n = 0
cnt = 1
while True:
  if n in a:
    print(cnt)
    exit()
  a.add(n)
  if p&1:
    n = 3*p +1
  else:
    n = p//2
  cnt += 1
  p = n

Solution (Python):
a = int(input())
a_list = [a]
b = 0
for i in range(1000001):
    
    
    if a_list[i] % 2== 0:
        b = int((a_list[i])/2)
        if b in a_list:
            print(i+2)
            break
        else:
            a_list.append(b)
    else:
        b = 3 * a_list[i] + 1
        if b in a_list:
            print(i+2)
            break
        else:
            a_list.append(b)

Solution (Python):
s = int(input())
checked = [s,]
for i in range(10**7):
    if checked[i] % 2 == 0:
        a_i = checked[i] // 2
    else:
        a_i = 3 * checked[i] + 1
    if a_i in checked:
        print(i+2)
        break
    checked.append(a_i)

Solution (Python):
s = int(input())
a = [s]
i = 1
t = 0
while t == 0:
  if s%2 == 0:
    s = s//2
  else:
    s = 3*s + 1
  a.append(s)
  i += 1
  for j in a:
    if a.count(j) == 2:
      t += 1
print(i)

Solution (Python):
def f(n):
    if n%2 == 0:
        return n//2
    return 3*n+1

s = int(input())
ans = 1
used = set()
while True:
    if s in used:
        break

    used.add(s)
    ans += 1
    s = f(s)
print(ans)

Solution (Python):
n = int(input())

counter = [0]*1000000
counter[n-1] += 1

m = 1

while True:
  if n % 2 == 0:
    n = n//2
    counter[n-1] += 1
    if counter[n-1] == 2:
      break
  else:
    n = 3 * n + 1
    counter[n-1] += 1
    if counter[n-1] == 2:
      break
  m += 1
  
print(m+1)

Solution (Python):
s = int(input())

def f(n):
    if n%2==0:
        return n//2
    else:
        return 3*n+1

a = [s]
for i in range(1000000):
    a_nxt = f(a[i])
    if a_nxt in a:
        print(i+2)
        break
    a.append(a_nxt)

Solution (Python):
s = int(input())


def f(v):
    return v // 2 if not v % 2 else 3 * v + 1


V = set([s])
prev = s
for i in range(1, 1000000 + 1):
    a = f(prev)
    if a in V:
        print(i + 1)
        exit()
    else:
        V.add(a)
        prev = a
print(V)

Solution (Python):
l=[int(input())]
i=0
while True:
  a=l[i]//2 if l[i]%2==0 else 3*l[i]+1
  if a in l:
    break
  else:
    l.append(a)
    i+=1
print(len(l)+1)

Solution (Python):
s = int(input())
a = [s]
while True:
  if s % 2 == 0:
    s = s // 2
  else:
    s = s * 3 + 1
  if s in a:
    print(len(a)+ 1)
    break
  a.append(s)

Solution (Python):
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def func(n):
    if n % 2 == 0: return n // 2
    return 3 * n + 1


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    ans = [N]
    cnt = 0
    while True:
        q = func(ans[cnt])
        if q in ans:
            print(len(ans) + 1)
            exit()
        else:
            ans.append(q)
            cnt += 1


if __name__ == '__main__':
    main()

Solution (Python):

s = int(input())
memo = {s:None}
ans = 1000000

for i in range(1, 1000001): 
    if s % 2 == 0:
        s = s / 2
        if s in memo:
            ans = i
            break
        else:
            memo[s] = None
    else:
        s = 3*s + 1
        if s in memo:
            ans = i
            break
        else:
            memo[s] = None
            
print(ans+1)

Solution (Python):
import sys

s = int(input())

res = [s]
c = 0
while True:
    if(res[c]%2 == 0):
        tmp = res[c]//2
    if(res[c]%2 == 1):
        tmp = res[c]*3+1
    res.append(tmp)
    if(len(set(res)) != len(res)):
        print(c+2)
        sys.exit()
    c+=1

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


def func(x):
    global cnt
    cnt += 1
    if x % 2:
        if f[3*x+1]: 
            print(cnt)
            quit()
        else:
            f[3*x+1] = 1
            func(3*x+1)
    else:
        if f[x//2]:
            print(cnt)
            quit()
        else:
            f[x//2] = 1
            func(x//2)


s = I()
f = defaultdict(int)
f[s] = 1
cnt = 1
func(s)

Solution (Python):
S = input()
s = int(S)
lis = [s]

def func(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1
 
while func(s) !=1:
    s = func(s)
    lis.append(s)

if S == "1":
    print(4)
elif S == "2":
    print(4)
elif S == "4":
    print(4)
else:
    print(len(lis)+2)