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: Wrong Answer

Solution code:
# coding: utf-8

n = int(input())

i = 0
while n > 0:
    if n % 2 == 0:
        n = n / 2
    else:
        n = n*3+1
    if n == 4:
        break
    else:
        i += 1

print(i+5)

Submission status: Wrong Answer

Solution code:
S=int(input())
count=1
for i in range(1000000):
    if S==8:
        print(count+4)
        break
    elif S%2==0:
        S//=2
        count+=1
    else:
        S=S*3+1
        count+=1

Submission status: Wrong Answer

Solution code:
n = int(input())
ls = [n]
m = 0

for i in range(1, 1000001):
    n = int(n/2) if int(n%2) == 0 else 3*n+1
    ls.append(n)
    if n == 4:
        break

print(ls.index(4)+4)

Submission status: Wrong Answer

Solution code:
n = int(input())
ls = []
m = 0

for i in range(1, 1000001):
    if int(n%2) == 0:
        n = int(n/2)
    else:
        n = 3*n+1

    if n in ls:
        m = i+1  # 答えは次のインデックス
        break
    ls.append(n)

print(m)

Submission status: Wrong Answer

Solution code:
s = int(input())

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

i = 0
count = 1

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

print(count + 3)

Submission status: Wrong Answer

Solution code:
s = int(input())

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

i = 0
count = 0

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

print(count + 3)

Submission status: Wrong Answer

Solution code:
s = int(input())

i = 1
m = 1000000
while s != 4 and i <= m:
    
    if s % 2 == 0:
        s = s/2
    else:
        s = 3*s+1
    
    i += 1

print(i+3)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = int(input())
a = 0
if s not in [1,2,4]:
    while s != 4:
        if s%2 == 0:
            s = s//2
        else:
            s = 3*s+1
        a += 1
    print(a+4)
else:
    print(3)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

A.append(s)
a = s
for i in range(100):
    if a % 2 == 0:
        a = int(a/2)
        A.append(a)
    else:
        a = 3*a+1
        A.append(a)
    if A.count(a) == 2:
        print(len(A))
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s = int(input())
a = [0] * 1
a[0] = s
ans = 0

for i in a:
    b = f(i)
    ans += 1
    if b in a:
        break
    a.append(b)
print(ans)

Submission status: Wrong Answer

Solution code:
s = int(input())

sum = 0
flag = 0
for i in range(1000):
    if s == 1 and flag == 0:
        print(0)
        exit()
    if s % 2 == 0:
        s = s // 2
    else:
        s = 3 * s + 1
    sum += 1
    if flag == 1 and s == 4:
        print(sum+1)
        exit()
    if s == 1:
        flag = 1

Submission status: Wrong Answer

Solution code:
s = int(input())

sum = 0
flag = 0
for i in range(1000):
    if s % 2 == 0:
        s = s // 2
    else:
        s = 3 * s + 1
    sum += 1
    if flag == 1 and s == 4:
        print(sum+1)
        exit()
    if s == 1:
        flag = 1

Submission status: Wrong Answer

Solution code:
s=int(input())
Key=False
a=[]
a.append(s)
cnt=2
t=0

while 1000000>cnt:
    if a[cnt-2]%2==0:
        a.append(int(a[cnt-2]/2))
    else:
        a.append(int(3*a[cnt-2]+1))
    cnt+=1
    
    if a[cnt-2]==4:
        t+=1
        if t==2:
            break


print(len(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = int(input())
count = 1


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

if s == 1:
    print(4)
elif s == 2:
    print(5)
else:
    while True:

        if s == 4:
            break
        else: 
            s = f(s)
            count += 1

    print(count + 3)

Submission status: Wrong Answer

Solution code:
s = int(input())
count = 1


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

while True:

    if s == 4:
        break
    else: 
        s = f(s)
        count += 1

print(count + 3)

Submission status: Wrong Answer

Solution code:
S = int(input())
counter = 0
ans = 1
if S <= 2:
    print('4')
    exit()
else:
    while True:
        if S % 2 == 0:
            S = S // 2
            ans += 1
            if S == 4:
                counter += 1
                if counter == 2:
                    print(ans)
                    exit()
        else:
            S = 3 * S + 1
            ans += 1
            if S == 4:
                counter += 1
                if counter == 2:
                    print(ans)
                    exit()

Submission status: Wrong Answer

Solution code:
a = [0 for i in range(3 * 1000000 + 1)]

s = int(input().rstrip())

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

Submission status: Wrong Answer

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

s = int(input())
ansFlg = True

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

ans = 1
while ansFlg:
    if s == 4:
        ans += 3
        break
    s = kansu(s)
    ans += 1
print(ans)

Submission status: Wrong Answer

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

s = int(input())
ansFlg = True

ans = 1
while ansFlg:
    if s == 4:
        ans += 3
        break
    s = kansu(s)
    ans += 1
print(ans)

Submission status: Wrong Answer

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

s = int(input())
ansFlg = True

ans = 1
while ansFlg:
    s = kansu(s)
    ans += 1
    if s == 4:
        ans += 3
        break
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
d = defaultdict(int)
a = int(input())
d[a] += 1

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
d = defaultdict(int)
a = int(input())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = int(input())
x = 0
if s ==1 or s == 1:
    print(4)
    exit()

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

Submission status: Wrong Answer

Solution code:
s = int(input())


for i in range(1000000):
    if s == 4:
        print(i + 4)
        break

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

Submission status: Wrong Answer

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

        for j in range(len(a)-1):
            if a[-1] == a[j]:
                ans = len(a)
                break
    else:
        print(ans)
        break

Submission status: Wrong Answer

Solution code:
s = int(input())


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


def insert(sslist, x):
    if not sslist:
        sslist.append(x)
        return False

    start = 0
    end = len(sslist)

    while start < end - 1:
        y = sslist[(start + end) // 2]
        if x == y:
            return True
        if x < y:
            end = (start + end) // 2
        if x > y:
            start = (start + end) // 2

    if sslist[start] == x:
        return True
    if sslist[start] < x:
        sslist.insert(start + 1, x)
        return False
    if sslist[start] > x:
        sslist.insert(start, x)
        return False


slist = []
ss = s
for i in range(2, 2**32):
    ret = insert(slist, ss)
    ss = f(ss)
    if ret:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
s = int(input())


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


def insert(sslist, x):
    if not sslist:
        sslist.append(x)
        return False

    start = 0
    end = len(sslist)

    while start < end - 1:
        y = sslist[(start + end) // 2]
        if x == y:
            return True
        if x < y:
            end = (start + end) // 2
        if x > y:
            start = (start + end) // 2

    if sslist[start] == x:
        return True
    if sslist[start] < x:
        sslist.insert(start + 1, x)
        return False
    if sslist[start] > x:
        sslist.insert(start, x)
        return False


slist = []
ss = s
for i in range(2, 2**32):
    ret = insert(slist, ss)
    print(slist)
    ss = f(ss)
    if ret:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
s = int(input())


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


def insert(sslist, x):
    idx = len(sslist) // 2
    sslen = len(sslist) // 2
    while True:

        if sslist[idx] < x:
            idx += sslen // 2 if sslen // 2 else 1
        elif sslist[idx] > x:
            idx -= sslen // 2 if sslen // 2 else 1
        elif sslist[idx] == x:
            return True

        idx = max(0, idx)
        idx = min(len(sslist) - 1, idx)

        if sslen == 0:
            sslist.insert(idx, x)
            return False
        sslen = sslen // 2


slist = [s]
ss = s
for i in range(2, 2**32):
    ss = f(ss)
    if insert(slist, ss):
        print(i)
        break

Submission status: Wrong Answer

Solution code:
#116 B
s =int(input())
lists=[]
lists.append(s)
for i in range(2,100):
    if lists[-1]%2==0:
        tmp=int(lists[-1]/2)
        lists.append(tmp)
        if lists.count(tmp)==2:
            print(i)
            exit()
    else:
        tmp=(3*lists[-1])+1
        lists.append(tmp)
        if lists.count(tmp)==2:
            print(i)
            exit()

Submission status: Wrong Answer

Solution code:
S = int(input())
counter = 0
ans = 1
while True:
    if S % 2 == 0:
        S = S // 2
        ans += 1
        if S == 4:
            counter += 1
            if counter == 2:
                print(ans)
                exit()
    else:
        S = 3 * S + 1
        ans += 1
        if S == 4:
            counter += 1
        if counter == 2:
            print(ans)
            exit()

Submission status: Wrong Answer

Solution code:
s = int(input())

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

Submission status: Wrong Answer

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

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

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

print(len(a)+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = int(input())
one = 0
two = 0
fou = 0
syo = True
ans = 1
while syo:
    if s == 1:
        print(3)
        break
    elif s == 2:
        print(3)
        break
    if s == 4:
        print(ans + 3)
        break
    if s%2 == 1:
        s = s*3+1
    else:
        s //= 2
    ans += 1

Submission status: Wrong Answer

Solution code:
# 2019/04/14
# AtCoder Beginner Contest 116 - B

s = int(input())
sl = list()
lflg = True
sl.append(s)
cnt = 1

while(lflg):
    cnt += 1
    if s % 2 == 0:
        s = s / 2
    else:
        s = 3 * s + 1
        for i in range(len(sl)):
            if s == sl[i]:
                print(cnt)
                lflg = False
                break
    sl.append(s)

Submission status: Wrong Answer

Solution code:
s = int(input())
progression = []
n = s
count = 1
while True:
    count += 1
    if n % 2 == 0:
        n = n/2
    else:
        n = 3 * n + 1

    if n in progression:
        break
    else:
        progression.append(n)

print(count)

Submission status: Wrong Answer

Solution code:
s = int(input())
progression = []
n = s
count = 1
while True:
    count += 1
    if n % 2 == 0:
        n = n//2
    else:
        n = 3 * n + 1

    if n in progression:
        break
    else:
        progression.append(n)

print(count)

Submission status: Wrong Answer

Solution code:
s = int(input())
progression = []
n = s
count = 1
while True:
    if n % 2 == 0:
        n = n//2
    else:
        n = 3 * n +1
    
    count += 1

    if n in progression:
        print(count)
        break
    else:
        progression.append(n)

Submission status: Wrong Answer

Solution code:
s = int(input())
a = s
already = set()
for i in range(10000000):
    if a % 2:
        a = 3 * a + 1
        if {a} <= already:
            print(i + 2)
            exit(0)
        already.add(a)
    else:
        a //= 2
        if {a} <= already:
            print(i + 2)
            exit(0)
        already.add(a)

Submission status: Wrong Answer

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

s = int(input())
#コラッツ予想を認める
n = 1
while s!=1:
    s = f(s)
    n += 1
print(n+1)

Submission status: Wrong Answer

Solution code:
s = int(input())

mp = dict()
cnt = 1
while True:
    if s % 2 == 0:
        s = s//2
    else:
        s = 3*s + 1

    cnt += 1

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

print(cnt)

Submission status: Wrong Answer

Solution code:
s = int(input())

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

    cnt2 += 1

    if s == 4:
        cnt1 += 1
    if cnt1 == 2:
        break

print(cnt2)

Submission status: Wrong Answer

Solution code:
a = int(input())
ans = 1 + 3

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

print(ans)

Submission status: Wrong Answer

Solution code:
s = int(input())
l = [s]
chk = 0
for i in range(10**6):
	if(s % 2 == 0):
		s = s/2
	else:
		s = 3*s+1
	s = int(s)
	print("{}, {}".format(l,s))
	for j in range(0,len(l)):
		if(l[j] == s):
			chk = 1
			break
	if(chk == 1):
		break
	l.append(s)
print(i+2)

Submission status: Wrong Answer

Solution code:
s = int(input())

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

a = list()
a.append(s)
for i in range(1000):
  a.append(func(a[i]))
for j in range(1001):
  for k in range(1001):
    if (j != k and a[j] == a[k]):
      print(k)
      exit()

Submission status: Wrong Answer

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

l = [0] * MAX
for i in range(MAX):
    temp = f(s)
    if l[temp]==1:
        print(i+2)
        exit()
    l[temp] = 1
    s = temp

Submission status: Wrong Answer

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

INF = 1000000

s = int(input())
a = [s] * (INF + 1)

answer = 0

for i in range(INF):
    if a[i] % 2 == 0:
        a[i+1] = int(a[i] / 2)
    else:
        a[i+1] = 3 * a[i] + 1
    for j in range(0,i):
        if a[i] == a[j]:
            answer = i+1
            break
    if answer != 0:
        break

print(a)
print(answer)

Submission status: Wrong Answer

Solution code:
s=int(input())
count=0
for i in range(1000000):
  if s%2==0:
    s=s//2
    count+=1
    if s==4:
      break
  else:
    s=s*3+1
    count+=1
print(count+4)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
res = 0
if(n == 1) : res = 2
if(n == 2) : res = 2  
while(n != 1) :
  if(n % 2 == 0) : n = n/2
  else : n = n*3+1
  res += 1
print(res+2)

Submission status: Wrong Answer

Solution code:
n = int(input())
res = 0
while(n != 1) :
  if(n % 2 == 0) : n = n/2
  else : n = n*3+1
  res += 1
print(res+2)

Submission status: Wrong Answer

Solution code:
s = int(input())

i = 0
count = 0
a = []
a.append(s)

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

print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=int(input())
def f(n):
    if n%2==0:
        return n//2
    else:
        return 3*n+1
cnt = 1
while True:
    s = f(s)
    if s == 1:
        print(cnt+2)
        break
    cnt+=1

Submission status: Wrong Answer

Solution code:
s=int(input())
def f(n):
    if n%2==0:
        return n/2
    else:
        return 3*n+1
cnt=2
while True:
    s=f(s)
    if s==1:
        print(cnt+1)
        break
    cnt+=1

Submission status: Wrong Answer

Solution code:
s = int(input())

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

print(a.index(4) + 4)

Submission status: Wrong Answer

Solution code:
s=int(input())
a=s
num=[s]
for i in range(2,10**7+1):
  if a%2==0:
    a=a//2
  else:
    a=3*a+1
  if a==4 or a==1 or a==2:
    ans=i+3
    break
print(ans)

Submission status: Wrong Answer

Solution code:
s=int(input())
a=s
num=[s]
for i in range(2,10**7+1):
  if a%2==0:
    a=a//2
  else:
    a=3*a+1
  if a==4:
    ans=i+3
    break
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
L=set();i=4
while 1:
  i+=1;N=N*3+1 if N%2 else N//2
  if N==4:print(i);exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
L=set();i=2
while 1:
  N=N*3+1 if N%2 else N//2
  if N in L:print(i);exit()
  else:L|={N};i+=1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

count = 0
b = []

while (len(b) == count):
    n = calc(n)
    if n not in b:
        b.append(n)
        count += 1
    else:
        print(count+2)
        break

Submission status: Wrong Answer

Solution code:
import math

s = int(input().strip())


def get_next(a):
    if a % 2 == 0:
        return math.floor(a / 2)
    else:
        return 3 * a + 1


flag = True
tmp = s
As  = []
counter = 1
while flag:
    nex = get_next(tmp)
    counter += 1
    tmp= nex
    if nex in As:
        flag = False
    As.append(nex)

print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = int(input())

a_set = set()

a_n = s
i = 1
while True:
    a_n_1 = (3 * a_n + 1 if a_n % 2 else a_n // 2)
    if a_n_1 in a_set:
        print(i + 1)
        break
    else:
        a_set.add(a_n_1)
        a_n = a_n_1
        i += 1

Submission status: Wrong Answer

Solution code:
import sys

s = int(sys.stdin.readline().strip())
a = s
a_all = []
a_all.append(a)

def fnc_odd(n):
    return 3*n+1
    
def fnc_even(n):
    return int(n/2)
    
i = 2

while (i<120):
    if(a%2==0):
        a = fnc_even(a)
        a_all.append(a)
    else:
        a = fnc_odd(a)
        print("now i,a:",i,a)
        a_all.append(a)
    if(i>3 and a_all[(i-3)-1]==a):
        break
    i += 1
        
print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
i = int(input())
seen = set()
seen.add(i)
temp = i
for x in range(2,1000000):
    if(temp%2 == 0):
        temp = temp/2
    else:
        temp = 3*temp+1
    if(temp in seen):
        print("out:{}".format(x))
        break
    else:
        seen.add(temp)

Submission status: Wrong Answer

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

s = int(input())
cnt = 1
while(s != 1):
  s = func(s)
  cnt += 1
print(cnt + 1)

Submission status: Wrong Answer

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

s = int(input())
cnt = 0
while(s != 1):
  s = func(s)
  cnt += 1
print(cnt + 1)

Submission status: Wrong Answer

Solution code:
#ABC 116 B
s = int(input())
i = 1
def collatz(x):
	if x%2 == 0:
		return int(x/2)
	else:
		return int(3*x+1)

while True:
	if s == 4:
		break
	else:
		s = collatz(s)
		i += 1

print(str(i+3))

Submission status: Wrong Answer

Solution code:
#ABC 116 B
s = int(input())
i = 1
def collatz(x):
	if x%2 == 0:
		return int(x/2)
	else:
		return int(3*x+1)

while True:
	s = collatz(s)
	i += 1
	if s == 4:
		break

print(str(i+3))

Submission status: Wrong Answer

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

while True:
	s = collatz(s)
	i += 1
	if s == 4:
		break

print(str(i+3))

Submission status: Wrong Answer

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

while s!=4:
  s = collatz(s)
  i += 1

print(str(i+3))

Submission status: Wrong Answer

Solution code:
s = int(input())

arr = [s]
i = 0
while 1:
    if arr[i] % 2 == 0:
        arr.append(arr[i] // 2)
    elif arr[i] % 2 == 1:
        arr.append(arr[i] * 3 + 1)
    i += 1
    if arr[i] == 4:
        print(i + 4)
        break

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

s = int(input())

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

print(len(ls))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = int(input())
a_prev = s
a_old = {}
for i in range(2,1000001):
    if a_prev % 2:
        a = 3 * a_prev + 1
    else:
        a = a_prev / 2
    if a in a_old:
        print(int(i))
        break
    else:
        a_old[a] = 1
        a_prev = a

Submission status: Wrong Answer

Solution code:
s = int(input())
a_prev = s
a_old = {}
for i in range(2,101):
    if a_prev % 2:
        a = 3 * a_prev + 1
    else:
        a = a_prev / 2
    if a in a_old:
        print(int(i))
        break
    else:
        a_old[a] = 1
        a_prev = a

Submission status: Wrong Answer

Solution code:
s = int(input())

ans = 0

def f(n, ans):
    ans += 1
    if n % 2:
        n = 3 * n + 1
    else:
        n = n / 2
    
    if n == 4:
        print(ans + 4)
        exit(0)
    return f(n, ans)

f(s, 0)

Submission status: Wrong Answer

Solution code:
s = int(input())
a_list = [s]
INF = 10 ** 5
for i in range(INF):
    value = a_list[-1]
    if value % 2 == 0:
        next_value = value / 2
        if next_value in a_list:
            print(a_list)
            print(i + 2)
            break
        else:
            a_list.append(int(next_value))
    else:
        next_value = (3 * value) + 1
        if next_value in a_list:
            print(a_list)
            print(i + 2)
            break
        else:
            a_list.append(int(next_value))

Submission status: Wrong Answer

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

s = int(input())
s_list = [f(s)]

while len(set(s_list)) == len(s_list):
    s_list.append(f(s_list[-1]))

print(len(s_list)+1)

Submission status: Wrong Answer

Solution code:
s, = (int(x) for x in input().split())

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

print(ncount+1)

Submission status: Wrong Answer

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