Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math

def main():
  R = input()
  if 1 <= R <= 100:
    answer = float(R) * 2 / math.pi
  else:
    main()
  print(answer)
  
if __name__ == '__main__':
  main()

Fixed submission:
import math

def main():
  R = input()
  answer = float(R) * 2 * math.pi  
  print(answer)
  
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Runtime Error):
R = input()
answer = R * 2 / 3.14
print(answer)

Fixed submission:
import math

def main():
  R = input()
  answer = float(R) * 2 * math.pi  
  print(answer)
  
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Runtime Error):
def main():
  R = input()
  answer = R * 2 / 3.14
  print(answer)
  
if __name__ == '__main__':
  main()

Fixed submission:
import math

def main():
  R = input()
  answer = float(R) * 2 * math.pi  
  print(answer)
  
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Runtime Error):
import math

def main():
  R = input()
  answer = R * 2 / 3.14
  print(answer)
  
if __name__ == '__main__':
  main()

Fixed submission:
import math

def main():
  R = input()
  answer = float(R) * 2 * math.pi  
  print(answer)
  
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Runtime Error):
import math

def main():
  R = input()
  answer = R * 2 / math.pi
  print(answer)
  
if __name__ == '__main__':
  main()

Fixed submission:
import math

def main():
  R = input()
  answer = float(R) * 2 * math.pi  
  print(answer)
  
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Runtime Error):
import math

def main():
  R = input()
  if 1 <= R <= 100:
    answer = R * 2 / math.pi
  else:
    main()
  print(answer)
  
if __name__ == '__main__':
  main()

Fixed submission:
import math

def main():
  R = input()
  answer = float(R) * 2 * math.pi  
  print(answer)
  
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Runtime Error):
import numpy as np

def main():
  R = input()
  if 1 <= R <= 100:
    answer = R * 2 / np.pi
  else:
    main()
  print(answer)
  
if __name__ == '__main__':
  main()

Fixed submission:
import math

def main():
  R = input()
  answer = float(R) * 2 * math.pi  
  print(answer)
  
if __name__ == '__main__':
  main()
Buggy python submission (verdict: Runtime Error):
import math
import numpy as np

def main():
  N,M = (int(x) for x in input().split())
  A = [int(x) for x in input().split(M)]
  
  for i in range(M):
    N = N - A[i]
  
  if N < 0:
    print('-1')
  else:
    print(N)  
  
if __name__ == '__main__':
  main()

Fixed submission:
import math
import numpy as np

def main():
  N,M = (int(x) for x in input().split())
  A = [int(x) for x in input().split()]
  
  for i in range(M):
    N = N - A[i]
  
  if N < 0:
    print('-1')
  else:
    print(N)  
  
if __name__ == '__main__':
  main()
Buggy python submission (verdict: Runtime Error):
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = []
  for i in range(N):
    B.append(0)
    
  for i in range(N):
    e = int(A[N-i-1])
    B[e] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

Fixed submission:
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N    
  for i in range(N-1):
      B[A[N-i-2]-1] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Runtime Error):
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N
  for i in range(N):
    e = int(A[N-i-1])
    B[e] = B[e] + 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

Fixed submission:
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N    
  for i in range(N-1):
      B[A[N-i-2]-1] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Runtime Error):
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N
  B = int(B)
  for i in range(N):
    e = int(A[N-i-1])
    B[e] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

Fixed submission:
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N    
  for i in range(N-1):
      B[A[N-i-2]-1] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Runtime Error):
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N
  for i in range(N):
    e = A[N-i-1]
    B[e] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

Fixed submission:
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N    
  for i in range(N-1):
      B[A[N-i-2]-1] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Runtime Error):
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N
  for i in range(N):
    B[A[N-i-1]] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

Fixed submission:
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N    
  for i in range(N-1):
      B[A[N-i-2]-1] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Runtime Error):
def main():
  N = input()
  A = [int(x) for x in input().split()]
  
  B = [0] * N
  for i in range(N):
    B[A[N-i-1]] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

Fixed submission:
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N    
  for i in range(N-1):
      B[A[N-i-2]-1] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()
Buggy python submission (verdict: Runtime Error):
H,W = (int(i) for i in input().split())

a = [0 for i in range(H)]

for i in range(H):
    a[i] = list(input())

count = 0
check = []
for i in range(H):
    for j in range(W):
        if a[i][j] == '#':
            count = 1
            break
    if count == 0:
        check.append(i)
    count = 0

for i in check:
    del a[i]

ck = []
for i in range(W):
    for j in range(len(a)):
        if a[j][i] == '#':
            count = 1
            break
    if count == 0:
        ck.append(i)
    count = 0

for i in ck:
    for j in range(len(a)):
        del a[j][i]

ans = ''
for i in range(len(a)):
    for j in a[i]:
        ans += j
    print(ans)
    ans = ''

Fixed submission:
H,W = (int(i) for i in input().split())

a = [0 for i in range(H)]

for i in range(H):
    a[i] = list(input())

count = 0
check = []
n = 0
for i in range(H):
    for j in range(W):
        if a[i-n][j] == '#':
            count = 1
            break
    if count == 0:
        del a[i-n]
        n += 1
    count = 0

ck = []
n = 0
for i in range(W):
    for j in range(len(a)):
        if a[j][i] == '#':
            count = 1
            break
    if count == 0:
        ck.append(i)
    count = 0

for i in ck:
    for j in range(len(a)):
        del a[j][i-n]
    n += 1

ans = ''
for i in range(len(a)):
    for j in a[i]:
        ans += j
    print(ans)
    ans = ''
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())

S = (A-1)*(B-1)
print(S)

Fixed submission:
A,B = (int(i) for i in input().split())

S = (A-1)*(B-1)
print(S)
Buggy python submission (verdict: Runtime Error):
N,M = (int(i) for i in input().split())
a = input()
s = a.split()
A = []
for i in range(N):
    A.append(int(s[i]))

count = 0
total = 0

for r in range(N):
    for j in range(int(r+1)):
        l = j
        total = 0
        while l <= r:
            total += A[l]
            if l == r:
                if total % M == 0:
                    count += 1
                    break
                else:
                    break
            else:
                l += 1
print(count)

Fixed submission:
N,K = (int(i) for i in input().split())

if N % K == 0:
    print(0)
else:
    print(1)

Buggy python submission (verdict: Runtime Error):
s = input("number of senbei:")
p = input("number of people:")
N = int(s)
K = int(p)

if N % K == 0:
    print(0)
else:
    print(1)

Fixed submission:
N,K = (int(i) for i in input().split())

if N % K == 0:
    print(0)
else:
    print(1)

Buggy python submission (verdict: Runtime Error):
s = input("number of senbei:")
p = input("number of people:")
N = int(s)
K = int(p)

member = []
for i in range(K):
    member.append(0)

n = N

if N <= K:
    for j in range(N):
        member[j] += 1
    print(member[0] - member[-1])
else:
    while n > 0:
        for l in range(K):
            member[l] += 1
        n = n - K
        if n >= K:
            continue
        elif 0 < n < K:
            for l in range(n):
                member[l] += 1
    print(member[0] - member[-1])

Fixed submission:
N,K = (int(i) for i in input().split())

if N % K == 0:
    print(0)
else:
    print(1)
Buggy python submission (verdict: Time Limit Exceeded):
import unittest


class TestD(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(25), 17)

    def test_2(self):
        self.assertEqual(think(1), 1)

    def test_3(self):
        self.assertEqual(think(100), 108)

    def test_4(self):
        self.assertEqual(think(2020), 40812)

    def test_5(self):
        self.assertEqual(think(200000), 400000008)


def solve():
    n = read()
    result = think(n)
    write(result)


def read():
    return read_int(1)[0]


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n):
    count = 0
    for i in range(1, n + 1):
        first_digit = first_digit_of(i)
        for j in range(first_digit, n + 1, 10):
            count += 1 if satisfies_condition(i, j) else 0
    return count


def write(result):
    print(result)


def satisfies_condition(a, b):
    str_a, str_b = str(a), str(b)
    return str_a[-1] == str_b[0]


def first_digit_of(a):
    return int(str(a)[0])


if __name__ == '__main__':
    # unittest.main()
    solve()

Fixed submission:
import unittest


class TestD(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(25), 17)

    def test_2(self):
        self.assertEqual(think(1), 1)

    def test_3(self):
        self.assertEqual(think(100), 108)

    def test_4(self):
        self.assertEqual(think(2020), 40812)

    def test_5(self):
        self.assertEqual(think(200000), 400000008)


def solve():
    n = read()
    result = think(n)
    write(result)


def read():
    return read_int(1)[0]


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n):
    count = 0
    dp = [[0 for last_digit in range(10)] for first_digit in range(10)]
    for i in range(1, n + 1):
        first_digit = first_digit_of(i)
        last_digit = last_digit_of(i)
        dp[first_digit][last_digit] += 1
    for first_digit in range(10):
        for last_digit in range(10):
            count += dp[first_digit][last_digit] * dp[last_digit][first_digit]
    return count


def write(result):
    print(result)


def first_digit_of(a):
    return int(str(a)[0])


def last_digit_of(a):
    return int(str(a)[-1])


if __name__ == '__main__':
    # unittest.main()
    solve()
Buggy python submission (verdict: Runtime Error):
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([2, 3, 1]), [3, 1, 2])

    def test_2(self):
        self.assertEqual(think([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])

    def test_3(self):
        self.assertEqual(think([8, 2, 7, 3, 4, 5, 6, 1]), [8, 2, 4, 5, 6, 7, 3, 1])


def solve():
    a = read()
    result = solve(a)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a):
    list_of_index_and_a = []
    for index, e in enumerate(a):
        list_of_index_and_a.append((index + 1, e))

    list_of_index_and_a.sort(key=lambda x: x[1])
    return [x[0] for x in list_of_index_and_a]


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Fixed submission:
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([2, 3, 1]), [3, 1, 2])

    def test_2(self):
        self.assertEqual(think([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])

    def test_3(self):
        self.assertEqual(think([8, 2, 7, 3, 4, 5, 6, 1]), [8, 2, 4, 5, 6, 7, 3, 1])


def solve():
    a = read()
    result = think(a)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a):
    list_of_index_and_a = []
    for index, e in enumerate(a):
        list_of_index_and_a.append((index + 1, e))

    list_of_index_and_a.sort(key=lambda x: x[1])
    return [x[0] for x in list_of_index_and_a]


def write(result):
    print(' '.join(list(map(lambda x: str(x), result))))


if __name__ == '__main__':
    # unittest.main()
    solve()
Buggy python submission (verdict: Runtime Error):
import unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([1, 3, 5, 4, 2]), 2)

    def test_2(self):
        self.assertEqual(think([9, 6, 3, 2, 5, 8, 7, 4, 1]), 5)


def solve():
    p = read()
    result = think(p)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    n = len(data)
    count = 0
    for i in range(n):
        if i + 2 >= n:
            break
        if data[i] < data[i + 1] < data[i + 2]:
            count += 1
    return count


def write(result):
    print(result)


if __name__ == '__main__':
    unittest.main()
    # solve()

Fixed submission:
import unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([1, 3, 5, 4, 2]), 2)

    def test_2(self):
        self.assertEqual(think([9, 6, 3, 2, 5, 8, 7, 4, 1]), 5)


def solve():
    p = read()
    result = think(p)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    n = len(data)
    count = 0
    for i in range(n):
        if i + 2 >= n:
            break
        if data[i] < data[i + 1] < data[i + 2] or data[i] > data[i + 1] > data[i + 2]:
            count += 1
    return count


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    max_weight, list_of_weight_and_value = read()
    result = think(max_weight, list_of_weight_and_value)
    write(result)


def read():
    n, max_weight = read_int(2)
    list_of_weight_and_value = []
    for i in range(n):
        list_of_weight_and_value.append(read_int(2))
    return max_weight, list_of_weight_and_value


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(max_weight, list_of_weight_and_value):
    MAX_WEIGHT = 10 ** 5
    MAX_N = 100
    INVALID_VALUE = MAX_WEIGHT * MAX_N + 1

    # dp[w] means max value at total weight 'w'
    dp = [INVALID_VALUE for x in range(max_weight + len(list_of_weight_and_value) + 1)]
    dp[0] = 0

    for weight, value in list_of_weight_and_value:
        for i in range(len(dp) - 1, -1, -1):
            if dp[i] != INVALID_VALUE and i + weight < len(dp):
                if dp[i + weight] == INVALID_VALUE:
                    dp[i + weight] = dp[i] + value
                else:
                    dp[i + weight] = max(dp[i + weight], dp[i] + value)
    return max(filter(lambda x: x != INVALID_VALUE, dp[:max_weight + 1]))


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Fixed submission:
def solve():
    max_weight, list_of_weight_and_value = read()
    result = think(max_weight, list_of_weight_and_value)
    write(result)


def read():
    n, max_weight = read_int(2)
    list_of_weight_and_value = []
    for i in range(n):
        list_of_weight_and_value.append(read_int(2))
    return max_weight, list_of_weight_and_value


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(max_weight, list_of_weight_and_value):
    MAX_WEIGHT = 10 ** 5
    MAX_N = 100
    INVALID_VALUE = -1

    # dp[w] means max value at total weight 'w'
    dp = [INVALID_VALUE for x in range(max_weight + len(list_of_weight_and_value) + 1)]
    dp[0] = 0

    for weight, value in list_of_weight_and_value:
        for i in range(len(dp) - 1, -1, -1):
            if dp[i] != INVALID_VALUE and i + weight < len(dp):
                if dp[i + weight] == INVALID_VALUE:
                    dp[i + weight] = dp[i] + value
                else:
                    dp[i + weight] = max(dp[i + weight], dp[i] + value)
    return max(filter(lambda x: x != INVALID_VALUE, dp[:max_weight + 1]))


def write(result):
    print(result)


if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    k, a = read()
    result = think(k, a)
    write(result)


def read():
    n, k = read_int(2)
    a = read_int(n)
    return k, a


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(k, a):
    max_n = 100
    max_k = 10 ** 5

    # dp[i] = True/False; True means First player win if num of stone is i
    dp = [False] * (max_n * max_k + 1)

    for i in range(len(dp)):
        for elem in a:
            if i >= elem:
                dp[i] |= not dp[i - elem]

    return dp[k]


def write(result):
    if result:
        print('First')
    else:
        print('Second')


if __name__ == '__main__':
    solve()

Fixed submission:
def solve():
    k, a = read()
    result = think(k, a)
    write(result)


def read():
    n, k = read_int(2)
    a = read_int(n)
    return k, a


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(k, a):
    max_n = 100

    # dp[i] = True/False; True means First player win if num of stone is i
    dp = [False] * (k + max_n + 1)

    for i in range(len(dp)):
        for elem in a:
            if i >= elem:
                dp[i] |= not dp[i - elem]

    return dp[k]


def write(result):
    if result:
        print('First')
    else:
        print('Second')


if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Runtime Error):
def solve():
    a, b, c, d = read()
    result = think(a, b, c, d)
    write(result)


def read():
    return read_int(4)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def think(a, b, c, d):
    if b <= c or d <= a:
        return 0
    elif a <= c and d <= b:
        return d - c
    elif c <= a and b <= d:
        return b - a
    else:
        if a == c:
            return min(b, d) - a
        elif a < c:
            return abs(c - b)
        else:  # a > c
            return abs(d - a)


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Fixed submission:
def solve():
    a, b, c, d = read()
    result = think(a, b, c, d)
    write(result)


def read():
    return read_int(4)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a, b, c, d):
    if b <= c or d <= a:
        return 0
    elif a <= c and d <= b:
        return d - c
    elif c <= a and b <= d:
        return b - a
    else:
        if a == c:
            return min(b, d) - a
        elif a < c:
            return abs(c - b)
        else:  # a > c
            return abs(d - a)


def write(result):
    print(result)


if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    a = read()
    result = think(a)
    write(result)


def read():
    n = read_int(1)[0]
    a = []
    for _ in range(n):
        a.append(read_int(1)[0])
    return a


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a):
    dummy = -1
    buttons_flash_info = list(a)
    buttons_flash_info.insert(0, dummy)

    index = 1
    visited = set()
    visited.add(index)
    push_count = 1
    while True:
        next_index = buttons_flash_info[index]
        index = next_index
        if index == 2:
            return push_count
        if index in visited:
            return -1
        push_count += 1
    return -1


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Fixed submission:
def solve():
    a = read()
    result = think(a)
    write(result)


def read():
    n = read_int(1)[0]
    a = []
    for _ in range(n):
        a.append(read_int(1)[0])
    return a


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a):
    dummy = -1
    flag_for_not_visited = 0
    flag_for_visited = 1

    buttons_flash_info = list(a)
    buttons_flash_info.insert(0, dummy)

    index = 1
    visited = [flag_for_not_visited for i in range(len(buttons_flash_info))]
    visited[index] = flag_for_visited
    push_count = 1
    while True:
        next_index = buttons_flash_info[index]
        index = next_index
        if index == 2:
            return push_count
        if visited[index] == flag_for_visited:
            return -1
        visited[index] = flag_for_visited
        push_count += 1
    return -1


def write(result):
    print(result)


if __name__ == '__main__':
    solve()