TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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).

Submission attempts (in order):
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()
      


s = int(input())

def func(n):
  if n % 2 == 0:
    return (n/2)
  else:
    return (3n+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()
      

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

s=int(input())
nlist =[]
tmp_in = collatz(s)
nlist.append(s)
nlist.append(tmp_in)
cnt = 1
while True:
    cnt += 1
    tmp_out = collatz(tmp_in)

    if tmp_out in nlist:
        print(len(nlist)+1)
        #print(nlist)
        break
    nlist.append(tmp_out)
    tmp_in = tmp_out


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
ans = [s]

for i in range(1,10**6+1):
    if len(set(ans)) != len(ans):
        print(i)
        break
    if s % 2 != 0:
        s = 3 * s + 1
        ans.append(s)
    else:
        s = s // 2
        ans.append(s)
    print(ans)

s = int(input())
ans = [s]

for i in range(1,10**6+1):
    if len(set(ans)) != len(ans):
        print(i)
        break
    if s % 2 != 0:
        s = 3 * s + 1
        ans.append(s)
    else:
        s = s // 2
        ans.append(s)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
a = int(input())
t = [0]*1000000
t[a] = 1
for i in range(2,1000001):
    if a % 2 == 0:
        a //= 2
    else:
        a = 3*a + 1
    print(a)
    if t[a]:
        break
    t[a] = 1
print(i)

a = int(input())
t = set()
t.add(a)
for i in range(2,1000001):
    if a % 2 == 0:
        a //= 2
    else:
        a = 3*a + 1
    if a in t:
        break
    t.add(a)
print(i)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
l=[s]
i=1
def func(a):
  if a%2==0:
    return(a/2)
  else:
    return(3*a+1)

while (len(l)==len(set(l))):
  i+=1
  s = func(s)
  l.append(func(s))
print(i+1)

s = map(int, input().split())
l=[s]
i=1
def func(a):
  if a%2==0:
    return a/2
  else:
    return 3s+1

def Collatz(s):
    i+=1
	l.append(func(s))
	if not len(l) == len(set(l)):
        print(i)
        break
    else:
        continue
Collatz(s)

s = map(int, input().split())
l=[s]
i=1
def func(a):
  if a%2==0:
    return(a/2)
  else:
    return(3*a+1)

def Collatz(s):
  i+=1
  l.append(func(s))
  if not len(l) == len(set(l)):
    print(i)
    break
  else:
    continue

Collatz(s)

s = map(int, input().split()
l=[s]
i=1
def func(a):
  if a%2==0:
    return a/2
  else:
    return 3s+1

def Collatz(s):
    i+=1
	l.append(func(s))
	if not len(l) == len(set(l)):
        print(i)
        break
    else:
        continue

s = int(input())
l=[s]
i=1
def func(a):
  if a%2==0:
    return(a/2)
  else:
    return(3*a+1)

while (len(l)==len(set(l))):
  i+=1
  l.append(func(s))
print(i)


s = int(input())
l=[s]
i=1
def func(a):
  if a%2==0:
    return(a/2)
  else:
    return(3*a+1)

def Collatz(s):
  i+=1
  l.append(func(s))
  if not len(l) == len(set(l)):
    print(i)
    break
  else:
    continue

Collatz(s)

s = int(input())
l=[s]
i=1
def func(a):
  if a%2==0:
    return(a/2)
  else:
    return(3*a+1)

while (len(l)==len(set(l))):
  i+=1
  s = func(s)
  l.append(s)
print(i)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
s = list(int(input()))
for i in range(1000001):
    if s[i] % 2 == 0:
        s.append(s[i]/2)
    else:
        s.append(3 * s[i] + 1)
    if s[i] in s[:i]:
        print(i+1)
        break

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

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
# -*- coding: utf-8 -*-


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


def main():
    """Function."""
    s = int(input())

    check_dic = {}
    check = set()

    old = s
    counter = 1

    while old not in check:
        print(old,counter)
        check.add(old)
        check_dic[old] = counter

        counter += 1
        old = fn(old)

    print("!!!!!!!!!!!")
    print(counter)


if __name__ == "__main__":
    main()

# -*- coding: utf-8 -*-


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


def main():
    """Function."""
    s = int(input())

    check_dic = {}
    check = set()

    old = s
    counter = 1

    while old not in check:
        # print(old,counter)
        check.add(old)
        check_dic[old] = counter

        counter += 1
        old = fn(old)

    # print("!!!!!!!!!!!")
    print(counter)


if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
a = []
a.append(s)
while a[0] != s:
  if s % 2 ==0:
    s = s//2
    a.append(s)
  else:
    s = 3*s +1
    a.append(s)
print(len(a))
  


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


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


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


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


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
def f(n):
  if(n % 2 == 0):
    return n // 2
  else:
    return (3 * n) + 1
N = int(input())
 
test = set(N)
before = N
for i in range(1, 10**6 + 1):
  current = f(before)
  if(current in test):
    print(i+1)
    exit()
  before = current
  test.add(current)


def f(n):
  if(n % 2 == 0):
    return n // 2
  else:
    return (3 * n) + 1
N = int(input())
 
test = set([N])
before = N
for i in range(1, 10**6 + 1):
  current = f(before)
  if(current in test):
    print(i+1)
    exit()
  before = current
  test.add(before)


Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())

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

def function(n):
    if n % 2 == 0:
        return int(n/2)
    else:
        return int(n*3+1)
i = 0
count = 0
a = []
a.append(s)
while count < 2:
    a.append(function(a[i]))
    if a[i] == 4:
        count += 1
    i += 1
print(a)
print(i)

s = int(input())

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

def function(n):
    if n % 2 == 0:
        return int(n/2)
    else:
        return int(n*3+1)
i = 0
count = 0
a = []
a.append(s)
while count < 2:
    a.append(function(a[i]))
    if a[i] == 4:
        count += 1
    i += 1
print(i)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
c = 0
a = [s]
while c < 100000:
  if s % 2 == 0:
    s = s//2
    c += 1
  else:
    s = 3*s+1
    c += 1
    a += [s]
  for i in range(c):
    if a[i] in a[:i]:
      print(i+1)
      exit()

s = int(input())
c = 0
a = [s]
while c < 100000:
	if s % 2 == 0:
		s = s//2
		c += 1
	else:
		s = 3*s+1
		c += 1
		a += [s]
for i in range(c):
	if a[i] in a[:i]:
		print(i+1)
		exit()

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

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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).

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

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

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

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

Verdicts: Time Limit Exceeded

Runtime Error

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
count = 0
for i in range(1000000):
  if s%2 == 0:
    s /=2
  else:
    s = 3*x+1
  
  if s==4:
    print(count+4)
  count +=1

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


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

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


Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
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)

s = int(input())
arr = [s]
for _ in range(1000000):
    if s % 2 == 0:
        s //= 2
    else:
        s = 3 * s + 1
    if s in arr:
        break
    arr.append(s)
print(len(arr) + 1)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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


from collections import defaultdict
import sys

import math

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




do_submit = True

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(int, line.split())) for line in lines]
    a = parsed_lines[0]
    return a[0]


if not do_submit:
    a= input_parse("""
    54
    """)
    print(sol(a))
else:
    # a, b, c = list(map(int, input().split()))
    # print(sol(a, b, c))
    a = list(map(int, input().split()))
    print(sol(a[0]))

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
# -*- 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)

# -*- 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
    if int(index) in dp:
        break
    else:
        dp.append(int(index))
        a_1 = int(index)
        i+=1

print(i)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):

s = int(input())

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


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


s = int(input())

val = s
mp = {s:1}
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

Verdicts: Time Limit Exceeded

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())

a = []

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

s = int(input())

a = [s]

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

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
lists=[]
lists.append(s)
for i in range(2,1000000):
    print("A",i)
    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()

lists=[]
lists.append(s)
for i in range(2,1000000000000000):
    print("A",i)
    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()

#116 B
s =int(input())
lists=[]
lists.append(s)
for i in range(2,1000001):
    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()

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
import sys
s = int(input())
flg=0
A = []
A.append(s)

index = 0
if s==4 or s==2 or s==1:
    print(index+4)
    sys.exit()
while flg!=1:
    if A[index]%2==0:
        f = (A[index]//2)
    else:
        f = 3*A[index]+1
    print(index)
    A.append(f)
    index = index + 1

    if f==4 or f==2 or f==1:
        flg=1
        break

#1,4,2,1,4

print(index+4)

import sys
s = int(input())
flg=0
A = []
A.append(s)

index = 0
if s==4 or s==2 or s==1:
    print(index+4)
    sys.exit()
while flg!=1:
    if A[index]%2==0:
        f = (A[index]//2)
    else:
        f = 3*A[index]+1

    A.append(f)
    index = index + 1

    if f==4 or f==2 or f==1:
        flg=1
        break

#1,4,2,1,4

print(index+4)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
def collaz(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1

s = int(input())

box = [-1]*(int(1e10))

i = 1

while 1:
    if box[collaz(s)] == 1:
        print(i+1)
        break
    else:
        box[collaz(s)] = 1
        s = collaz(s)
        i += 1
    

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

s = int(input())

box = [-1]*(int(1e6+1))

box[s] = 1

i = 1

while 1:
    if box[collaz(s)] == 1:
        print(i+1)
        break
    else:
        box[collaz(s)] = 1
        s = collaz(s)
        i += 1
    

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
a=int(input())
l=[a]
b=True
i=1
while b==True:
  if a%2==0:
    a=a//2
  else:
    a=3*a+1
  if a in l:
    b==False
    print(i+1)
    exit
  else:
    l.append(a)
    i+=1
   
  
    

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

Verdicts: Time Limit Exceeded

Accepted
Problem: 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).

Submission attempts (in order):
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)

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 = i + 1
    break
  a.append(ai)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
def func(n):
  if n%2 == 1:
    return 3n+1
  else:
    return n//2
def prog(N):
  if N == 1:
    return s
  else:
    a=s
    for i in range(1,N):
      a = func(a)
    return a

b=[]
for i in range(1,1000001):
  tmp = prog(i)
  if tmp in b:
    print(i)
    break
  else:
    b.append(tmp)
  



s = int(input())
def func(n):
  if n%2 == 1:
    return 3n+1
  else:
    return n/2
def prog(N):
  if N == 1:
    return s
  else:
    a=s
    for i in range(1,N):
      a = func(a)
    return a


while prog(k)==prog(j):
  



s = int(input())
def func(n):
  if n%2 == 1:
    return 3n+1
  else:
    return n//2
def prog(N):
  if N == 1:
    return s
  else:
    a=s
    for i in range(1,N):
      a = func(a)
    return a

b=[]
for i in range(1,10000):
  tmp = prog(i)
  if tmp in b:
    print(i)
    break
  else:
    b.append(tmp)
  



s = int(input())
def func(n):
  if n%2 == 1:
    return 3*n+1
  else:
    return n//2
def prog(N):
  if N == 1:
    return s
  else:
    a=s
    for i in range(1,N):
      a = func(a)
    return a

b=[]
for i in range(1,1000000):
  tmp = prog(i)
  if tmp in b:
    print(i)
    break
  else:
    b.append(tmp)
  



Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
a = []
flag = 0
i = 0
while s not in a:
    a.append(s)
    if s % 2 == 0:
        s = s/2
    else:
        s = 3 * s + 1
    i += 1
print(i)

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

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
a = int(input())
b = [a]
c = 0
while:
  c += 1
  if a % 2 == 0:
    a /= 2
    if b.contain(a):
      print(c)
      exit()
    else:
      b.append(a)
  else:
    a = a * 3 + 1
    if b.contain(a):
      print(c)
      exit()
    else:
      b.append(a)


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


a = int(input())
b = [a]
d = 1
while True:
    c = b[len(b)-1]
    d += 1
    if c % 2 == 0:
        c = c // 2
    else:
        c = c * 3 + 1
    if c not in b:
        b.append(c)
    else:
        print(d)
        exit()


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())

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

a = [s]
n = 1

while True:
  a.append(calc_next(a[n-1]))
  for i in range(n):
    if a[k] == a[n]:
      print(n+1)
      exit(0)
  n += 1

s = int(input())

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

a = [s]
n = 1

while True:
  a.append(calc_next(a[n-1]))
  for i in range(n):
    if a[i] == a[n]:
      print(n+1)
      exit(0)
  n += 1


Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
s=int(input())
a=[]
na=[]
a.append(s)
for i in range(1,10**6):
    if a[i-1]%2==0:
        a.append(a[i-1]/2)
    else:
        a.append(a[i-1]*3+1)
    na=set(a)
    if len(na)!=i+1:
        print(a[i])
        exit()

s=int(input())
a=[]
na=[]
a.append(s)
for i in range(1,10**6):
    if a[i-1]%2==0:
        a.append(a[i-1]/2)
    else:
        a.append(a[i-1]*3+1)
    na=set(a)
    if len(na)!=i+1:
        print(i+1)
        exit()

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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


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

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
n = int(input())
cnt = 1
if n>=3:
    cnt = cnt + 1
elif n=2:
    cnt = cnt + 2
else:
    cnt = cnt + 3
while n != 1:
    if n % 2 == 0:
        n /= 2
    else:
        n = 3*n+1
    cnt += 1
print(cnt)

n = int(input())
cnt = 1
if n>=3:
    cnt = cnt + 1
elif n==2:
    cnt = cnt + 2
else:
    cnt = cnt + 3
while n != 1:
    if n % 2 == 0:
        n /= 2
    else:
        n = 3*n+1
    cnt += 1
print(cnt)

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
a=[int(input())]
for i in range(1000000):
    n=a[i]
    if n%2==0:
        a.append(n/2)
    else:
        a.append(3*n+1)
    if a[i+1]==4:
        print(i+5)
        break
print(a)

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

for i in range(1000000):
    if a[i-3]==a[i]:
        print(i+1)
        break

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3*n + 1
s = int(input())
a = [0]
a.append(s)
for i in range(1,10**8):
    x = a[-1]
    y = f(x)
    if y in a:
        print(i)
        break
    a.append(y)

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

Verdicts: Wrong Answer

Accepted
Problem: 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).

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


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


Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
n=int(input().split())
dic=set()
dic|={1}
i=1
while True:
  if n%2==0:
    n=n//2
  else:
    n=3*n+1
  i+=1
  if n in dic:
    print(i)
    break
  else:
    dic|={i}


n=int(input().split())
dic={n:1}
i=1
while True:
  if n%2==0:
    n=n//2
  else:
    n=3*n+1
  i+=1
  if n in dic:
    print(i)
    break
  else:
    dic[n]=i

n=int(input().split())
dic=set()
dic|={n}
i=1
while True:
  if n%2==0:
    n=n//2
  else:
    n=3*n+1
  if n in dic:
    print(i+1)
    break
  else:
    dic|={n}
    i+=1


n=int(input().split())
dic=set()
dic|={n}
i=1
while True:
  if n%2==0:
    n=n//2
  else:
    n=3*n+1
  i+=1
  if n in dic:
    print(i)
    break
  else:
    dic|={n}


n=int(input().split())
dic={n:1}
i=1
while True:
  if n%2==0:
    n=n//2
  else:
    n=3*n+1
  i+=1
  if n in dic:
    print(dic[n])
    break
  else:
    dic[n]=i

n=int(input())
dic=set()
dic|={n}
i=1
while True:
  if n%2==0:
    n=n//2
  else:
    n=3*n+1
  if n in dic:
    print(i+1)
    break
  else:
    dic|={n}
    i+=1


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
l = [s]
tmp = 0
ans = 0
for i in range(1,1000000):
  if l[-1] % 2 == 0:
    tmp = l[-1]/2
    l.append(tmp)
    if l.count(tmp) == 2:
      ans = len(l)-1
      break
  else:
    tmp = 3*l[-1]+1
    l.append(tmp)
    if l.count(tmp) == 2:
      ans = len(l)-1
      break
print(ans)



s = int(input())
l = [s]
i = 0
def calc(n):
  if n % 2 == 0:
    return n // 2
  else:
    return 3 * n + 1
while True:
  l.append(calc(l[i]))
  if l.count(calc(l[i])) == 2:
    break
  i += 1
#print(l)
print(i+2)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
a = [s]

while len(a) - len(set(a)) != 0:
  for i in range(1000000):
    m = i+1
    if a[i] % 2 == 0:
      a.append(int(a[i]/2))
    else:
      a.append(3*a[i] + 1)
      
print(m)

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

def a(i):
    if i == 1:
        return s
    else:
        return f(a(i-1))

list = []
for i in range(1,1000000):
    list.append(a(i))
    if len(list) != len(set(list)):
        print(i)
        break

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
# -*- 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)


# -*- 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(answer)


Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


memo = []


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


def solve():
    s = ii()
    d = {}
    for i in range(1, 10000000):
        s = f(s)
        if d.get(s) is None:
            d[s] = i + 1
        else:
            return d[s]


if __name__ == "__main__":
    print(solve())


import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


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


def solve():
    s = ii()
    d = {s: 0}
    for i in range(1, 1000000000):
        s = f(s)
        if d.get(s) is None:
            d[s] = 0
        else:
            return i + 1


if __name__ == "__main__":
    print(solve())


Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
N = int(input())
Flag = 0
nList = []
nList.append(N)
i = 2
while Flag==0:
  Tmp = N % 2
  if Tmp == 0:
    TmpN /= 2
  else:
    TmpN = 3 * N + 1
  
  if TmpN in nList:
    Flag = 1
    break
  else:
    nList.append(TmpN)
    N = TmpN
    i += 1

print(i)





N = int(input())
Flag = 0
nList = []
nList.append(N)
i = 2
while Flag==0:
  Tmp = N % 2
  TmpN = N
  if Tmp == 0:
    TmpN /= 2
  else:
    TmpN = 3 * N + 1
  
  if TmpN in nList:
    Flag = 1
    break
  else:
    nList.append(TmpN)
    N = TmpN
    i += 1

print(i)


Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
s=int(input())

line=[]
count=1

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

print(s)

s=int(input())

line=[]
count=1

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

print(count)


Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
a = [int(input())]
s = a[0]
while 1:
    if s%2 == 0: a.append(s//2)
    else:a.append(3*s+1)
    s = a[len(a)-1]
    print(a)
    if s in a[0:len(a)-1]:
        print("saa",a[0:len(a)-1])
        break
print(len(a))

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

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
f = []
i = 0
n = s
while(i<1000000):
  if n % 2 == 0:
    f.append(n/2)
  else:
    f.append(3*n+1)
  n = f[i]
  i = i + 1
f_ = list(dict.fromkeys(f))
f.pop(f.index(f_[0]))
print(f.index(f_[0])+1)

s = int(input())
f = [s]
i = 1
n = s
while(i<=1000001):
  if n % 2 == 0:
    f.append(int(n/2))
  else:
    f.append(3*n+1)
  n = f[i]
  i = i + 1
f_ = list(dict.fromkeys(f))
f.pop(f.index(f_[0]))
print(f.index(f_[0]))

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


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
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)

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)
        a += 1
    else:
        List.append(n)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
def f(a):
    cnt=0
    st=set()
    while True:
        if n%2!=0:
            tmp=a/2
        else:
            tmp=3*a+1
        if tmp in st:
            break
        st.add(tmp)
        a=tmp
    return cnt
a=int(input())     
ans= f(s)
print(ans)

def f(a):
    cnt=0
    st=set()
    cnt+=1
    st.add(a)
    while True:
        if n%2!=0:
            tmp=a/2
        else:
            tmp=3*a+1
        if tmp in st:
            break
        st.add(tmp)
        a=tmp
    return cnt
a=int(input())     
ans= f(s)
print(ans)

def f(s):
    cnt = 0
    st = set()

    cnt += 1
    st.add(s)

    while True:
        cnt += 1

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

        if tmp in st:
            break

        st.add(tmp)
        s = tmp
    return cnt


s = int(input())
ans = f(s)
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
from collections import defaultdict
a = int(input())
idxs = defaultdict(int)
idxs[a] = 1
i = 1
ans = None
while True:
  i += 1
  if a % 2 == 0:
    a //= 2
  else:
    a = 3 * a + 1
    
  if not idxs[a]:
    idxs[a] = i
  else:
    ans = i

print(ans)
    
    



from collections import defaultdict
a = int(input())
idxs = defaultdict(int)
idxs[a] = 1
i = 1
ans = None
while True:
  i += 1
  if a % 2 == 0:
    a //= 2
  else:
    a = 3 * a + 1
    
  if not idxs[a]:
    idxs[a] = i
  else:
    ans = i
    break

print(ans)
    
    



Verdicts: Time Limit Exceeded

Accepted