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

Fixed submission:
nk = input().split()
n , k = int(nk[0]), int(nk[1])
a = [int(i) for i in input().split()]

t = 1
tl = [1]
ts = {1}


for i in range(len(a)):
    
    t = a[t-1]
    if t in ts:
        break
    else:
        tl.append(t)
        ts.add(t)

tl2 = tl[tl.index(t):len(tl)]
         
# print(tl)
# print(tl2)

ans = 0

if k < len(tl):
    ans = tl[k]
else:
    k = k - len(tl)
    j = k % len(tl2)
    ans = tl2[j]

print(ans)

Buggy submission (verdict: Runtime Error):
nk = input().split()
n , k = int(nk[0]), int(nk[1])
a = [int(i) for i in input().split()]

t = 1
tl = [1]
ts = {1}


for i in range(len(a)):
    
    t = a[t-1]
    if t in ts:
        break
    else:
        tl.append(t)
        ts.add(t)

tl2 = tl[tl.index(t):len(tl)]
         
# print(tl)
# print(tl2)

ans = 0

if k <= len(tl):
    ans = tl[k]
else:
    k = k - len(tl)
    j = k % len(tl2)
    ans = tl2[j]

print(ans)

Buggy submission (verdict: Runtime Error):
nk = input().split()
n , k = int(nk[0]), int(nk[1])
a = [int(i) for i in input().split()]

t = 1
tl = [1]
ts = {1}

flg = False
for i in range(len(a)):
    # flg = t > a[t-1]
    t  = a[t-1]
    # stl = sorted(tl)
    if t in ts:
        break
    else:
        tl.append(t)
        ts.add(t)

tl2 = tl[tl.index(t):len(tl)]
         
# print(tl)
# print(tl2)

ans = 0

if k <= len(tl):
    ans = tl[k]
else:
    k = k - len(tl)
    j = k % len(tl2)
    ans = tl2[j]

print(ans)
Problem p02690 (python)

Fixed submission:
x = int(input())

ans1, ans2 = 0,0
for i in range(-200,200):
    for j in range(-200,200):
        if i**5 - j**5 == x:
            # print(i,j)
            ans1, ans2 = i,j

print(ans1,ans2)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = input().split()
pl = []
sb = []
for i in range(len(a)):
	pl.append(i+int(a[i])+1)
	if i - int(a[i]) > 1:
		sb.append(i-int(a[i])+1)


if len(sb) == 0:
	print('0')
else:

# spl = sorted(pl)
	isb = [int(i) for i in sb]
	ipl = [int(i) for i in pl]
	ssb = sorted(isb)
	t = min(ssb)
	tl = [0] * max(ipl)
	for i in ssb:
		if int(i)-1 < len(tl):
			tl[int(i)-1] += 1
	# print(pl)
	# print(sb)
	# print(tl)
	cnt = 0
	for i in pl:
		if int(i)-1 < len(tl):
			cnt += tl[int(i)-1]

	print(cnt)
Problem p02789 (python)

Fixed submission:
nm = input().split(' ')

n = int(nm[0])
m = int(nm[1])

if n > m :
	print('No')
else:
	print('Yes')

Buggy submission (verdict: Runtime Error):
nm = input().split()

n = nm[0]
m = nm[1]

if n < m :
	print(No)
else:
	print(Yes)
Problem p02802 (python)

Fixed submission:
nm = input().split()
n = int(nm[0])
m = int(nm[1])

p = []
r = []

for i in range(m):
	pr = input().split()
	p.append(int(pr[0]))
	r.append(pr[1])

ac = 0
wa = 0
flg = [0 for i in range(n)]

if m != 0:
	for l in range(m):
		if r[l] == 'AC' and flg[p[l]-1] !=  'ac':
			ac += 1
			wa += flg[p[l]-1]
			flg[p[l]-1] = 'ac'
		elif  flg[p[l]-1] != 'ac' :
			flg[p[l]-1] += 1

print(ac)
print(wa)

Buggy submission (verdict: Runtime Error):
nm = input().split()
n = int(nm[0])
m = int(nm[1])

p = []
r = []

for i in range(m):
	pr = input().split()
	p.append(int(pr[0]))
	r.append(pr[1])

ac = 0
wa = 0
flg = [False for i in range(n)]

if m != 0:
	for l in range(m):
		if r[l] == 'AC' and flg[p[l]-1] == False :
			ac += 1
			flg[p[l]] = True
		elif  flg[p[l]-1] == False :
			wa += 1

print(ac)
print(wa)

Buggy submission (verdict: Runtime Error):
nm = input().split()
n = int(nm[0])
m = int(nm[1])

p = []
r = []

for i in range(m):
	pr = input().split()
	p.append(int(pr[0]))
	r.append(pr[1])

ac = 0
wa = 0
flg = [False for i in range(n)]

if m != 0:
	for l in range(m):
		if r[l] == 'AC' and flg[p[l]] == False :
			ac += 1
			flg[p[l]] = True
		elif  flg[p[l]] == False :
			wa += 1

print(ac)
print(wa)

Buggy submission (verdict: Runtime Error):
nm = input().split()
n = int(nm[0])
m = int(nm[1])

p = []
r = []

for i in range(m):
	pr = input().split()
	p.append(int(pr[0]))
	r.append(pr[1])

ac = 0
wa = 0
flg = [False for i in range(m)]

if m != 0:
	for l in range(m):
		if r[l] == 'AC' and flg[p[l]] == False :
			ac += 1
			flg[p[l]] = True
		elif  flg[p[l]] == False :
			wa += 1

print(ac)
print(wa)

Buggy submission (verdict: Runtime Error):
nm = input().split()
n = int(nm[0])
m = int(nm[1])

p = []
r = []

for i in range(m):
	pr = input().split()
	p.append(int(pr[0]))
	r.append(pr[1])

ac = 0
wa = 0

for i in range(1,p[-1]+1):
    for l in range(m):
#         print(p[l])
#         print(r[l])
        if i != p[l]: continue
        if r[l] == 'AC':
            ac += 1
            break
        else: wa += 1

            
print(ac)
print(wa)
Problem p02812 (python)

Fixed submission:
n = int(input())
s = input()

i = -1
c = 0

while True:
	i = s.find('ABC', i + 1)
	if i == -1:
		break
	c += 1
print(c)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()

i = -1
c = 0

while True:
	i = s.find('ABC', i + 1)
	if i == -1:
		break
	c++
print(c)
Problem p02628 (python)

Fixed submission:
n,k=map(int,input().split())
ar=list(map(int,input().split()))
ar.sort()
ans=0
for i in ar:
  if(k==0):
    break
  ans+=i
  k-=1
print(ans)

Buggy submission (verdict: Runtime Error):
n.k=map(int,input().split())
ar=list(map(int,input().split()))
ar.sort()
ans=0
for i in ar:
  if(k==0):
    break
  ans+=i
  k-=1
print(ans)
Problem p02639 (python)

Fixed submission:
ar=[int(x) for x in input().split()]
for i in range(len(ar)):
    if(ar[i]==0):
        print(i+1)
        break

Buggy submission (verdict: Runtime Error):
ar=[int(x) for x in input().split()]
for i in range(n):
  if(ar[i]==0):
    print((i+1))
    break
Problem p02657 (python)

Fixed submission:
a,b = list(map(int, input().split()))
print(a*b)

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

ans = 1
if 0 in int_list:
  ans = 0
else:
  for i in range(n):
    ans *= int_list[i]
    if ans > 10 ** 18:
      ans = -1
      break

print(ans)

Buggy submission (verdict: Runtime Error):
a,b = int(input().split())
print(int(a*b))
Problem p02696 (python)

Fixed submission:
a,b,n = map(int, input().split())

if b==1:
  print(0)
else:  
  if b-1>n:
    x = n
  else:
    x = (b-1)*(n//(b-1))

  ans = max(a*x//b-a*(x//b), a*n//b-a*(n//b))

  print(ans)

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

if b-1>n:
  x = n
else:
  x = (b-1)*(n//(b-1))

ans = max(a*x//b-a*(x//b), a*n//b-a*(n//b))

print(ans)

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

if b-1>n:
  start = n
else:
  start = (b-1)*(n//(b-1))

ans = 0

for i in range(start, n+1):
  ans = max(ans, (a*i//b)-a*(i//b))

print(ans)
Problem p02743 (python)

Fixed submission:
a,b,c=map(int, input().split())
print('Yes' if (c-a-b)>0 and 4*a*b < (c-a-b)**2 else 'No')

Buggy submission (verdict: Runtime Error):
import sympy

a,b,c=map(int, input().split())
print('Yes' if sympy.sqrt(a) + sympy.sqrt(b) < sympy.sqrt(c) else 'No')
Problem p02814 (python)

Fixed submission:
import math
from functools import reduce

n,m = map(int, input().split())
A = list(map(int, input().split()))

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

def lcm(target_list):
  return reduce(lcm_base, target_list)

A_gcd = reduce(math.gcd, A)
flg = True

for a in A:
  if a//A_gcd%2==0:
    flg = False
    break
    
if flg:
  min_x = int(lcm(A))//2
  ans = m//min_x - m//(2*min_x)
  print(ans)
else:
  print(0)

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

n,m = map(int, input().split())
A = list(map(int, input().split()))

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

def lcm(target_list):
  return reduce(lcm_base, target_list)

A_gcd = reduce(math.gcd, A)
flg = True

for a in A:
  if a//A_gcd%2==0:
    flg = False
    break

if flg:
  min_x = int(lcm(A)*0.5)
  ans = m//min_x - m//(2*min_x)
  print(ans)
else:
  print(0)

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

n,m = map(int, input().split())
A = list(map(int, input().split()))

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

def lcm(target_list):
  return reduce(lcm_base, target_list)

min_x = int(lcm(A)*0.5)
ans = m//min_x - m//(2*min_x)

print(ans)

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

n,m = map(int, input().split())
A = list(map(int, input().split()))

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

def lcm(target_list):
  return reduce(lcm_base, target_list)

min_x = lcm(A)*0.5
temp = m//min_x

if min_x%2==0:
  print(0)
elif temp%2==0:
  print(int(temp//2))
else:
  print(int(temp//2+1))

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

n,m = map(int, input().split())
A = list(map(int, input().split()))

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

def lcm(target_list):
  return reduce(lcm_base, target_list)

min_x = lcm(A)*0.5
temp = m//min_x

if temp%2==0:
  print(int(temp//2))
else:
  print(int(temp//2+1))
Problem p02936 (python)

Fixed submission:
n, q = map(int, input().split())
Tree = [[] for _ in range(n+1)]
Counter = [0 for _ in range(n+1)]
AB = (tuple(map(int, input().split())) for _ in range(n-1))
PX = (tuple(map(int, input().split())) for _ in range(q))

for a,b in AB:
  Tree[a].append(b)
  Tree[b].append(a)
  
for p,x in PX:
  Counter[p] += x

P = [-1]*(n+1)

nodes = [1]
while nodes:
  parent = nodes.pop()
  for node_i in Tree[parent]:
    if P[parent]==node_i:
      continue
    P[node_i] = parent
    nodes.append(node_i)
    Counter[node_i] += Counter[parent]

print(*Counter[1:])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

n, q = map(int, input().split())
Tree = {i:[] for i in range(1, n+1)}
Counter = {i:0 for i in range(1, n+1)}

for _ in range(n-1):
  a,b = map(int, input().split())
  Tree[a].append(b)
  
def dfs(i, c, t):
  if t[i]:
    for j in t[i]:
      c[j] += c[i]
      dfs(j, c, t)

for _ in range(q):
  p,x = map(int, input().split())
  Counter[p] += x

dfs(1, Counter, Tree)
print(*Counter.values())

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

n, q = map(int, input().split())
Tree = {i:[] for i in range(1, n+1)}
Counter = {i:0 for i in range(1, n+1)}

for _ in range(n-1):
  a,b = map(int, input().split())
  Tree[a].append(b)
  
def dfs(n, c, t):
  if t[n]:
    for m in t[n]:
      c[m] += c[n]
      dfs(m, c, t)

for _ in range(q):
  p,x = map(int, input().split())
  Counter[p] += x

dfs(1, Counter, Tree)
print(*Counter.values())

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
Tree = {i:[] for i in range(1, n+1)}
Counter = {i:0 for i in range(1, n+1)}

for _ in range(n-1):
  a,b = map(int, input().split())
  Tree[a].append(b)
  
def dfs(n, c, t):
  if t[n]:
    for m in t[n]:
      c[m] += c[n]
      dfs(m, c, t)

for _ in range(q):
  p,x = map(int, input().split())
  Counter[p] += x

dfs(1, Counter, Tree)
print(*Counter.values())

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
Tree = {i:[] for i in range(1, n+1)}
Counter = {i:0 for i in range(1, n+1)}

for _ in range(n-1):
  a,b = map(int, input().split())
  Tree[a].append(b)
  
def dfs(n, x, c, t):
  c[n] += x
  
  if t[n]:
    for m in t[n]:
      dfs(m, x, c, t)

for _ in range(q):
  p,x = map(int, input().split())
  dfs(p, x, Counter, Tree)
  
print(*Counter.values())
Problem p02953 (python)

Fixed submission:
n = int(input())
num_list = [int(i) for i in input().split()]
 
answer = "Yes"
 
for i in range(n-1):
  if num_list[i] - num_list[i+1] >= 2:
    answer = "No"
    break
  elif num_list[i] - num_list[i+1] >= 1:
    num_list[i+1] += 1
    
print(answer)

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

ans = 'Yes'

for i in range(n - 1):
  
  if i == 0:
    if num_list[i] > num_list[i + 1]:
    num_list[i] -= 1
  
  if num_list[i] > num_list[i + 1]:
    ans = 'No'
    break
  
  if num_list[i] < num_list[i + 1]:
    num_list[i + 1] -= 1
    
print(ans)
Problem p03076 (python)

Fixed submission:
dish_list = [int(input()) for _ in range(5)]
last_num_list = [int(str(dish_i)[-1]) for dish_i in dish_list]

if sum(last_num_list) % 10 == 0:
  print(sum(dish_list))
else:  
  target_index = min(list(filter(lambda x: x>0, last_num_list)))

  last_num_min_index = last_num_list.index(target_index)
  ceiling_dish_list = [-10* (-i//10) for i in dish_list]

  print(sum(ceiling_dish_list) - ceiling_dish_list[last_num_min_index] + dish_list[last_num_min_index])

Buggy submission (verdict: Runtime Error):
dish_list = [int(input()) for _ in range(5)]
last_num_list = [int(str(dish_i)[-1]) for dish_i in dish_list]
target_index =min(list(filter(lambda x: x>0, last_num_list)))

last_num_min_index = last_num_list.index(target_index)
ceiling_dish_list = [-10* (-i//10) for i in dish_list]

print(sum(ceiling_dish_list) - ceiling_dish_list[last_num_min_index] + dish_list[last_num_min_index])
Problem p03125 (python)

Fixed submission:
a, b = map(int, input().split())
print(b-a if b%a else a+b)

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split()) 
print(b-a if a%b a+b)

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split()) 
print(b-a a%b a+b)
Problem p03238 (python)

Fixed submission:
n = int(input())

print('Hello World' if n==1 else int(input())+int(input()))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = int(input())
b = int(input())

print('Hello World' if n==1 else a+b)
Problem p03274 (python)

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

# print(X)

time = float('inf')
for n_i in range(n-k+1):
  r_side = X[n_i+k-1]
  l_side = X[n_i]
  time = min(time, min(abs(r_side), abs(l_side)) + abs(r_side-l_side))
  
print(time)

Buggy submission (verdict: Runtime Error):
import bisect

n,k = map(int, input().split())
X = list(map(int, input().split()))

init_pos = bisect.bisect_left(X, 0)
ans = 10**8

for pos_i in [init_pos-1, init_pos]:
  temp_ans = abs(X[pos_i])
  left_case = 10**8
  right_case = 10**8
  if pos_i-k+1>=0:
    left_case = abs(X[pos_i-k+1]-X[pos_i])
  if pos_i+k-1<=n-1:
    right_case = abs(X[pos_i+k-1]-X[pos_i])
  temp_ans += min(left_case, right_case)
  
  ans = min(ans, temp_ans)

print(ans)
Problem p03280 (python)

Fixed submission:
a, b = map(int, input().split())
print((a-1)*(b-1))

Buggy submission (verdict: Runtime Error):
print((int(input()) - 1)*(int(input()) - 1))
Problem p03377 (python)

Fixed submission:
a, b, x = map(int, input().split())
print('YES' if a<=x and x-a<=b else 'NO')

Buggy submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
print('YES' if a<=c and x-a<=b else 'NO')
Problem p03408 (python)

Fixed submission:
n = int(input())
s_list = [input() for _ in range(n)]
m = int(input())
t_list = [input() for _ in range(m)]

cand_str_set = set(s_list)

calced_list = [(s_list.count(str_i) - t_list.count(str_i)) for str_i in cand_str_set]
calced_list.append(0)

print(max(calced_list))

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
s_list = [input() for _ in range(n)]
m = int(input())
t_list = [input() for _ in range(m)]

s_dict = collections.Counter(s_list)
t_dict = collections.Counter(t_list)

s_t_dict = (s_dict - t_dict).values()
print(max(s_t_dict))
Problem p03415 (python)

Fixed submission:
l1, l2, l3 = input(), input(), input()
print(l1[0]+l2[1]+l3[2])

Buggy submission (verdict: Runtime Error):
l1, l2, l3 = input() for _ in range(3)
print(l1[0]+l2[1]+l3[2])
Problem p03434 (python)

Fixed submission:
_ = input()
card_list = sorted(map(int, input().split()))[::-1]
print(sum(card_list[::2])-sum(card_list[1::2]))

Buggy submission (verdict: Runtime Error):
_ = input()
card_list = sorted(input().split())[::-1]
print(sum(card_list[::2])-sum(card_list[1::2]))
Problem p03455 (python)

Fixed submission:
print('Even' if eval(input().replace(' ', '*')+'%2==0') else 'Odd')

Buggy submission (verdict: Runtime Error):
print('Even' if eval(input().replace('', '*')+'%2==0') else 'Odd')
Problem p03502 (python)

Fixed submission:
n =  input()
print('No' if int(n) % sum(map(int, n)) else 'Yes')

Buggy submission (verdict: Runtime Error):
n =  input()
print('No' int(n) % sum(map(int, n)) else 'Yes')
Problem p03547 (python)

Fixed submission:
x, y = input().split()
print('>' if x>y else '<' if x<y else '=')

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())
print('>' if x>y else '<' if x<y else '=')
Problem p03565 (python)

Fixed submission:
import re

s = input().replace('?', '.')
t = input()

if len(t)>len(s):
  print('UNRESTORABLE')
elif len(t)==len(s):
  if re.match(s, t):
    print(t)
  else:
    print('UNRESTORABLE')
else:
  for i in range(len(s)-len(t)+1):
    check_str = s[len(s)-len(t)-i:len(s)-i]
    if re.match(check_str, t):
      break

  if i==len(s)-len(t):
    print('UNRESTORABLE')
  else:
    ans = s[:len(s)-len(t)-i] + t + s[len(s)-i:]
    ans = ans.replace('.', 'a')
    print(ans)

Buggy submission (verdict: Runtime Error):
import re

s = input().replace('?', '.')
t = input()

for i in range(len(s)-len(t)+1):
  check_str = s[len(s)-len(t)-i:len(s)-i]
  if re.match(check_str, t):
    break

if i==len(s)-len(t):
  print('UNRESTORABLE')
else:
  ans = s[:len(s)-len(t)-i] + t + s[len(s)-i:]
  ans = ans.replace('.', 'a')
  print(ans)
Problem p03609 (python)

Fixed submission:
x, t = map(int, input().split())
print(max(x-t, 0))

Buggy submission (verdict: Runtime Error):
print(max(int(input())-t, 0))
Problem p03624 (python)

Fixed submission:
s = input()
target = 'None'
for chr_i in range(ord('a'), ord('z')+1):
  if chr(chr_i) not in s:
    target = chr(chr_i)
    break

print(target)

Buggy submission (verdict: Runtime Error):
s = set(input())
alpha = set(map(chr, range(97, 123)))

print(sorted(s^alpha)[0])
Problem p03658 (python)

Fixed submission:
n, k = map(int, input().split())
print(sum(sorted(map(int, input().split()), key = lambda x:-x)[0:k]))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input())
print(sorted(map(int, input().split()), key = lambda x:-x)[0:k])
Problem p03679 (python)

Fixed submission:
x, a, b = map(int, input().split())
print('delicious' if a-b>=0 else 'safe' if a+x-b>=0 else 'dangerous')

Buggy submission (verdict: Runtime Error):
x, a, b = map(int, input().split())
print('delicious' if a-b>=0 else 'safe' a+x-b>=0 else 'dangerous')
Problem p03738 (python)

Fixed submission:
a = int(input())
b = int(input())

print('GREATER' if a>b else 'LESS' if a<b else 'EQUAL')

Buggy submission (verdict: Runtime Error):
a = input()
b = input()

print('GREATER' if a>b else if 'LESS' if a<b else 'EQUAL')

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())

print('GREATER' if a>b else if 'LESS' if a<b else 'EQUAL')
Problem p03773 (python)

Fixed submission:
a, b = map(int, input().split())
print((a+b)%24)

Buggy submission (verdict: Runtime Error):
print((int(input())+int(input()))%24)
Problem p03827 (python)

Fixed submission:
_ = input()
S = input()
max_n = 0
temp = 0

for s in S:
  if s == 'I':
    temp += 1 
  else:
    temp -= 1
  
  if max_n < temp:
    max_n = temp
    
print(max_n)

Buggy submission (verdict: Runtime Error):
_ = input()
S = input()
max_n = 0
temp = 0

for s in S:
  temp += 1 if s == 'I' else temp -= 1
  if max_n < temp:
    max_n = temp
    
print(max_n)
Problem p03860 (python)

Fixed submission:
print('A{}C'.format(input().split()[1][0]))

Buggy submission (verdict: Runtime Error):
print(input()[0]+input()[0]+input()[0])

Buggy submission (verdict: Runtime Error):
print('A{}C'.format(input().split()[1][1]))
Problem p03997 (python)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())

print((a+b)*h//2)

Buggy submission (verdict: Runtime Error):
a,b,h = map(int, input().split())
print((a+b)*h//2)
Problem p04030 (python)

Fixed submission:
s = input()
ans = ''

for str_i in s:
  if str_i == '0':
    ans += '0'
  elif str_i == '1':
    ans += '1'
  elif str_i == 'B':
    ans = ans[:len(ans)-1]
    
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
stack = []

for s in S:
  if s == 'B':
    stack.pop()
  else:
    stack.append(s)
    
    
print(*stack, sep = '')
Problem p02719 (python)

Fixed submission:
n, k = map(int, input().strip().split())

min_n = 1000000000000000000000000000
for i in range(1000):
    if n > k:
        n %= k
    n = abs(n - k)
    min_n = min(min_n, n)

print(min_n)

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

prev = None

n = n % k
print(min(n, k % n))

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

print(min(n % k, k % n))
Problem p02756 (python)

Fixed submission:
from collections import deque

s = input().strip()
s = deque(list(s))
q = int(input())

queries = [input().strip().split() for _ in range(q)]
is_reversed = False

for query in queries:
    t = query[0]
    if t == '1':
        is_reversed = not is_reversed
    else:
        f = query[1]
        c = query[2]
        if f == '1':
            if is_reversed:
                s.append(c)
            else:
                s.appendleft(c)
        else:
            if is_reversed:
                s.appendleft(c)
            else:
                s.append(c)

str_list = list(s)
if is_reversed:
    str_list = reversed(str_list)

ans = ''.join(str_list)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque

s = input().strip()
s = deque([*s])
q = int(input())

queries = [input().strip().split() for _ in range(q)]
is_reversed = False

for query in queries:
    t = query[0]
    if t == '1':
        is_reversed = not is_reversed
    else:
        f = query[1]
        c = query[2]
        if f == '1':
            if is_reversed:
                s.append(c)
            else:
                s.appendleft(c)
        else:
            if is_reversed:
                s.appendleft(c)
            else:
                s.append(c)

str_list = list(s)
if is_reversed:
    str_list = reversed(str_list)

ans = ''.join(str_list)
print(ans)
Problem p02888 (python)

Fixed submission:
import bisect


def main(ls):
    total = 0

    for i in range(len(ls) - 2):
        for j in range(i + 1, len(ls) - 1):
            a = ls[i]
            b = ls[j]
            left = j + 1
            num = bisect.bisect_left(ls, a + b) - left
            total += num

    print(total)


_n = input()
ls = list(sorted(map(int, input().strip().split())))

main(ls)

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

@numba.jit(nopython=True)
def main(ls):
    total = 0

    for i in range(len(ls) - 2):
        for j in range(i + 1, len(ls) - 1):
            a = ls[i]
            b = ls[j]
            ls2 = ls[j + 1:]
            if a + b == ls2[0]:
                 num = 0
            else:
                 num = np.searchsorted(ls2, a + b, side='right')
            total += num

    print(total)


_n = input()
ls = np.array(list(sorted(map(int, input().strip().split()))))

main(ls)