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_li = [s]
i = 0
f = 0
while True:
    if a_li[i] % 2 == 0:
        a_li.append(int(a_li[i] / 2))
    else:
        a_li.append(3 * a_li[i] + 1)
    i += 1
    for j in range(i):
        if a_li[i] == a_li[j]:
            f = 1
    if f == 1:
        break
print(i+1)

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

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

A = []

for i in range(1, 1000000):
  if i == 1:
    a = s
  elif a % 2 == 0:
    a = a / 2
  else:
    a = 3 * a + 1
  if a in A:
    print(i)
    break
  A.append(a)

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

def is_unique(seq):
        return len(seq) == len(set(seq))

while True:
        f(a[-1])
        if is_unique(a) == False:
                print(len(a))
                break

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

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

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

print(n)

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

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

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

i = 1
a = set([s])
while True:
    i += 1
    t = collatz(s)
    if t in a:
        break
    a.add(t)
    s = t
print(i)

Solution (Python):
import sys
s = int(input())
lis = [0 for i in range(1000001)]
lis[s] = lis[s] + 1
def solve(s):
    m = 1
    while True:
        m = m + 1
        if s%2 == 1:
            s = 3*s + 1
        else:
            s = s//2
        if not lis[s] == 0:
            return m
            sys.exit()
        else:
            lis[s] = lis[s]+1
print(solve(s))

Solution (Python):
s = int(input())
l = [s]
chk = 0
for i in range(10**6):
	if(s % 2 == 0):
		s = s/2
	else:
		s = 3*s+1
	s = int(s)
	for j in range(0,len(l)):
		if(l[j] == s):
			chk = 1
			break
	if(chk == 1):
		break
	l.append(s)
print(i+2)

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

numbers = [an]
while True:
  if an%2 == 1:
    an = 3*an+1
  else:
    an = an//2
  if an in numbers:
    print(len(numbers)+1)
    break
  else:
    numbers.append(an)

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

s = int(input())
l = [s]
for i in range(1000000):
    a_i = func(l[-1])
    if a_i in l:
        l.append(a_i)
        break
    l.append(a_i)
print(len(l))

Solution (Python):
s = int(input())
t = 1
an = [s]
while t>0:
    if s%2 == 0:
        si = int(s/2)
    if s%2 == 1:
        si = 3*s+1
    for a in an:
        if si == a:
            print(len(an)+1)
            exit()
            t=0
    s = si
    an.append(si)

Solution (Python):

import sys


def solve(s: int):
    memo = [-1] * 1000001
    for i in range(1000001):
        if memo[s] >= 0:
            ret = i + 1
            break
        memo[s] = i
        if s % 2 == 0:
            s //= 2
        else:
            s = 3 * s + 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = int(next(tokens))  
    solve(s)

if __name__ == '__main__':
    main()

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

s=int(input())
dic={s}


m=1
while True:
    m+=1
    s=f(s)
    if s in dic:
        print(m)
        break
    dic.add(s)

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

s=int(input())
nlist =[]
tmp_in = collatz(s)
nlist.append(s)
nlist.append(tmp_in)
cnt = 1
while True:
    cnt += 1
    tmp_out = collatz(tmp_in)

    if tmp_out in nlist:
        print(len(nlist)+1)
        
        break
    nlist.append(tmp_out)
    tmp_in = tmp_out

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

s=int(input())
nlist =[]
tmp_in = collatz(s)
nlist.append(s)
nlist.append(tmp_in)
cnt = 1
while True:
    cnt += 1
    tmp_out = collatz(tmp_in)

    if tmp_out in nlist:
        print(len(nlist)+1)
        
        break
    nlist.append(tmp_out)
    tmp_in = tmp_out

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

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

for i in range(1, 1000000 + 1):
    x = f(s)

    if x in l:
        print(i + 1)
        break

    l.append(x)
    s = x

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

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

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

li_a = []
i = 0
s = int(input())
li_a.append(s)
while True:
    temp = collatz(li_a[i])
    if temp in li_a:
        print(i+2)
        break
    else:
        li_a.append(temp)
    i += 1

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

def main():
    s = int(input())
    A = [0]
    A.append(s)
    flag = True
    count = 0
    while flag:
        count += 1
        A.append(f(A[count]))
        for i in range(1, len(A)):
            for j in range(i + 1, len(A)):
                if A[i] == A[j]:
                    flag = False
                    print(j)
main()

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

s = int(input())
a = [s]
while 1:
    m = f(s)
    if a.count(m) > 0:
        print(len(a) + 1)
        exit()
    a.append(m)
    s = m

Solution (Python):
def find_match(a):
    for i in range(len(a) - 1):
        if a[i] == a[-1]:
            return len(a)
    return None


s = int(input())
a = [s]
i = 1
ans = 1000000
while(True):
    if a[-1] % 2 == 0:
        a.append(a[-1] // 2)
    else:
        a.append(3 * a[-1] + 1)
    x = find_match(a)
    if x is not None:
        if ans < x:
            break
        ans = x
print(ans)

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

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

for i in range(1,1000000):
  c=b[i-1]
  if c%2==0:
    d=int(c/2)
  else:
    d=c*3+1
  if d in b:
    print(i+1)
    break
  b.append(d)

Solution (Python):

import sys

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

def solve(s: int):
    a = [s]
    
    
    
    while(True):
        t = f(a[-1])
        if(t in a):
            print(len(a)+1)
            sys.exit(0)
        else:
            a.append(t)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = int(next(tokens))  
    solve(s)

if __name__ == '__main__':
    main()

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

    a.append(tmp)

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

l = []
l.append(s)
for i in range(2,MAX+1):
    temp = f(s)
    if temp in l:
        print(i)
        exit()
    l.append(temp)
    s = temp

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

l = [0] * MAX
l[s] = 1
for i in range(2,MAX+1):
    temp = f(s)
    if l[temp]==1:
        print(i)
        exit()
    l[temp] = 1
    s = temp

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


s = int(input())

a = []

a.append(s)

for i in range(1, 10000000):
    if f(a[i-1]) in a:
        print(i+1)
        exit()

    a.append(f(a[i-1]))

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

a = [s]
for i in range(2, 10**6+1):
    if a[-1] % 2 == 0:
        a.append(a[-1]/2)
    else:
        a.append(3 * a[-1] + 1)
    
    if len(a) != len(set(a)):
        print(i)
        break

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

def f(n):
    if n % 2 == 0:
        return n / 2
    else:
        return 3 * n + 1
a_s = [s]
A = set([s])
for m in range(1, 1000000):
    a_m = f(a_s[-1])
    if a_m in A:
        ans = m + 1
        break

    a_s.append(a_m)
    A.add(a_m)

print(ans)

Solution (Python):


INF = 1000000

s = int(input())
a = [s] * (INF + 1)

answer = 0

for i in range(INF):
    if a[i] % 2 == 0:
        a[i+1] = int(a[i] / 2)
    else:
        a[i+1] = 3 * a[i] + 1
    for j in range(0,i):
        if a[i] == a[j]:
            answer = i+1
            break
    if answer != 0:
        break

print(answer)

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

a = [s]

while True:
    if a[-1]%2 ==0:
        a.append(a[-1]//2)
    else:
        a.append(a[-1]*3+1)
    
    for i in range(0,len(a)-1):
        if a[-1] == a[i]:
            break
    else:
        continue
    break
print(len(a))

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

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

s = int(input())
a = [s]
i = 0
while True:
    next_insert = f(a[i])
    
    if (next_insert in a) == True:
        break
    a.append(next_insert)
    i +=1
print(i+2)

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

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

arr = [s]

for i in range(1, 1000001):
    c = f(arr[i-1])
    if c in arr:
        re = i + 1
        break
    arr.append(c)

print(re)

Solution (Python):
from functools import lru_cache

appeared = [False] * 1000001


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


def a(s):
    yield s
    y = s
    while True:
        y = f(y)
        yield y


def main():
    s = int(input())
    seq_a = a(s)
    i = 1
    while True:
        elem = next(seq_a)
        if appeared[elem]:
            print(i)
            return
        else:
            appeared[elem] = True
            i += 1


if __name__ == '__main__':
    main()

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

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

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

def main():
    a = [s]
    for n in range(1, 1000000):
        a.append(f(a[n-1]))
        if len(set(a)) != n+1:
            return n+1

if __name__ == '__main__':
    print(main())

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

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

Solution (Python):
S = int(input())
A = [S,]
n = 1
def calc1():
  global n
  while True:
    if A[n-1] % 2 == 0:
      A.append(int(A[n-1] /2))
    else:
      A.append(int(3*A[n-1] +1))
    if A[n] in set(A[0:n]):
      return n+1
    n += 1
      
print(calc1())

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

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

i = 0
a = []
a.append(s)
b = [0] * 10000

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

print(i + 1)

Solution (Python):
n=int(input())
log=[]
cnt=1
while n not in log:
    cnt+=1
    log+=[n]
    n=3*n+1 if n%2 else n//2
print(cnt)

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

Solution (Python):
def even(n):
    return n//2

 
def odd(n):
    return 3*n + 1


s = int(input())
a = [s]
count = 1
while 1:
    if a[count-1] % 2 == 0:
        a.append(even(a[count-1]))
    else:
        a.append(odd(a[count-1]))
    count += 1
    if a[-1] in a[:-1]:
        print(count)
        quit()

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

memo = [N]
while True:
  if N%2 == 0:
    N //= 2
  else:
    N = 3*N+1
  if N in memo:
    break
  memo.append(N)
print(len(memo)+1)

Solution (Python):
def calc(n):
    if n % 2 == 0:
        return int(n/2)
    return 3 * n + 1
n = int(input())
a = set()
count = 1
while (n not in a):
    a.add(n)
    n = calc(n)
    count += 1
print(count)

Solution (Python):
s = int(input())
a = [0] * (1000000+7)
a[0] = s
for i in range(1,1000001):
    if a[i-1] % 2 == 0:
        a[i] = a[i-1] // 2
    else:
        a[i] = a[i-1] * 3 + 1
for i in range(1,1000001):
    for j in range(0,i):
        if a[i] == a[j]:
            print(i+1)
            break
    else:
        continue
    break

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

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

while f(s) not in L:
    s = f(s)
    L.append(s)
    Count += 1
print(Count)

Solution (Python):
import sys
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

s = read_int()[0]

A = [False for _ in range(1000000 + 1)]

def solve():
    a = s
    A[a] = True
    ans = 0
    m = 1
    while True:
        if a % 2 == 0:
            a = a // 2
            m += 1
            if A[a]:
                ans = m
                break
            else:
                A[a] = True
        elif a % 2 == 1:
            a = 3*a + 1
            m += 1
            if A[a]:
                ans = m
                break
            else:
                A[a] = True
    return ans


if __name__ == "__main__":
    print(solve())

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

Solution (Python):


def main():
    s = int(input())
    se = {s}
    for i in range(10 ** 6):
        s = next(s)
        if s in se:
            print(i + 2)
            return
        se.add(s)

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

main()

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

S = [s]

for i in range(1,100000000):
  if(s%2 == 0):
    s = s / 2
  else:
    s = 3 * s + 1
  if s in S:
    print(i+1)  
    break
  else: S.append(s)

Solution (Python):

import sys
def f(n):
    if n % 2 == 0:
        return n / 2
    else:
        return 3*n + 1
s = int(input())
l = [s]
while True:
    l.append(f(l[-1]))
    for i in range(len(l)):
        for j in range(i+1, len(l)):
            if l[i] == l[j]:
                print(j+1)
                sys.exit()

Solution (Python):
s=int(input())
def f(n):
    if n%2==0:
        return n//2
    else:
        return 3*n+1
cnt = 2
while True:
    if s in [1, 2, 4]:
        print(4)
        break
    s = f(s)
    if s == 4:
        print(cnt+3)
        break
    cnt+=1

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

if s == 1 or s == 2:
    print(4)
else:
    a = [s]
    for i in range(1000):
        if a[-1] % 2 == 0:
            a.append(int(a[-1] / 2))
        else:
            a.append(int(a[-1] * 3 + 1))

    print(a.index(4) + 4)

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

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

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

a.append(int(s))

for i in range(10**10):
    if f(a[i]) in a:
        ans = i+2
        break
    a.append(int(f(a[i])))

print(ans)

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

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

while 1:
  if s %2 == 0:
    l.append(s/2)
    s = int(s/2)
  else:
    l.append(3*s + 1)
    s = 3*s+1
    max = s
  
  if any(l.count(i) >= 2 for i in range(s+1)):
    print(len(l))
    break

Solution (Python):
s=int(input())
a=s
num=[s]
if a==4 or a==1 or a==2:
  print(4)
  exit()
for i in range(2,10**7+1):
  if a%2==0:
    a=a//2
  else:
    a=3*a+1
  if a==4 or a==1 or a==2:
    ans=i+3
    break
print(ans)

Solution (Python):
N=int(input())
L=set();i=4
while 1:
  if N in[1,2,4]:print(i);exit()
  N=N*3+1 if N%2 else N//2;i+=1

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

s = int(input())

i=0
sl = [s]
while True:
    n = func(sl[-1])
    if( n  in sl):
        print(i+2)
        exit()
    sl.append(n)
    
    i+=1

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

Solution (Python):
s = int(input())
def func(n):
  if n%2 == 1:
    return 3*n+1
  else:
    return n//2
def prog(N):
  if N == 1:
    return s
  else:
    a=s
    for i in range(1,N):
      a = func(a)
    return a

b=[]
for i in range(1,1000000):
  tmp = prog(i)
  if tmp in b:
    print(i)
    break
  else:
    b.append(tmp)

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

Solution (Python):

S = int(input())
A = set([])
while S not in A:
    A.add(S)
    if (S%2==0):
        S //= 2
    else:
        S = S*3+1

print(len(A)+1)

Solution (Python):
s = int(input())
ans_list = {1:4,2:4,3:9,4:4,5:7,6:10,7:18,8:5,9:21,10:8,11:16,12:11,13:11,14:19,15:19,16:6,17:14,18:22,19:22,20:9,21:9,22:17,23:17,24:12,25:25,26:12,27:113,28:20,29:20,30:20,31:108,32:7,33:28,34:15,35:15,36:23,37:23,38:23,39:36,40:10,41:111,42:10,43:31,44:18,45:18,46:18,47:106,48:13,49:26,50:26,51:26,52:13,53:13,54:114,55:114,56:21,57:34,58:21,59:34,60:21,61:21,62:109,63:109,64:8,65:29,66:29,67:29,68:16,69:16,70:16,71:104,72:24,73:117,74:24,75:16,76:24,77:24,78:37,79:37,80:11,81:24,82:112,83:112,84:11,85:11,86:32,87:32,88:19,89:32,90:19,91:94,92:19,93:19,94:107,95:107,96:14,97:120,98:27,99:27,100:27}

print(ans_list[s])

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

Solution (Python):
s = int(input())
ans = -999
ans_list = []
counter = 1
ans_list.append(s)
while   True:
    counter += 1
    if s%2 == 0:
        s = s//2
    else:
        s = 3*s +1

    if  s in ans_list:
        ans = counter
        break
    elif  counter > 1000000:
        break
    ans_list.append(s)
print(ans)

Solution (Python):
import math

s = int(input().strip())


def get_next(a):
    if a % 2 == 0:
        return math.floor(a / 2)
    else:
        return 3 * a + 1


flag = True
tmp = s
As  = [s]
counter = 1
while flag:
    nex = get_next(tmp)
    counter += 1
    tmp = nex
    if nex in As:
        flag = False
    As.append(nex)

print(counter)

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

Solution (Python):
from sys import stdin
s=int(stdin.readline().rstrip())
al=[s]
while True:
    if al[-1]%2 == 0:
        new = int(al[-1]/2)
    else:
        new = int(3*al[-1]+1)
    if new in al:
        al.append(new)
        print(len(al))
        break
    al.append(new)

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

Solution (Python):


n = int(input())

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

a = [n]
i = 0
while a.count(f1(a[i]))!=1:
    a.append(f1(a[i]))
    i+=1

print(i+2)

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

l = [a]
b = a
c = 1
while True:
    if b % 2 == 0:
        b = int(b/2)
    else:
        b = 3 * b + 1

    c += 1

    if b in l:
        break

    l.append(b)

print(c)

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

for i in range(1, 1000001):
    new = func(a[i])
    if new in a:
        break
    
    a.append(new)
    
print(i+1)

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

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

a = ['
i = 0
while i < 1000001:
  i += 1
  if i == 1:
    a.append(s)
  else:    
    if a[i-1]%2 == 0:
      ai = a[i-1] / 2
    else:
      ai = 3 * a[i-1] + 1
   
    if ai in a:
      print(i)
      exit()
    
    a.append(ai)

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

Solution (Python):

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

while len(set(a)) == len(a):
    a.append(s)
    if s % 2 == 0:
        s = s/2
    else:
        s = 3 * s + 1
    cnt += 1
print(cnt)

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

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

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

a_n = s
a_set = {a_n}
i = 1
while True:
    a_n_1 = (3 * a_n + 1 if a_n % 2 else a_n // 2)
    if a_n_1 in a_set:
        print(i + 1)
        break
    else:
        a_set.add(a_n_1)
        a_n = a_n_1
        i += 1

Solution (Python):
a = int(input())
def f(x):
    return (3*x+1) if x%2 else (x//2)
i = 1
already = set()
while 1:
    if a in already:
        break
    else:
        i+=1
        already.add(a)
        a = f(a)
print(i)

Solution (Python):
import sys

s = int(sys.stdin.readline().strip())
a = s
a_all = []
a_all.append(a)

def fnc_odd(n):
    return 3*n+1
    
def fnc_even(n):
    return int(n/2)
    
i = 2

while (i<120):
    if(a%2==0):
        a = fnc_even(a)
        a_all.append(a)
    else:
        a = fnc_odd(a)
        a_all.append(a)
    if(i>3 and a_all[(i-3)-1]==a):
        break
    i += 1
        
print(i)

Solution (Python):
s = int(input())
def calc(a):
    if (a % 2 == 0):
        return a/2
    else:
        return 3*a+1
a_set = set([s])
ss = calc(s)
while (ss not in a_set):
    a_set.add(ss)
    ss = calc(ss)
print(len(a_set)+1)

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

Solution (Python):
s = int(input())
A = []
A.append(s)
B = []
i = 2

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

  B = list(set(A))
  if(len(A) != len(B)):
    m = i
    break
  i += 1
  
print(m)

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

Solution (Python):
list=[int(input())]
def f(n):
    if n%2==0:
        return n/2
    else:
        return 3*n+1
while True:
    a=f(list[-1])
    if a in list:
        print(len(list)+1)
        exit()
    else:
        list.append(a)

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

a = [n]

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

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

def judge(a, numbers):
    for i in range(len(numbers)):
        if a == numbers[i]:
            return False

    return True

s = int(input())
number = s
numbers = []
count = 1

while judge(number, numbers):
    numbers.append(number)
    count += 1
    number = func(number)

print(count)

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

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

l = [int(input())]
while True:
    x = f(l[-1])
    if x in l:
        print(len(l) + 1)
        break
    l.append(x)

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

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

Solution (Python):
s = int(input())
if s==1 or s==2 or s==4:
    print(4)
else:
    t = {}
    while True:
        if s not in t:
            t.setdefault(s, 0)
        t[s]+=1
        if (4 in t) and t[4]==2:
            break
        if s%2==0:
            s//=2
        else:
            s = 3*s+1
    print(sum(list(t.values())))

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

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

array = []
for i in range(1,1000000):
  if i == 1:
    a_new = s
  else:
    a_new = f(array[-1])
  if a_new in array:
    print(i)
    break
  array.append(a_new)

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

s = int(input())
if((s == 1) or (s == 2)):
  print(4)
  exit()
  
cnt = 1
while(s != 1):
  s = func(s)
  cnt += 1
print(cnt + 1)

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

while True:
	if s in [1,2,4]:
		break
	else:
		s = collatz(s)
		i += 1

print(str(i+3))

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

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

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

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

for i in range(1, 100000):
    if a[i-1]%2==0:
        a.append(a[i-1]//2)
    else:
        a.append(3*a[i-1]+1)
l=[]
for i in range(len(a)):
    for j in range(i+1, len(a)):
        if a[i]==a[j]:
            l.append(j+1)
            break

print(l[0])

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

while True:
	if s in [1,2,4]:
		break
	else:
		s = collatz(s)
		i += 1

print(str(i+3))

Solution (Python):
def main():
    s = get_params()
    collatz_seq = collatz(s)
    am_index = first_duplicate_index(collatz_seq)
    print(am_index+1)


def get_params():
    return int(input())


def collatz(s):
    return iterate(f, s)


def iterate(f, init):
    while True:
        yield init
        init = f(init)


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


def first_duplicate_index(seq):
    s = set()
    for e in seq:
        if e in s:
            return len(s)
        s.add(e)


if __name__ == "__main__":
    main()

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

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