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:
A=input()
i=1
a = int(A)
while True:
	if a % 2 == 1:
		a = a*3+1
	elif a == 4:
		print(i+3)
		break
	else:
		a /= 2
	i += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def even(n):
  return n//2
def odd(n):
  return 3*n+1
s=int(input())
c=0
while 1:
  if s%2==0:
    s=even(s)
  else:
    s=odd(s)
  c+=1
  if s==4:
    print(c+4)
    exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = int(input())

#関数f(n)の定義
def f(n):
  if n % 2 == 0:
    n = n/2
  else:
    n = 3 * n + 1
  return n
    
#数列anの作成
a = []
c = []  # 比較用のaのコピー数列
i = 1
a.append(s)
while i <= 1000000:
  a.append(f(a[i-1]))
  if a[i] in c:
    index = a.index(a[i])
    print(i +1)
    break
  c.append(a[i])
  i += 1

Submission status: Wrong Answer

Solution code:
s = int(input())

#関数f(n)の定義
def f(n):
  if n % 2 == 0:
    n = n/2
  else:
    n = 3 * n + 1
  return n
    
#数列anの作成
a = []
c = []  # 比較用のaのコピー数列
i = 1
a.append(s)
while i < 1000000:
  a.append(f(a[i-1]))
  if a[i] in c:
    index = a.index(a[i])
    print(i +1)
    break
  c.append(a[i])
  i += 1

Submission status: Wrong Answer

Solution code:
s=int(input())
z=[s]
for _ in range(100000):
    if z[-1]%2==0:
        z.append(z[-1]//2)
    else:
        z.append(3*z[-1]+1)
    if z[-1]==4:
        print(len(z)+3)
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s = int(input())

n = s
for i in range(1000000):
  try:
    ind = [1,2,4].index(n)
    print(ind+i+2)
    break
  except:
    n = next_num(n)

Submission status: Wrong Answer

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

s = int(input())

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

Submission status: Wrong Answer

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

s = int(input())

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

Submission status: Wrong Answer

Solution code:
s = int(input())


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

a = set()
m = 1
while True:
    s = f(s)
    m += 1
    if s in a:
        break
    else:
        a.add(s)
print(m)

Submission status: Wrong Answer

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

s = int(input())

data = set()

for i in range(1000010):
    l = len(data)
    val = func(s)
    data.add(val)
    if l == len(data):
        print(i+2)
        break
    s = val

Submission status: Wrong Answer

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

s = int(input())

data = set()
l = 100
for i in range(1000010):
    val = func(s)
    data.add(val)
    if l == len(data):
        print(i+2)
        break
    s = val
    l = len(data)

Submission status: Wrong Answer

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

s = int(input())

data = set()
l = 100
for i in range(1000000):
    val = func(s)
    data.add(val)
    if l == len(data):
        print(i+2)
        break
    s = val
    l = len(data)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def sol(a):
    dp = [a]
    #print(dp)
    for i in range(1, 1000000+1):
        x = dp[i-1]
        ans = f(x)
        if ans in dp:
            #print(i, ans, dp)
            return i+1
        else:
            dp.append(ans)
    return None

Submission status: Wrong Answer

Solution code:

s = int(input())

val = s
mp = {}
i= 1
while True:
  i+=1
  if val%2==0:
    val = val//2
  else:
    val = 3*val+1
  
  if val in mp:
    print(i)
    break
  else:
    mp[val] = 1

Submission status: Wrong Answer

Solution code:

s = int(input())

val = s
mp = {}
i= 0
while True:
  i+=1
  if val%2==0:
    val = val//2
  else:
    val = 3*val+1
  
  if val in mp:
    print(i)
    break
  else:
    mp[val] = 1

Submission status: Wrong Answer

Solution code:
import sys
a = int(input())
numlist = [a]
for i in range(2,20):
    if a % 2 ==0:
        a //= 2
        numlist.append(a)
    else:
        a = a*3 + 1
        numlist.append(a)
#print(numlist)
kind = {}
count = 0
for s in numlist:
    count += 1
    if s in kind:
        print(count)
        sys.exit()
    else:
        kind[s] = 1

Submission status: Wrong Answer

Solution code:
#abc116c
import sys

n=int(raw_input())
if n==1:
 print 4
 sys.exit()
j=0
while j<1000000:
 if n%2==0:
  n=n/2
 else:
  n=n*3+1
 if n==4:
  print j+5
  break 
 j+=1

Submission status: Wrong Answer

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


s = int(input())
a = [s]
ans = 0
for i in range(1,1000000):
    ai = f(a[i -1])
    if a.count(ai) == 1:
        ans = i + 1
        break
    a.append(ai)

Submission status: Wrong Answer

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

s = int(input())
a = [s]
ans = 0
for i in range(1, 1000000):
  ai = f(a[i - 1])
  if a.count(ai) == 1:
    ans = a.index(ai)
    break
  a.append(ai)
print(ans)

Submission status: Wrong Answer

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

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

print(len(a) + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = int(input())
an = []
an.append(s)
n = s
while an.count(4) != 2:
    if n % 2 == 0:
        n /= 2
        an.append(int(n))
    else:
        n = 3 * n + 1
        an.append(int(n))
if an.index(1) or an.index(2) == 0:
    print(4)
else:
    print(an.index(4) + 4)

Submission status: Wrong Answer

Solution code:
s = int(input())
an = []
an.append(s)
n = s
while an.count(4) != 2:
    if n % 2 == 0:
        n /= 2
        an.append(int(n))
    else:
        n = 3 * n + 1
        an.append(int(n))
if an.index(1 or 2) == 0:
    print(4)
else:
    print(an.index(4) + 4)

Submission status: Wrong Answer

Solution code:
s = int(input())
an = []
an.append(s)
n = s
while an.count(1 or 2 or 4) != 2:
    if n % 2 == 0:
        n /= 2
        an.append(int(n))
    else:
        n = 3 * n + 1
        an.append(int(n))
if an.index(1 or 2) == 0:
    print(4)
else:
    print(an.index(4) + 4)

Submission status: Wrong Answer

Solution code:
s = int(input())
an = []
an.append(s)
n = s
while an.count(1 or 2 or 4) != 2:
    if n % 2 == 0:
        n /= 2
        an.append(int(n))
    else:
        n = 3 * n + 1
        an.append(int(n))
print(an.index(1 or 2 or 4) + 4)

Submission status: Wrong Answer

Solution code:
s = int(input())
an = []
an.append(s)
n = s
while an.count(1 or 2 or 4) != 2:
    if n % 2 == 0:
        n /= 2
        an.append(int(n))
    else:
        n = 3 * n + 1
        an.append(int(n))
print(an.index(4) + 4)

Submission status: Wrong Answer

Solution code:
s = int(input())
an = []
an.append(s)
n = s
while an.count(4) != 2:
    if n % 2 == 0:
        n /= 2
        an.append(int(n))
    else:
        n = 3 * n + 1
        an.append(int(n))
print(an.index(4) + 4)

Submission status: Wrong Answer

Solution code:
n = raw_input()
n = int(n)

n_dict = {n:0}
cont = 1
while n_dict[n]<=1:
	if n%2==0:
		n = n/2
	else:
		n = 3*n+1
	n_dict[n] = n_dict.get(n,0)+1
	cont += 1
print(cont)

Submission status: Wrong Answer

Solution code:
n = raw_input()
n = int(n)

cont = 1
while n>1:
	if n%2==0:
		n = n/2
	else:
		n = 3*n+1
	cont += 1
print(cont+1)

Submission status: Wrong Answer

Solution code:
n, = map(int,input().split())

cnt = 1
if (n == 1):
    print("3")
    exit(0)
while(n!=1):
    if (n%2==0):
        n //=2
    else:
        n = 3*n + 1
    cnt += 1
print(cnt + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = int(input())

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

for i in range(1000001):
    if f(a[i]) in a:
        print(i+1)
        break
    a.append(f(a[i]))

Submission status: Wrong Answer

Solution code:


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

s = int(input())


memo = set()
for i in range(2, 1000000):
    tmp = f(s)
    # print(tmp)
    if tmp in memo:
        print(i)
        break
    memo.add(tmp)
    s = tmp

Submission status: Wrong Answer

Solution code:
a = int(input())

def func_1(x):
    return x//2

def func_2(x):
    return 3*x+1

dp = [0] * 1000000

c = 1
while True:
    c += 1
    if a % 2 == 0:
        a = func_1(a)
    else:
        a = func_2(a)

    if dp[a] > 0:
        print(c)
        break
    else:
        dp[a] = 1

Submission status: Wrong Answer

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

i = 2
x = int(input())

while(x != 1):
    i += 1
    x = collatz(x)
    
print(i)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
s = int(input())

dp = [s]

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

print(i)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
s = int(input())

dp = []

i=2
a_1=s
while(True):
    if(a_1 % 2==0):
        index = a_1 /2
    else:
        index = 3 * a_1 + 1
    
    if int(index) in dp:
        break
    else:
        dp.append(int(index))
        a_1 = int(index)
        i+=1

print(i)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
s = int(input())

dp = [0] * 1000000

i=2
a_1=s
while(True):
    if(a_1 % 2==0):
        index = a_1 /2
    else:
        index = 3 * a_1 + 1
    
    if dp[int(index)-1] > 0:
        break
    else:
        dp[int(index)-1] +=1
        a_1 = int(index)
        i+=1

print(i)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
s = int(input())

dp = [0] * 1000000

i=2
a_1=s
while(True):
    if(a_1 % 2==0):
        index = a_1 /2
    else:
        index = 3 * a_1 + 1
    
    if dp[int(index)] > 0:
        break
    else:
        dp[int(index)] +=1
        a_1 = int(index)
        i+=1

print(i)

Submission status: Wrong Answer

Solution code:
init = int(input())

m = 1000000


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


ls = [init]
s = init
flag = 1
while 1:
    ls.append(f(s))
    s = f(s)
    # print(s)
    if s == 1 and flag == 1:
        flag = 0
    elif s == 1 and flag == 0:
        break

if init == 2:
    print(3)
elif init == 1:
    print(4)
else:
    # print(ls)
    print(len(ls)-2)

Submission status: Wrong Answer

Solution code:
from collections import Counter

s = int(input())
a = [s]
def f_even(n):
    return n//2
def f_odd(n):
    return 3*n + 1
for i in range(100):
    if a[i]%2 == 0:
        a.append(f_even(a[i]))
    else:
        a.append(f_odd(a[i]))
    tmp = Counter(a).most_common()[0]
    if tmp[1] > 1:
        print(i+2)
        break

Submission status: Wrong Answer

Solution code:
s = int(input())
vals = []
vals += [s]
n=1
while True:
    if vals[n-1]%2==0:
        val = vals[n-1]/2
    else:
        val = vals[n-1]*3+1
        
    if val in vals:
        print(val)
        break
    else:
        vals += [val]
        n += 1

Submission status: Wrong Answer

Solution code:
S = int(input())
cache = {}
cache[S] = 1
for i in range(100):
  if i % 2 == 0:
    S = S // 2
  else:
    S = 3 * S + 1
  if cache.get(S):
    print(i + 2)
    exit()
  cache[S] = 1

Submission status: Wrong Answer

Solution code:
#n = map(int,input().split())
mlist = list(map(int,input().split()))

i=0
while(True):

    if mlist[i] % 2 == 0:
        mlist.append(mlist[i]/2)
    else:
        mlist.append(3*mlist[i]+1)
    print(mlist[i+1])
    i=i+1
    
    if int(mlist[0])==int(mlist[i]):
        break
    
print(i)

Submission status: Wrong Answer

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

four = 0
count = 1
s = int(input())
while True:
    count += 1
    s = fc(s)
    if s==4:
        if four==0:
            four = 1
        else:
            print(count)
            break

Submission status: Wrong Answer

Solution code:
s = int(input())
result_list=[]
i=1
while len(set(result_list))==len(result_list):
    i+=1
    if(s%2==0):
        out = int(s/2)
        result_list.append(out)
        s = out
    else:
        out = int(3*s + 1)
        result_list.append(out)
        s=out

print(i)

Submission status: Wrong Answer

Solution code:
n = int(input())
cnt,cnt_1 = 0,0
while n!=1 or cnt_1!=2:
    if n%2==0:
        n//=2
    else:
        n = n*3+1
    cnt += 1
    if n==1:
        cnt_1+=1
print(cnt-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = int(input())
time = 0
ch = 2
while True:
    time += 1
    if a == 4:
        ch -= 1
        if ch == 0:
            break
    if a % 2 == 0:
        a = a / 2
    else:
        a = a * 3 + 1

print(int(time))

Submission status: Wrong Answer

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

time += 4
print(int(time))

Submission status: Wrong Answer

Solution code:
import math
import sys
from operator import itemgetter

# N, K = map(int, input().split())
# h = list(map(int, input().split()))
# S = [input() for _ in range(H)]
# X = [[0 for j in range(100)] for i in range(200)]


### input
a = list(range(0))
a.append(int(input()))

## solve
ans = 0
while(ans == 0):
	p = 0
	if (a[-1] % 2 == 0):
		p = a[-1]//2
	else:
		p = a[-1]*3+1
	
	if (p in a):
		ans = a.index(p)
	elif (p == 1):
		ans = len(a)+2
	else:
		a.append(p)

print(ans)

Submission status: Wrong Answer

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

def ans1(s):
    a = list()
    a.append(s)
    a.append(f(s))

    while True:
        x = f(a[-1])
        if x in a:
            return len(a) + 1
        else:
            a.append(x)

def ans2(s):
    n = s
    i = 0
    while n != 4:
        n = f(n)
        i += 1
    return i + 4

s = int(input())
print(ans2(s))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l = list()
l.append(int(input()))
s = set(l)

while(1):
    if(int(l[-1] / 2)):
        l.append(l[-1]/2)
    else:
        l.append(l[-1]*3 + 1)
    s = set(l)
    if(len(s) != len(l)):
        print(len(l))
        break

Submission status: Wrong Answer

Solution code:
import numpy as np
import gc

if __name__ == '__main__':
    s=int(input())
    l=[]
    l.append(s)
    flag=False
    for i in range(1,1000000):
        if s%2:
            s=3*s+1
        else:
            s=s/2
        l.append(s)
        for j in range(0,i-1):
            if i>3 and s==l[j]:
                print(i+1)
                del l
                gc.collect()
                flag=True
                break
        if flag:
            break

Submission status: Wrong Answer

Solution code:
import numpy as np
import gc

if __name__ == '__main__':
    s=int(input())
    l=[]
    l.append(s)
    flag=False
    for i in range(1,1000000):
        if s%2:
            s=3*s+1
        else:
            s=s/2
        l.append(s)
        for j in range(0,i-2):
            if i>3 and s==l[j]:
                print(i+1)
                del l
                gc.collect()
                flag=True
                break
        if flag:
            break

Submission status: Wrong Answer

Solution code:
import numpy as np

if __name__ == '__main__':
    s=int(input())
    l=[]
    l.append(s)
    for i in range(1,1000000):
        if s%2:
            s=3*s+1
        else:
            s=s/2
        l.append(s)
        if i>3 and s==l[i-3]:
            print(i+1)
            break

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

a = int(input())
A = []
while True:
  b = calc(a)
  A.append(b)
  c = A.count(a)
  a = b
  if c == 2:
    break
print(len(A))

Submission status: Wrong Answer

Solution code:
s = int(input())

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

if s in (1, 2):
    print(4)
else:
    ai = s
    cnt = 1
    while ai != 4:
        print(ai)
        ai = f(ai)
        cnt += 1

    print(cnt + 3)

Submission status: Wrong Answer

Solution code:
s = int(input())

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

ai = s
cnt = 1
while ai != 4:
    ai = f(ai)
    cnt += 1

print(cnt + 3)

Submission status: Wrong Answer

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

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

s = INT()
N = 1000000

aN = [0] * (N+1)
aN[0] = s
c = Counter()
for i in range(1, N+1):
    n = aN[i-1]
    if n % 2 == 0:
        aN[i] = n // 2
    else:
        aN[i] = 3*n + 1
    if c[aN[i]] == 0:
        c[aN[i]] += 1
    else:
        print(i+1)
        exit()

Submission status: Wrong Answer

Solution code:
colatz=[1,2,4]
colatz.append(int(input()))
if colatz[3]==1 or 2 or 4:
    print(4)
else:
    b=3
    while colatz[b]!=4:
        if colatz[b]%2==0:
            colatz.append(colatz[b]/2)
        else: colatz.append(3*colatz[b]+1)
        b=b+1
    print(b+1)

Submission status: Wrong Answer

Solution code:
colatz=[1,2,4]
colatz.append(int(input()))
if colatz[3]==2 or colatz[3]==4:
    print(4)
else:
    b=3
    while colatz[b]!=4:
        if colatz[b]%2==0:
            colatz.append(colatz[b]/2)
        else: colatz.append(3*colatz[b]+1)
        b=b+1
    print(b+1)

Submission status: Wrong Answer

Solution code:
colatz=[1,2,4]
colatz.append(int(input()))
if colatz[3]==2 or colatz[3]==4:
    print(4)
else:
    b=3
    while colatz[b]!=colatz[b-3]:
        if colatz[b]%2==0:
            colatz.append(colatz[b]/2)
        else: colatz.append(3*colatz[b]+1)
        b=b+1
    print(b+1)

Submission status: Wrong Answer

Solution code:
colatz=[1,2,4]
colatz.append(int(input()))
b=3
while colatz[b]!=colatz[b-3]:
    if colatz[b]%2==0:
        colatz.append(colatz[b]/2)
    else: colatz.append(3*colatz[b]+1)
    b=b+1
print(b+1)

Submission status: Wrong Answer

Solution code:
colatz=[1,2,4]
colatz.append(int(input()))
b=3
while colatz[b]!=colatz[b-3]:
    if colatz[b]%2==0:
        colatz.append(colatz[b]/2)
    else: colatz.append(3*colatz[b]+1)
    b=b+1
print(b)

Submission status: Wrong Answer

Solution code:
def odd(n):
    return 3 * n + 1

def even(n):
    return n / 2

s = input("s=")

a_n = [int(s)]

for i in range(1000000):
    if a_n[i] % 2 == 0:
        a_n.append(even(a_n[i]))
    else :
        a_n.append(odd(a_n[i]))

flag = False

# print(a_n)

for i in range(len(a_n)):
    print("i:",i)

    for k in range(1,10000):
        print("k:",k)

        if a_n[i] == a_n[i+k]:
            print("k(内):",k)
            print(i + k + 1)
            flag = True
            break
    if flag:
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = int(input())
array = [s]
 
m = 2
while m < 100000:
  if (s % 2 == 0):
    s = s / 2
  else:
    s = 3 * s + 1
  
  if s in array:
    print(m)
    break
  else:
    array.append(m)
    m += 1

Submission status: Wrong Answer

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

m = 1
while m < 100000:
  if (s % 2 == 0):
    s = s / 2
  else:
    s = 3 * s + 1
  
  if s in array:
    print(m)
    break
  else:
    array.append(m)
    m += 1

Submission status: Wrong Answer

Solution code:
S=int(input())
a=S
ans=[]
for i in range(2,1000001):
    if a%2==1:
        a = a*3+1
    else:
        a = a//2

    if a in ans:
        print(i)
        exit()
    else:

        ans.append(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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())

memo = []

for m in range(1,1000000000000000):
    if m == 1:
        tmp = s
    elif f(tmp) == 2:
        print(int(m)+2)
        exit(0)
    else:
        tmp = f(tmp)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = set()
cnt = 1

while True:
    
    cnt += 1
    
    if n%2 == 0:
        n //=2
        
    else:
        n = n * 3 + 1

    if n in x:
        print(cnt)
        exit()
    else:
        x.add(n)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = set()
cnt = 1

while True:
    
    cnt += 1
    
    if n%2 == 0:
        n /=2
        
    else:
        n = n * 3 + 1

    if n in x:
        print(cnt)
        break
    else:
        x.add(n)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = set()
cnt = 2
while True:
    if n%2 == 0:
        n /=2
        
    else:
        n = n * 3 + 1

    if n in x:
        print(cnt)
        break
    else:
        x.add(n)

    cnt += 1

Submission status: Wrong Answer

Solution code:
s = int(input())

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

Submission status: Wrong Answer

Solution code:
s = int(input())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = int(input())
query = []
tmp = s
count = 1
ans = -1
while tmp != 1:
 count += 1

 if tmp%2 == 0:
  tmp = tmp//2
  query.append(tmp)
 else:
  tmp = tmp*3 +1
  query.append(tmp)
 
  
print(count+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def f(A):
    global i
    if A[i] % 2 == 0:
        A.append(A[i]/2)
    else:
        A.append(A[i]*3+1)
    i += 1
    if A[i]==4:
        return i + 4
    else:
        return f(A)

n= int(input())
A = [n]
i = 0

print(f(A))

Submission status: Wrong Answer

Solution code:
def f(A):
    global i
    if A[i] % 2 == 0:
        A.append(A[i]/2)
    else:
        A.append(A[i]*3+1)
    i += 1
    if A[i]==1 and A[i-1]==2 and A[i-2]==4:
        return i-2 + 4
    else:
        return f(A)

n= int(input())
A = [n]
i = 0

print(f(A))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
s=int(input())

x=[]

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


count=0

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

print(count+4)

Submission status: Wrong Answer

Solution code:
def f(s):
    a=[s]
    i=0
    while not s==4:
        if a[i]%2==0:
            s//=2
            a+=[s]
        else:
            s=3*s+1
            a+=[s]
        i+=1

    return a.index(4)+4
print(f(int(input())))