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 resolve():
    s=int(input())
    l=[s]
    while True:
        if l[-1]%2==0:
            if l[-1]//2 in l:
                print(len(l)+1)
                break
            else:
                l.append(l[-1]//2)
        else:
            if 3*l[-1]+1 in l:
                print(len(l)+1)
                break
            else:
                l.append(3 * l[-1] + 1)
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = int(input())
a_list = [s]
while True:
    # 偶数
    if a_list[-1] % 2 == 0:
        a = a_list[-1] / 2
    # 奇数
    else:
        a = 3 * a_list[-1] + 1
    
    if a in a_list:
        ans = len(a_list) + 1
        break
    
    a_list.append(a)

print(ans)

Submission status: Accepted

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

print(len(ans)+1)

Submission status: Accepted

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

Submission status: Accepted

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

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]
i = 1
while True:
    i += 1
    p = f(a[-1])
    if p in a:
        print(i)
        break
    a.append(p)

Submission status: Accepted

Solution code:
s = int(input())

l = list()
l.append(s)

num = s

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

print(len(l)+1)

Submission status: Accepted

Solution code:
s = int(input())

la = [s]

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

Submission status: Accepted

Solution code:
def solve():
   N = int(input())
   table = [False] *1000000
   table[N] = True
   count = 1
   while True:
       if N&1:
           N = 3*N + 1
       else:
           N = N//2
       count += 1
       if not table[N]:
           table[N] = True
       else:
           print(count)
           break

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys

s=int(input())

if s==1 or s==2:
    print(4)
else:
    cnt=1
    tmp=s
    while True:
        if tmp==4:
            print(cnt+3)
            break
        cnt+=1
        if tmp%2==0:
            tmp=tmp/2
        else:
            tmp=tmp*3+1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=set()
s=int(input())
ans=0
while True:
    ans+=1
    if s in x:
        print(ans)
        break
    x.add(s)

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

Submission status: Accepted

Solution code:
s = int(input())
v = [False] * (10**6 + 1)

v[s] = True
a = s

for i in range(2, 10**6+1):
    if a % 2 == 0:
        a = a // 2
    else:
        a = 3 * a + 1

    if v[a]:
        break
    else:
        v[a] = True

print(i)

Submission status: Accepted

Solution code:
def I(): return int(input())
N = I()
ans = 0
a = [N]
set_a ={N}
i = 0
while 1:
    i += 1
    if a[i-1]%2==0:
        a.append(a[i-1]//2)
    else:
        a.append(a[i-1]*3+1)
    if a[i] in set_a:
        print(i+1)
        break
    else:
        set_a.add(a[i])

Submission status: Accepted

Solution code:

import numpy as np
import sys

input = sys.stdin.readline

s = int(input())

if s == 1 :
    n = 2
elif s == 2:
    n = 1
else:
    n = 3

ans = 1

while s != 4:
    if s%2 == 0 :
        s = s/2
    else:
        s = 3*s + 1
    
    
    ans+=1


print(ans+n)

Submission status: Accepted

Solution code:
s = int(input())

d = {}

n = 1

while s not in d:
    d[s] = n
    if s % 2 == 0:
        s = s // 2
    else:
        s = 3 * s + 1
    n += 1

print(n)

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(int)
import sys
sys.setrecursionlimit(10**8)
def f(n,i):
  d[n]+=1
  if d[n]==2:
    return i
  if n%2==0:
    x=n//2
  else:
    x=3*n+1
  return f(x,i+1)
print(f(int(input()),1))

Submission status: Accepted

Solution code:
s = int(input())

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


a_list = [s]
i = 1
while True:
    if i == 1:
        pass
    else:
        n = a_list[i-2]
        a_list.append(func(n))
    i += 1
    if len(a_list) != len(set(a_list)):
        print(len(a_list))
        break

Submission status: Accepted

Solution code:
import numpy as np
n = int( input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = int(input())

List = []
List.append(s)

if s==1 or s==2 or s==4:
    print(4)

else:
    for i in range(1000000):
        if List[i]%2 == 0:
            List.append(List[i]/2)
        else:
            List.append(List[i]*3+1)
        if List[i+1] == 4:
            Answer=i+5
            break

    print(Answer)

Submission status: Accepted

Solution code:
import math
import sys


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


s = int(input())
list = [s]
x = s
cnt = 1
while(True):
    x = f(x)
    cnt += 1
    if x in list:
        break
    else:
        list.append(x)

print(cnt)

Submission status: Accepted

Solution code:
s = int(input())
apple = []
count = 0

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

while s not in apple:
    apple.append(s)
    s = func_1(s)
    count += 1
else:
    print(count + 1)

Submission status: Accepted

Solution code:
s=int(input())
l=[]
cnt=0
while True:
    if s not in l:
        l.append(s)
        cnt +=1
    else:
        print(cnt+1)
        break

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

Submission status: Accepted

Solution code:


def solve():

    S = int(input())
    list = []
    list.append(S)

    i = 0

    while True:
        s = list[i]

        v = 0

        if s % 2 == 0:
            v = s//2
            if v in list:
                print(i+2)
                exit()
            list.append(v)
        else:
            v = 3*s+1
            if v in list:
                print(i+2)
                exit()
            list.append(v)

        i += 1


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

s = INT()
ans = 4
while not (s == 4 or s == 2 or s == 1):
    if s % 2 == 0:
        s //= 2
    else:
        s = s * 3 + 1
    ans += 1
print(ans)

Submission status: Accepted

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


check = [False for _ in range(1000005)]

s = int(input())
cnt = 1
check[s] = True
while (1):
    s = f(s)
    cnt += 1
    if check[s]:
        print(cnt)
        exit()
    else:
        check[s] = True

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def F(x):
    if x&1:
        return 3*x + 1
    else:
        return x // 2

S = ir()
se = set()
dp = S; se.add(dp)
count = 1
while True:
    count += 1
    dp = F(dp)
    if dp in se:
        break
    se.add(dp)

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = int(input())

count = 1

x = [0] * 1000000
x[s] = 1
while True:
    if s % 2 == 0:
        s = s / 2
    else:
        s = 3 * s + 1
    count += 1
    if x[int(s)] == 1:
        print(count)
        break
    else:
        x[int(s)] = 1

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = INT()
a = [s]
i = 0
p = len(set(a))-1

while p+1 == len(set(a)):
	p = 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)

Submission status: Accepted

Solution code:
s = int(input())
A = []
B = zip(A)
i = s
count = 0
while i not in A:
    A.append(i)
    if i % 2 == 0:
        i /= 2
    else:
        i = 3*i+1
    count += 1

print(count+1)

Submission status: Accepted

Solution code:
s = int(input())

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

print(i)

Submission status: Accepted

Solution code:
N = int(input())

if N == 1 or N == 2:
	print(4)
else:
	m = 0
	while N > 1:
		if N % 2 == 0:
			N = N // 2
		else:
			N = 3 * N + 1
		m += 1
	print(m+2)

Submission status: Accepted

Solution code:
s = int(input())

def odd(i):
    return int(3*i+1)

def even(i):
    return int(i/2)

lib = {
    s: 0
}


index = 1

while True:
    if s % 2 == 0:
        s = even(s)
    else:
        s = odd(s)
    
    if s not in lib.keys():
        lib[s] = index
        index += 1
    else:
        index+=1
        break


print(index)

Submission status: Accepted

Solution code:
s = int(input())

lst = [s]

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

Submission status: Accepted

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


a = int(input())
s = set()
m = 1
while a not in s:
    s.add(a)
    a = f(a)
    m += 1
print(m)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = [0]*10000
    a[n] = 1
    cnt = 1
    while True:
        if n%2 == 0:
            n //= 2
        else:
            n = 3*n + 1
        cnt += 1
        if a[n] == 1:
            print(cnt)
            break
        else:
            a[n] = 1

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = int(input())
l = []
while not s 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:
from collections import deque, defaultdict

S = int(input())


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


d = defaultdict(int)
ans = deque()
ans.append(S)
# print(f(S, ans))
for i in range(1, 10**6):
    ans.append(f(ans[i - 1]))

for i, v in enumerate(ans):
    d[v] += 1
    if (d[v] == 2):
        print(i + 1)
        break

Submission status: Accepted

Solution code:
s = int(input())

fn = lambda n: n / 2 if n % 2 == 0 else 3 * n +1

results = [s]
result = s
m = 1
while True:
    result = fn(result)
    m += 1
    if result in results: break

    results.append(result)

print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def Collatz_Problem(n):

    ans = 1
    count = []
    while True:
        if n in count:
            break
        else:
            count.append(n)
        if n%2 == 0:
            n = n/2
        else:
            n = 3*n+1
        ans += 1


    return ans

def main():
    n = int(input())
    print(Collatz_Problem(n))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    s = int(input())
    M = 2 * (10**6)
    A = [False] * (M+1)
    A[s] = True
    pre = s
    count = 1
    while True:
        count += 1
        if pre%2==1:
            now = 3*pre + 1
        else:
            now = pre//2
        if A[now] == False:
            A[now] = True
            pre = now
            continue
        else:
            print(count)
            break


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = int(input())

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

a = {}
a[1] = s

i = 2
while True:
    tmp = func(a[i-1])
    if tmp in a.values():
        print(i)
        break
    else:
        a[i] = tmp
        i += 1

Submission status: Accepted

Solution code:
a=input()
b=int(a)
c=[b]
num=1
while True:
    if b%2==0:
        num+=1
        if c.count(b/2)==0:
            c.append(b/2)
            b=b/2
        else:
            print('%d'%num)
            break
    else:
        num+=1
        if c.count(3*b+1)==0:
            c.append(3*b+1)
            b=3*b+1
        else:
            print('%d'%num)
            break

Submission status: Accepted

Solution code:
a = int(input())
if a == 1 or a == 2:
    print(4)
else:
    i = 1
    while a != 4:
        if a%2 == 0:
            a //= 2
        else:
            a = 3*a+1
        i += 1
    print(i+3)

Submission status: Accepted

Solution code:
s = int(input())

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

a = []
i = 1
while True:
    if s in a:
        print(i)
        exit()
    else:
        a.append(s)
        s = f(s)
        i+=1

Submission status: Accepted

Solution code:

import math
N= int(input())
nums = set()
f = lambda x: x//2 if x % 2 == 0 else 3 * x + 1
nums.add(N)
before = N

for i in range(1,1000005):
    new_num = f(before)

    if new_num in nums:
        print(i + 1)
        exit(0)
    else:
        nums.add(new_num)
        before = new_num

Submission status: Accepted

Solution code:
s = int(input())

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

Submission status: Accepted

Solution code:
s=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = int(input())
list = [s]
for i in range(1, 1000001):
    if list[i-1]%2==0:
        a = int(list[i-1]/2)
    elif list[i-1]%2==1:
        a = 3*(list[i-1])+1

    if a in list:
        print(i+1)
        break
    else:
        list.append(a)

Submission status: Accepted

Solution code:
import bisect
s=int(input())
a=[]
ans=1
x=s
def coll(x):
  if x%2==0:
    return x//2
  else:
    return x*3+1

while x not in a:
  bisect.insort_left(a,x)
  ans+=1
  x=coll(x)

print(ans)

Submission status: Accepted

Solution code:
def fn(num):
    if num%2==0:
        return int(num/2)
    else:
        return int((3*num)+1)
        
s=int(input())
ans=[s]
count=0
ns=s
while True:
    ns=fn(ns)
    if ns in ans:
        ans.append(ns)
        break
    ans.append(ns)
print (len(ans))

Submission status: Accepted

Solution code:
s = int(input())
l = [s]
ans = True
while ans:
    m = len(l)
    if l[m - 1] % 2 == 0:
        l.append(l[m - 1] // 2)
    else:
        l.append(3 * l[m - 1] + 1)
    for i in range(m):
        if l[i] == l[m]:
            print(m + 1)
            ans = False

Submission status: Accepted

Solution code:
s = int(input())

tmp = s
a = [s]

while True:
    if tmp % 2 == 0:
        num = (tmp // 2)
        a.append(num)
        tmp = num
    else:
        num = 3 * tmp + 1
        a.append(num)
        tmp = num
    if a.count(tmp) == 2:
        print(len(a))
        break

Submission status: Accepted

Solution code:
icase=0
if icase==0:
    aset=set()
    s=int(input())
    aset.add(s)
    for m in range(2,1000001):
        if s%2==0:
            s=s//2
        else:
            s=3*s+1
        if s in aset:
            print(m)       
            break
        else:
            aset.add(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    s = int(input())
    an = list()
    a = 0
    for i in range(1000000):
        if i == 0:
            a = s
            an.append(a)
        else:
            if a % 2 == 0:
                a = int(a/2)
                an.append(a) 
            else:
                a = 3*a + 1
                an.append(a)
    for i in range(1000000):
        try:
            m = an.index(an[i], i+1)
            print(m+1)
            break
        except:
            continue
main()

Submission status: Accepted

Solution code:
def main():
    s = int(input())
    an = list()
    a = 0
    for i in range(1000000):
        if i == 0:
            a = s
            an.append(a)
        else:
            if a % 2 == 0:
                a = int(a/2)
                an.append(a) 
            else:
                a = 3*a + 1
                an.append(a)
    for i in range(1000000):
        a = an[i]
        try:
            m = an.index(a, i+1)
            if m != -1:
                print(m+1)
                break
        except:
            continue
main()

Submission status: Accepted

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

for i in range(1,1000000):
    a.append(F(a[i-1]))
    if a[i] in a[:i]:
        ans=i+1
        break 

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    s = int(input())
    a_set = set()
    a = s
    cnt = 1
    while a not in a_set:
        cnt += 1
        a_set.add(a)
        if a % 2 == 0:
            a = a // 2
        else:
            a = a * 3 + 1
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = int(input())
li = [s]
num = s

for i in range(1,1000000):
    if num%2 == 0:
        num = num//2
    else:
        num = 3*num+1
    if num in li:
        print(i+1)
        exit(0)
    else:
        li.append(num)

Submission status: Accepted

Solution code:
n = int(input())

n_li = [n]
while True:
    if n%2==0:
        n = n/2
    elif n%2!=0:
        n = 3*n+1

    if n in n_li:
        break
    else:
        n_li.append(n)
print(len(n_li)+1)

Submission status: Accepted

Solution code:
# ABC 116: B – Collatz Problem
s = int(input())
a = []
b = s
m = 1

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

print(m)

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]
i = 0

while len(a) == len(set(a)):
    a.append(f(a[i]))
    i += 1

print(i+1)

Submission status: Accepted

Solution code:
s = int(input())

nums = {s}
while True:
    if s % 2 == 0:
        s //= 2
    else:
        s = 3 * s + 1
    if s in nums:
        break
    nums.add(s)

print(len(nums)+1)

Submission status: Accepted

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

s = int(input())
ans = [s]
while True:
  s = func(s)
  if s in ans:
    ans.append(s)
    print(len(ans))
    break
  ans.append(s)

Submission status: Accepted

Solution code:
# solution
import io

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s=int(input())
a={s}
def f(x):
  if x%2==0:
    return x//2
  else:
    return 3*x+1
ax=f(s)
m=2
while ax not in a:
  a.add(ax)
  ax=f(ax)
  m+=1
print(m)

Submission status: Accepted

Solution code:
s = int(input())
li = [s]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict


def check(num):
    if num in dic:
        print(len(f)+1)
        exit()
    else:
        f.append(num)
        dic[num] = 1


if __name__ == "__main__":
    s = int(input())

    dic = defaultdict(int)
    f = list()
    dic[s] = 1
    f.append(s)

    while True:
        if f[len(f)-1] % 2 == 0:
            tmp = f[len(f)-1] // 2
            check(tmp)
        else:
            tmp = f[len(f)-1] * 3 + 1
            check(tmp)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = int(input())

L =[]
for _ in range(10**6):
  L.append(0)

for i in range(10**6):
  L[S-1] += 1
  #print(L)
  if L[S-1] > 1:
    print(i+1)
    break
  
  if S%2 == 0:
    S = S//2
  else :
    S = S*3 + 1

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8

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

def main():
    s = int(input())
    a = set()


    while True:
        if s in a:
            print(len(a)+1)
            break
        a.add(s)
        s = collatz(s)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=int(input())
List=[s]
ns=0
bs=s
for i in range(2,10**6+1):
  if (bs%2==0):
    ns=bs//2
  else:
    ns=3*bs+1
  if (List.count(ns)>0):
    print(i)
    #print(List)
    break
  else:
    List.append(ns)
    bs=ns

Submission status: Accepted

Solution code:
s = int(input())

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

a = []
a.append(s)
for i in range(1000001):
    tmp = collatz(a[i])
    if tmp in a:
        print(len(a)+1)
        exit()
    a.append(tmp)

Submission status: Accepted

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