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())
ans = 1

while True:
    if s == 1 or s == 2 or s == 4:
        ans = ans + 3
        break
    else:
        if s % 2 == 0:
            s = s // 2
        else:
            s = s * 3 + 1
        ans = ans + 1

print(ans)

Solution (Python):
def main():
  s = int(input())
  
  
  
  
  
  
  
  ans = 0
  count = 2
  lis = []
  if s == 1 or s == 2:
    print(4)
    exit()
  while s > 1:
    if s % 2 == 0:
      s //= 2
    else:
      s = s*3 + 1
    count += 1
  print(count)

if __name__ == '__main__':
  main()

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


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


pre = s
result = set([s])
for i in range(1000005):
    current = f(pre)
    if current in result:
        print(i+2)
        break
    result.add(current)
    pre = current

Solution (Python):
s=int(input())
k=1
a=[]
while True:
    if k==1:
        a.append(s)
        k+=1
    elif a[-1]%2==0:
        p=a[-1]/2
        a.append(p)
        k+=1
    else:
        p=3*a[-1]+1
        a.append(p)
        k+=1
    if len(set(a))!=len(a):
            print(k-1)
            exit()

Solution (Python):
li = [int(input())]
for i in range(1, 10 ** 6):

    n = li[i - 1]
    if n % 2 == 0:
        fn = n / 2
    else:
        fn = 3 * n + 1
    if fn in li:
        print(i + 1)
        exit()
    li.append(fn)

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

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

A = [s]
ans = 1

while True:
    ans += 1
    num = f(A[-1])
    if num in A:
        print(ans)
        break
    else:
        A.append(num)

Solution (Python):
def main():
    s = int(input())
    ak = s
    k = 1

    history = set([ak])
    while True:
        k += 1
        if ak%2 == 0:
            ak = ak//2
        else:
            ak = ak*3 + 1

        if ak in history:
            print(k)
            break
        else:
            history = history | set([ak])

main()

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

tmp_list = [0]*1000000

for i in range(1000000):
    if i == 0:
        tmp = s
        tmp_list[tmp] = 1

    else:
        
        if tmp % 2 == 0:
            tmp = tmp//2
        else:
            tmp = 3*tmp+1
        
        if tmp_list[tmp] == 0:
            
            
            tmp_list[tmp] = 1

        elif tmp_list[tmp] == 1:
            
            print(i+1)
            break

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

while s not in a:
    a.add(s)
    if s%2 == 1:
        s = s*3 + 1
    else:
        s = s//2

print(len(a) + 1)

Solution (Python):
s = int(input())
l = [s]
a = 0
cnt = 1

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

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())

def fx(s):
    if s % 2 == 1:
        return 3*s + 1
    else:
        return s//2

a = [s]
b0 = a[0]

ans = 1
while fx(b0) not in a:
    a.append(fx(b0))
    b0 = a[-1]
    ans += 1

print(ans+1)

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

Solution (Python):
s = int(input())
l = [s]
i = s
while s:
    if i % 2 == 0:
        l.append(i // 2)
        i //= 2
    else:
        l.append(i * 3 + 1)
        i = i * 3 + 1
    if l.count(i) == 2:
        l2 = [j for j, x in enumerate(l) if x == i]
        print(l2[1] + 1)
        exit()

Solution (Python):
def main():
    n = int(input())
    
    a_list = [n]

    for i in range(1000001):
        if a_list[i] % 2 == 0:
            tmp = a_list[i] // 2
        else:
            tmp = a_list[i] * 3 + 1
        
        if tmp in a_list:
            break
        a_list.append(tmp)

    print(len(a_list)+1)

if __name__ == '__main__':
    main()

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

s = int(input())
a = {s}
n = s
for i in range(2, 1000000):
    n = f(n)
    if n not in a:
        a.add(n)
    else:
        print(i)
        break

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

s = int(input())
a = {s}
n = s
for i, _ in enumerate(range(1000000), 2):
    n = f(n)
    if n not in a:
        a.add(n)
    else:
        print(i)
        break

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

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


s = int(input())
i = 1
k = 0
old = [s]

while 1:
    k = f(s) if i == 1 else f(k)
    if k in old:
        break
    else:
        old.append(k)
        i += 1

print(i+1)

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

def func(n):
    if n%2==0:
        return n//2
    else:
        return 3*n+1
series=[s]
for i in range(2,10**6):
    s=func(s)
    if s in series:
        print(i)
        break
    series.append(s)

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

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

print(count)

Solution (Python):
k = input().split()
a = int(k[0])

def b(n):
    return int(n/2)
def c(n):
    return int((3*n)+1)

Counter = 0

flag = True
IntSet = set()
IntSet.add(a)
Buffer = int(a)
for i in range(1,1000000+1):
    if Buffer%2 == 0:
        Buffer = b(Buffer)
        Counter+=1
    else:
        Buffer = c(Buffer)
        Counter+=1
    if Buffer in IntSet:
        print(Counter+1)
        break
    else:
        IntSet.add(Buffer)

Solution (Python):

import math
import itertools
import statistics



s = int(input())

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

count1 = 0

a = [s]
while count1<2:
    s = calc_f(s)
    a.append(s)
    if s==1:
        count1+=1
 
for i in range(len(a)):
    for j in range(i+1, len(a)):
        if a[i]==a[j]:
            print(j+1)
            exit()

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

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

Solution (Python):
s = int(input())
arr = []
arr.append(s)

def sample(s):
    if s % 2 is 0:
    	  s2 = int(s / 2)
    else:
    	  s2 = int(s * 3 + 1)

    if s2 in arr:
        print(arr.index(s) + 2)
        return
    
    arr.append(s2)
    sample(s2)

sample(s)

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

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

Solution (Python):
s = int(input())
tar = s
used = [s]
for i in range(2,int(1e8)):
    if tar % 2 == 0:
        tar = tar//2
    else:
        tar = tar*3+1
    if tar in used:
        print(i)
        exit()
    else:
        used.append(tar)

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

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

an = 0
list = []

for i in range(1, 1000001):
    if i == 1:
        an = s
        list.append(an)

    elif an % 2 == 0:
        an = an/2
        list.append(an)

    else:
        an = 3 * an + 1
        list.append(an)

    for j in range(len(list)-1):
        if list[j] == an:
            print(i)
            break
        else:
            continue
    else:
        continue
    break

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

ar = []
ar.append(s)
flag = 0
count = 0

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


print(count+1)

Solution (Python):
import sys
INF = 10 ** 10
MOD = 10 ** 9 + 7
from functools import lru_cache
sys.setrecursionlimit(100000000)

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

def main():
    s = int(input())
    a = set()
    a.add(s)
    x = s
    i = 2
    while True:
        y = f(x)
        if y in a:
            break
        a.add(y)
        x = y
        i += 1
    
    print(i)

if __name__ =='__main__':
    main()

Solution (Python):
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

def main():
    s = int(input())
    seen = set()
    i = 1
    while True:
        if s in seen:
            print(i)
            return
        seen.add(s)
        if s % 2 == 0:
            s /= 2
        else:
            s = s * 3 + 1
        i += 1


main()

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

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

num_list = []
count = 0

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

print(count+1)

Solution (Python):
s=int(input())
from collections import Counter
cc=Counter()
cc[s]=1
cnt=1
while True:
    if s%2==0:
        s=s/2
    else:
        s=3*s+1
    cnt+=1
    if cc[s]>0:
        print(cnt)
        import sys
        sys.exit()
    cc[s]+=1

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

num_list = []
count = 0

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

print(count+1)

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    s=INT()
    aset=set()
    aset.add(s)
    ct=1
    while True:
        ct+=1
        if s%2==0:
            s=int(s/2)
        else:
            s=3*s+1
        aset.add(s)
        if len(aset)!=ct:
            break
    print(ct)
        
if __name__ == '__main__':
    do()

Solution (Python):
l = []
l.append(int(input()))

def next(i:int):
    if l[i-1]%2 == 0:
        return l[i-1]//2
    else:
        return (3*l[i-1])+1

i = 0
while True:
    i += 1
    if next(i) in l:
        print (i+1)
        exit ()
    else:
        l.append(next(i))

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

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

a = int(input())

if a==4 or a==2 or a==1:
    print(4)
else:
    count = 0
    i=0
    while(count!=2):
        i+=1
        
        if a==4:
            count+=1
        a = int(f(a))
    print(i)

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

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

Solution (Python):
s = int(input())
ans = 1
while s not in [4, 2, 1]:
    ans += 1
    s = s // 2 if s % 2 == 0 else 3 * s + 1
print(ans + 3)

Solution (Python):
a = int(input())
alist = set()
count = 1
def f(a):
    if a%2==1:
        return 3*a+1
    else:
        return a//2

def check(a,alist):
    if a in alist:
        return False
    else:
        return True
while check(a,alist):
    count += 1
    alist.add(a)
    a = f(a)

print(count)

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

print(len(k)+1)

Solution (Python):
def next(n):
    if n & 1:
        return 3 * n + 1
    else:
        return int(n / 2)

s = int(input())

a = [0] * 1000000
a[0] = s

f = True
i = 1
ans = 0
while f:
    a[i] = next(a[i - 1])
    for j in range(i):
        if a[j] == a[i]:
            ans = i + 1
            f = False
            break
    i += 1

print(ans)

Solution (Python):
s = int(input())
lst = []
lst.append(s)
flag = True
cnt = 1
while flag:
    if lst[-1] % 2 == 0:
        tmp = lst[-1] / 2
        cnt += 1
    elif lst[-1] % 2 != 0:
        tmp = 3 * lst[-1] + 1
        cnt += 1
    if tmp in lst:
        flag = False
    else:
        lst.append(tmp)

print(cnt)

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

Solution (Python):
s = int(input())
a = []
ans = 0
i = 0
while ans == 0:
    if i == 0:
        a.append(s)
        i += 1
    else:
        if a[i - 1] % 2 == 0:
            a.append(a[i - 1] // 2)
        else:
            a.append(a[i - 1] * 3 + 1)
        if len(a) != len(set(a)):
            ans = i + 1
        i += 1
print(ans)

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

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

Solution (Python):
s = int(input())
l = []
l.append(s)

for i in range(10000000):

    if s%2 == 0:
        s //= 2

    else:
        s = s*3+1 

    if s in l:
        print(i+2)
        break

    l.append(s)

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

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

a = s
a_set = set([s])
for i in range(2, 10000):
    a = f(a)
    if a in a_set:
        print(i)
        exit()

    
    a_set.add(a)

Solution (Python):



s = int(input())
min_m = 1
number_queue = []
number_queue.append(s)


while True:
    min_m += 1
    if s%2==0:
        s = s / 2
    else:
        s = 3 * s + 1

    if s in number_queue:
        break

    number_queue.append(s)


print(min_m)

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

Solution (Python):
s = int(input())
a = [s]
count = 0
if s == 4 or s == 2 or s == 1:
    print(4)
else:
    for _ in range(1000):
        if s % 2 == 0:
            s = s // 2
        else:
            s = 3*s+1
        count += 1
        a.append(s)
        if s == 4:
            break
    print(count+4)

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

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

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

a=[s]+[0]*1000000

if s%2==0:
    a[1]=s//2
else:
    a[1]=3*s+1

i=1
while a[i] not in a[:i]:
    if a[i]%2==1:
        a[i+1]=3*a[i]+1
    else:
        a[i+1]=a[i]//2
    i+=1

print(i+1)

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

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

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

a=[s]+[0]*1000000

if s%2==0:
    a[1]=s//2
else:
    a[1]=3*s+1

i=1
while a[i] not in a[:i]:
    if a[i]%2==1:
        a[i+1]=3*a[i]+1
    else:
        a[i+1]=a[i]//2
    i+=1

print(i+1)

Solution (Python):
s = int(input())
a = set()
a.add(s)
def collatz(n):
	if n%2 == 0:
		return n//2
	else:
		return 3*n + 1
c = 1
while True:
	c += 1
	a.add(s)
	s = collatz(s)
	if s in a:
		print (c)
		exit()

Solution (Python):

from collections import defaultdict as dic
s = int(input())

flag = dic(int)
flag[s - 1] = 1
def f(n, i):
    if flag[n - 1] == 1:
        print(i)
        exit()
    else:
        flag[n - 1] = 1
        if n % 2 == 1:
            f(3 * n + 1, i + 1)
        else:
            f(int(n / 2), i + 1)
        

if s % 2 == 1:
    f(3 * s + 1, 2)
else:
    f(int(s / 2), 2)

Solution (Python):

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

Solution (Python):
s = int(input())
st = set([s])
i = 1
while 1:
	if s%2: s = 3*s+1
	else: s //= 2
	if s in st:
		print(i+1)
		break
	st.add(s)
	i += 1

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

u = set()
for i in range(1000000):
    if s in u:
        print(i+1)
        exit()
    u.add(s)
    s = f(s)

Solution (Python):
import bisect

s = int(input())

a = [s]
n = s
for i in range(1000000):
    
    o = n
    n = 3 * o + 1
    if o % 2 == 0:
        n = o // 2
    
    if bisect.bisect_left(a,n) == bisect.bisect_right(a,n):
        bisect.insort(a,n)
        
    else:
        
        print(i+2)
        exit()

Solution (Python):
S=int(input())
count=1
if S==1:
	print(4)
elif S==2:
	print(4)
else:
	while(1):
		if S==4:
			print(count+3)
			exit()
		elif S%2==0:
			count+=1
			S=S//2
		elif S%2==1:
			count+=1
			S=3*S+1

Solution (Python):
s = int(input())
d = set([s])
for i in range(2,1000000):
  if s%2==0:
    s//=2
  else:
    s=3*s+1
  if s in d:
    print(i)
    break
  else:
    d.add(s)

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

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

a = [s]
cnt = 1
ans = -1
while True:
  a.append(f(a[cnt - 1]))
  if a.count(a[cnt]) > 1:
    ans = cnt + 1
    break
  cnt += 1

print(ans)

Solution (Python):
def main():
    s = int(input())
    i = 1
    save_num = [s]
    while True:
        i += 1

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

        if s not in save_num:
            save_num.append(s)
        else:
            ans = i
            break

    print(ans)


if __name__ == "__main__":
    main()

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

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

n = int(input())

m = 2
a = [n, ]

while fun(n) not in a:
    n = fun(n)
    a.append(n)
    m += 1
print(m)

Solution (Python):

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

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

a = [s]
idx = 1
while True:
    idx += 1

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

print(idx)

Solution (Python):
S = int(input())
list = [S]
cnt = 2

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

while True:
	n = solve(S)
	if not (n in list):
		list.append(n)
		S = n
		cnt += 1
	else:
		print(cnt)
		exit()

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

A = [s]
m = 2
while True:
  n = A[-1]
  if n % 2 == 0:
    f = n // 2
  else:
    f = n * 3 + 1
  if f in A:
    break
  else:
    A.append(f)
  m += 1


print(m)

Solution (Python):
def main(s: int):
    t = set([s])
    n = s
    i = 1

    while True:
        i += 1

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

        if n in t:
            print(i)
            return
        else:
            t.add(n)


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

    main(s)

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

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


a = [s]
while(not f(a[-1]) in a):
    a.append(f(a[-1]))
else:
    print(len(a)+1)

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

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

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

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

a = set()
a.add(s)
index = 1
  
while True:
  index += 1
  s = f(s)
  if s not in a:
    a.add(s)
  else:
    break
    
print(index)

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

Solution (Python):
s=int(input())
nums=[]
now=s
cnt=0
nums.append(now)
while cnt<1000100:
        cnt+=1
        if now%2==0:
                now=now//2
        else:
                now=(now*3+1)
        if now in nums:
                break
        nums.append(now)
print(cnt+1)

Solution (Python):
s = int(input())
L = [0]*1000001
a = s
t = 1
while True:
    if L[a]==1:
        break
    else:
        L[a] = 1
    if a%2==0:
        a = a//2
    else:
        a = 3*a+1
    t+=1
print(t)

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

lis = []

flag = True
while flag:
    lis.append(s)
    if s%2==0:
        s /= 2
    else:
        s = s*3 + 1
    s = int(s)

    if s in lis:
        print(len(lis)+1)
        flag = False

Solution (Python):
def f(n):
  if(n % 2 == 0):
    return n // 2
  else:
    return (3 * n) + 1
N = int(input())
 
test = set([N])
before = N
for i in range(1, 10**6 + 1):
  current = f(before)
  if(current in test):
    print(i+1)
    exit()
  before = current
  test.add(before)

Solution (Python):


s = int(input())

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

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

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

a = [0] * (10**6)
a[1] = s
a[0] = s
for i in range(2,10**6):
    x = f(a[i-1])
    if x in a:
        print(i)
        break
    else:
        a[i] = f(a[i-1])

Solution (Python):
def func1(N):
    if N%2==0:
        return N//2
    else:
        return 3*N+1
s = int(input())
a_n = {}
for i in range(1, 1000001):
    if s in a_n:
        break
    else:
        a_n[s] = 1
    s = func1(s)
print(i)

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


s = int(input())
a = [s]

i=1
while i<100000:
    ai = calc_a(a[i-1])
    if ai in a:
        
        print(i+1)
        a.append(ai)
        break
    else:
        a.append(ai)
    i+=1

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

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

    S = int(input())
    collatz_set = {S}
    num = S
    ans = 1
    while True:
        num = collatz(num)
        ans += 1
        if num in collatz_set:
            return ans
        collatz_set.add(num)

print(b_collatz_problem())

Solution (Python):
from collections import defaultdict

s = int(input())

A = defaultdict(int)

n = 1
while True:
  if A[s]:
    print(n)
    exit()
  A[s] = n
  if s % 2:
    s = 3 * s + 1
  else:
    s //= 2
  n += 1

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


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


a = [s]
i = 1
while True:
    ret = f(a[i - 1])
    i += 1
    if ret in a:
        ans = i
        break
    a.append(ret)

print(ans)

Solution (Python):
s=int(input())
if s<3:
    print(4)
    exit()
for i in range(10**7+1):
    if s==4:
        print(i+4)
        exit()
    if s%2:
        s=3*s+1
    else:
        s//=2

Solution (Python):
a = int(input())
als = [0]*(30000)
for i in range(0,10**6+2):
    als[a] = 1
    if a%2 == 0:
        a = a//2
    else:
        a = 3*a+1
    if als[a] == 1:
        print(i+2)
        exit()

Solution (Python):
a = int(input())
als = [0]*(100000)
for i in range(0,10**6+2):
    als[a] = 1
    if a%2 == 0:
        a = a//2
    else:
        a = 3*a+1
    if als[a] == 1:
        print(i+2)
        exit()

Solution (Python):
a = int(input())
als = [0]*(10**6+2)
for i in range(0,10**6+2):
    als[a] = 1
    if a%2 == 0:
        a = a//2
    else:
        a = 3*a+1
    if als[a] == 1:
        print(i+2)
        exit()

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

if s == 4:
    ans = 4
elif s == 2:
    ans = 4
elif s == 1:
    ans = 4
else:
    while s != 4:
        if s % 2 == 0:
            s = s // 2
        else:
            s = 3 * s + 1
        i += 1
    ans = i + 3

print(ans)

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


s = int(input())
sequences = [s]
while True:
    s = f(s)
    if s in sequences:
        print(len(sequences) + 1)
        break
    else:
        sequences.append(s)

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

a = list()
a.append(int(input()))
while True:
    x = F(a[-1])
    if x in a:
        print(len(a)+1)
        exit(0)
    a.append(x)

Solution (Python):
n=int(input())
st=set([n])
for i in range(2,10**7):
    if n%2==0:
        n//=2
    else:
        n=3*n+1
    if n in st:
        print(i)
        break
    st.add(n)

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

def f(n):
  if n%2==0:
    return n//2
  else:
    return 3*n+1
  
r = [s]
n = s
c = 1
while True:
  n = f(n)
  c += 1
  if n in r:
    break
  r.append(n)
print(c)

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

a = [0]*1000000
a[0] = s
i = 1
d = {}
d[s] = 1
while True:
    if a[i-1] % 2 == 0:
        a[i] = a[i-1] // 2
    else:
        a[i] = 3 * a[i-1] + 1

    if d.get(a[i]) is None:
        d[a[i]] = 1
    else:
        print(i+1)
        exit()

    i += 1

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

Solution (Python):
s = int(input())
def f(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n + 1
a = s
dp = [a]
li = [0 for i in range(10**6)]
li[a] +=1
for i in range(1,10**6):
    a = f(dp[i-1])
    dp.append(a)
    li[a]+=1
    if li[a]>=2:
        break
print(len(dp))

Solution (Python):
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


s = int(input())


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


S = {s}

for i in range(10**6):
    s = func(s)
    
    if s in S:
        print(i+2)
        break
    else:
        S.add(s)

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

s = int(input())

cap = ["no"] * 1000000
for i in range(1000000):

    if cap[s] == ["yes"]:
        print(i+1)
        break
    cap[s] = ["yes"]
    s = next(s)

Solution (Python):
s=int(input())
l,a=[s],s
for i in range(2,pow(10,7)+1):
  a=a//2 if a%2==0 else 3*a+1
  l.append(a)
  if l.count(a)==2:
    print(i)
    exit()

Solution (Python):
s=int(input())
x=[0]*1000001
x[s]=1
for i in range(1,1000010):
    if s%2==0:
        s//=2
    else:
        s=3*s+1

    if x[s]==1:
        print(i+1)
        exit()
    else:
        x[s]=1

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

kizon=[]

cnt=1

while (S not in kizon):
    kizon.append(S)
    if S%2==0:
        S=S//2
        
        cnt+=1
    else:
        S=3*S+1
        cnt+=1

print(cnt)

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

kizon=[S]

cnt=1

while True:
    if kizon[-1]%2==0:
        kizon.append(kizon[-1]//2)
        
        cnt+=1
    else:
        kizon.append(3*kizon[-1]+1)
        cnt+=1
    if len(kizon)!=len(set(kizon)):
        print(cnt)
        break

Solution (Python):
S=int(input())
a=[]
while not(str(S) in a):
    a.append(str(S))
    S=(S%2==0)*(S//2)+(S%2==1)*(S*3+1)
print(len(a)+1)

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

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


l =[s]

for i in range(1000):
  if l[i] % 2==0:
    l.append(int(l[i] /2))
  else:
    l.append(int(3* l[i] +1))
    
ans =0

for i in range(len(l)):
  if l[i] in l[:i]:
    ans = i
    break
print(ans + 1)

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

s = int(input())

li = [s]
i = 1
while True :
    a_i = f(li[i - 1])
    if a_i in li :
        print(i + 1)
        exit()
    li.append(a_i)
    i += 1