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):
import sys

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

s = int(sys.stdin.readline().rstrip())

def main():
    a_m = set([1, 2, 4])
    a = s
    for i in range(1, 10**6-2):
        if a in a_m:
            return i + 3
        a = f(a)

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

Solution (Python):
import sys

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

s = int(sys.stdin.readline().rstrip())

def main():
    a = s
    res = set([a])
    for i in range(2, 10**6+1):
        a = f(a)
        if a in res:
            return i 
        res.add(a)

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

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


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


for i in range(1000000):
    if i == 0:
        l.append(s)
    else:
        l.append(f(l[i - 1]))

count = [0] * len(l)
for i in range(len(l)):
    count[int(l[i])] += 1
    if 1 < count[int(l[i])]:
        print(i+1)
        break

Solution (Python):

s = int(input())

count = 2
a = s
a_list = [a]
while True:
    if a % 2 == 0:
        an = a // 2
    else:
        an = 3 * a + 1

    if an in a_list:
        break
    else:
        count += 1
        a_list.append(an)
        a = an

print(count)

Solution (Python):
n = int(input())
k = set()
i = 1
while True:
  if n in k: break
  k.add(n)
  i += 1
  n = 3*n+1 if n&1 else n//2
  
print(i)

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

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    s=int(input())
    S=set()
    S.add(s)
    n=s
    for i in range(2,10**7):
        if n%2:
            n=3*n+1
        else:
            n=n//2
        if n in S:
            print(i)
            exit()
        S.add(n)
            

if __name__ == '__main__':
    main()

Solution (Python):
def up(num, li):
    if num % 2 == 0:
        next_num = num // 2
    else:
        next_num = 3 * num + 1
    if num in li:
        return len(li) + 1
    li.append(num)
    return up(next_num, li)

print(up(int(input()), []))

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

d = {s: 0}

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

    if s in d:
        break
    else:
        d[s] = 1

print(len(d)+1)

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

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())
rec = set()


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


c = 1
while True:
    if s in rec:
        print(c)
        exit()
    rec.add(s)
    s = f(s)
    c += 1

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

a = [s]

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

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

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

Solution (Python):
s=int(input())
a=set()
a.add(s)
cnt=2

while True:
  if s%2:
    t=3*s+1
  else:
    t=s//2
  if t in a:
    print(cnt)
    exit(0)
  a.add(t)
  cnt+=1
  s=t

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

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

for i in range(2, 1000000):
  a=calc(F[i-1])
  if a in F:
    print(i)
    break
  else:
    F.append(a)

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

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

Solution (Python):
s=int(input())
data=[0]*(10**6+100)
data[s]=1
cnt=1
while True:
    if s%2==0:
        s//=2
    else:
        s=3*s+1
    cnt+=1
    if data[s]==1:
        break
    data[s]=1
print(cnt)

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


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


def a(i, s):
    if i == 1:
        return s
    return f(a(i - 1, s))


i = 1
a_l = []
while True:
    a_l.append(a(i, s))
    if len(a_l) != len(set(a_l)):
        print(i)
        break
    i += 1

Solution (Python):
import os
import sys

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


S = int(sys.stdin.buffer.readline())

seen = [0] * 1000001

a = S
i = 0
while not seen[a]:
    seen[a] = 1
    if a % 2 == 0:
        a //= 2
    else:
        a = 3 * a + 1
    i += 1
print(i + 1)

Solution (Python):


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

first = int(input())

log = {first: 0}

prev = first
for i in range(1, 1000000 + 1):
    num = f(prev)
    if num in log:
        print(i + 1)
        break
    log[num] = i
    prev = num

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

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

for i in range(1,1000001):
    a.append(f(a[i-1]))
    if a.count(f(a[i-1]))==2:
        print(i+1)
        break

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

Solution (Python):
s = int(input())
check = ""
count = 1
result = [s]
while check != "OK":
    if s % 2 == 0:
        s = s/2
    else:
        s = 3*s + 1
    count += 1
    s = int(s)
    result.append(s)
    for i in range(len(result)-1):
        if result[i] == s:
            check = "OK"
        else:
            pass
        
print(count)

Solution (Python):
import sys
s = int(input())
flg=0
A = []
A.append(s)

index = 0
if s==4 or s==2 or s==1:
    print(index+4)
    sys.exit()
while flg!=1:
    if A[index]%2==0:
        f = (A[index]//2)
    else:
        f = 3*A[index]+1

    A.append(f)
    index = index + 1

    if f==4 or f==2 or f==1:
        flg=1
        break



print(index+4)

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


def even(n):
    return n / 2


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


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

for i in range(len(a)):
    for j in range(i + 1, len(a)):
        if a[i] == a[j]:
            print(j + 1)
            flg = True
            break
    if flg == True:
        break

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

i = 1
f = lambda x : (x//2) if x%2 == 0 else x*3+1
l = [N]
val = N

while True:
    val = f(val)
    if val in l:
        print(i+1)
        break
    else:
        l.append(val)    
        i+=1

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

A = [s]

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

Solution (Python):





s = int(input())
li = [0 for i in range(10**7)]
li[s] = 1

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

Solution (Python):
n=int(input())
a=[]
a.append(n)
i=0
flg=0
while True:
  i+=1
  if n%2==0:
    n=n//2
  else:
    n=3*n+1
  a.append(n)
  for j in range(len(a)):
    if i!=j and a[j]==n:
      print(i+1)
      flg=1
      break
  if flg==1:
    break

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

for i in range(1,1000001):

    if lst[i-1]%2 == 0:
        lst.append(lst[i-1]//2)
    else:
        lst.append(lst[i-1]*3+1)

    if lst.count(lst[i])==2:
        break

print(i+1)

Solution (Python):
s = int(input())
cnt = {s}

for i in range(2, 1000001):
    if s % 2 == 0:
        s //= 2
    else:
        s = 3 * s + 1
    if s in cnt:
        print(i)
        exit()
    else:
        cnt.add(s)

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

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

i = 0
while True:
    next = f(list[i])
    if list.count(next) == 1:
        print(i + 2)
        break
    else:
        list.append(next)
        i+=1

Solution (Python):
A = []

s = int(input())
A.append(s)

i = 0
while True:
    if A[i] % 2 == 0:
        a = A[i] // 2
    else:
        a = A[i] * 3 + 1
    if a in A:
        m = i + 2
        print(m)
        exit()
    A.append(a)
    i += 1

Solution (Python):
import sys
input = sys.stdin.readline
S = int(input())
li = [S]
count = 0
while True:
    count += 1
    if S%2 == 0:
        S //=2
    else:
        S = 3*S + 1

    if S in li:
        print(count+1)
        break
    else:
        li.append(S)

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

l = []
l.append(n)

ans = 2
while True :

    if n % 2 == 0:
        n = n / 2
    else:
        n = n * 3 + 1
    
    if n in l:
        break
    else:
        l.append(n)

    ans += 1

print(ans)

Solution (Python):


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

s = int(input())

if s == 1 or s == 2:
    print(4)
    exit()
ans = 2
while s > 1:
    s = f(s)
    ans += 1

print(ans)

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

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

while s not in a:
    a.append(s)
    s = f(s)
    i += 1
else:
    ans = i

print(ans)

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


if __name__ == '__main__':
    solve()

Solution (Python):


s = [int(input())]


while len(s) == len(set(s)):
    if s[-1]%2==0:
        s.append(s[-1]//2)

    else:
        s.append(s[-1]*3+1)


print(len(s))

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

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

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

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

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

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

ans = [s]

for i in range(1000001):
    if ans[i] %2 == 0:
        ans.append(int((ans[i])/2))
    elif ans[i] %2 != 0:
        ans.append(int(3*(ans[i])) +1)
    
    if ans.count(ans[i]) == 2:
        print(i+1)
        break

Solution (Python):
list_a = [int(input())]
while list_a[-1] < 1000001:
  if list_a[-1] % 2 == 0:
    temp = int(list_a[-1] / 2)
  else:
    temp = 3 * list_a[-1] + 1
  if temp in list_a:
    print(len(list_a) + 1)
    exit()
  else:
    list_a.append(temp)

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

l=[]
ans=1
a=s
while a not in [4,2,1]:
    if a % 2 == 0:
        a=a//2
    else:
        a=3*a+1
    ans+=1
    l.append(a)

print(ans+3)

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

values = set()

values.add(s)
ans = 1
while True:
    if s % 2 == 0:
        s = s //2
    else:
        s = 3*s + 1
    ans += 1

    if s in values:
        break
    else:
        values.add(s)

print(ans)

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

sequence = [s]
ans = 1
while True:
    if s%2 == 0:
        s //= 2
    else:
        s = 3*s+1

    ans += 1

    if s in sequence:
        break

    sequence.append(s)

print(ans)

Solution (Python):
s = int(input())
alist = [s]
aset=set()
for i in range(1000000):
  n = alist[-1]
  if n in aset:
    print(len(alist))
    break
  aset.add(n)
  if n%2 ==0:
    x = n//2
  else:
    x = 3*n+1
  alist.append(x)

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

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

ans.add(s)
j = 1
while 1:
        if j  > 1000000:
                break
        if s % 2 == 0:
                s = s // 2
        else:
                s = 3 * s + 1
        j += 1
        for i in ans:
                if s == i:
                        print(j)
                        exit()
        ans.add(s)

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

ans = [0] * 1000
ans[0] = s

j = 1
while 1:
        if j  > 1000000:
                break
        if ans[j-1] % 2 == 0:
                ans[j] = ans[j-1] // 2
        else:
                ans[j] = 3 * ans[j-1] + 1
        for i in range(len(ans)):
                if i == j:
                        break
                if ans[i] == ans[j]:
                        print(j+1)
                        exit()
        j += 1

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

Solution (Python):
h=int(input())
def feb(s):
    i=0
    A=[0]*2000
    A[0]=s
    while(1):
        if A[i]%2==0:
            
            A[i+1]=(A[i]//2)
        elif A[i]%2==1:
            A[i+1]= 3*A[i]+1
        for j in range(i):
            if A[j]==A[i]:
               return i+1
        i+=1
print(feb(h))

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

count = 4
while (s != 4):
    s = f(s)
    count += 1
print(count)

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

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

v = [s]
for i in range(2, 1000001):
    v.append(collatz(v[-1]))
    d = set(v)
    if len(v) != len(d):
        print(i)
        exit()

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

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

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

count=0
exist=[s]
while True:
	count+=1
	
	tmp = f(s)
	if tmp in exist:
		print(count+1)
		sys.exit(0)
	
	exist.append(tmp)
	s=tmp

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

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

l=[s]
m=0
before=s
while True:
  new=f(before)
  m+=1
  if new in l:
    break
  l.append(new)
  before=new

print(m+1)

Solution (Python):
s=int(input())
A=[0 for i in range(10**6+1)]
A[1]=s
def func(a):
    if a%2==0:
        return(a//2)
    else:
        return(3*a+1)
for j in range(1,10**6+1):
    A[j+1]=func(A[j])
    if A[j+1] in A[0:j]:
        print(j+1)
        break

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

Solution (Python):
import sys
input = sys.stdin.readline
import numpy as np
s = int(input())
L = set()
L.add(s)
n = 1
while True:
    n += 1
    if s % 2 == 0:
        s //= 2
        if s in L:
            print(n)
            sys.exit()
        L.add(s)
    else:
        s = 3 * s + 1
        if s in L:
            print(n)
            sys.exit()
        L.add(s)

Solution (Python):
import sys
input = sys.stdin.readline
import numpy as np
s = int(input())
L = [s]
n = 1
while True:
    n += 1
    if s % 2 == 0:
        s //= 2
        if s in L:
            print(n)
            sys.exit()
        L.append(s)
    else:
        s = 3 * s + 1
        if s in L:
            print(n)
            sys.exit()
        L.append(s)

Solution (Python):
s=int(input())
t=set()
count=1

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

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

print(ans + 3)

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

print(ans+3)

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

visited = set()
visited.add(s)
m = 2
if s % 2 == 0:
    s = s / 2
else:
    s = 3 * s + 1

while s not in visited:
    visited.add(int(s))

    m += 1
    if s % 2 == 0:
        s = s / 2
    else:
        s = 3 * s + 1
print(m)

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

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

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

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

n=1
while 1:
    pre_s=s
    if i%2==0:
        i=i//2
    else:
        i=3*i+1
    
    n+=1
    if {i}<=s:
        break
    s.add(i)
    
print(n)

Solution (Python):
s=int(input())
def f(a):
    if a%2:
        return 3*a+1
    else:
        return a//2
value=(s,)
a=s
for i in range(2,1000000):
    a=f(a)
    if a in value:
        print(i)
        break
    value += (a,)

Solution (Python):

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

s = int(input())
ai = []
ai.append(s)
for i in range(1000000):
    x = f(ai[i])
    if x in ai:
        print(i+2)
        break
    ai.append(x)

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

l=[s]*(10**6)
for i in range(10**6):
    if l[i]%2==0:
        l[i+1]=l[i]//2
    else:
        l[i+1]=3*l[i]+1
    if l[i]==4:
        print(i+4)
        exit()
    if l[i]==1:
        print(i+4)
        exit()
    if l[i]==2:
        print(i+4)
        exit()

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

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

S = []
ans = 1

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

print(ans)

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

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

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

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


s = int(input())

a = [0] * 1000000
a[0] = s
for i in range(1, 1000000):
    a[i] = f(a[i - 1])

t = set()
for i in range(1000000):
    if a[i] in t:
        print(i + 1)
        break
    t.add(a[i])

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


for n in range(2,1000001):
    if A[-1]%2==0: 
        f=A[-1]//2
    else: 
        f=3*A[-1]+1

    if f in A: 
        print(n)
        break

    A.append(f)

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

l = []
l.append(s)

ans = 0

i = 1

while ans == 0:
	if l[i-1]%2 == 0:
		l.append(int(l[i-1]/2))
	else:
		l.append(int(3*l[i-1]+1))
	
	if len(l)!=len(set(l)):
		ans = i
	else:
		i = i + 1

print(i+1)

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

def find_the_same(itter, number, answer_list):
    if itter == 1:
        answer_list.append(number)
    if number%2 == 0:
        answer = number // 2
    else:
        answer = (number * 3) + 1
    if answer in answer_list:
        itter += 1
        return itter
    else:
        itter += 1
        answer_list.append(answer)
        return find_the_same(itter, answer, answer_list)
answer_list = []
print(find_the_same(1, s, answer_list))

Solution (Python):

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

n = int(input())
past_values = []
iter = 1
while n not in past_values:
    past_values.append(n)
    n = f(n)
    iter += 1

print(iter)

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

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

ls_a = [s]

for i in range(10**5):
    if ls_a[i] % 2 == 0:
        ls_a.append(ls_a[i] / 2)
    elif ls_a[i] % 2 == 1:
        ls_a.append(3 * ls_a[i] + 1)

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

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

ls_a = [0]
ls_a[0] = s

for i in range(10**5):
    if ls_a[i] % 2 == 0:
        ls_a.append(ls_a[i] / 2)
    elif ls_a[i] % 2 == 1:
        ls_a.append(3 * ls_a[i] + 1)

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

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

Solution (Python):
s = int(input())
tmp = [s]
for i in range(2, 10**6+1):

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

    if j in tmp:
        print(i)
        exit()
    tmp.append(j)

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

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

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

def has_duplicates(seq):
    return len(seq) != len(set(seq))

while True:
    if s%2==0:
        s=s/2
    else :
        s=3*s+1
    a.append(s)
    if has_duplicates(a):
        break;

print(len(a))

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

list_aaa = []

for i in range(1,100000+1):
    if i ==1:
        list_aaa.append(s)
    elif s%2 ==0:
        s= s//2
        list_aaa.append(s)
    elif s%2 ==1:
        s= (3*s)+1
        list_aaa.append(s)


for i in list_aaa:
    index_num = [n for n, v in enumerate(list_aaa) if v == i]
    if len(index_num) >=2:
        print(index_num[1]+1)
        break

Solution (Python):
s = int(input())
seq = [s]
next_a = 0

for i in range(1, 100000000):
    if seq[i-1] % 2 == 0:
        next_a = int(seq[i-1] / 2)
    else:
        next_a = int(3 * seq[i-1] + 1)

    seq.append(next_a)
    if seq[i] in seq[:-1]:
        print(i+1)
        break

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

s = int(input())
nextn = d(s)
nums = set()
nums.add(nextn)
res = 3

while(1):
    nextn = d(nextn)
    if(nextn in nums):break
    else: 
        res += 1
        nums.add(nextn)
if(s in [1, 2, 4]): print(4)
else: print(res)

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

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

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

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

if s == 1 or s == 2 or s == 4:
  print(4)
else:
  count = 1
  while s != 4:
    s = calc(s)
    count += 1
  print(count + 3)

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

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

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
s = int(input())
dp = [0] * (10 ** 6 + 1)
dp[0] = s
x = 0

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

Solution (Python):
n = int(input())
cnt = 0
if n == 1:
    print(4)
    exit()
if n == 2:
    print(4)
    exit()
if n == 4:
    print(4)
    exit()
while n != 4:
    if n%2 == 0:
        n = n//2
        cnt += 1
    else:
        n = 3*n+1
        cnt += 1
print(cnt+4)

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

    m = 1000000
    array = []
    array.append(s)
    count = 0
    for i in range(1,m):
        if array[i-1] == 1:
            count += 1
        if count == 2:
            break
        if array[i-1]%2 == 0:
            array.append(array[i-1]/2)
        else:
            array.append(array[i-1]*3+1)
    ans = m
    for i in range(len(array)):
        for j in range(i+1, len(array)):
            if array[i] == array [j]:
                ans = min(ans, max(i+1,j+1))
        if m == 3:
            break
    print(ans)


if __name__ == '__main__':
    main()

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

a = s
l = set()
l.add(int(a))
cnt = 1
for i in range(1, 1000000):
  if a%2 == 0:
    a = a//2
  else:
    a = 3*a + 1
  cnt += 1
  if a in l:
    break
  l.add(int(a))
  i += 1

print(int(cnt))

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

  i += 1
 
print(int(cnt))

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

print(int(nun))

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

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

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

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

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

a = [s]
for i in range(10000):
  ai = fun(a[i])
  a.append(ai)

b = 0
for i in range(10000):
  if b ==1:
    break
  for j in range(i + 1,9999):
    if a[j] == a[i]:
      b += 1
      print(j + 1)
      break

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

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

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

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

print(i+1)

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

def even(n):
    return n // 2

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

l = [0 for _ in range(100000+10)]
a = s
ans = 1
l[a] += 1
while True:
    if a % 2 == 0:
        a = even(a)
    else:
        a = odd(a)
    l[a] += 1
    ans += 1
    if l[a] >= 2:
        break
print(ans)

Solution (Python):

s = int(input())
the_sequence = []
m = 1

while s not in the_sequence:
    the_sequence.append(s)

    if s % 2 == 0:
        s //= 2
    else:
        s = 3 * s + 1
    
    m += 1
    
print(m)

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

Solution (Python):
s=int(input())
flag=False
d=[s]
count=1
while flag!=True:
  if s%2:
    s=3*s+1
    if s in d:
      flag=True
    d.append(s)
    count+=1
  else:
    s/=2
    if s in d:
      flag=True
    d.append(s)
    count+=1
print(count)

Solution (Python):
import os, sys, re, math

s = int(input())
nums = [-1,s]
M = 1000001

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

for i in range(2,M):
    tmp = doit(nums[i-1])
    if tmp in nums:
        break
    else:
        nums.append(tmp)

print(i)

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

Solution (Python):
import os, sys, re, math

s = int(input())

a = s
ans = [a]

for n in range(2, 1000001):
    a = a // 2 if a % 2 == 0 else 3 * a + 1
    if a in ans:
        print (n)
        break
    ans.append(a)