Language: C++

using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Text.RegularExpressions;

namespace Yuzuki
{
    class Yukari
    {
        static int n;
        static long k;
        static int[] As;
        public static void Main(string[] args)
        {
            input();
            int cur = 0, t = 1, s;
            int[] memo = new int[n];

            while(true)
            {
                cur = As[cur];
                t++;
                if (memo[cur] > 0)
                {
                    s = t - memo[cur];
                    break;
                }
                memo[cur] = t;
            }
            k = (k - t) % s;
            while(k > 0)
            {
                cur = As[cur];
                k--;
            }
            Console.WriteLine(cur);
        }
        public static void input()
        {
            string[] buf = Console.ReadLine().Split();
            n = int.Parse(buf[0]);
            k = long.Parse(buf[1]);
            As = new int[n];
            buf = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
            {
                As[i] = int.Parse(buf[i]) - 1;
            }
        }

    }
}

Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Text;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Linq;
      |       ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'System'
    4 | using System.Collections;
      |       ^~~~~~
a.cc:5:7: error: expected nested-name-specifier before 'System'
    5 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:6:7: error: expected nested-name-specifier before 'static'
    6 | using static System.Console;
      |       ^~~~~~
a.cc:7:7: error: expected nested-name-specifier before 'static'
    7 | using static System.Math;
      |       ^~~~~~
a.cc:8:7: error: expected nested-name-specifier before 'System'
    8 | using System.Text.RegularExpressions;
      |       ^~~~~~
a.cc:16:19: error: expected unqualified-id before '[' token
   16 |         static int[] As;
      |                   ^
a.cc:17:15: error: expected ':' before 'static'
   17 |         public static void Main(string[] args)
      |               ^~~~~~~
      |               :
a.cc:17:33: error: 'string' has not been declared
   17 |         public static void Main(string[] args)
      |                                 ^~~~~~
a.cc:17:42: error: expected ',' or '...' before 'args'
   17 |         public static void Main(string[] args)
      |                                          ^~~~
a.cc:42:15: error: expected ':' before 'static'
   42 |         public static void input()
      |               ^~~~~~~
      |               :
a.cc:55:6: error: expected ';' after class definition
   55 |     }
      |      ^
      |      ;
a.cc: In static member function 'static void Yuzuki::Yukari::Main(int*)':
a.cc:21:16: error: structured binding declaration cannot have type 'int'
   21 |             int[] memo = new int[n];
      |                ^~
a.cc:21:16: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:21:16: error: empty structured binding declaration
a.cc:21:19: error: expected initializer before 'memo'
   21 |             int[] memo = new int[n];
      |                   ^~~~
a.cc:25:23: error: 'As' was not declared in this scope; did you mean 's'?
   25 |                 cur = As[cur];
      |                       ^~
      |                       s
a.cc:27:21: error: 'memo' was not declared in this scope
   27 |                 if (memo[cur] > 0)
      |                     ^~~~
a.cc:32:17: error: 'memo' was not declared in this scope
   32 |                 memo[cur] = t;
      |                 ^~~~
a.cc:37:23: error: 'As' was not declared in this scope; did you mean 's'?
   37 |                 cur = As[cur];
      |                       ^~
      |                       s
a.cc:40:13: error: 'Console' was not declared in this scope
   40 |             Console.WriteLine(cur);
      |             ^~~~~~~
a.cc: In static member function 'static void Yuzuki::Yukari::input()':
a.cc:44:13: error: 'string' was not declared in this scope
   44 |             string[] buf = Console.ReadLine().Split();
      |             ^~~~~~
a.cc:44:20: error: expected primary-expression before ']' token
   44 |             string[] buf = Console.ReadLine().Split();
      |                    ^
a.cc:45:17: error: expected primary-expression before 'int'
   45 |             n = int.Parse(buf[0]);
      |                 ^~~
a.cc:46:17: error: expected primary-expression before 'long'
   46 |             k = long.Parse(buf[1]);
      |                 ^~~~
a.cc:47:13: error: 'As' was not declared in this scope
   47 |             As = new int[n];
      |             ^~
a.cc:48:13: error: 'buf' was not declared in this scope
   48 |             buf = Console.ReadLine().Split();
      |             ^~~
a.cc:48:19: error: 'Console' was not declared in this scope
   48 |             buf = Console.ReadLine().Split();
      |                   ^~~~~~~
a.cc:51:25: error: expected primary-expression before 'int'
   51 |                 As[i] = int.Parse(buf[i]) - 1;
      |                         ^~~