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

Fixed submission:
a = input().split(" ")
b = input().split(" ")
c = 0
for i in b:
    c += int(i)
if int(a[0]) >= c:
    print(int(a[0]) - c)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
a = input().split(" ")
b = input().split(" ")
c = 0
for i in b:
    c += int(i)
if a >= c:
    print(a - c)
else:
    print(-1)
Problem p02755 (python)

Fixed submission:
a = input().split(" ")
t8 = int(a[0])
t10 = int(a[1])

for i in range(13, 1001):
	b = int(i * 0.08)
	c = int(i * 0.1)
	if b == t8 and c == t10:
		print(i)
		break
	if i == 1000:
		print(-1)
		break

Buggy submission (verdict: Runtime Error):
a = input()
b = int(input())
c = 0
for i in range(b):
	d = input().split(" ")
	if d[0] == "1":
		c += 1
	else:
		if c % 2 == 0:
			if d[1] == "1":
				a = d[2] + a
			else:
				a = a + d[2]
		else:
			if d[1] == "2":
				a = d[2] + a
			else:
				a = a + d[2]
if c % 2 == 1:
	a = a[::-1]
print(a)
Problem p02761 (python)

Fixed submission:
a = input().split(" ")
N = int(a[0])
M = int(a[1])
ans1 = 10
ans2 = 10
ans3 = 10
x = 0
for i in range(M):
    b = input().split(" ")
    c = int(b[0])
    d = int(b[1])
    if c == 1:
        if ans1 == 10:
            if d == 0:
                if N == 1:
                    ans1 = 0
                else:
                    x = 1
            else:
                ans1 = d
        elif ans1 != d:
            x = 1
    elif c == 2:
        if ans2 == 10:
            ans2 = d
        elif ans2 != d:
            x = 1
    else:
        if ans3 == 10:
            ans3 = d
        elif ans3 != d:
            x = 1
if ans1 == 10:
    if N == 1:
        ans1 = 0
    else:
        ans1 = 1
if ans2 == 10:
    ans2 = 0
if ans3 == 10:
    ans3 = 0

if x == 1:
    print(-1)
else:
    if N == 1:
        print(ans1)
    elif N == 2:
        if ans1 == 0:
            print(-1)
        else:
            print(str(ans1) + str(ans2))
    else:
        if ans1 == 0:
            print(-1)
        else:
            print(str(ans1) + str(ans2) + str(ans3))

Buggy submission (verdict: Runtime Error):
a = input().split(" ")
N = int(a[0])
M = int(a[1])
ans1 = 10
ans2 = 10
ans3 = 10
x = 0
for i in range(M):
    b = input().split(" ")
    c = int(b[0])
    d = int(b[1])
    if c == 1:
        if d == 0:
            if N == 1:
                ans1 = 0
            else:
                x = 1
        elif ans1 == 10:
            ans1 = d
        elif ans1 != d:
            x = 1
    elif c == 2:
        if ans2 == 10:
            ans2 = d
        elif ans2 != d:
            x = 1
    else:
        if ans3 == 10:
            ans3 = d
        elif ans3 != d:
            x = 1
if ans1 == 10:
    ans1 = 0
if ans2 == 10:
    ans2 = 0
if ans3 == 10:
    ans3 = 0

if x = 1:
    print(-1)
else:
    if N == 1:
        print(ans1)
    elif N == 2:
        if ans1 == 0:
            print(-1)
        else:
            print(str(ans1) + str(ans2))
    else:
        if ans1 == 0:
            print(-1)
        else:
            print(str(ans1) + str(ans2) + str(ans3))

Buggy submission (verdict: Runtime Error):
a = input().split(" ")
N = int(a[0])
M = int(a[1])
ans1 = 10
ans2 = 10
ans3 = 10
for i in range(M):
    b = input().split(" ")
    c = int(b[0])
    d = int(b[1])
    if c == 1:
        if d == 0:
            if N == 1:
                ans1 = d:
        elif d < ans1:
            ans1 = d
    elif c == 2:
        if d < ans2:
            ans2 = d
    else:
        if d < ans3:
            ans3 = d
if ans1 == 10:
    ans1 = 0
if ans2 == 10:
    ans2 = 0
if ans3 == 10:
    ans3 = 0
if N == 1:
    print(ans1)
elif N == 2:
    if ans1 == 0:
        print(-1)
    else:
        print(str(ans1) + str(ans2))
else:
    if ans1 == 0:
        print(-1)
    else:
        print(str(ans1) + str(ans2) + str(ans3))
Problem p02995 (python)

Fixed submission:
def gcd(a, b):
    while b!=0:
        a, b = b, a%b
    return a

num = input().split(" ")
a = int(num[0])-1
b = int(num[1])
c = int(num[2])
d = int(num[3])
e = int(c * d / int(gcd(c, d)))
bb = b - (b//c) -(b//d) +(b//e) 
aa = a - (a//c) -(a//d) + (a//e)
print(int(bb-aa))

Buggy submission (verdict: Runtime Error):
# cording: utf-8
import math
num = input().split(" ")
a = int(num[0])-1
b = int(num[1])
c = int(num[2])
d = int(num[3])
e = int(c * d / int(math.gcd(c, d)))
bb = b - (b//c) -(b//d) +(b//e) 
aa = a - (a//c) -(a//d) + (a//e)
print(int(bb-aa))

Buggy submission (verdict: Runtime Error):
import math
num = input().split(" ")
a = int(num[0])-1
b = int(num[1])
c = int(num[2])
d = int(num[3])
e = int(c * d / int(math.gcd(c, d)))
bb = b - (b//c) -(b//d) +(b//e) 
aa = a - (a//c) -(a//d) + (a//e)
print(int(bb-aa))

Buggy submission (verdict: Runtime Error):
import math
num = input().split(" ")
a = int(num[0])-1
b = int(num[1])
c = int(num[2])
d = int(num[3])
e = c * d // int(math.gcd(c, d))
bb = b - (b//c) -(b//d) +(b//e) 
aa = a - (a//c) -(a//d) + (a//e)
print(int(bb-aa))

Buggy submission (verdict: Runtime Error):
import math
num = input().split(" ")
a = int(num[0])-1
b = int(num[1])
c = int(num[2])
d = int(num[3])
e = c * d // int(math.gcd(c, d))
aaa = b - (b//c) -(b//d) +(b//e) -(a -(a//c) -(a//d) + (a//e))
print(int(aaa))

Buggy submission (verdict: Runtime Error):
import math
num = input().split(" ")
a = int(num[0])-1
b = int(num[1])
c = int(num[2])
d = int(num[3])
e = math.gcd(c, d)
x = b - (b//c) -(b//d) +(b//(c*d/e)) -(a -(a//c) -(a//d) + a//(c*d/e))
print(int(x))

Buggy submission (verdict: Runtime Error):
import math
num = input().split(" ")
a = int(num[0])-1
b = int(num[1])
c = int(num[2])
d = int(num[3])
x = b - (b//c) -(b//d) +(b//(c*d//math.gcd(c, d))) -(a -(a//c) -(a//d) + a//(c*d//math.gcd(c, d)))
print(x)

Buggy submission (verdict: Runtime Error):
num = input().split(" ")
a = int(num[0])
b = int(num[1])
c = int(num[2])
d = int(num[3])
print(b - b // c - b // d + b // (c * d) -(a - a // c - a // d + a // (a // (c * d)))
Problem p03000 (python)

Fixed submission:
a = input().split(" ")
l = input().split(" ")
x = int(a[1])
y = 0
num = 1
for i in l:
    y += int(i)
    if y <= x:
        num += 1
    else:
        break
print(num)

Buggy submission (verdict: Runtime Error):
a = input().split(" ")
l = input().split(" ")
x = int(a[1])
y = 0
num = 1
for i in l:
    y += i
    if y <= x:
        num += 1
    else:
        break
print(num)
Problem p03001 (python)

Fixed submission:
a = input().split(" ")
w = int(a[0])
h = int(a[1])
x = int(a[2])
y = int(a[3])
s = w * h / 2
if w % 2 == 0:
    if h %  2 == 0:
        if x == int(w/2):
            if y == int(h/2):
                how = 1
            else:
                how = 0
        else:
            how = 0
    else:
        how = 0
else:
    how = 0
print(str(s) + " " + str(how))

Buggy submission (verdict: Runtime Error):
a = input().split(" ")
w = int(a[0])
h = int(a[1])
x = int(a[2])
y = int(a[3])
s = w * h / 2
if w % 2 == 0:
    if h %  2 == 0:
        if x == int(w/2):
            if y == int(h/2):
                how = 1
else:
    how = 0
print(str(s) + " " + str(how))
Problem p02690 (python)

Fixed submission:
import math
x = int(input())
b = 0

"""
def calc(b, b5):
    a = (x+b5)**0.2

    if a.real.is_integer():
        print(int(a), b)
        exit()

while True:
    b5 = b ** 5
    calc(b, b5)
    if x-b5 >= 0:
        calc(-b, -b5)
    b += 1
    """

for i in range(-120,120):
    for j in range(-120,120):
        if i**5 - j**5 == x:
            print(i, j)
            exit()

Buggy submission (verdict: Runtime Error):
import math
x = int(input())
b = 0

@njit
def calc(b, b5):
    a = (x+b5)**0.2

    if a.real.is_integer():
        print(int(a), b)
        exit()

while True:
    b5 = b ** 5
    calc(b, b5)
    calc(-b, -b5)
    b += 1

Buggy submission (verdict: Runtime Error):
import math
x = int(input())
b = 0import math
x = int(input())
b = 0

@njit
def calc(b, b5):
    a = (x+b5)**0.2

    if a.real.is_integer():
        print(int(a), b)
        exit()

while True:
    b5 = b ** 5
    calc(b, b5)
    calc(-b, -b5)
    b += 1


def calc(b, b5):
    a = (x+b5)**0.2

    if a.real.is_integer():
        print(int(a), b)
        exit()

while True:
    b5 = b ** 5
    calc(b, b5)
    calc(-b, -b5)
    b += 1

Buggy submission (verdict: Runtime Error):
import math
x = int(input())
b = 0

while True:
    a = math.pow(x+pow(b, 5), 0.2)
    if a.is_integer():
        print(int(a), b)
        break
    a = math.pow(x+pow(-b, 5), 0.2)
    if a.is_integer():
        print(int(a), b)
        break
    b += 1
Problem p02861 (python)

Fixed submission:
n = int(input())
pos = [list(list(map(int, input().split()))) for _ in range(n)]

dst = 0
for i in range(n-1):
    for j in range(i+1, n):
        dst += ((pos[i][0]-pos[j][0])**2 + (pos[i][1]-pos[j][1])**2)**(1/2)
print(dst*2/n)

Buggy submission (verdict: Runtime Error):
from itertools import permutations, tee
import numpy as np

n = int(input())
pos = [np.array(list(map(int, input().split()))) for _ in range(n)]

def pairwise(itr):
    a, b = tee(itr)
    next(b, None)
    return zip(a, b)

dist = np.array([])
for p in permutations(pos):
    d = 0
    for i, j in pairwise(p):
        d += np.linalg.norm(i-j)
    dist = np.append(dist, d)
print(np.mean(dist))
Problem p03494 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
cnt = 0

while True:
    for num, a in enumerate(A):
        if a % 2:
            print(cnt)
            break
        else:
            A[num] = a / 2
    if a % 2:
        break
    cnt += 1

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
c = a * b
if c % 2:
    print("Odd")
else:
    print("Even")
Problem p02732 (python)

Fixed submission:
# coding: utf-8
n = int(input())
A = list(map(int, input().split()))
X = [0]*(n+1)
for a in A:
    X[a] += 1
s = 0
for x in X:
    s += x*(x-1)//2
for a in A:
    print(s-X[a]+1)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
n = int(input())
A = list(map(int, input().split()))
X = [0]*n
for a in A:
    X[a] += 1
s = 0
for x in X:
    s += x*(x-1)//2
for a in A:
    print(s-X[a]+1)
Problem p02855 (python)

Fixed submission:
# -*- coding: utf-8 -*-
#DISCO C
import sys
import math
import collections
#sys.setrecursionlimit(100000)

#n=int(input())

tmp = input().split()
h,w,k = list(map(lambda a: int(a), tmp))

list = [[0 for i in range(w+1)] for j in range(h)]
for i in range(0,h):
	tmp = input()
	for j in range(0,w):
		if(tmp[j]=='#'):
			list[i][j]+=1
			list[i][w]+=1

ans = [[0 for i in range(w)] for j in range(h)]
index=1
for i in range(0,h):
	if(list[i][w]!=0):
		flg=0
		for j in range(0,w):
			if(list[i][j]==1):
				if(flg==0):
					flg=1
				else:
					index+=1
			ans[i][j] = index
		index+=1
for i in range(1,h):
	if(list[i][w]==0)and(list[i-1][w]!=0):
		for j in range(0,w):
			ans[i][j]=ans[i-1][j]
		list[i][w]=1
for i in range(1,h):
	if(list[h-i-1][w]==0):
		for j in range(0,w):
			ans[h-i-1][j]=ans[h-i][j]
		list[h-i-1][w]=1

#print(list)
#print(ans)


for i in range(0,h):
	outstr=""
	for j in range(0,w):
		outstr+=str(ans[i][j])
		if(j!=w-1):
			outstr+=" "
	print(outstr)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#DISCO C
import sys
import math
import collections
#sys.setrecursionlimit(100000)

#n=int(input())

tmp = input().split()
h,w,k = list(map(lambda a: int(a), tmp))

list = [[0 for i in range(w+1)] for j in range(h)]
for i in range(0,h):
	tmp = input()
	for j in range(0,w):
		if(tmp[j]=='#'):
			list[i][j]+=1
			list[i][w]+=1

ans = [[0 for i in range(w)] for j in range(h)]
index=1
for i in range(0,h):
	if(list[i][w]!=0):
		flg=0
		for j in range(0,w):
#			print(index)
			if(list[i][j]==1):
				if(flg==0):
					flg=1
				else:
					index+=1
			ans[i][j] = index
		index+=1
#			print(list[i][j])
for i in range(1,h):
	if(list[i][w]==0)and(list[i-1][w]!=0):
		for j in range(0,w):
			ans[i][j]=ans[i-1][j]
		list[i][w]==1
for i in range(1,h):
	if(list[h-i][w]==0)and(list[h-i+1][w]!=0):
		for j in range(0,w):
			ans[h-i][j]=ans[h-i+1][j]
		list[h-i][w]==1

#print(list)
#print(ans)


for i in range(0,h):
	outstr=""
	for j in range(0,w):
		outstr+=str(ans[i][j])
		if(j!=w-1):
			outstr+=" "
	print(outstr)
Problem p02885 (python)

Fixed submission:
# -*- coding: utf-8 -*-
#ABC143A
import sys
import math
import collections
#sys.setrecursionlimit(100000)


#n=int(input())

tmp = input().split()
a,b = list(map(lambda a: int(a), tmp))



sum = a
sum -=b
sum -=b
if (sum<0):
	sum=0


print(sum)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#ABC143D
import sys
import math
import collections
#sys.setrecursionlimit(100000)
 
 
n=int(input())
 
tmp = input().split()
l = list(map(lambda a: int(a), tmp))
 
sum=0
 
for i in range(n):
	for j in range(i+1,n):
		tmp1 = l[i]+l[j]
		tmp2 = abs(l[i]-l[j])
		for k in range(j+1,n):
			if((tmp1>l[k])and(tmp2<l[k])):
				sum+=1
print(sum)
Problem p03240 (python)

Fixed submission:
# -*- coding: utf-8 -*-
#ABC112C
import sys

n = int(input())

x = []
y = []
h = []
for i in range(0,n):
	tmp = input().split()
	hoge = list(map(lambda a: int(a), tmp))
	x.append(hoge[0])
	y.append(hoge[1])
	h.append(hoge[2])

distance=0
height=0

m=0
while(h[m]==0):
	m+=1
for i in range(0,101):
	for j in range(0,101):
		distance=abs(i-x[m])
		distance+=abs(j-y[m])
		height=distance+h[m]
		for k in range(0,n):
			distance=abs(i-x[k])
			distance+=abs(j-y[k])
			if(max(height-distance,0)!=h[k]):
				break
			if(k==n-1):
				print(i,j,height)
				sys.exit()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#ABC112C
import sys

n = int(input())

x = []
y = []
h = []
for i in range(0,n):
	tmp = input().split()
	hoge = list(map(lambda a: int(a), tmp))
	x.append(hoge[0])
	y.append(hoge[1])
	h.append(hoge[2])

distance=0
height=0
#peak ga (i,j) to katei
for i in range(0,101):
	for j in range(0,101):
		distance=abs(i-x[0])
		distance+=abs(j-y[0])
		height=distance+h[0]

		for k in range(1,n):
			distance=abs(i-x[k])
			distance+=abs(j-y[k])
			if(height==distance+h[k]!):
				break
			if(k==n-1):
				print(i,j,height)
				sys.exit()
Problem p03613 (python)

Fixed submission:
# -*- coding: utf-8 -*-
#ARC082C
import copy
import sys
import math

n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

hoge.sort()
hoge.append(-1)
a=0
b=0
c=1
maxhoge=0
for i in range(0,n):
	if(hoge[i]!=hoge[i+1]):
		if(i!=n-1):
			if(hoge[i+1]-hoge[i]==1):
				a=b
				b=c
				c=1
			elif(hoge[i+1]-hoge[i]==2):
				a=c
				b=0
				c=1
			else:
				a=0
				b=0
				c=1
	else:
		c+=1
#	print("i:{} | {} {} {}".format(i,a,b,c))

	maxhoge=max(maxhoge,a+b+c)



#print(hoge)
print(maxhoge)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#ARC082C
import copy
import sys
import math

n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

hoge.sort()
hoge.append(-1)
a=0
b=0
c=1
maxhoge=0
for i in range(0,n):
	if(hoge[i]!=hoge[i+1]):
		if(i!=n-1):
			if(hoge[i+1]-hoge[i]==1):
				a=b
				b=c
				c=1
			elif(hoge[i+1]-hoge[i]==2):
				a=c
				b=0
				c=1
			else:
				a,b=0
				c=1
	else:
		c+=1
#	print("i:{} | {} {} {}".format(i,a,b,c))

	maxhoge=max(maxhoge,a+b+c)



#print(hoge)
print(maxhoge)
Problem p03633 (python)

Fixed submission:
# -*- coding: utf-8 -*-
#ABC070C
import math

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

n = int(input())

t=[]
for i in range(0,n):
	t.append(0)
for i in range(0,n):
    t[i] = int(input())

ans = t[0]
for i in range(1,n):
	j = gcd(ans,t[i])
	ans *= t[i]
	ans = ans//j

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#ABC070C
import math

#def lcm(x, y):
#	ans=((x * y) // math.gcd(x, y))
#	return ans

n = int(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))

t=[]
for i in range(0,n):
	t.append(0)
for i in range(0,n):
    t[i] = int(input())

ans = t[0]
for i in range(1,n):
	j = math.gcd(ans,t[i])
	ans *= t[i]
	ans = ans//j

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#ABC070C
import math

def lcm(x, y):
	ans=((x * y) // math.gcd(x, y))
	return ans

n = int(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))

t=[]
for i in range(0,n):
	t.append(0)
for i in range(0,n):
    t[i] = int(input())

ans = t[0]
for i in range(1,n):
	ans = lcm(ans,t[i])

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#ABC070C
import math

def lcm(x, y):
	ans=((x * y) // math.gcd(x, y))
	return ans

n = int(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))

t=[]
for i in range(0,n):
	t.append(int(input()))
#print(t)

ans = t[0]
for i in range(1,n):
	ans = lcm(ans,t[i])

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#ABC070C
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

n = int(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))

t=[]
for i in range(0,n):
	t.append(int(input()))
#print(t)

ans = t[0]
for i in range(1,n):
	ans = lcm(ans,t[i])

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#ABC070C
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

n = int(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))

t=[]
for i in range(0,n):
	t.append(int(input()))
#print(t)

ans = t[0]
for i in range(1,n):
	ans = lcm(ans,t[i])

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#ABC070C
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

n = int(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))

t=[]
for i in range(0,n):
	t.append(int(input()))
#print(t)

ans = t[0]
for i in range(1,n):
	ans = lcm(ans,t[i])

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#ABC070C
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

n = int(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))

t=[]
for i in range(0,n):
	t.append(int(input()))
#print(t)

ans = t[0]
for i in range(1,n):
	ans = lcm(ans,t[i])

print(ans)
Problem p03651 (python)

Fixed submission:
# -*- coding: utf-8 -*-
#AGC014A
import sys
#import collections

#n= int(input())

tmp = input().split()
n,k = list(map(lambda a: int(a), tmp))

tmp = input().split()
a = list(map(lambda a: int(a), tmp))

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

maxa=a[0]
tmp=a[0]
for i in range(1,n):
	maxa=max(maxa,a[i])
	tmp=gcd(tmp, a[i])

if(k<=maxa)and(k%tmp ==0):
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

#print(maxa)
#print(tmp)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#AGC014A
import sys
#import collections

#n= int(input())

tmp = input().split()
n,k = list(map(lambda a: int(a), tmp))

tmp = input().split()
a = list(map(lambda a: int(a), tmp))

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

maxa=a[0]
tmp=a[0]
for i in range(1,n):
	maxa=max(maxa,a[i])
	tmp=gcd(tmp, a[i])

if(k<=m)and(k%tmp ==0):
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

#print(maxa)
#print(tmp)
Problem p02641 (python)

Fixed submission:
X,N = map(int,input().split())
A = list(map(int,input().split()))

i=0

while True:
    if X-i in A and X+i in A:
        i+=1
    elif X-i in A:
        print(X+i)
        exit()
    else:
        print(X-i)
        exit()

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

A.sort()
ans=0

if A[0]!=A[1]:
    ans=1

for i in range(1,N):
    if A[i]==A[i-1]:            
        continue
    for j in range(i):
        if A[i]%A[j]==0:
            break
        if j==i-1:
            ans+=1

print(ans)
Problem p02658 (python)

Fixed submission:
import numpy as np

N = int(input())
P = list(map(int,input().split()))

if 0 in P:
    print(0)
    exit()

ans=1
P.sort(reverse=True)

for i in range(N):
    ans*=P[i]
    if ans>10**18:
        print(-1)
        exit()

print(ans)

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

N = int(input())
P = list(map(int,input().split()))

ans = np.prod(P)

if ans>10**18:
    print(-1)
    exit()

print(ans)
Problem p02684 (python)

Fixed submission:

N,K = map(int,input().split())
A=list(map(int,input().split()))

P=[1]
S=[0]*N
S[0]=1
now=1

for i in range(K):
    now=A[now-1]
    if S[now-1]==1:
        x = i+1
        y = P.index(now)
        break
    elif i == K-1:
        print(now)
        exit()
    else:
        P.append(now)
        S[now-1]=1

c=(K-y)%(x-y)

print(P[y+c])

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
A=list(map(int,input().split()))

P=[1]
now=1

for i in range(K):
    now=A[now-1]
    if now in P:
        x = i+1
        y = P.index(now)
        break
    else:
        P.append(now)

c=(K-y)%(x-y)

for i in range(c):
    now=A[now-1]

print(now)
Problem p02702 (python)

Fixed submission:
from collections import defaultdict

S = input()
B = defaultdict(int)
B[0]=1
ans=0
prev=0

for i in range(len(S)):
    m=(prev+int(S[-i-1])*pow(10,i,2019))%2019
    ans+=B[m]
    B[m]+=1
    prev=m

print(int(ans))

Buggy submission (verdict: Runtime Error):
S = input()
B = defaultdict(int)
B[0]=1
ans=0

for i in range(len(S)):
    m=int(S[-i-1:])%2019
    ans+=B[m]
    B[m]+=1

print(int(ans))
Problem p02684 (python)

Fixed submission:
n,k = map(int, input().split())
a = list(map(int, input().split()))
visit = [-1 for i in range(n)]
root = []
now = 1
length = 0
root.append(now)
if k > n:
    for i in range(n):
        if visit[now - 1] != 1:
            visit[now - 1] = 1
            now = a[now - 1]
            root.append(now)
            length += 1
        else:break
    start = 0
    for i in range(n):
        if root[i] == now:
            start = i
            break
    length -= start
    k -= start
    k %= length
    ans = root[start + k]
    print(ans)
else:
    for i in range(k):
        now = a[now - 1]
    print(now)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = list(map(int, input().split()))
visit = [-1 for i in range(n)]
root = []
now = 1
length = 0
root.append(now)
if k > n:
    for i in range(n):
        if visit[now - 1] != 1:
            visit[now - 1] = 1
            now = a[now - 1]
            root.append(now)
            length += 1
        else:break
    start = 0
    for i in range(n):
        if root[i] == now:
            start = i
            break
    length -= start + 1
    k -= start
    k %= length
    ans = root[start]
    for i in range(k):
        ans = root[start + i]
    print(ans)
else:
    for i in range(k):
        now = a[now - 1]
    print(now)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = list(map(int, input().split()))
visit = [-1 for i in range(n)]
root = []
now = 1
length = 0
root.append(now)
if k > 10**6:
    for i in range(n):
        if visit[now - 1] != 1:
            visit[now - 1] = 1
            now = a[now - 1]
            root.append(now)
            length += 1
        else:break
    start = 0
    for i in range(n):
        if root[i] == now:
            start = i
            break
    k -= start
    k %= length
    ans = root[start]
    for i in range(k):
        ans = root[start + i]
    print(ans)
else:
    for i in range(k):
        now = a[now - 1]
    print(now)