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



Sample input:
8


Sample output:
5

Submission status: Accepted

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

dic = {}
s = int(input())
dic[s] = 1
cnt = 1
while True:
  s = f(s)
  if s in dic.keys():
    print(cnt+1)
    break
  else:
    dic[s] = 1
    cnt += 1

Submission status: Accepted

Solution code:
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]:
    print(i+2)
    exit()
  i+=1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    s = int(input())
    i = 1
    seen = {s}
    while True:
        i += 1
        if s & 1:
            s = s*3+1
        else:
            s //= 2
        if s in seen:
            print(i)
            break
        else:
            seen.add(s)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=int(input())

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

d={}
for i in range(10000001):
    d[i]=0

now =s
d[now]=1
num =1
while True:

    now = collatz(now)
    num +=1

    if d[now]!=0:
        print(num)
        exit(0)
    else:
        d[now]+=1

Submission status: Accepted

Solution code:
def even(num):
    return int(num / 2)


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


def main():
    s = int(input())
    tmp = s
    list = [s] * 1
    i = 0
    
    while True:
        i += 1
        if tmp % 2 == 0:
            tmp = even(tmp)
        else:
            tmp = odd(tmp)
        if tmp in list:
            break
        list.append(tmp)
    
    ans = i + 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=int(input())
f=lambda n:[3*n+1, n/2][n%2<1]
x=[s]
i=0
while(True):
    n=int(f(x[i]))
    if n in x:
        print(i+2)
        break
    x.append(n)
    i+=1

Submission status: Accepted

Solution code:
s=int(input())

dic=[]

dic.append(s)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# input
s = int(input())

# check
lim = 1000001
# 初項が 4 or 2 or 1 なら
# 4, 2, 1, 4, 2, 1, …
# となるので、答えは4になる
if s == 1 or s == 2:
  print(4)
else:

    c4 = 0
    c = 1
    for m in range(2, lim):
        # 4の出現回数をカウントする
        if s == 4:
            c4 += 1

        # 2回4が出てきたら終了
        if c4 == 2:
            print(c)
            exit()

        # 指示された操作
        if s % 2 == 0:
            s //= 2
        else:
            s = 3 * s + 1

        # 項番をインクリメント
        c += 1

Submission status: Accepted

Solution code:
s = int(input())

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

a = [s]
ans = 1

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

Submission status: Accepted

Solution code:
N = int(input())
if N == 1 or N == 2:
  print(4)
  exit()
ans = 1
while N != 4:
  N = N // 2 if not N % 2 else N * 3 + 1
  ans += 1

print(ans + 3)

Submission status: Accepted

Solution code:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())

ans = 0
s = set()

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

print(ans+1)

Submission status: Accepted

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


s = int(input())
a = {s}
while True:
    s = f(s)
    if s in a:
        break
    a.add(s)
print(len(a) + 1)

Submission status: Accepted

Solution code:
s = int(input())
a = [s]
for i in range(10**6):
    if int(a[i]/2)*2 == a[i]:#偶数
        a.append(a[i]/2)
    else:
        a.append(a[i]*3 +1)

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)
#print(a)
i = 1
while True:
    if(a[i]%2 == 0):
        a.append(int(a[i]/2))
    else:
        a.append(3*a[i]+1)
    #print(a)
    if(a[i] in a[0:i-1]):
      print(i+1)
      exit()
    i = i + 1

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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): # root
		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): # much time
		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()} # 1~n
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): #j:aの個数
			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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# B - Collatz Problem

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
N = int(input())
#A = list(map(int,input().split()))

a=[0]*10**7
c=1
b=[]
a[N]+=1
for i in range(10**6+100):
    #print(b)
    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()

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    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:
        # print(d)
        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()

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
N = int(input())

x = {i:0 for i in range(50000)}
i = 1
while True:
  #print(N)
  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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
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))
#%%code

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
        
        

#%%submit!    
resolve()

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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