Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02761 (python)

Fixed submission:
from sys import stdin


def main():
    N, M = [int(x) for x in stdin.readline().rstrip().split()]
    result = ['*'] * N
    for i in range(M):
        s, c = [int(x) for x in stdin.readline().rstrip().split()]
        if result[s - 1] == '*' or result[s - 1] == str(c):
            result[s - 1] = str(c)
        else:
            print(-1)
            return
    if result[0] == '0' and N != 1:
        print(-1)
        return
    if result[0] == '*' and N == 1:
        result[0] = '0'
    if result[0] == '*':
        result[0] = '1'
    for i in range(N):
        if result[i] == '*':
            result[i] = '0'
    print(''.join(result))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from sys import stdin


def main():
    N, M = [int(x) for x in stdin.readline().rstrip().split()]
    result = ['*'] * N
    for i in range(M):
        s, c = [int(x) for x in stdin.readline().rstrip().split()]
        if result[s - 1] == '*' or result[s - 1] == str(c):
            result[s - 1] = str(c)
        else:
            print(-1)
            return
    if result[0] == '0' and N != 1:
        print(-1)
        return
    if result[0] == '*':
        result[0] = '1'
    for i in range(N):
        if result[i] == '*':
            result[i] = '0'
    if N == 1:
        aaa
    print(''.join(result))


if __name__ == "__main__":
    main()
Problem p02844 (python)

Fixed submission:
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    S = stdin.readline().rstrip()
    count = 0
    for i in range(1000):
        left = 0
        not_found = False
        for c in '{:03}'.format(i):
            for j in range(left, N):
                if S[j] == c:
                    left = j + 1
                    break
            else:
                not_found = True
                break
            if not_found:
                break
        if not not_found:
            count += 1
    print(count)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    S = stdin.readline().rstrip()
    count = 0
    for i in range(1000):
        left = 0
        not_found = False
        for c in f'{i:03}':
            for j in range(left, N):
                if S[j] == c:
                    left = j + 1
                    break
            else:
                not_found = True
                break
            if not_found:
                break
        if not not_found:
            count += 1
    print(count)


if __name__ == "__main__":
    main()
Problem p02973 (python)

Fixed submission:
import bisect
from collections import deque
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    As = [int(stdin.readline().rstrip()) for x in range(N)]
    dq = deque([])
    for A in As:
        idx = bisect.bisect_left(dq, A)
        if idx == 0:
            dq.appendleft(A)
        else:
            dq[idx - 1] = A
    print(len(dq))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from sys import stdin


def increment_left(li, As):
    while True:
        if As[li] < As[li + 1]:
            li += 1
            continue
        break
    return li


def decrement_right(ri, As):
    while True:
        if As[ri] > As[ri - 1]:
            ri -= 1
            continue
        break
    return ri


def main():
    N = int(stdin.readline().rstrip())
    As = [int(stdin.readline().rstrip()) for x in range(N)]
    result = 0
    li = 0
    ri = N - 1
    while True:
        li = increment_left(li, As)
        ri = decrement_right(ri, As)
        if ri <= li:
            result += 1
            break
        if As[li] < As[ri]:
            result += 1
        else:
            result += 2
        li += 1
        ri -= 1
        if ri == li:
            result += 1
            break
        elif ri < li:
            break
    print(result)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from sys import stdin


def increment_left(li, As):
    while True:
        if As[li] < As[li + 1]:
            li += 1
            continue
        break
    return li


def decrement_right(ri, As):
    while True:
        if As[ri] > As[ri - 1]:
            ri -= 1
            continue
        break
    return ri


def main():
    N = int(stdin.readline().rstrip())
    As = [int(stdin.readline().rstrip()) for x in range(N)]
    result = 0
    li = 0
    ri = N - 1
    while True:
        li = increment_left(li, As)
        ri = decrement_right(ri, As)
        if ri <= li:
            result += 1
            break
        if As[li] < As[ri]:
            result += 1
        else:
            result += 2
        li += 1
        ri -= 1
        if ri <= li:
            break
    print(result)


if __name__ == "__main__":
    main()
Problem p03061 (python)

Fixed submission:
from functools import lru_cache
from sys import stdin


@lru_cache(maxsize=None)
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def make_acc_gdbs(As):
    result = []
    tmp = 0
    for x in As:
        tmp = gcd(tmp, x)
        result.append(tmp)
    return result


def main():
    N = int(stdin.readline().rstrip())
    As = [int(x) for x in stdin.readline().rstrip().split()]
    lAs = make_acc_gdbs(As)
    rAs = make_acc_gdbs(As[::-1])[::-1]
    max_ = 0
    for i in range(N):
        left = 0 if i == 0 else lAs[i - 1]
        right = 0 if i == (N - 1) else rAs[i + 1]
        max_ = max(max_, gcd(left, right))
    print(max_)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from math import gcd
from sys import stdin


def mygcd(lst):
    result = lst[0]
    for x in lst[1:]:
        result = gcd(result, x)
    return result


def main():
    _ = int(stdin.readline().rstrip())
    As = [int(x) for x in stdin.readline().rstrip().split()]
    max_ = 0
    for a in As:
        tmp = As[:]
        tmp.remove(a)
        max_ = max(max_, mygcd(tmp))
    print(max_)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from math import gcd
from sys import stdin
from functools import reduce


def main():
    _ = int(stdin.readline().rstrip())
    As = [int(x) for x in stdin.readline().rstrip().split()]
    max_ = 0
    for a in As:
        tmp = As[:]
        tmp.remove(a)
        max_ = max(max_, reduce(gcd, tmp))
    print(max_)


if __name__ == "__main__":
    main()
Problem p03145 (python)

Fixed submission:
from sys import stdin


def main():
    ab, bc, ca = [int(x) for x in stdin.readline().rstrip().split()]
    print(ab * bc // 2)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    with open('sample.txt') as f:
        ab, bc, ca = [int(x) for x in f.readline().rstrip().split()]
        print(ab * bc // 2)


if __name__ == "__main__":
    main()
Problem p03296 (python)

Fixed submission:
from sys import stdin


def get(l, r):
    for i in range(1, 10001):
        if i != l and i != r:
            return i
    assert False, 'damepo'


def main():
    N = int(stdin.readline().rstrip())
    a = [int(x) for x in stdin.readline().rstrip().split()]

    count = 0
    if N == 2:
        if a[0] == a[1]:
            count += 1
    else:
        for i, x in enumerate(a[1:-1]):
            idx = i + 1
            l = a[idx - 1]
            r = a[idx + 1]
            if (l == x and x != r) or (l == x == r) or ((idx == len(a) - 2) and x == r):
                x = get(l, r)
                count += 1
                a[idx] = x
        # print(a)
    print(count)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from sys import stdin


def get(l, r):
    for i in range(1, 10001):
        if i != l and i != r:
            return i
    assert False, 'damepo'


def check(a):
    for i, x in enumerate(a[1:-1]):
        idx = i + 1
        l = a[idx - 1]
        r = a[idx + 1]
        assert l != x and x != r, 'damepo'


def main():
    N = int(stdin.readline().rstrip())
    a = [int(x) for x in stdin.readline().rstrip().split()]
    check(a)
    count = 0
    for i, x in enumerate(a[1:-1]):
        idx = i + 1
        l = a[idx - 1]
        r = a[idx + 1]
        if (l == x and x != r) or (l == x == r) or ((idx == len(a) - 2) and x == r):
            x = get(l, r)
            count += 1
            a[idx] = x
    # print(a)
    print(count)


if __name__ == '__main__':
    main()
Problem p03328 (python)

Fixed submission:
from sys import stdin
from itertools import accumulate


def main():
    a, b = [int(x) for x in stdin.readline().rstrip().split()]
    c = list(accumulate(range(1, 1000)))
    for i in range(len(c) - 1):
        if (c[i + 1] - c[i]) == (b - a):
            print(c[i] - a)
            return


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from sys import stdin
from itertools import accumulate


def main():
    a, b = [int(x) for x in stdin.readline().rstrip().split()]
    c = list(accumulate(range(1, 1000)))
    for i in range(len(c) - 1):
        if (c[i + 1] - c[i]) == (b - a):
            print(f'{c[i] - a}')
            return


if __name__ == '__main__':
    main()
Problem p03339 (python)

Fixed submission:
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    S = stdin.readline()
    count = 0
    s1 = []
    for i, x in enumerate(S):
        if x == 'W':
            count += 1
        s1.append(count)
    count = 0
    s2 = []
    for i, x in enumerate(S[::-1]):
        if x == 'E':
            count += 1
        s2.append(count)
    s2.reverse()

    result = N
    for i in range(N):
        count = 0
        idx = i - 1
        if idx >= 0:
            count += s1[idx]
        idx = i + 1
        if idx < N:
            count += s2[idx]
        result = min(result, count)

    print(result)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from sys import stdin
stdin = open('sample.txt')


def main():
    N = int(stdin.readline().rstrip())
    S = stdin.readline()
    count = 0
    s1 = []
    for i, x in enumerate(S):
        if x == 'W':
            count += 1
        s1.append(count)
    count = 0
    s2 = []
    for i, x in enumerate(S[::-1]):
        if x == 'E':
            count += 1
        s2.append(count)
    s2.reverse()

    result = N
    for i in range(N):
        count = 0
        idx = i - 1
        if idx >= 0:
            count += s1[idx]
        idx = i + 1
        if idx < N:
            count += s2[idx]
        result = min(result, count)

    print(result)


if __name__ == '__main__':
    main()
Problem p03353 (python)

Fixed submission:
from sys import stdin
from string import ascii_lowercase


def myfind(s, c):
    result = []
    for i, x in enumerate(s):
        if x == c:
            result.append(i)
    return result


def main():
    s = stdin.readline().rstrip()
    K = int(stdin.readline().rstrip())
    result = []
    for x in ascii_lowercase:
        idxs = myfind(s, x)
        if not idxs:
            continue
        result.append(x)
        if len(result) >= K:
            break
        temp = sorted(list(set([s[x:] for x in idxs])))
        for y in temp:
            for z in range(len(y)):
                foo = y[: z + 1]
                if not foo in result:
                    result.append(foo)
                    if len(result) >= K:
                        break
            if len(result) >= K:
                break
        if len(result) >= K:
            break

    print(result[-1])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from sys import stdin
from string import ascii_lowercase

stdin = open('sample.txt')


def myfind(s, c):
    result = []
    for i, x in enumerate(s):
        if x == c:
            result.append(i)
    return result


def main():
    s = stdin.readline().rstrip()
    K = int(stdin.readline().rstrip())
    result = []
    for x in ascii_lowercase:
        idxs = myfind(s, x)
        if not idxs:
            continue
        result.append(x)
        if len(result) >= K:
            break
        temp = sorted(list(set([s[x:] for x in idxs])))
        for y in temp:
            for z in range(len(y)):
                foo = y[: z + 1]
                if not foo in result:
                    result.append(foo)
                    if len(result) >= K:
                        break
            if len(result) >= K:
                break
        if len(result) >= K:
            break

    print(result[-1])


if __name__ == '__main__':
    main()
Problem p03386 (python)

Fixed submission:
from sys import stdin


def main():
    A, B, K = [int(x) for x in stdin.readline().rstrip().split()]
    a = [x for x, y in zip(range(A, B + 1), range(K))]
    b = [x for x, y in zip(range(B, A - 1, -1), range(K))]
    c = sorted(list(set(a + b)))
    for x in c:
        print(x)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from sys import stdin


def main():
    A, B, K = [int(x) for x in stdin.readline().rstrip().split()]
    tmp = list(range(A, B + 1))
    a = tmp[:K]
    b = tmp[-K:]
    c = sorted(list(set(a + b)))
    for x in c:
        print(x)


if __name__ == '__main__':
    main()
Problem p03393 (python)

Fixed submission:
from sys import stdin
from string import ascii_lowercase
from bisect import bisect_left


def main():
    word = stdin.readline().rstrip()
    if word == ascii_lowercase[::-1]:
        print(-1)
        return

    spam = sorted(list(set(ascii_lowercase) - set(word)))
    if 1 <= len(spam):
        print(word + spam[0])
        return

    rword = word[::-1]
    tmp = []
    for x in rword:
        if len(tmp) != 0 and x < sorted(tmp)[-1]:
            idx = bisect_left(tmp, x)
            print(word[:-len(tmp) - 1] + sorted(tmp)[idx])
            return
        tmp.append(x)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import functools
import math
from itertools import combinations
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    ham = combinations(range(1, 30001), 100)
    for x in ham:
        if functools.reduce(math.gcd, x) == 1:
            for y in x:
                xx = list(x)
                xx.remove(y)
                if functools.reduce(math.gcd, [y, sum(xx)]) != 1:
                    break
            else:
                print(' '.join([str(i) for i in x]))
                return


if __name__ == '__main__':
    main()
Problem p03407 (python)

Fixed submission:
import sys


def main():
    A, B, C = [int(x) for x in sys.stdin.readline().split()]
    if C <= A + B:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys


def spam(ab, cd, count=0):
    ab = ab[:]
    cd = cd[:]
    for x in ab:
        for y in cd:
            if x[0] < y[0] and x[1] < y[1]:
                ab.remove(x)
                cd.remove(y)
                return spam(ab, cd, count + 1)
    return count


def main():
    N = int(sys.stdin.readline())
    ab = [[int(x) for x in sys.stdin.readline().split()] for _ in range(N)]
    cd = [[int(x) for x in sys.stdin.readline().split()] for _ in range(N)]
    ab1 = sorted(ab, key=lambda x: (x[0], x[1]))
    cd1 = sorted(cd, key=lambda x: (x[0], x[1]))
    ab2 = sorted(ab, key=lambda x: (x[1], x[0]))
    cd2 = sorted(cd, key=lambda x: (x[1], x[0]))
    print(max([spam(ab1, cd1), spam(ab2, cd2)]))


if __name__ == '__main__':
    main()
Problem p02687 (python)

Fixed submission:
S = input()
 
if S == 'ABC':
  print('ARC')
else:
  print('ABC')

Buggy submission (verdict: Runtime Error):
S = input()

if S = 'ABC':
  print('ARC')
else:
  print('ABC')
Problem p02713 (python)

Fixed submission:
from math import gcd

K = int(input())
ans = 0

for i in range(1,K+1):
    for k in range(1,K+1):
        b = gcd(i, k)
        for m in range(1,K+1):
            ans += gcd(b, m)

print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd

def solve():
    K = int(input())
    ans = 0
    
    for i in range(1,K+1):
        num = [0, 0, 0]
        num[0] = i
        for k in range(1,K+1):
            num[1] = k
            for m in range(1,K+1):
                num[2] = m
                ans += reduce(gcd, num)
    return ans

print(solve())
Problem p02818 (python)

Fixed submission:
a, b, k = map(int, input().split())
if a - k > 0:
    a = a - k
elif a - k < 0:
    if b - (k - a) > 0:
        b = b - (k - a)
        a = 0
    else:
        b = 0
        a = 0
else:
    a = 0
print(a, b)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
for i in range(k):
    if a >= 1:
        a-=1
    elif b >= 1:
        b-=1
    else:
        path
print(a, b)
Problem p02899 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a_sort = sorted(a)

for i, name in enumerate(a):
  a_sort[name-1] = str(i + 1)
print(' '.join(a_sort))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a_sort = sorted(a)

for i, name in enumerate(a):
  a_sort[name-1] = i + 1
print(' '.join(a_sort))
Problem p02923 (python)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))

count = 0
answer = 0

for i in range(n-1):
  if h[i] >= h[i+1]:
    count+=1
  else:
    answer = max(answer, count)
    count = 0
print(max(answer, count))

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))

count = 0
answer = 0

for i in range(len(h-1)):
  if a[i] >= a[i+1]:
    count+=1
  else:
    answer = max(answer, count)
    count = 0
print(answer)
Problem p03944 (python)

Fixed submission:
w, h, n = map(int, input().split())
lis = []
for i in range(n):
  lis.append(list(map(int, input().split())))
x=0
y=0

for i in lis:
  if i[2] == 1:
    if x < i[0]:
      x=i[0]
  elif i[2] == 2:
    if i[0] < w:
      w=i[0]
  elif i[2] == 3:
    if y < i[1]:
      y=i[1]
  else:
    if i[1] < h:
      h=i[1]
x_a = w-x
y_a= h-y
if x_a < 0 or y_a < 0:
  print(0)
  exit()
print(x_a*y_a)

Buggy submission (verdict: Runtime Error):
w, h, n = map(int, input().split())
lis = []
for i in range(n):
  lis.append(list(map(int, input().split())))
x=0
y=0

for i in lis:
  if i[2] == 1:
    if x < i[0]:
      x=i[0]
  elif i[2] == 2:
    if i[0] < w:
      w=i[0]
  elif i[2] == 3:
    if y < i[1]:
      y=i[1]
  else:
    if i[1] < h:
      h=i[1]
x_a = w-x
y_a= h-y
if x_a < 0 or y_a < 0:
  print(0)
  exit()
print(x_a*y_a)
    if i[1] < y:
      h=i[1]
x_a = w-x
y_a= h-y
if x_a < 0 or y_a < 0:
  print(0)
  exit()
print(x_a*y_a)
Problem p03415 (python)

Fixed submission:
list1 = []
list2 = []
for _ in range(3):
    list1.append(input())

for num, li_con in enumerate(list1):
    list2.append(li_con[num])

moji = "".join(list2)
print(moji)

Buggy submission (verdict: Runtime Error):
list1 = []
list2 = []
for _ in range(3):
    list1.append(input().split())

for num, li_con in enumerate(list1):
    list2.append(li_con[num])

moji = "".join(list2)
print(moji)
Problem p02727 (python)

Fixed submission:
lst = input().split()
X = int(lst[0])
Y = int(lst[1])
A = int(lst[2])
B = int(lst[3])
C = int(lst[4])

p_list = [int(num) for num in input().split(" ")]
q_list = [int(num) for num in input().split(" ")]
r_list = [int(num) for num in input().split(" ")]

sort_p = sorted(p_list,reverse = True)[:X]
sort_q = sorted(q_list,reverse = True)[:Y]
sort_r = sorted(r_list,reverse = True)[:X+Y]

max_score = 0
sort_p.extend(sort_q)
sort_p.extend(sort_r)
sort_p.sort(reverse = True)
for i in range(X+Y):
    max_score += sort_p[i]

print(max_score)

Buggy submission (verdict: Runtime Error):
lst = input().split()
X = int(lst[0])
Y = int(lst[1])
A = int(lst[2])
B = int(lst[3])
C = int(lst[4])

p_list = [int(num) for num in input().split(" ")]
q_list = [int(num) for num in input().split(" ")]
r_list = [int(num) for num in input().split(" ")]

sort_p = sorted(p_list,reverse = True)[:X]
sort_q = sorted(q_list,reverse = True)[:Y]
sort_r = sorted(r_list,reverse = True)[:X+Y]

max_score = 0

for i in range(X+Y):
    if len(sort_p) ==0:
        if sort_q[0] >= sort_r[0]:
            max_score += sort_q[0]
            sort_q = sort_q[1:]
        else:
            max_score += sort_r[0]
            sort_r = sort_r[1:]
            sort_q.pop()
    elif len(sort_q) ==0:
        if sort_p[0] >= sort_r[0]:
            max_score += sort_p[0]
            sort_p = sort_p[1:]
        else:
            max_score += sort_r[0]
            sort_r = sort_r[1:]
            sort_p.pop()

    else:
        if sort_p[0] >= sort_q[0] and sort_p[0] >= sort_r[0]:
            max_score += sort_p[0]
            sort_p = sort_p[1:]
        elif sort_p[0] >= sort_r[0]:
            max_score += sort_q[0]
            sort_q = sort_q[1:]
        else:
            max_score += sort_r[0]
            sort_r = sort_r[1:]
            if sort_p[-1] < sort_q[-1]:
                sort_p.pop()
            else :
                sort_q.pop()
print(max_score)
Problem p02909 (python)

Fixed submission:
s = input()
if s == "Rainy":
  print("Sunny")
elif s == "Sunny":
  print("Cloudy")
else:
  print("Rainy")

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

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
for i in range(M):
  A[-1] = A[-1]/2
  if len(A) == 1:
    continue
  elif A[-1] < A[-2]:    
    A = sorted(A)
A = np.array(A)
A = np.floor(A)
print(int(np.sum(A)))

Buggy submission (verdict: Runtime Error):
s = input()
if s == "Rainy":
  print("Sunny")
elif s == "Sunny":
  prin("Cloudy")
else
print("Rainy")
Problem p02684 (python)

Fixed submission:
import sys 
def solve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    p_bool = [False] * n
    ne_p = 1
    p_bool[ne_p-1] = True
    step = 0
    for i in range(n):
        ne_p = a[ne_p-1]
        step += 1
        if p_bool[ne_p-1]:
            break
        else:
            p_bool[ne_p-1] = True
        if step == k:
            print(ne_p)
            sys.exit()
    
    p_list = []
    sta = ne_p
    for i in range(n):
        ne_p = a[ne_p-1]
        step += 1
        p_list.append(ne_p)
        if ne_p == sta:
            break
        if step == k:
            print(ne_p)
            sys.exit()

    len_l = len(p_list)
    left = k-step
    left -= (left//len_l) * len_l
    print(p_list[left-1])
    # p_list = [1]
    # ne_p = a[0]
    # p_bool = [False] * n
    # p_bool[0] = True
    # check = False
    # step = 0
    # for _ in range(n):
    #     p_bool[ne_p-1] = True
    #     p_list.append(ne_p)
    #     step = 0
    #     if step == k:
    #         #print(ne_p)
    #         sys.exit()
    #     ne_p = a[ne_p-1]
    #     # if ne_p in p_list:
    #     #     ind = p_list.index(ne_p)
    #     #     break
    #     if p_bool[ne_p-1]:
    #         check = True
    #         break
        
    # #print(p_list)
    # #print(p_bool)
    # if check:
    #     ind = p_list.index(ne_p)
    # else:
    #     ind = 0
    # k = k - ind
    # #print(ind)
    # #print(k)
    # #print(p_list)
    # #print(k%(len(p_list)-ind))
    # print(p_list[ind + k%(len(p_list)-ind)])

solve()

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))

p_list = [1]
ne_p = a[0]
for _ in range(k):
    p_list.append(ne_p)
    ne_p = a[ne_p-1]
    if ne_p in p_list:
        ind = p_list.index(ne_p)
        break
k = k - ind
print(p_list[ind + k%(len(p_list)-ind)])