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

s = int(input())

c = 1

l = []

while f(s) not in l:
    l.append(f(s))
    c += 1

print(c+1)

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

s = int(input())

l = []
l.append(s)

c = 1

while f(s) not in l:
    s = f(s)
    l.append(s)
    c+=1

print(c+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())
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))

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 in [1,2,4]:
		break
	else:
		s = collatz(s)
		i += 1

print(str(i+3))

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=input()
cnt=1
while a!=1
  if(a%2==0):
    a//=2
    cnt+=1
  else:
    a=3a+1
    cnt+=1
print(cnt=+3)

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

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

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

s = int(input())
a = list(map(int,input().split()))
ans = [s]

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

  if s in ans:
        break
  else:
        ans.append(s)
      
print(len(ans)+1)

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

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())
a=[s]
def f(s):
    if s%2==0:
        return s//2
    else:
        return 3*s+1
for i in range(1000001):
    if f(a[i]) in a:
        print(i+2)
        break
    else:
        a.append(f(a[i]))
print(a)

s=int(input())
a=[s]
def f(s):
    if s%2==0:
        return s//2
    else:
        return 3*s+1
for i in range(1000001):
    if f(a[i]) in a:
        print(i+2)
        break
    else:
        a.append(f(a[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):
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
 
import itertools
hoges = {}
for i in itertools.combinations(xy, 2):
    if i[0][0] - i[1][0] >= 0:
        hoge = (i[0][0] - i[1][0], i[0][1] - i[1][1])
    else:
        hoge = (i[1][0] - i[0][0], i[1][1] - i[0][1])
    hoges.setdefault(hoge, 0)
    hoges[hoge] += 1
# print(hoges)
max_v = max(hoges.values())
print(N - max_v)

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

s = int(input())
  
al = []
al.append(s)
cnum = s
for i in range(2,1000000):
  cnum = fn(cnum)
  if cnum in al[:-1]:
    print(i)
    exit()
  else:
    al.append(cnum)



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())
M = 1000000
m = 1

while m <= M:
    if a in (1, 2, 41):
        m += 3
        break
    if a % 2 == 0:
        a //= 2
    else:
        a = 3 * a + 1
    m += 1

print(m)


a = int(input())
M = 1000000
m = 1

while m <= M:
    if a in (1, 2, 4):
        m += 3
        break
    if a % 2 == 0:
        a //= 2
    else:
        a = 3 * a + 1
    m += 1

print(m)


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]

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

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

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

a, b, _ = map(int, input().split())
print(a * b / 2)

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

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

Verdicts: Wrong Answer

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())
def functionF(n):
    result = n/2 if n % 2 == 0 else 3 * n + 1
    return int(result)
def calc(s):
  array = []
  for i in range(1,1000000):
    if i == 1:
      array.append(s)
      elif i > 1:
        array.append(functionF(array[i - 2]))
        return array
def result(s):
    result = calc(s)
    for i in range(1, 1000000):
#         print('i',i)
        for k in range(i):
#             print('k',k)
#             print(result[i], result[k])
            if result[i] == result[k]:
                print(i - 1)
                return

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

def calc(s):
    array = []
    for i in range(1,1000000):
        if i == 1:
            array.append(s)
        elif i > 1:
            array.append(functionF(array[i - 2]))
            for k in range(1, i):
#                 print(i, k)
#                 print(array[i-1], array[k-1])
                if array[i-1] == array[k-1]:
                    print(i)
                    return
calc(s)

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):
import collections
s=int(input())
count=1
ans=s
prev=0
counter = collections.defaultdict(int)
counter[ans]=1
while(1):
  count+=1
  if ans % 2 == 0:
    ans = ans / 2
  else:
    ans = 3*n+1
    
  if ans not in counter.keys:
    counter[ans]=count
  else:
    print(counter[ans])
    break

import collections
s=int(input())
count=1
ans=s
prev=0
counter = collections.defaultdict(int)
counter[ans]=1
while(1):
  count+=1
  if ans % 2 == 0:
    ans = ans / 2
  else:
    ans = 3*ans+1
    
  if ans not in counter.keys():
    counter[ans]=count
  else:
    print(count)
    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):
k = input().split()
a = int(k[0])

def b(n):
    return int(n/2)
def c(n):
    return int((3*n)+1)

Counter = 0

flag = True
IntSet = set()
IntSet.add(a)
Buffer = int(a)
for i in range(1,1000000+1):
    if Buffer%2 == 0:
        Buffer = b(Buffer)
        Counter+=1
    else:
        Buffer = c(Buffer)
        Counter+=1
    print(Buffer)
    if Buffer in IntSet:
        print(Counter+1)
        break
    else:
        IntSet.add(Buffer)

k = input().split()
a = int(k[0])

def b(n):
    return int(n/2)
def c(n):
    return int((3*n)+1)

Counter = 0

flag = True
IntSet = set()
IntSet.add(a)
Buffer = int(a)
for i in range(1,1000000+1):
    if Buffer%2 == 0:
        Buffer = b(Buffer)
        Counter+=1
    else:
        Buffer = c(Buffer)
        Counter+=1
    if Buffer in IntSet:
        print(Counter+1)
        break
    else:
        IntSet.add(Buffer)

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


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

s = int(input())
if(s == 1 || s == 2):
  print(4)
  exit()
  
cnt = 1
while(s != 1):
  s = func(s)
  cnt += 1
print(cnt + 1)


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

s = int(input())
if((s == 1) or (s == 2)):
  print(4)
  exit()
  
cnt = 1
while(s != 1):
  s = func(s)
  cnt += 1
print(cnt + 1)



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):
import collections

s = int(input())
A = [s]
for i in range(1000000+1):
  A.append(i//2 if i%2==0 else 3*n+1)
  c = collections.Counter(A)
  if c.most_common()[0][1] ==2:
    print(i)
    break

import collections

s = int(input())
A = [s]
for i in range(1000000+1):
  A.append(A[i]//2 if A[i]%2==0 else 3*A[i]+1)
  c = collections.Counter(A)
  if c.most_common()[0][1] == 2:
    print(len(A))
    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):
s = int(input())
progression = []
n = s
count = 1
while n not in progression:
    count += 1
    if n % 2 == 0:
        n = n/2
    else:
        n = 3 * n + 1
        
print(count)

s = int(input())
progression = [s]
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)

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):
import sys
import math
from collections import Counter
import itertools
import fractions
import datetime
from decimal import Decimal
#from functools import reduce


def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())

def LI(): return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'


p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

s=II()
l=[s]
cnt = 1
while True:
    cnt += 1
    if s%2==0:
        s/=2
    else:
        s = 3*s+1
    if s in se:
        print(cnt)
        exit()
    else:
        l.append(s)

import sys
import math
from collections import Counter
import itertools
import fractions
import datetime
from decimal import Decimal
#from functools import reduce


def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())

def LI(): return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'


p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

s=II()
l=[s]
cnt = 1
while True:
    cnt += 1
    if s%2==0:
        s/=2
    else:
        s = 3*s+1
    if s in l:
        print(cnt)
        exit()
    else:
        l.append(s)

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())
ai=[s]
for i in range(1000000):
    if s%2:
        s =3*s+1
        ai.append(s)
    else:
        s = s//2
        ai.append(s)
    print(ai)
    if len(ai) != len(set(ai)):
        c=0
        for j in range(len(ai)):
            if ai.count(ai[j])==2:
                c +=1
                if c ==2:
                    print(j+1)
                    exit()

ai=[s]
for i in range(1000000):
    if s%2:
        s =3*s+1
        ai.append(s)
    else:
        s = s//2
        ai.append(s)
    print(ai)
    if len(ai) != len(set(ai)):
        c=0
        for j in range(len(ai)):
            if ai.count(ai[j])==2:
                c +=1
                if c ==2:
                    print(j+1)
                    break
        exit()

s = int(input())
ai=[s]
for i in range(1000000):
    if s%2:
        s =3*s+1
        ai.append(s)
    else:
        s = s//2
        ai.append(s)
    print(ai)
    if len(ai) != len(set(ai)):
        c=0
        for j in range(len(ai)):
            if ai.count(ai[j])==2:
                c +=1
                if c ==2:
                    print(j+1)
                    break
        exit()

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

Verdicts: Wrong Answer

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


s = int(input())

a = []
b = s
count = 0
for i in range(10**6 + 1):
    a.append(b)
    b = fn(b)
    if b == 1:
        count += 1
        if count == 3:
            break

for i in range(len(a)):
    for j in range(i+1, len(a)):
        if a[i] == a[j]:
            result = j
            break
print(j)


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


s = int(input())

a = []
b = s
for i in range(10**6 + 1):
    if b not in a:
        a.append(b)
        b = fn(b)
    else:
        a.append(b)
        break
print(len(a))


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())
count = 0
while s!=1:
  if s%2==0:
    s /= 2
  else:
    s = s*3+1
  count += 1
if s == 1:
  print(4)
elif s == 2:
  print(2)
else:
  print(count+2)


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


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(True):
  i=0
  n=0
  if a[i]%2==0:
    n=a[i]//2
  else:
    n=a[i]*3+1
  if n in a:
    print(a.index(n)+1)
    break
  i+=1
  a.append(n)

s=int(input())
a=[s]
i=0
while(True):
  n=0
  if a[i]%2==0:
    n=a[i]//2
  else:
    n=a[i]*3+1
  if n in a:
    print(len(a)+1)
    break
  i+=1
  a.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):
a=int(input())
s=set(a)
i=1
while True:
  if a % 2==1:
    a = a * 3 + 1
  else:
    a = a//2
    
  if a in s:
    break
  s|={a}
  i+=1
print(i)

a=int(input())
s=set(a)
i=1
while True:
  if a % 2==1:
    a = a * 3 + 1
  else:
    a = a//2
    
  if a in s:
    break
  s|=｛a｝
  i+=1
print(i)

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


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 numpy as np
import sys

input = sys.stdin.readline

s = int(input())

ans = 1

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


print(ans+3)



import numpy as np
import sys

input = sys.stdin.readline

s = int(input())

ans = 1

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


print(ans+3)



import numpy as np
import sys

input = sys.stdin.readline

s = int(input())

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

ans = 1

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


print(ans+n)


Verdicts: Wrong Answer

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):
s = int(input())
cou = 1
tmp = 0
flag = 0
List = []
while(flag == 0):
  if(cou == 1):
    if(s % 2 == 0):
      tmp = s / 2
      List.append(tmp)
    else:
      tmp = 3 * s + 1
      List.append(tmp)
    cou += 1
  else:
    if(List.count(tmp) == 2):
      print(str(cou))
      break
    if(tmp % 2 == 0):
      tmp = tmp / 2
      List.append(tmp)
    else:
      tmp = 3 * tmp + 1
      List.append(tmp)
    cou += 1
    cou += 1

s = int(input())
cou = 1
tmp = 0
flag = 0
List = [s]
while(flag == 0):
  if(cou == 1):
    if(s % 2 == 0):
      tmp = s / 2
      List.append(tmp)
    else:
      tmp = 3 * s + 1
      List.append(tmp)
    cou += 1
  else:
    if(List.count(tmp) == 2):
      print(str(cou))
      break
    if(tmp % 2 == 0):
      tmp = tmp / 2
      List.append(tmp)
    else:
      tmp = 3 * tmp + 1
      List.append(tmp)
    cou += 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(n):
    if n%2==0:
        n//2
    else:
        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)

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)


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


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


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)
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):
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [str(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))
def f(n):
    print(l)
    if n%2 == 0:
        return n//2
    else:
        return 3*n + 1
if __name__ == "__main__":
    n = i()
    c = 0
    cnt = 1
    l = [n]
    #if n != 2 or n != 1 or n != 4:l = [n]
    while c < 2:
        n = f(n)
        cnt += 1
        if n in l:
            print(cnt)
            break
        l.append(n)

import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [str(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))
def f(n):
    #print(l)
    if n%2 == 0:
        return n//2
    else:
        return 3*n + 1
if __name__ == "__main__":
    n = i()
    c = 0
    cnt = 1
    l = [n]
    #if n != 2 or n != 1 or n != 4:l = [n]
    while c < 2:
        n = f(n)
        cnt += 1
        if n in l:
            print(cnt)
            break
        l.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):
s=int(input())
def f(n):
	if n % 2 ==0:
		return int(n/2)
	else:
		return int(3*n+1)
a=[s]
while len(set(a)) == len(a):
		a.append(f(a[-1]))
		print(a)
print(len(a))

s=int(input())
def f(n):
	if n % 2 ==0:
		return int(n/2)
	else:
		return int(3*n+1)
a=[s]
while len(set(a)) == len(a):
		a.append(f(a[-1]))
print(len(a))

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())]
i=0
while 1>0:
  if i%2>0:
    b=3*s[i]+1
  else:
    b=s[i]//2
  if b in s:
    print(i+1)
    break


s=[int(input())]
i=0
while 1>0:
  if i%2>0:
    b=3*s[i]+1
  else:
    b=s[i]//2
  if b in s:
    print(i+1)
    break
  i+=1


s=[int(input())]
i=0
while 1>0:
  if s[i]%2>0:
    b=3*s[i]+1
  else:
    b=s[i]//2
  if b in s:
    print(i+2)
    break
  i+=1
  s+=[b]

Verdicts: Time Limit Exceeded

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())
count=0
if s==1:
  print(4)
elif s==2:
  print(4)
else:
  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)


s = int(input())
cnt = 1
box = set()
while not s in box:
	box.add(s)
	if s % 2 == 0:
		s = s / 2
	else:
		s = 3 * s + 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):
#include <bits/stdc++.h>

#define mod 1000000007

#define rep(i, n) for(int i=1; i<=n; ++i)

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int a[100000];
	
	cin >> a[0];
	
	rep(i, 100000){
		if(a[i-1] % 2 == 0)
			a[i] = a[i-1] / 2;
		else
			a[i] = 3 * a[i-1] + 1;
		rep(j, i){
			if(a[j] == a[i]){
				cout << i;
				return 0;
			}
		}
	}
}

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

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

print(len(a) + 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):
def f(n):
  if n % 2 == 0:
    return n//2
  else:
    return 3*n + 1


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


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


s = int(input())
a = [s]
i = 0
while True:
  s = f(a[i])
  if a in s:
    print(i)
    break
  else:
    a.ppend(s)
    i += 1

s = int(input())


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


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

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

a = [s]
i = 0
flg = 1

while(flg):
    a.append(func(a[i]))
    #print(a)
    for k in range(len(a)):
        for l in range(1, len(a)-k): 
            if a[k] == a[k+l]:
                print(k+l+1)
                break
        else:
            continue
        break   
        
    i += 1
            
    


while(flg):
    a.append(func(a[i]))
    #print(a)
    for k in range(len(a)):
        for l in range(1, len(a)-k): 
            if a[k] == a[k+l]:
                print(k+l+1)
                break
        else:
            continue
        break   
        
    i += 1

s = int(input())

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

def check(a, k):    
    for l in range(1, len(a)-k): 
        if a[k] == a[k+l]:
            print(k+l+1)
            return False
    return True

a = [s]
i = 0
flg = 1

while(flg):
    a.append(func(a[i]))
    #print(a)
    for k in range(len(a)):
        if not check(a, k):
            flg = 0
            break
    i += 1

Verdicts: Time Limit Exceeded

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

s = int(input())
lst = []
lst.append(s)
cnt = 1
while (True):
  cnt += 1
  if (s % 2 == 0):
    s = int(s / 2)
  else:
    s = int(3*s + 1)
  if (s not in lst):
    lst.append(s)
  else:
    break
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):
s = int(input())
a = [0]*1000010

i = 1
a[s] = 1
while True:
	s = s//2 if s%2 == 0 else 3*s+1
	if a[s] == 0:
		i += 1
		a[s] = i
	else:
		print(i)
		break

s = int(input())
a = [0]*1000010

i = 1
a[s] = 1
while True:
	i += 1
	s = s//2 if s%2 == 0 else 3*s+1
	if a[s] == 0:
		a[s] = i
	else:
		print(i)
		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):
s = int(input())
a = [s]
i = 1

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

while true:
    a.append(f(a[i-1]))
    i += 1

    if a[-1] in a[:-1]:
        break

print(i)


s = int(input())
a = [s]
i = 1

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

while True:
    a.append(f(a[i-1]))
    i += 1

    if a[-1] in a[:-1]:
        break

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

tag = 0
i = 1
num = [0]*1000000

while tag == 0:
    if int(s)%2 == 0:
        s = int(s)/2
    else:
        s = 3*int(s) + 1
    i += 1
    for j in range(i):
        if s == num[j]:
            tag = 1
            break
        else:
            continue

print (i)



s = input()

tag = 0
i = 1
num = []

while tag == 0:
    if i > 1000000:
        break
    num.append(int(s))
    if int(s)%2 == 0:
        s = int(s)/2
    else:
        s = 3*int(s) + 1
    i += 1
    for j in range(int(i)-1):
        if int(s) == int(num[j]):
            tag = 1
            print (i)
            break
        else:
            continue



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(x):
  if x % 2 == 0:
    return x//2
  else:
    return 3*x+1
  
s = int(input())
a = [s]
m = 1
while True:
	t = f(s)
    m += 1
	if t not in a:
      a.append(t)
      s = t
    else:
      break
print(m)

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

s = int(input())
a = [s]
m = 1
while True:
	t = f(s)
    m += 1
    if t not in a:
    	a.append(t)
        s = t
	else:
    	break
print(m)

def f(x):
	if x % 2 == 0:
		return x//2
	else:
		return 3*x+1
 
s = int(input())
a = [s]
m = 1
while True:
	t = f(s)
	m += 1
	if t not in a:
		a.append(t)
		s = t
	else:
		break
print(m)

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]
num=2
while num<=1000000:
  if num%2==0:
    list.append(list[num-2]/2)
    if len(list)>len(set(list)):
      break
    num+=1
  else:
    list.append(3*list[num-2]+1)
    if len(list)>len(set(list)):
      break
    num+=1
print(num)

s=int(input())
list=[s]
num=2
while num<=1000000:
  if num%2==0:
    if list[num-2]/2 in list:
      break
    else:
      list.append(list[num-2]/2)
    num+=1
  else:
    if 3*list[num-2]+1 in list:
      break
    else:
      list.append(list[num-2]*3+1)
    num+=1
print(num)

int(input())
list=[s]
num=2
while num<=1000000:
  if num%2==0:
    list.append(list[num-2]/2)
  else:
    list.append(list[num-2]*3+1)
  if list[num-1] in list[:num-1]:
    print(num)
    break
  num+=1

s=int(input())
list=[s]
num=2
while num<=1000000:
  if num%2==0:
    list.append(list[num-2]/2)
  else:
    list.append(list[num-2]*3+1)
  if list[num-1] in list[:num-1]:
    break
  num+=1
print(num)

int(input())
list=[s]
num=2
while num<=1000000:
  if num%2==0:
    list.append(list[num-2]/2)
  else:
    list.append(list[num-2]*3+1)
  if list[num-1] in list[:num-1]:
    break
  num+=1
print(num)

s=int(input())
list=[s]
num=2
while num<=1000000:
  if num%2==0:
    list.append(list[num-2]/2)
    if list[num-2]/2 in list:
      break
    num+=1
  else:
    list.append(3*list[num-2]+1)
    if 3*list[num-2]+1 in list:
      break
    num+=1
print(num)

s=int(input())
list=[s]
num=2
while num<=1000000:
  if list[num-2]%2==0:
    list.append(list[num-2]/2)
  else:
    list.append(list[num-2]*3+1)
  if list[num-1] in list[:num-1]:
    break
  num+=1
print(num)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

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())
result = []
ans = []
for i in range(1000000):
    if i == 0:
        result.append(s)
    elif result[i-1] % 2 == 0:
        aim = result[i - 1] // 2
        result.append(aim)
    else:
        aim = result[i - 1] * 3 + 1
        result.append(aim)
for j in range(len(result)):
    for k in range(len(result)):
        if result[j] == result[k] and j > k:
            ans.append(j)
            
print(ans[0] + 1)
            

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: 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):
s = int(input())
a = set()
a.add(s)
index = 1
while True:
  if s % 2 == 0:
    s = int(s/2)
  else:
    s = 3*s + 1

  if s in a:
    print(index)
    exit()
  else:
    index += 1
    a.add(s)

s = int(input())
a = set()
a.add(s)
index = 2
while True:
  if s % 2 == 0:
    s = int(s/2)
  else:
    s = 3*s + 1

  if s in a:
    print(index)
    exit()
  else:
    index += 1
    a.add(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):
s=int(input())
cur=set([s])
i=1
while True:
  i=i+1
  if s%2==0:
    s=s//2
  else:
    s=3*s+1
  if s in cur:
    print(i)
  else:
    cur.add(s)

s=int(input())
c=set([s])
i=1
while True:
  i+=1
  if s&1:
    s=3*s+1
  else:
    s//=2
  if s in c:
    print(i)
    break
  c.add(s)


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):
a = [int(input())]

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

a = [int(input())]

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

a = [int(input())]

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

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):
    i = int(input())
    seen = set()
    seen.add(i)
    temp = i
    for x in range(0,1000000):
      if(temp%2 == 0):
        temp = temp/2
      else:
        temp = 3*temp+1
      if(temp in seen):
        print(x)
        break
      else:
        seen.add(temp)

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)


i = int(input())
seen = set()
seen.add(i)
temp = i
for x in range(0,1000000):
  if(temp%2 == 0):
    temp = temp/2
  else:
    temp = 3temp+1
  if(temp in seen):
    print(x)
    break
  else:
    seen.add(temp)

i = int(input())
seen = set()
seen.add(i)
temp = i
for x in rannge(0,1000000):
  if(temp%2 == 0):
    temp = temp/2
  else:
    temp = 3temp+1
  if(temp in seen):
    print(x)
    break
  

i = int(input())
seen = set()
seen.add(i)
temp = i
for x in rannge(0,1000000):
  if(temp%2 == 0):
    temp = temp/2
  else:
    temp = 3temp+1
  if(temp in seen):
    print(x)
    break
  else:
    seen.add(temp)

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(x)
        break
    else:
        seen.add(temp)


Verdicts: Runtime Error

Wrong Answer

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

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)

Verdicts: Wrong Answer

Accepted