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())
def f(n):
  if n%2==0:
    return n/2
  else:
    return 3*n+1
counter = 4
while s!=4 and s!=2 and s!=1:
  s = f(s)
  counter+=1
print(counter)

Solution (Python):
def has_duplicates(seq):
    return len(seq) != len(set(seq))
import sys

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

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

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

a = list()
n = 1


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

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

print(i)

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

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

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

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

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

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

data = [s]


def calc(n):
    tmp = n/2 if n % 2 == 0 else 3*n+1
    data.append(tmp)
    if len(set(data)) != len(data):
        print(len(data))
    else:
        calc(tmp)


calc(s)

Solution (Python):

def inp():
    return(int(input()))



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



def instr():
    s = input()
    return(list(s[:len(s)]))



def invr():
    return(map(int, input().split()))


s = inp()

A = []

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

Solution (Python):
s = int(input())
a = [s]
z = set([s])
idx = 1
for i in range(10**8):
    idx += 1
    if a[i] % 2 == 0:
        ai = a[i] // 2
    else:
        ai = 3 * a[i] + 1
    if ai in z:
        print(idx)
        exit()
    a.append(ai)
    z.add(ai)

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

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

Solution (Python):
s = int(input())
n = 1
ans = set()

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

Solution (Python):
import math
from collections import deque
from collections import defaultdict


def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): 
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): 
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} 
def bitArr(n):
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): 
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

s = readInt()

ex = [s]

while 1:
	if ex[-1]%2:
		ex.append(3*ex[-1]+1)
	else:
		ex.append(ex[-1]//2)
	if ex.count(ex[-1])==2:
		break

print(len(ex))

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

s = int(input())
l = set()
l.add(s)
c = 2
while 1:
    if s%2 == 0:
        s = s//2
    else:
        s = 3*s + 1
    if (s in l) == True:
        print(c)
        sys.exit()
    else:
        c += 1
        l.add(s)

print(l)

Solution (Python):
s=int(input())
l=[0]*10000
for i in range(1,10000):
    if i==1:
        f=s
        l[i]=f
        setl=2
    else:
        tmp=setl
        if f%2==0:
            f=f//2
        else:
            f=3*f+1
        l[i]=f
        setl=len(set(l))
        
        if tmp==len(set(l)):
            print(i)
            exit()

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

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

    a = s
    max_a = a
    i = 1

    m = {}
    m[s] = 1

    while True:
        a = f(a)
        i += 1
        if not a in m:
            m[a] = i
        else:
            print(i)
            exit()


main()

Solution (Python):
import sys
from heapq import heappush, heappop
def input(): return sys.stdin.readline().strip()


def main():
    s = int(input())
    appear =set([])
    cnt = 0
    while s not in appear:
        appear.add(s)
        if s % 2 == 0: s = s // 2
        else: s = 3 * s + 1
        cnt += 1
    print(cnt + 1)



if __name__ == "__main__":
    main()

Solution (Python):
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)

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

Solution (Python):
a = int(input())
s = {a}
i=1
lenPrev=len(s)
while i<1000000:
  i+=1
  if a%2==0:
    a=a/2
  else:
    a=3*a+1
  s.add(a)
  
  if len(s) == lenPrev:
    print(i)
    break
  lenPrev=len(s)

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

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

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

dic = {s}

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

Solution (Python):
from collections import Counter
def collatz(n):
    if n%2:
        return n*3 + 1
    else:
        return n//2
    
i = int(input())
dic = dict()
dic[i] = 1
cur = i
for n in range(1,10000):
    cur = collatz(cur)
    if cur in dic:
        print(n+1)
        break
    else:
        dic[cur] = 1

Solution (Python):
import itertools
import math
import fractions
import functools
import copy
s = int(input())
a = set()
index = 0
a.add(s)
for i in range(1,1000000):
    if s % 2 == 0:
        s = s / 2
    else:
        s = 3*s + 1
    if s in a:
        index = i
        break
    a.add(s)
    
print(index+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):
def f(n):
    if n % 2 == 0:
        return int(n / 2)
    else:
        return 3 * n + 1

def solve_B():
    s = int(input())
    list = [0] * 1000000
    list[s] += 1
    for i in range(2, 1000000):
        x = f(s)
        if list[x] == 1:
            return i
        list[x] += 1
        s = x

print(int(solve_B()))

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

s = int(input())
l = []
l.append(s)
for i in range(1000000):
    a = func(s)
    if a not in l:
        l.append(a)
        s = a
    else :
        print(i+2)
        break

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

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

while 10000 >cnt:
    if s%2==0:
        s=s//2
        l.append(s)
    else:
        s=3*s+1
        l.append(s)
    if l.count(s)==2:
        cnt+=1
        break
    cnt+=1

print(cnt)

Solution (Python):
s=int(input())
a=[s]
b=0
f=False
for i in range(10**6):
	if a[i]%2 == 0:
		a.append(a[i]//2)
	else:
		a.append(a[i]*3+1)
	for j in range(i):
		if a[i]==a[j]:
			b=i+1
			f=True
			break
	if f:
		break
print(b)

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

Solution (Python):


s = int(input())
a = [0]
a.append(s)

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

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

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

A = []
ans = 1

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

while s not in A:
  A.append(s)
  s = seq(s)
  ans += 1
else:
  print(ans)

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

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

Solution (Python):
s = int(input())
bit = [0] * 1000000

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

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


s = int(input())

a = []
b = s
for i in range(10**6 + 1):
    if b not in a:
        a.append(b)
        b = fn(b)
    else:
        a.append(b)
        break
print(len(a))

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

bi = [1, 2, 4, 8, 16, 32, 64]

a = [s]

for i in range(10000):

    n = a[i] 

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

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

print(0)

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

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

L = [int(input())]

for i in range(10**10):
    L.append(f(L[i]))

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

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

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

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

def fn(n):

    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1
        
for i in range(1, 10**8):
    if i == 1:
        a = s
    else:
        a = fn(a)
    if a ==1 or a == 2 or a == 4:
        print(i+3)
        break

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

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

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18


s = I()
def f(n):
    if n % 2 == 0:
        return int(n/2)
    else:
        return int(3*n+1)
use = {s}
a = s
for i in range(1, 10**6+1):
    na = f(a)
    if na in use:
        print(i+1)
        exit()
    use.add(na)
    a = na

Solution (Python):
s = int(input())
A = [s]
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]:
    ans = i+1
    break
  i += 1
print(ans +1)

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

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def SS(): return map(str,sys.stdin.readline().rstrip().split())
def II(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

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

s = I()
a = {s}


for i in range(2,1000001):
  ai = f(s)
  if ai in a:
    print(i)
    exit()
  s = ai
  a.add(ai)

Solution (Python):
ai = int(input())
a = [ai]
f = True
count = 0
def check(ai,a):
    if ai in a:
        return False
    else:
        return True
while f:
    if count >= 10:
        f = False
    if ai%2 == 1:
        ai = 3*ai+1
        f = check(ai,a)
        a.append(ai)
        count +=1
    else:
        ai = ai//2
        f = check(ai,a)
        a.append(ai)
        count +=1

print(count+1)

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

Solution (Python):
s=int(input())
a=[]
a.append(s)
def has_duplicates(seq):
    if len(seq) != len(set(seq)):
        return True
    else:
        return False
i=0
while has_duplicates(a)==False:
    if a[i]%2==0:
        a.append(int(a[i]/2))
    else:
        a.append(int(3*a[i]+1))
    i+=1
print(len(a))

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

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


a=[0]*10**7
c=1
b=[]
a[N]+=1
for i in range(10**6+100):
    
    c+=1
    if N%2==0:
        N=N//2
        b.append(N)
        if a[N]==0:
            a[N]+=1
        else:
            print(c)
            exit()
    else:
        N=3*N+1
        b.append(N)
        if a[N]==0:
            a[N]+=1
        else:
            print(c)
            exit()

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

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

Solution (Python):


import sys






















def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    def func(x):
        if x % 2 == 0:
            return x // 2
        else:
            return 3 * x + 1

    s = ii()
    d = dict()
    cnt = 1
    d[s] = cnt
    prev = s
    while True:
        
        cnt += 1
        next_num = func(prev)
        if next_num in d:
            print(cnt)
            exit()
        else:
            d[next_num] = cnt
            prev = next_num



if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
l = [0] * 1000001
count = 1
while not l[n]:
    l[n] = 1
    n = 3 * n + 1 if n & 1 else n >> 1
    count += 1
print(count)

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

x = {i:0 for i in range(50000)}
i = 1
while True:
  
  x[N] += 1
  if x[N] == 2:
    print(i)
    break
  else:
    if N%2==0:
      N = N//2
    else:
      N = 3*N+1
  i += 1

Solution (Python):
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0

b = iin()
f = [0] * 1000001
i = 1
while True:
    if f[int(b)] == 0:
        f[int(b)] = i
    else:
        break
    b =  3 * b + 1 if b%2 else b/2
    i = i + 1
print(i)

Solution (Python):
s = int(input())
ans = [s]
bool = True
while bool==True:
	if ans[-1] % 2 == 0:
		tmp = int(ans[-1] / 2)
		ans.append(tmp)
	else:
		tmp = int((ans[-1]*3)+1)
		ans.append(tmp)
	num = []
	for index,a in enumerate(ans):
		if a in num:
			print(index+1)
			bool = False
		num.append(a)

Solution (Python):
A=int(input())
B=set([A])
for i in range(1000000):
    if A%2==0:
        A=A//2
    else:
        A=3*A+1
    if A in B:
        print(len(B)+1)
        exit()
    else:
        B.add(A)

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

def main():
    s = int(input())
    sets = set([])
    lists = []
    m = 0
    for _ in range(pow(10,5)):
        lists.append(s)
        sets.add(s)
        if len(sets) != len(lists):
            break
        s = f(s)
        m += 1
    print(m+1)


if __name__ == "__main__":
    main()

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))


def resolve():
    s,=pin()
    a=set()
    for i in range(10**7):
        if s in a:
            print(i+1)
            break
        else:a.add(s)
        
        if s%2:s=s*3+1
        else:s//=2
        
        


resolve()

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

Solution (Python):
s = int(input())
a = [0 for i in range(10**6+1)]
cnt = [0 for i in range(10**6+1)]

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

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

    if cnt[a[i]] == 0:
        cnt[a[i]] += 1
    else:
        print(i)
        break

Solution (Python):
import sys

input = sys.stdin.readline

def calc(n):
    if n%2 == 0:
        return n//2
    else:
        return n*3 + 1
        
def main():
    ans = 1
    s = int(input())
    l = [s]
    while True:
        temp = calc(l[ans-1])
        ans += 1
        if temp in l:
            break
        else:
            l.append(temp)
    print(ans)

if __name__ == '__main__':
    main()

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

Solution (Python):
number = int(input())
count = 2

if number in [1,2,4]:
    count = 4
else:
    while number != 1:
        count += 1
        if number % 2 == 0:
            number = number / 2
        else:
            number = number * 3 + 1

print(count)

Solution (Python):
from itertools import product

def read():
    s = int(input())
    return s,


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


def solve(s):
    a = s
    count = [0] * 5
    i = 1
    while True:
        if a in [1, 2, 4]:
            count[a] += 1
            if count[a] == 2:
                break
        a = f(a)
        i += 1
    return i

if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))

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

Solution (Python):
s = int(input())
f_num = []
tmp = s
m = 1

while tmp not in f_num:
    f_num.append(tmp)
    if tmp % 2 == 0:
        tmp = tmp // 2
    else:
        tmp = 3 * tmp + 1
    m += 1

print(m)

Solution (Python):
S = int(input())
def f(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1
a = S
al = [a]
for i in range(2,1000001):
    na = f(a)
    if na in al:
        print(i)
        break
    a = na
    al.append(na)

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

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

Solution (Python):
s =int(input())
a = []
a.append(s)
memory = []
memory.append(s)
while True:
    n = a.pop()
    if n % 2 == 0:
        a.append(n//2)
        if n//2 in memory:
            memory.append(n//2)
            break
        else:
            memory.append((n//2))

    else:
        a.append(3*n+1)

        if 3*n+1 in memory:
            memory.append(3*n+1)
            break
        else:
            memory.append(3*n+1)

print(len(memory))

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


set_num = set()

set_num.add(s)
ans = 1

while True:
    ans += 1
    if s%2 == 1:
        s = s*3+1
    else:
        s = s//2
    if s in set_num:
        break
    else:
        set_num.add(s)

print(ans)

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

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

Solution (Python):
s = int(input())
cou = 1
tmp = 0
flag = 0
List = [s]
while(flag == 0):
  if(cou == 1):
    if(s % 2 == 0):
      tmp = s / 2
      List.append(tmp)
    else:
      tmp = 3 * s + 1
      List.append(tmp)
    cou += 1
  else:
    if(List.count(tmp) == 2):
      print(str(cou))
      break
    if(tmp % 2 == 0):
      tmp = tmp / 2
      List.append(tmp)
    else:
      tmp = 3 * tmp + 1
      List.append(tmp)
    cou += 1

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


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


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

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

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

i = 1
tmp = {s}
while True:
	res = f(s)
	if res not in tmp:
		tmp.add(res)
		s = res
	else:
		print(i+1)
		break
	i += 1

Solution (Python):
from sys import exit

def f(x):
	if x%2==0:
		return x//2
	else:
		return x*3+1
		
s=int(input())
A=[]
A.append(s)

for i in range(2,10**10):
	if f(s) in A:
		print(i)
		exit()
	else:
		s=f(s)
		A.append(s)

Solution (Python):

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

Solution (Python):
import itertools
import math
s =int(input())
a = s
count = 0
if a <= 2:
    print(4)
    quit()
if a == 3:
    print(9)
    quit()
while a >=4:
    if a % 2 == 0:
        a /= 2
    else:
        a = 3 * a + 1
    count += 1

print(count+3)

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

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

i = 1
num_list = [s]
while True:
    num_list.append(func(num_list[i-1]))
    if num_list[i] in num_list[:i-1]:
        print(i+1)
        break
    i += 1

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

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

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

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

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

Solution (Python):
s = int(input())
l = [s]
flag = True
i = 2
while flag:
  x = l.pop()
  y = x/2 if x%2==0 else 3*x+1
  l.append(x)
  if y in l:
    print(i)
    exit()
  l.append(y)
  i += 1