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):
def run(s):
    n = 1000001
    a = [0, s]
    for i in range(2, n):
        pre = a[i-1]
        if pre % 2 == 0:
            a.append(pre // 2)
        else:
            a.append(3*pre + 1)
    ret_dic = {}
    ret = None
    for i in range(1, n):
        ai = a[i]
        if ai in ret_dic:
            ret = i
            break
        else:
            ret_dic[ai] = 1
    return ret


def main():
    s = int(input())
    print(run(s))


if __name__ == '__main__':
    main()

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

li = [s]
k = 0

while True:
    if li[k] % 2 == 0:
        li.append(int(li[k] / 2))
    else:
        li.append(3 * li[k] + 1)

    for n in range(len(li) - 1):
        for m in range(n + 1, len(li)):
            if li[n] == li[m]:
                print(m + 1)
                quit()
    k += 1

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

a1=s
arr=[]
arr.append(s)
i=1
while True:
  i=i+1
  if arr[-1]%2==0:
    temp=arr[-1]//2
  else:
    temp=int(arr[-1]*3+1)
  if temp in arr:
    print(i)
    break
  else:
    arr.append(temp)

Solution (Python):

import sys
def formula(num):
    if (int(num) % 2 == 1):
        return int(3*num + 1)
    else:
        return int(num / 2)

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

n = formula(s)
while(True):
    if ( n in nums ):
        print(len(nums) + 1)
        sys.exit(0)
    nums.append(n)
    n = formula(n)

Solution (Python):
from collections import Counter
s = int(input())
c = Counter()
for i in range(1, 1000010):
  if c[s]:
    print(i)
    break
  c[s] = 1
  s = s // 2 if s % 2 == 0 else 3 * s + 1

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

s=int(input())
a=[]
m=1
while not s in a:
    a.append(s)
    s=f(s)
    m+=1
print(m)

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

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

n=0
while True:
    if in_list[n]%2==1:
        in_list.append(int(3*in_list[n]+1))
    if in_list[n]%2==0:
        in_list.append(int(in_list[n]/2))
    if in_list[n+1] in in_list[0:n]:
        print(n+2)
        break
    n+=1

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

S = int(input())
l =[]
m = 1
while not S in l:
    l.append(S)
    S =f(S)
    m += 1
print(m)

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

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

s = int(input())
a = [s]
check = True
m = 1

while check:
    if function(a[m-1]) in a:
        check = False
    else:
        a.append(function(a[m-1]))
        m += 1
print(m+1)

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

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

print (counter)

Solution (Python):
s = int(input())
his = {s}
while 1:
    f = lambda n: n // 2 if n % 2 == 0 else 3 * n + 1
    s = f(s)
    if s in his:
        print(len(his) + 1)
        exit()
    his.add(s)

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


def main():
    s = int(input())
    a_list = [s]
    counter = 2
    while True:
        s = cal_f(s)
        if s in a_list:
            print(counter)
            break
        else:
            a_list.append(s)
            counter += 1

main()

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

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

Solution (Python):

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

a= []
a.append(int(input()))
for i in range(1000000):
  x = f(a[i])
  if x in a:
    print(len(a)+1)
    break
  a.append(x)

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

Solution (Python):
s=int(input())
i=4
while s>4or 3==s:s=[s//2,s*3+1][s%2];i+=1
print(i)

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

Solution (Python):
s=int(raw_input())
f=lambda x:(x/2)*(x%2==0)+(3*x+1)*(x%2==1)
r=[s]
map(lambda x:r.append(f(r[-1])),xrange(1,300))
for i in xrange(300,1,-1):
  try:
    s=r[:i].index(r[i])
    rs=i+1
  except:
    pass
print rs

Solution (Python):
import sys

def main(inp):
    A=[inp]
    s=inp
    while True:
        if(s%2==0): s=s/2
        else: s=3*s+1
            
        for i in range(len(A)):
            if(s==A[i]):
                return len(A)+1
                break
        
        A.append(s)

print(main(int(next(sys.stdin))))

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

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

Solution (Python):
def f(n):
    if n%2==0:
        return n//2
    else:
        return 3*n+1
s=int(input())
a=list()
i=1
while 1:
    if s in a:
        break
    a.append(s)
    s=f(s)
    i+=1
print(i)

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

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

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

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

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

def main() :
    
    s = int(input())
    li = [s]
    loop_count = 1
    while(True) :
        loop_count += 1
        n = f(s)
        if (li.count(n) > 0) :
            print(loop_count)
            return
        else :
            li.append(n)
            s = n

    

main()

Solution (Python):
class Collatz_Problems:
	def __init__(self,n):
		self.n = [n]
	def calc_even_odd(self):
		if self.n[-1] % 2 == 0:
			self.n.append(self.n[-1]/2)
			
		elif self.n[-1] % 2 != 0:
			self.n.append(3*self.n[-1]+1)

	def compare(self):
		for i in range(0,len(self.n)-1):
			if self.n[-1] == self.n[i]:
				return True
        
n = int(raw_input().strip())
num = Collatz_Problems(n)
i = 0
while i != 100:
	num.calc_even_odd()
	if num.compare():
		print(len(num.n))
		break

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

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


i = 0

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

    if a[i+1] in a[:i+1]:
        break
    i += 1

print(i+2)

Solution (Python):
s = int(input())
query = [s]
tmp = s
count = 1
ans = -1
while tmp != 0:
 count += 1
    
 if tmp%2 == 0:
  tmp = tmp//2
  if tmp in query:
    break
  query.append(tmp)
 else:
  tmp = tmp*3 +1
  if tmp in query:
   break
  query.append(tmp)

print(count)

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

Solution (Python):
def f(s):
    if s == 2 or s == 1:
        print(4)
        exit()

    a=[s]
    i=0
    while not s==4:
        if a[i]%2==0:
            s//=2
            a+=[s]
        else:
            s=3*s+1
            a+=[s]
        i+=1
    return i+4
print(f(int(input())))

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

s = int(input())
ans = 1
used = set()

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

Solution (Python):

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


s = int(input())
memory = dict()

n = s
count = 1
while True:
    if n in memory.keys():
        break

    memory[n] = True
    n = collatz(n)
    count += 1

print(count)

Solution (Python):
def oddFun(num):
	return num//2
 
def evenFun(num):
	return (3 * num) + 1
 
s = int(input())
set = set()
index = 1
while s not in set:
	set.add(s)
	if s % 2 == 0:
		s = oddFun(s)
	else:
		s = evenFun(s)
	index+=1

print(index)

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

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

    ans = solve(s)
    print(ans)


def solve(s):
    """
    数列 a={a1,a2,a3,......} は、以下のようにして定まります。
    初項 s は入力で与えられる。

    関数 f(n) を以下のように定める
    n が偶数なら f(n)=n/2
    n が奇数なら f(n)=3n+1

    i=1 のとき ai=s
    i>1 のとき ai=f(a(i−1))

    このとき、次の条件を満たす最小の整数 mを求めてください。
    a(m) = a(n) (m>n) を満たす整数 n が存在する。
    制約: 1 ≦ s ≦ 100
    入力はすべて整数である。
    a のすべての要素、および条件を満たす最小の m は 1000000 以下となることが保証される。
    """
    bef_a = s
    d = {s: None}

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

    for i in range(2, 1000000 + 1):
        bef_a = f(bef_a)
        if bef_a in d:
            return i

        d[bef_a] = None


if __name__ == '__main__':
    main()

Solution (Python):






def f(n):
    if n & 1 == 1:
        return n+n+n+1
    else:
        return n>>1


def main():
    s = int(raw_input().strip())

    hist = [s]
    i = 2
    while True:
        n = f(s)
        if n in hist:
            print i
            exit()
        hist.append(n)
        s = n
        i += 1


if __name__ == '__main__':
    main()

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

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

Solution (Python):


s = int(input())


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


a = [s]
while True:
    a.append(f(a[-1]))
    if a[-1] in a[:-1]:
        print(len(a))
        exit()

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

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

while True:
    m = a[-1]

    if m % 2 == 0:
        a_m = m / 2
    else:
        a_m = 3 * m + 1
        
    for index, a_n in enumerate(a):
        if a_m == a_n:
            ans = len(a) + 1
            print(ans)
            exit()

    a.append(a_m)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a = I()
    s = set([a])
    i = 2
    while 1:
        if a % 2 == 0:
            a //= 2
        else:
            a = a * 3 + 1
        if a in s:
            return i
        s.add(a)
        i += 1

    return -1



print(main())

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

while True:
    if a % 2 == 0:
        a = a // 2
    else:
        a = 3*a + 1
    cou += 1
    if a in nums:
        break
    else:
        nums.append(a)

print(cou)

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

a=[]
a.append(s)

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

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

count = 1
while True:
    if s == 1 or s == 2 or s == 4:
        print(count + 3)
        break
    else:
        s = f(s)
    count += 1

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

Solution (Python):
def solve():
    s = int(input())
    al = [s]
    prev = s

    while True:
        new_a = fn(prev)
        if new_a in al:
            break
        al.append(new_a)
        prev = new_a
    print(len(al) + 1)

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

if __name__ == "__main__":
    solve()

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

x=[]

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


count=0
if(s>4 or s==3):
    while(True):
        s=collatz(s)
        count+=1
        if(s==4):
            break


    
        

print(count+4)

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


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

for x in range(1000000):
    tmp = f(a_i[x])
    
    if tmp in a_i:
        print(x+2)
        break
    
    a_i.append(tmp)

Solution (Python):
s=int(input())
dp=[False]*1000000
dp[s]=True
for i in range(2,1000002):
    if s%2:
        s=s*3+1
    else:
        s//=2
    if dp[s]:
        print(i)
        break
    dp[s]=True

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

Solution (Python):
S = int(input())
A = set([])

while S not in A:
    A.add(S)
    if S % 2 == 0:
        S = S // 2
        
    else:
        S = 3 * S + 1
        
print(len(A) + 1)

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

s = int(input())
l = []
n = 1
while(1):
  if s in l:
    print(n)
    quit()
  l.append(s)
  s = f(s)
  n += 1

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

Solution (Python):
def f(n):
    
    if n % 2 == 0:
        return int(n / 2)
    else:
        return 3 * n + 1
 
if __name__ == "__main__":
    s = int(input())
    if s == 2 or s == 1:
        print(4)
        exit()
    for m in range(1, 1000000): 
        if s == 4:
            print(m + 3)
            break
        s = f(s)

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

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

Solution (Python):

s = int(input())


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


a = [s]
used = [None] * 1000000
used[s] = True
while True:
    x = f(a[-1])
    if used[x] is not None:
        print(len(a) + 1)
        exit()
    a += [x]
    used[x] = True

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

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

for i in range(100000):
    for j in range(i + 1,100000):
        if nums[i] == nums[j]:
            print(j + 1)
            break
    else:
        continue
    break

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

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

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

print(len(a) + 1)

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

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

kizon=[]

while(True):
  if s not in kizon:
    kizon.append(s)
    if s%2==1:
      s=3*s+1
    else:
      s=s/2
  else:
    print(len(kizon)+1)
    exit()

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

memory=[0 for i in range(10**6)]
a=s
memory[s-1]=1
for i in range(10**6):
    if a%2==0:
        a=a//2
    else:
        a=a*3+1
    if memory[a-1]==1:
        break
    else:
        memory[a-1]=1

print(i+2)

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


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


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

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

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

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

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

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

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

Solution (Python):


n = int(input())
a = {}
cnt = 0

while True:
    cnt += 1
    

    if n in a:
        print(str(cnt))
        exit()
    else:
        a[n] = 1

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

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

while True:
    idx += 1
    a.append(s)

    if s % 2 == 0:
        s //= 2
    else:
        s = 3 * s + 1
    if s in a:
        print(idx)
        break

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

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

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

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

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

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

Solution (Python):


num = int(input())
li =[]
count = 1
li.append(num)
while True:
    count += 1
    new_num = li[-1]/2 if li[-1]%2 == 0 else li[-1]*3+1
    if new_num in li:
        print (count)
        break
    else:
        li.append(new_num)

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

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

    print(res+3)

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

a = [0 for _ in range(1000001)]

a[s] = 1

i = 2
while 1:
    if s % 2 == 0:
        s //= 2
    else:
        s = 3 * s + 1
    if a[s] != 0:
        print(i)
        exit()
    else:
        a[s] = 1
        i += 1

Solution (Python):
s = int(input())
x = []
n = 0
while True:

    if x.count(s):
        print(n+1)
        break
    else:
        x.append(s)
        n += 1
    if s % 2 == 0:
        s /= 2
    else:
        s = 3*s + 1

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

Solution (Python):

s = int(input())

from collections import defaultdict
d = defaultdict(int)

num = 1
while True:
    

    if s in d.keys():
        print(num)
        exit(0)
    d[s] += 1



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

    num += 1

Solution (Python):
flg=[False for i in range(1000001)]
a=int(input())
flg[a]=True
for i in range(2,10000000000000):
  if a%2==0:
    a//=2
  else:
    a=3*a+1
  if flg[a]:
    break
  flg[a]=True
print(i)

Solution (Python):
def main() -> None:
    s = int(input())
    dp = [s]
    st = set()
    st.add(s)

    i = -1
    while True:
        i += 1
        n = dp[i]
        if n % 2 == 0:
            dp += [n // 2]
        else:
            dp += [3 * n + 1]

        m = i + 1
        if dp[m] in st:
            print(m + 1)
            return
        st.add(dp[m])


if __name__ == "__main__":
    main()

Solution (Python):
def fun(n):
    if n%2:return 3*n+1
    return n//2
a=[0]+[int(input())]
i=1
while not fun(a[i]) in a:a.append(fun(a[i]));i+=1
print(i+1)

Solution (Python):
def judge(a):
    if a%2 == 0:
        n = a/2
    else:
        n = 3*a+1
    return(int(n))
list=[]
x=int(input())
list.append(x)
for i in range(100000):
    b = judge(x)
    if (b in list) == True:
        print(i+2)
        break
    else:
        list.append(b)
        x = b

Solution (Python):

s = int(input())
temp = []
temp.append(s)
former = s
idx = 1

while True:
    idx += 1
    later = former / 2 if former % 2 == 0 else former * 3 + 1

    if later in temp:
        print(idx)
        break
    temp.append(later)
    former = later

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

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

a = cou(s)
a_list = [s]
while True:
    if a in a_list:
        print(len(a_list)+1)
        break
    a_list.append(a)
    a = cou(a)

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())
numbers = set([s])
ans = 1
while True:
    if s % 2:
        s = 3 * s + 1
    else:
        s //= 2
    ans += 1
    if s in numbers:
        print(ans)
        exit()
    else:
        numbers.add(s)

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

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

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

a = [s]
n = 1

while True:
  a.append(calc_next(a[n-1]))
  for i in range(n):
    if a[i] == a[n]:
      print(n+1)
      exit(0)
  n += 1

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

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

while 1:
  v=f(l[-1])
  if v in l:
    print(len(l)+1)
    break
  l.append(v)

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

s = int(input())

A = [s]
tmp = s
ind = 1

while not(tmp in A[:-1]) or ind == 1:
    ind += 1
    tmp = func(tmp)
    A.append(tmp)

print(ind)

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

Solution (Python):
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


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


def solve():
    s = ii()
    d = {s: 0}
    for i in range(1, 1000000000):
        s = f(s)
        if d.get(s) is None:
            d[s] = 0
        else:
            return i + 1


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

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

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

Solution (Python):
s=int(input())
i=2
while s>1:s=[s//2,s*3+1][s%2];i+=1
print(max(i,4))

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

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

while (len(l)==len(set(l))):
  i+=1
  s = func(s)
  l.append(s)
print(i)

Solution (Python):
a=[]
cp_a=[]
an = input()
a.append(int(an))
i=0
cp_a.append(a[0])
t_or_f = 0
m = 0
n = 0

for k in range(1000000):
    if int(a[i])%2==0:
        cal = int(a[i])* (1/2)
        next_i = i+1
        a.append(int(cal))
        cp_a.append(a[next_i])
        i = i+1
    elif int(a[i])%2!=0:
        next_i = i+1
        cal  = 3*int(a[i]) + 1
        a.append(int(cal))
        cp_a.append(a[next_i])
        i = i+1


    for s in range(i):
        for t in range(s+1,i):
            if a[s]==cp_a[t]:
                n = s
                m = t
                print(m+1)
                t_or_f = 1
                break
        if t_or_f:
            break
    if t_or_f:
        break

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

s = int(input())
a = dict()
a[0] = s
a[1] = a[0]

b = dict()
b[s] = 1

for i in range(1,1000001):
  a[i] = func(a[i-1]) 
  if a[i] in b.keys():
    print(i+1)
    break
  else:
    b[a[i]] = 1

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

a_list=[s]
i=1
while True:
    i+=1
    s=collatz(s)
    if s in a_list:
        break
    else:
        a_list.append(s)
print(i)

Solution (Python):
s=int(input())
def function(tmp):
    if tmp%2==0:
        return int(tmp/2)
    else:
        return int(3*tmp+1)
def hoge(t):
    if t==0:
        return s
    else:
        return function(a[t-1])
a=[]
for i in range(0,1000):
    if len(a):
        a.append(hoge(i))
    else:
        a=[hoge(i)]
    if a.count(hoge(i))==2:
        print(i+1)
        break

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

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

lis = []
count = 1

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

print count

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

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

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

Solution (Python):
s = int(input())
kaku = set()
kaku.add(s)
def f(x):
  if x %2 == 0:
    return x//2
  else:
    return 3*x+1
for i in range(2,10**9):
  s = f(s)
  if s in kaku:
    print(i)
    exit()
  kaku.add(s)

Solution (Python):

import sys

def io_generator():
	while True:
		yield raw_input()



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

def main(io):
	s=int(io.next())
	i=1
	opened=[]
	while True:
		opened.append(s)
		s=next(s)
		i+=1
		if s in opened:
			return i
	return -1



if __name__ == "__main__":
	io=io_generator()
	print main(io)

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

Solution (Python):
list_after = [int(input())]
counter = 1

def f(list_):
    if list_[-1] %2 == 0:
        after = list_[-1]/2
    else:
        after = 3 * (list_[-1]) + 1
    return after

break_ = 0
while break_ == 0:
    after = f(list_after)
    if after in list_after:
        print(counter+1)
        break_ = 1
        break
    list_after.append(after)
    counter += 1

Solution (Python):
if __name__ == '__main__':
    s = int(input())

    i = 1
    n = s
    prev = set()
    while True:
        prev.add(n)
        i += 1
        if n % 2 == 0:
            n = n // 2
        else:
            n = 3 * n + 1
        if n in prev:
            break
    print(i)