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

Fixed submission:
S, T = (str(i) for i in input().split())

U = T + S
print(U)

Buggy submission (verdict: Runtime Error):
x = int(input())
 
for val in range(x, x**1000) :
	if x ==2 :
		print(x)
		break
	elif ((10** (val-1)) % val) == 1 :
		print (val)
		break
	else :
		continue

Buggy submission (verdict: Runtime Error):
x = int(input())
 
for val in range(x, x**1000) :
	if x ==2 :
		print(x)
		break
	elif ((10** val) % val) == 10 :
		print (val)
		break
	else :
		continue

Buggy submission (verdict: Runtime Error):
x = int(input())
 
for val in range(x, x**100) :
	if x ==2 :
		print(x)
		break
	elif ((10** val) % val) == 10 :
		print (val)
		break
	else :
		continue

Buggy submission (verdict: Runtime Error):
x = int(input())
 
for val in range(x+1, x**100) :
	if x ==2 :
		print(x)
		break
	elif ((2** val) % val) == 2 :
		print (val)
		break
	else :
		continue

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

U = T + S
print(U)
Problem p02886 (python)

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

u = 0

for val in range(n):
	u += t_list[val]*(sum(t_list) - t_list[val])

u /= 2
m = int(u)
print(m)

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

u = 0

for val in range(n):
	u += t_list[n]*(sum(t_list) - t_list[n])

u /= 2
m = int(u)
print(m)
Problem p02909 (python)

Fixed submission:
today_weather = input()

if today_weather == 'Sunny' :
	print('Cloudy')
elif today_weather == 'Cloudy' :
	print('Rainy')
else :
	print('Sunny')

Buggy submission (verdict: Runtime Error):
today_weather = input('')

if today_weather = 'Sunny' :
	print('Cloudy')
elif today_weather = 'Cloudy' :
	print('Rainy')
else :
	print('Sunny')
Problem p02811 (python)

Fixed submission:
# coding: utf-8

num_of_coins, border = (int(n) for n in input().split())
if 500 * num_of_coins >= border:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
# coding: utf-8

num_of_coins, border = (int(n) for n in input().split)
if 500 * num_of_coins >= border:
  print("Yes")
else:
  print("No")
Problem p02841 (python)

Fixed submission:
a,b=(int(x) for x in input().split())
c,d=(int(x) for x in input().split())

if(a!=c):
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
number=[]
for i in S:
    number.append(i)

numberlist=[]
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            candidate=number[i]+number[j]+number[k]
            if candidate not in numberlist:
                numberlist.append(candidate)

print(len(numberlist))
Problem p03071 (python)

Fixed submission:
a,b=input().split()
a=int(a)
b=int(b)
sum=0
for i in range(1,3):
    sum += max(a,b)
    if (sum == a ):
        a -=1
    elif (sum==b):
        b -=1
print(sum)

Buggy submission (verdict: Runtime Error):
A,B=input()
coin=0
for i in range(0,2):
    pre=max(A,B)
    coin+=pre
    if(pre==A):
        A-=1
    else:
        B-=1

Buggy submission (verdict: Runtime Error):
A,B=input()
coin=0
for i in range(0,2):
    pre=max(A,B)
    coin+=pre
    if(pre==A):
        A-=1
    else:
        b-=1
Problem p03085 (python)

Fixed submission:
ref=input()

if (ref=="A"):
  print("T")
elif (ref=="T"):
  print("A")
elif (ref=="G"):
  print("C")
elif (ref=="C"):
  print("G")

Buggy submission (verdict: Runtime Error):
ref=imput()

if (ref=="A"):
  print("T")
elif (ref=="T"):
  print("A")
elif (ref=="G"):
  print("C")
elif (ref=="C"):
  print("G")
Problem p03086 (python)

Fixed submission:
ref=input()
count=0
count_list=[]
seq=["A","T","G","C"]
for base in ref:
    if base in seq:
        count +=1
       
    else:
        count_list.append(count)
        count =0
    count_list.append(count)

print(max(count_list))

Buggy submission (verdict: Runtime Error):
ref=input()
count_list=[]
count=0
seq=["A","T","G","C"]
for base in ref:
    if base in seq:
        count +=1
    else:
        count_list.append(count)
        count =0

print(max(count_list))

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

count=0
seq=["A","T","G,","C"]
for base in ref:
    if base in ref:
        count +=1
    else count =0

print(count)
Problem p03106 (python)

Fixed submission:
A,B,K=(int(x) for x in input().split())
GC_list=[]
for i in range(1,max(A,B)+1):
    if(A%i==0 and B%i==0):
        GC_list.append(i)

print(GC_list[len(GC_list)-K])

Buggy submission (verdict: Runtime Error):
A,B,K=(int(x) for x in input().split())
GC_list=[]
for i in range(1,max(A,B)):
    if(A%i==0 and B%i==0):
        GC_list.append(i)

print(GC_list[len(GC_list)-K])
Problem p02924 (python)

Fixed submission:
n = int(input())

output = (n * (n - 1)) // 2
print(output)

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

print(sum(list(range(n))))
Problem p02995 (python)

Fixed submission:
import fractions
a, b, c, d = map(int, input().split())

#a~bでnで割り切れるものの数
def func(a, b, n):
    answer = (int(b/n) - int((a-1)/n))
    return answer

lcm = int((c * d) / fractions.gcd(c, d))

#print ((b - a + 1) - func(a,b,c) - func(a,b,d) + func(a,b,lcm))

#b以下でc,dで割り切れない数
b_anti_devide = b - b//c - b//d + b//lcm
#a未満でc,dで割り切れない数
a_anti_devide = (a - 1) - (a - 1)//c - (a - 1)//d + (a - 1)//lcm

print (b_anti_devide - a_anti_devide)

Buggy submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())

#a~bでnで割り切れるものの数
def func(a, b, n):
    answer = (int(b/n) - int((a-1)/n))
    return answer

lcm = (c * d) //math.gcd(c, d)

print ((b -a + 1) - func(a,b,c) - func(a,b,d) + func(a,b,lcm))
Problem p03030 (python)

Fixed submission:
# -*- coding: utf-8 -*-

from operator import itemgetter

N = int(input())
SP_list = []
SP_dict = {}
for i in range(N):
    name, point = input().split()
    pair = (name, int(point))
    SP_list.append(pair)
    SP_dict[pair] = i + 1

for i in range(len(SP_list)):
    SP_dict[SP_list[i]] = i + 1

point_sorted = sorted(SP_list, key=itemgetter(1), reverse=True)
name_sorted = sorted(point_sorted, key=itemgetter(0))

for pair in name_sorted:
    print (SP_dict[pair])

Buggy submission (verdict: Runtime Error):
from operator import itemgetter

city_point_list = []
N = int(input())
for i in range(N):
    c, p = input().split()
    city_point_list.append(c, int(p))

cp_num_dict = {}
for i in range(city_point_list):
    cp_num_dict[city_point_list[i]] = i + 1

point_sort_rev = sorted(city_point_list, key=itemgetter(1), reverse=True)
city_sort = sorted(point_sort_rev, key=itemgetter(0))

for cp in city_sort:
    print (cp_num_dict[cp])
Problem p03373 (python)

Fixed submission:
# -*- coding: utf-8 -*-

import sys

lst = list(map(int, input().split()))

a_value = lst[0]
b_value = lst[1]
c_value = lst[2]
a_number = lst[3]
b_number = lst[4]

value = 0

if a_value + b_value <= c_value * 2:
    value = a_value * a_number + b_value * b_number
    print (value)
else:
    if a_number >= b_number:
        value += c_value * 2 * b_number
        if (a_number - b_number) * a_value >= (a_number - b_number) * c_value * 2:
            value += (a_number - b_number) * c_value * 2
        else:
            value += (a_number - b_number) * a_value

    else:
        value += c_value * 2 * a_number
        if (b_number - a_number) * b_value >= (b_number - a_number) * c_value * 2:
            value += (b_number - a_number) * c_value * 2
        else:
            value += (b_number - a_number) * b_value
    print (value)

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

import sys

args = sys.argv

a_value = int(args[1])
b_value = int(args[2])
c_value = int(args[3])
a_number = int(args[4])
b_number = int(args[5])

value = 0

if a_value + b_value <= c_value * 2:
    value = a_value * a_number + b_value * b_number
    print (value)
else:
    if a_number >= b_number:
        value += c_value * 2 * b_number
        if (a_number - b_number) * a_value >= (a_number - b_number) * c_value * 2:
            value += (a_number - b_number) * c_value * 2
        else:
            value += (a_number - b_number) * a_value

    else:
        value += c_value * 2 * a_number
        if (b_number - a_number) * b_value >= (b_number - a_number) * c_value * 2:
            value += (b_number - a_number) * c_value * 2
        else:
            value += (b_number - a_number) * a_value
    print (value)
Problem p02855 (python)

Fixed submission:
h, w, k = map(int, input().split())
m = []
for i in range(h):
    m.append(list(input()))

ans = []
for i in range(h):
    ans.append([0 for _ in range(w)])

if m[0][0] == '#':
    c = 0
else:
    c = 1
emp = []
for i in range(h):
    s1 = 0
    s = m[i].count('#')
    # 行に一つもいちごがない
    if s == 0:
        emp.append(i)
        continue
    for j in range(w):
        flag = 0
        if m[i][0] == '#':
            if m[i][j] == '#':
                if s1 < s and c < k:
                    s1 += 1
                    c += 1
            ans[i][j] = c
        else:
            ans[i][j] = c
            if m[i][j] == '#':
                flag = 1
                if s1 < s-1 and c < k:
                    s1 += 1
                    c += 1
    if i != h-1 and m[i+1][0] != '#':
        c += 1

if 0 in emp:
    for j in range(w):
        for i1 in range(1, h):
            if ans[i1][0] != 0:
                idx = ans[i1]
                break
        ans[0][j] = idx[j]
    emp.remove(0)
if h-1 in emp:
    for j in range(w):
        for i1 in list(range(h-1))[::-1]:
            if ans[i1][0] != 0:
                idx = ans[i1]
                break
        ans[h-1][j] = idx[j]
    emp.remove(h-1)
for e in emp:
    for j in range(w):
        idx = []
        for i1 in range(e+1, h):
            if ans[i1][0] != 0:
                idx = ans[i1]
                break
        ans[e][j] = idx[j]

for i in ans:
    print(' '.join(map(str, i)))

Buggy submission (verdict: Runtime Error):
h, w, k = map(int, input().split())
m = []
for i in range(h):
    m.append(list(input()))

ans = []
for i in range(h):
    ans.append([0 for _ in range(w)])

if m[0][0] == '#':
    c = 0
else:
    c = 1
emp = []
for i in range(h):
    s1 = 0
    s = m[i].count('#')
    # 行に一つもいちごがない
    if s == 0:
        emp.append(i)
        continue
    for j in range(w):
        flag = 0
        if m[i][0] == '#':
            if m[i][j] == '#':
                if s1 < s and c < k:
                    s1 += 1
                    c += 1
            ans[i][j] = c
        else:
            ans[i][j] = c
            if m[i][j] == '#':
                flag = 1
                if s1 < s-1 and c < k:
                    s1 += 1
                    c += 1
    if i != h-1 and m[i+1][0] != '#':
        c += 1

for e in emp:
    for j in range(w):
        idx = []
        if e == 0:
            for i1 in range(1, h):
                if ans[i1][0] != 0:
                    idx = ans[i1]
                    break
            ans[e][j] = idx[j]
        elif e == h-1:
            for i1 in list(range(h-1))[::-1]:
                if ans[i1][0] != 0:
                    idx = ans[i1]
                    break
            ans[e][j] = idx[j]
        else:
            for i1 in range(e+1, i+1):
                if ans[i1][0] != 0:
                    idx = ans[i1]
                    break
            ans[e][j] = idx[j]

for i in ans:
    print(' '.join(map(str, i)))
Problem p02918 (python)

Fixed submission:
n, k = map(int, input().split())
s = input()
cnt = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        cnt += 1
ans = min(cnt+2*k, n-1)
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
S = input()
s = S.split("L")
s = [i for i in s if i != '']
s.sort(reverse=True)
cnt = 0
for i in range(k):
    cnt += len(s[i])
    s.remove(s[i])
for i in s:
    if len(i) >= 2:
        cnt += len(i) - 1
r = S.split('R')
for i in r:
    if len(i) >= 2:
        cnt += len(i) - 1
    if len(i) == 1 and k > 0:
        cnt += 1
        k -= 1
print(cnt)
Problem p02936 (python)

Fixed submission:
n, q = map(int, input().split())
tree = [list() for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
c = [0] * n
for i in range(q):
    p, x = map(int, input().split())
    c[p-1] += x

stack = [0]
j = [False] * n # すでに探索したか
while stack:
    node = stack.pop()
    j[node] = True
    for snode in tree[node]:
        if j[snode]:
            continue
        c[snode] += c[node]
        stack.append(snode)

print(*c)

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
tree = [list() for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
c = [0] * n
for i in range(q):
    p, x = map(int, input().split())
    subtree = tree[p-1].copy()
    c[p-1] += x

for i, subnode in enumerate(tree):
    for s in subnode:
        c[s] += c[i]

print(*c)

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
tree = [list() for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
c = [0] * n
for i in range(q):
    p, x = map(int, input().split())
    subtree = tree[p-1].copy()
    c[p-1] += x
    while subtree:
        snode = subtree.pop()
        c[snode] += x
        subtree += tree[snode]
print(*c)

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

n, q = map(int, input().split())
tree = [list() for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
c = [0] * n
deq = deque()
for i in range(q):
    p, x = map(int, input().split())
    subtree = tree[p-1].copy()
    c[p-1] += x
    while subtree:
        snode = subtree.pop()
        c[snode] += x
        subtree += tree[snode]
print(*c)
Problem p02971 (python)

Fixed submission:
n = int(input())
max1 = 0
max2 = 0
index = 0
for i in range(n):
    a = int(input())
    new_max = max(a, max1)
    if (a == new_max and max2 <= max1) or (a == new_max and max2 <= max1 and a == max1):
        max2 = max1
        index = i
    elif (a != new_max and max2 <= a) or (a != new_max and max2 <= a and a == max1):
        max2 = a
    max1 = new_max

for i in range(n):
    if i != index:
        print(max1)
    else:
        print(max2)

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

n = int(input())
a = np.zeros(n, dtype=np.int64)
for i in range(n):
    a[i] = int(input())
for i in range(n):
    max1 = 0
    max2 = 0
    if len(a[:i]) != 0:
        max1 = np.max(a[:i])
    if len(a[i+1:]) != 0:
        max2 = np.max(a[i+1:])
    print(max(max1, max2))
Problem p02983 (python)

Fixed submission:
l, r = map(int, input().split())

if (r-1) * r < 2019:
    print(l * (l+1))
elif r - l > 2019:
    print(0)
else:
    ans = 2019
    for i in range(l, r):
        for k in range(i+1, r+1):
            a = ((i % 2019) * (k % 2019)) % 2019
            if a < ans:
                ans = a
    print(ans)

Buggy submission (verdict: Runtime Error):
l, r = map(int, input().split())

flag = 0
for i in range(l, r+1):
    if i % 2019 == 0:
        flag = 1
        break

if flag == 0:
    a = (l % 2019) * ((l+1) % 2019)) % 2019
    print(a)
elif flag == 1:
    print(0)

Buggy submission (verdict: Runtime Error):
l, r = map(int, input().split())
# m = 2 * (10 ** 9)
# n = 2 * (10 ** 9) + 2
flag = 0
for i in range(l, r+1):
    if i != 0 and i % 2019 == 0:
        flag = 1
        break
#     a = m
#     m = min(m, i % 2019)
#     if a == m:
#         n = min(n, i % 2019)
#     else:
#         n = min(n, a)
#
# print('m', m)
# print('n', n)

if flag != 1:
    if l == 0:
        a = (l+1 % 2019) * (l+2 % 2019) % 2019
    else:
        a = (l % 2019) * (l+1 % 2019) % 2019

if l == 0 and a == 0:
    flag = 2

if flag == 0:
    print(a)
elif flag == 1:
    print(0)
else:
    print(2019)

Buggy submission (verdict: Runtime Error):
l, r = map(int, input().split())
# m = 2 * (10 ** 9)
# n = 2 * (10 ** 9) + 2
flag = 0
for i in range(l, r+1):
    if i != 0 and i % 2019 == 0:
        flag = 1
        break
#     a = m
#     m = min(m, i % 2019)
#     if a == m:
#         n = min(n, i % 2019)
#     else:
#         n = min(n, a)
#
# print('m', m)
# print('n', n)

if flag != 1:
    if l == 0:
        a = (l+1 % 2019) * (l+2 % 2019) % 2019
    else:
        a = (l % 2019) * (l+1 % 2019) % 2019

if l == 0 and a == 0:
    flag = 2

if flag == 0:
    print(a)
elif flag == 1:
    print(0)
else:
    print(2019)
Problem p03031 (python)

Fixed submission:
import numpy as np

n, m = map(int, input().split())
S = []
for _ in range(m):
    *a, = map(int, input().split())
    l = a[1:]
    S.append(l)
*p, = map(int, input().split())

ans = 0
for i in range(2**n):
    tmp = np.array([i >> j & 1 for j in range(n)])
    if p == [sum(tmp[np.array(s)-1]) % 2 for s in S]:
        ans += 1
print(ans)

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

n, m = map(int, input().split())
S = []
for _ in range(m):
    *a, = map(int, input().split())
    l = a[1:]
    S.append(l)
*p, = map(int, input().split())

ans = 0
for i in range(2**n):
    tmp = np.array([i >> j & 1 for j in range(n)])
    if p == [sum(tmp[np.array(s)-1]) % 2 for s in S]:
        ans += 1
print(ans)

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

n, m = map(int, input().split())
S = []
for _ in range(m):
    *a, = map(int, input().split())
    l = a[1:]
    S.append(l)
*p, = map(int, input().split())

ans = 0
for i in range(2**n):
    tmp = np.array([i >> j & 1 for j in range(n)])
    if p == [sum(tmp[np.array(s)-1]) % 2 for s in S]:
        ans += 1
print(ans)
Problem p03161 (python)

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))
cost = [float('inf') for i in range(n)]
cost[0] = 0
for i in range(1,n):
    for j in range(1, k+1):
        if i >= j:
            cost[i] = min(cost[i], cost[i-j]+abs(h[i]-h[i-j]))

print(cost[n-1])

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = list(map(int, input().split()))
cost = [0 for i in range(n)]
cost[1] = abs(h[1]-h[0])
min_cost = 10000
for i in range(1,n-1):
    for j in range(k):
        if i >= j:
            min_cost = min(min_cost, cost[i-j]+abs(h[i+1]-h[i-j]))
    cost[i+1] = min_cost

print(cost[i+1])
Problem p03163 (python)

Fixed submission:
N, W = map(int, input().split())
# dp[i][w] : i個目の時の重さwの最大値
dp = [[0] * 100010 for _ in range(N+1)]
for i in range(N):
    w_i, v_i = map(int, input().split())
    for w in range(W+1):
        if w >= w_i:
            dp[i+1][w] = max(dp[i][w-w_i]+v_i, dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]

print(dp[N][W])

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
# dp[i][w] : i個目の時の重さwの最大値
dp = [[0] * 10010 for _ in range(N+1)]
for i in range(N):
    w_i, v_i = map(int, input().split())
    for w in range(W+1):
        if w >= w_i:
            dp[i+1][w] = max(dp[i][w-w_i]+v_i, dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]

print(dp[N][W])

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
# dp[i][j] : i日めにjをした。(j=0:持つ, j=1:持たない)
dp = [[0] * 10010 for _ in range(N+1)]
for i in range(N):
    w_i, v_i = map(int, input().split())
    for w in range(W+1):
        if w >= w_i:
            dp[i+1][w] = max(dp[i][w-w_i]+v_i, dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]

print(dp[N][W])
Problem p03068 (python)

Fixed submission:
N = int(input())
S = input()
K = int(input())

key = S[K - 1]
result = 'a'

for i in range(N):
    if S[i] == key:
        result += S[i]
    elif S[i] != key:
        result += '*'
        

print(result[1:])

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
K = int(input())

key = S[K]
result = 'a'

for i in range(N):
    if S[i] == key:
        result += S[i]
    elif S[i] != key:
        result += '*'
        

print(result[1:])
Problem p03030 (python)

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())
x = [list(input().split()) for _ in range(n)]

for i in range(n):
    x[i][1] = int(x[i][1])

X = []
for i in range(len(x)):
    X.append(int(x[i][1]))
    
xx = sorted(x)
flag = True
temp = xx[0][0]
l = []
ans = []
l.append(xx[0][1])
for i in range(1, n):
    if temp == xx[i][0]:
        l.append(xx[i][1])
        flag = True
    else:
        flag = False
        l.sort(reverse=True)
        for j in l:
            ans.append(j)

        l = []
        temp = xx[i][0]
        l.append(xx[i][1])

if flag:
    l.sort(reverse=True)
    for j in l:
        ans.append(j)
    
ans = [int(a) for a in ans]

if len(ans) != len(X):
    ans.append(xx[i][1])
for j in range(n):
    print(X.index(ans[j]) + 1)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n = int(input())
x = [list(input().split()) for _ in range(n)]

for i in range(n):
    x[i][1] = int(x[i][1])

X = []
for i in range(len(x)):
    X.append(int(x[i][1]))
    
xx = sorted(x)
flag = True
temp = xx[0][0]
l = []
ans = []
l.append(xx[0][1])
for i in range(1, n):
    if temp == xx[i][0]:
        l.append(xx[i][1])
        flag = True
    else:
        flag = False
        l.sort(reverse=True)
        for j in l:
            ans.append(j)

        l = []
        temp = xx[i][0]
        l.append(xx[i][1])


if len(x) == 2 : ans.append(xx[i][1])


if flag:
    l.sort(reverse=True)
    for j in l:
        ans.append(j)
    
ans = [int(a) for a in ans]
for i in range(n):
    print(X.index(ans[i]) + 1)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n = int(input())
x = [list(input().split()) for _ in range(n)]

for i in range(n):
    x[i][1] = int(x[i][1])

X = []
for i in range(len(x)):
    X.append(int(x[i][1]))
xx = sorted(x)
flag = True
temp = xx[0][0]
l = []
ans = []
l.append(xx[0][1])
for i in range(1, n):
    if temp == xx[i][0]:
        l.append(xx[i][1])
        flag = True
    else:
        flag = False
        l.sort(reverse=True)
        for j in l:
            ans.append(j)

        l = []
        temp = xx[i][0]
        l.append(xx[i][1])



if flag:
    l.sort(reverse=True)
    for j in l:
        ans.append(j)
    
ans = [int(a) for a in ans]

for i in range(n):
    print(X.index(ans[i]) + 1)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n = int(input())
x = [list(input().split()) for _ in range(n)]

for i in range(n):
    x[i][1] = int(x[i][1])

X = []
for i in range(len(x)):
    X.append(int(x[i][1]))
xx = sorted(x)

temp = xx[0][0]
l = []
ans = []
l.append(xx[0][1])
for i in range(1, n):
    if temp == xx[i][0]:
        l.append(xx[i][1])
        flag = True
    else:
        flag = False
        l.sort(reverse=True)
        for j in l:
            ans.append(j)

        l = []
        temp = xx[i][0]
        l.append(xx[i][1])



if flag:
    l.sort(reverse=True)
    for j in l:
        ans.append(j)
    
ans = [int(a) for a in ans]

for i in range(n):
    print(X.index(ans[i]) + 1)
Problem p03067 (python)

Fixed submission:
import sys
input = sys.stdin.readline

a, b, c = map(int, input().split())

flag = False
if a<=c and c<=b:
    flag = True

if b<=c and c<=a:
    flag = True


if flag:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline


n = int(input())
s = input()
s = list(s)
# print(s)



pre = s[0]
for i in range(1, n):
    if pre=='#' and s[i]=='.':
        temp = i
        break
    pre = s[i]


# print(temp)
try:
    s = s[temp:]
    ans = sum(1 for x in s if x=='.')
    ans2 = sum(1 for x in s if x=='#') + 1
    if s[-1]=='#':
        ans -=1
        ans2 -=1

    print(min(ans, ans2))
except:
    print(0)