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

Fixed submission:
import numpy as np
from numba import njit

N = int(input())
S = input()
Q = int(input())
ks = list(map(int, input().split()))

def func(ch):
    if ch == 'D':
        return 1
    if ch == 'M':
        return 2
    if ch == 'C':
        return 3
    return 0
    
S_arr = np.array([func(ch) for ch in S], dtype = np.int32)

@njit("i8(i8, i4[:], i8)", cache = True)
def solve(N, S_arr, k):
    ans = 0
    D = 0
    M = 0
    DM = 0
    for i in range(k):
        if S_arr[i] == 1:
            D += 1
        elif S_arr[i] == 2:
            DM += D
            M += 1
        elif S_arr[i] == 3:
            ans += DM
    for i in range(k, N):
        if S_arr[i-k] == 1:
            D -= 1
            DM -= M
        elif S_arr[i-k] == 2:
            M -= 1

        if S_arr[i] == 1:
            D += 1
        elif S_arr[i] == 2:
            DM += D
            M += 1
        elif S_arr[i] == 3:
            ans += DM

    return ans

for k in ks:
    print(solve(N, S_arr, k))

Buggy submission (verdict: Runtime Error):
def solve(N, S, k):
    k -= 1

    # i-th of these counts the thing in [ max(0, i-k), i ).
    D_counts  = [0]
    M_counts  = [0]
    DM_counts = [0]

    D = 0
    M = 0
    DM = 0
    for i in range(k):
        if S[i] == 'D':
            D += 1
        elif S[i] == 'M':
            DM += D
            M += 1
        D_counts.append(D)
        M_counts.append(M)
        DM_counts.append(DM)
    for i in range(k, N):
        if S[i-k] == 'D':
            D -= 1
            DM -= M
        elif S[i-k] == 'M':
            M -= 1

        if S[i] == 'D':
            D += 1
        elif S[i] == 'M':
            DM += D
            M += 1
            
        D_counts.append(D)
        M_counts.append(M)
        DM_counts.append(DM)

    ans = 0
    for i, c in enumerate(S):
        if c == 'C':
            ans += DM_counts[i]
    return ans

def main():
    N = int(input())
    S = input()
    Q = int(input())
    ks = list(map(int, input().split()))
    for k in ks:
        print(solve(N, S, k))

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve')(solve)
    cc.compile()

if __name__ == '__main__':
    import sys
    if sys.argv[-1] == 'ONLINE_JUDGE':
        cc_export()
        exit(0)
    from my_module import solve
    main()
Problem p03263 (python)

Fixed submission:
H, W = map(int, input().split())
As = [list(map(int, input().split())) for _ in range(H)]

before_A = None
history = []
for h, row in enumerate(As):
    it = enumerate(row)
    if h % 2 == 0:
        it = reversed(list(it))
    for w, A in it:
        if A % 2 == 0:
            if before_A is not None:
                path.append((h, w))

        else:
            if before_A is None:
                before_A = (h, w)
                path = [(h, w)]
            else:
                path.append((h, w))
                history.append(path[:])
                before_A = None

ans = []
for path in history:
    for i in range(len(path) - 1):
        ans.append( (path[i], path[i+1]) )

print(len(ans))
for (a, b), (c, d) in ans:
    print(a+1, b+1, c+1, d+1, sep = ' ')

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
As = [list(map(int, input().split())) for _ in range(H)]

before_A = None
history = []
for h, row in enumerate(As):
    it = enumerate(row)
    if h % 2 == 0:
        it = reversed(list(it))
    for w, A in enumerate(row):
        if A % 2 == 0:
            if before_A is not None:
                path.append(h, w)

        else:
            if before_A is None:
                before_A = (h, w)
                path = [(h, w)]
            else:
                path.append((h, w))
                history.append(path[:])
                before_A = None

ans = []
for path in history:
    for i in range(len(path) - 1):
        ans.append( (path[i], path[i+1]) )

print(len(ans))
for (a, b), (c, d) in ans:
    print(a+1, b+1, c+1, d+1, sep = ' ')

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
As = [list(map(int, input().split())) for _ in range(H)]

before_A = None
history = []
for h, row in enumerate(As):
    it = enumerate(row)
    if h % 2 == 0:
        it = reversed(list(it))
    for w, A in enumerate(row):
        if A % 2 == 0:
            if before_A is not None:
                path.append(h, w)

        else:
            if before_A is None:
                before_A = (h, w)
                path = [(h, w)]
            else:
                path.append((h, w))
                history.append(path[:])
                before_A = None

ans = []
for path in history:
    for i in range(len(path) - 1):
        ans.append( (*path[i], *path[i+1]) )

print(len(ans))
for a, b, c, d in ans:
    print(a+1, b+1, c+1, d+1, sep = ' ')
Problem p03312 (python)

Fixed submission:
from itertools import accumulate

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

csum = list(accumulate(As, initial=0))

P_end = 1
R_end = 3
ans = 10 ** 18
for Q_end in range(2, N - 1):
    former_half = csum[Q_end] / 2
    latter_half = (csum[-1] - csum[Q_end]) / 2
    while P_end + 1 <= Q_end and csum[P_end + 1] < former_half:
        P_end += 1
    while R_end + 1 < N and csum[R_end + 1] - csum[Q_end] < latter_half:
        R_end += 1
    
    if abs(csum[P_end] - former_half) > abs(csum[P_end + 1] - former_half):
        P = csum[P_end + 1]
    else:
        P = csum[P_end]
    Q = csum[Q_end] - P

    if abs(csum[R_end] - csum[Q_end] - latter_half) > abs(csum[R_end + 1] - csum[Q_end] - latter_half):
        R = csum[R_end + 1] - csum[Q_end]
        S = csum[-1] - csum[R_end + 1]
    else:
        R = csum[R_end] - csum[Q_end]
        S = csum[-1] - csum[R_end]

    # print(P, Q, R, S)
    diff = max(P, Q, R, S) - min(P, Q, R, S)
    ans = min(diff, ans)
    

print(ans)

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

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

csum = list(accumulate(As, initial=0))

P_end = 1
R_end = 3
ans = 1001001001
for Q_end in range(2, N - 1):
    former_half = csum[Q_end] // 2
    latter_half = (csum[-1] - csum[Q_end]) // 2
    while P_end + 1 <= Q_end and csum[P_end + 1] < former_half:
        P_end += 1
    while R_end + 1 < N and csum[R_end + 1] - csum[Q_end] < latter_half:
        R_end += 1
    
    if abs(csum[P_end] - former_half) > abs(csum[P_end + 1] - former_half):
        P = csum[P_end + 1]
    else:
        P = csum[P_end]
    Q = csum[Q_end] - P

    if abs(csum[R_end] - csum[Q_end] - latter_half) > abs(csum[R_end + 1] - csum[Q_end] - latter_half):
        R = csum[R_end + 1] - csum[Q_end]
        S = csum[-1] - csum[R_end + 1]
    else:
        R = csum[R_end] - csum[Q_end]
        S = csum[-1] - csum[R_end]

    # print(P, Q, R, S)
    diff = max(P, Q, R, S) - min(P, Q, R, S)
    ans = min(diff, ans)
    

print(ans)
Problem p03373 (python)

Fixed submission:
a, b, c, x, y = map(int, input().split())
possible_minimum_sum1 = a * x + b * y
possible_minimum_sum2 = c * x * 2 + max(y-x, 0) * b
possible_minimum_sum3 = c * y * 2 + max(x-y, 0) * a

print(min(possible_minimum_sum1, possible_minimum_sum2, possible_minimum_sum3))

Buggy submission (verdict: Runtime Error):
a, b, c, x, y = map(int, input().split())
possible_minimum_sum1 = a * x + b * y
possible_minimum_sum2 = c * max(a, b) * 2
possible_minimum_sum3 = c * a * 2 + max(b-a, 0) * b
possible_minimum_sum4 = c * b * 2 + max(a-b, 0) * a

print(min(tuple(possible_minimum_sum1, possible_minimum_sum2, possible_minimum_sum3, possible_minimum_sum4)))
Problem p03379 (python)

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

A_sorted = sorted(As)
med1 = A_sorted[N//2-1]
med2 = A_sorted[N//2]

for A in As:
  if A <= med1:
    print(med2)
  else:
    print(med1)

Buggy submission (verdict: Runtime Error):
N = int(input())
As = list(map(int, input()))

A_sorted = sorted(As)
med1 = A_sorted[N//2]
med2 = A_sorted[N//2+1]

for A in As:
  if A <= med1:
    print(med2)
  else:
    print(med1)
Problem p03409 (python)

Fixed submission:
N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]
CD = [tuple(map(int, input().split())) for _ in range(N)]

AB.sort(key = max, reverse = True)
CD.sort(key = min)

counter = 0
for a, b in AB:
    for c, d in CD:
        if a < c and b < d:
            CD.remove( (c, d) )
            counter += 1
            break

print(counter)

Buggy submission (verdict: Runtime Error):
import networkx as nx

N = int(input())
ABs = [tuple(map(int, input().split())) for _ in range(N)]
CDs = [tuple(map(int, input().split())) for _ in range(N)]

# 0 <= i <   N  -> i: ABs[i]
# N <= i < 2*N  -> i: CDs[i-N]
# i == 2*N+1    -> start
# i == 2*N+2    -> goal

DG = nx.DiGraph()
DG.add_nodes_from(range(2 * N + 3))
for i in range(N):
    for j in range(N):
        if ABs[i][0] < CDs[j][0] and ABs[i][1] < CDs[j][1]:
            DG.add_edge(i, j + N, capacity = 1)

DG.add_edges_from([(2 * N + 1, i, {"capacity":1}) for i in range(N)])
DG.add_edges_from([(i, 2 * N + 2, {"capacity":1}) for i in range(N, 2*N)])

print(nx.maximum_flow_value(DG, 2 * N + 1, 2 * N + 2))
Problem p03448 (python)

Fixed submission:
numof500 = int(input())
numof100 = int(input())
numof50  = int(input())
moneyneeded = int(input())
 
counter = 0
for i in range(numof500 + 1):
  for j in range(numof100 + 1):
    for k in range(numof50 + 1):
      if 500 * i + 100 * j + 50 * k == moneyneeded:
        counter += 1
 
print(counter)

Buggy submission (verdict: Runtime Error):
numof500 = int(input())
numof100 = int(input())
numof50  = int(input())
moneyneeded = int(input())
 
counter = 0
for i in range(numof500 + 1):
  for j in range(numof100 + 1):
  	for k in range(numof50 + 1):
      if 500 * i + 100 * j + 50 * k == moneyneeded:
        counter += 1
 
print(counter)

Buggy submission (verdict: Runtime Error):
numof500 = int(input())
numof100 = int(input())
numof50  = int(input())
moneyneeded = int(input())

counter = 0
for i in range(numof500):
  for j in range(numof100):
  	for k in range(numof50):
      if 500 * i + 100 * j + 50 * k == moneyneeded:
        counter += 1

print(counter)
Problem p03478 (python)

Fixed submission:
n, a, b = map(int, input().split())
 
s = 0
for i in range(n+1):
  digitsum = i%10 + (i//10)%10 + (i//100)%10 + (i//1000)%10 + (i//10000)%10
  if a <= digitsum <= b:
    s += i
    
print(s)

Buggy submission (verdict: Runtime Error):
n, a, b = input().split()
 
s = 0
for i in range(n+1):
  digitsum = i%10 + (i//10)%10 + (i//100)%10 + (i//1000)%10 + (i//10000)%10
  if a <= digitsum <= b:
    s += i
    
print(s)

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

s = 0
for i in range(n+1):
  digitsum = i%10 + (i//10)%10 + (i//100)%10 + (i//1000)%10 + (i//10000)%10
  if a <= digitsum <= b:
    s += i
    
print(i)
Problem p03488 (python)

Fixed submission:
import numpy as np

s = input()
x_goal, y_goal = map(int, input().split())

directed_x = None
steps = 0
xs = [0]
ys = [0]
for c in (s+'T'):   #sentinel
    if c == 'F':
        steps += 1
    else:
        if directed_x is None:
            x_goal -= steps
            directed_x = True
        elif steps != 0:
            if directed_x:
                xs.append(steps)
            else:
                ys.append(steps)
        steps = 0
        directed_x = not directed_x

dx_2 = sum(xs) - x_goal
if dx_2 % 2 == 1 or dx_2 < 0:
    ans = False
else:
    dx = dx_2 // 2
    possible_x = np.full(dx + 1, False)
    possible_x[0] = True
    for x in xs:
        possible_x[x:] = np.logical_or(possible_x[:len(possible_x)-x], possible_x[x:])
        if possible_x[dx]:
            ans = True
            break
    else:
        ans = False

if ans:
    dy_2 = sum(ys) - y_goal
    if dy_2 % 2 == 1 or dy_2 < 0:
        ans = False
    else:
        dy = dy_2 // 2
        possible_y = np.full(dy + 1, False)
        possible_y[0] = True
        for y in ys:
            possible_y[y:] = np.logical_or(possible_y[:len(possible_y)-y], possible_y[y:])
            if possible_y[dy]:
                ans = True
                break
        else:
            ans = False

if ans:
    print("Yes")
else:
    print("No")

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

s = input()
x_goal, y_goal = map(int, input().split())

directed_x = None
steps = 0
xs = [0]
ys = [0]
for c in (s+'T'):   #sentinel
    if c == 'F':
        steps += 1
    else:
        if directed_x is None:
            x_goal -= steps
            directed_x = True
        elif steps != 0:
            if directed_x:
                xs.append(steps)
            else:
                ys.append(steps)
        steps = 0
        directed_x = not directed_x

dx_2 = sum(xs) - x_goal
if dx_2 % 2 == 1:
    ans = False
else:
    dx = dx_2 // 2
    possible_x = np.full(dx + 1, False)
    possible_x[0] = True
    for x in xs:
        possible_x[x:] = np.logical_or(possible_x[:len(possible_x)-x], possible_x[x:])
        if possible_x[dx]:
            ans = True
            break
    else:
        ans = False

if ans:
    dy_2 = sum(ys) - y_goal
    if dy_2 % 2 == 1:
        ans = False
    else:
        dy = dy_2 // 2
        possible_y = np.full(dy + 1, False)
        possible_y[0] = True
        for y in ys:
            possible_y[y:] = np.logical_or(possible_y[:len(possible_y)-y], possible_y[y:])
            if possible_y[dy]:
                ans = True
                break
        else:
            ans = False

if ans:
    print("Yes")
else:
    print("No")
Problem p03494 (python)

Fixed submission:
def how_many_times_divisible(n):
  counter = 0
  while n % 2 == 0:
    n //= 2
    counter += 1
  return counter
  

_ = input()
print(min(map(lambda x: how_many_times_divisible(int(x)), input().split())))

Buggy submission (verdict: Runtime Error):
def how_many_times_divisible(n):
    counter = 0
	
    while n % 2 == 0:
    	n //= 2
        counter +=1
    
    return counter
  
_ = input()
return min(map(lambda x: how_many_times_divisible(int(x)), input().split())
Problem p03625 (python)

Fixed submission:
from collections import Counter
 
N = int(input())
d = Counter(map(int, input().split()))
 
sticks_len = []
for k, v in d.items():
  if v >= 2:
    sticks_len.append(k)
  if v >= 4:
    sticks_len.append(k)
    
sticks_len.sort()
 
if len(sticks_len) >= 2:
  print(sticks_len[-1] * sticks_len[-2])
else:
  print(0)

Buggy submission (verdict: Runtime Error):
from colletions import Counter

N = int(input())
d = Counter(map(int, input().split()))

sticks_len = []
for k, v in d:
  if v >= 2:
    sticks.append(k)
  if v >= 4:
    sticks.append(k)
    
sticks.sort()

if len(sticks) >= 2:
  print(sticks[-1] * sticks[-2])
else:
  print(0)

Buggy submission (verdict: Runtime Error):
from colletions import Counter

N = int(input())
d = Counter(map(int, input().split()))

sticks_len = []
for k, v in d:
  if v >= 2:
    sticks.append(k)
  if v >= 4:
    sticks.append(k)
    
sticks.sort()

if len(sticks) >= 2:
  print(sticks[-1] * sticks[-2]
else:
  print(0)
Problem p03651 (python)

Fixed submission:
from fractions import gcd

N, K = map(int, input().split())
As = list(map(int, input().split()))
if len(As) == 1:
    possible = (As[0] == K)
else:
    g = max(abs(As[1] - As[0]), 1)
    for A in As[2:]:
        g = gcd(g, A - As[0])

    possible = ((K-As[0]) % g == 0) and (min(As) <= K <= max(As))

if possible:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

N, K = map(int, input().split())
As = list(map(int, input().split()))
if len(As) == 1:
    possible = (As[0] == K)
else:
    g = As[1] - As[0]
    for A in As[2:]:
        g = gcd(g, A - As[0])

    possible = ((K-As[0]) % g == 0) and (min(As) <= K <= max(As))

if possible:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Problem p03722 (python)

Fixed submission:
import sys
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import bellman_ford, connected_components
from scipy.sparse.csgraph._shortest_path import NegativeCycleError

input = sys.stdin.buffer.readline


N, M = map(int, input().split())
starts = []
ends = []
costs = []
for _ in range(M):
    a, b, c = map(int, input().split())
    starts.append(a-1)
    ends.append(b-1)
    if c != 0:
        costs.append(-c)
    else:
        costs.append(sys.float_info.epsilon)

look_for_loop = csr_matrix((costs + [0], (starts + [N-1], ends + [0])), shape = (N, N))
_, labels = connected_components(look_for_loop, connection = "strong")
mask = (labels == labels[0])

graph = csr_matrix((costs, (starts, ends)), shape = (N, N)).toarray()
graph = graph[mask, :][:, mask]

try:
    ans = bellman_ford(graph, directed = True, indices = [0])[0][-1]
    ans = int(round(-ans))
except NegativeCycleError:
    ans = "inf"

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import bellman_ford
from scipy.sparse.csgraph._shortest_path import NegativeCycleError

input = sys.stdin.buffer.readline


N, M = map(int, input().split())
starts = []
ends = []
costs = []
for _ in range(M):
    a, b, c = map(int, input().split())
    starts.append(a-1)
    ends.append(b-1)
    costs.append(-c)

graph = csr_matrix((costs, (starts, ends)), shape = (N, N))
try:
    ans = bellman_ford(graph, directed = True, indices = 0)[N-1]
    ans = int(round(-ans))
except NegativeCycleError:
    ans = "inf"
    
if ans == float("inf"):
    raise ValueError

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import bellman_ford
from scipy.sparse.csgraph._shortest_path import NegativeCycleError

input = sys.stdin.buffer.readline


N, M = map(int, input().split())
starts = []
ends = []
costs = []
for _ in range(M):
    a, b, c = map(int, input().split())
    starts.append(a-1)
    ends.append(b-1)
    if c != 0:
        costs.append(-c)
    else:
        costs.append(sys.float_info.epsilon)

graph = csr_matrix((costs, (starts, ends)), shape = (N, N))
try:
    ans = bellman_ford(graph, directed = True, indices = 0)[N-1]
    ans = int(round(-ans))
except NegativeCycleError:
    ans = "inf"

print(ans)
Problem p03863 (python)

Fixed submission:
# from functools import lru_cache

# @lru_cache
# def grundy(s):
#     if len(s) == 2:
#         return 0
#     gs = set()
#     for i in range(1, len(s) - 1):
#         if s[i - 1] == s[i + 1]:
#             continue
#         gs.add(grundy(s[:i] + s[i + 1:]))
#     for i in range(100):
#         if i not in gs:
#             return not (i == 0)

def win_first(s):
    return ((s[0] == s[-1]) + len(s)) % 2

# def test():
#     for i in range(1000000):
#         s = str(i)
#         for c1, c2 in zip(s[:-1], s[1:]):
#             if c1 == c2:
#                 break
#         else:
#             assert win_first(s) == grundy(s)

def main():
    print("First" if win_first(input()) else "Second")

main()

Buggy submission (verdict: Runtime Error):
from functools import lru_cache

@lru_cache
def grundy(s):
    if len(s) == 2:
        return 0
    gs = set()
    for i in range(1, len(s) - 1):
        if s[i - 1] == s[i + 1]:
            continue
        gs.add(grundy(s[:i] + s[i + 1:]))
    for i in range(100):
        if i not in gs:
            return not (i == 0)

def win_first(s):
    return ((s[0] == s[-1]) + len(s)) % 2

def test():
    for i in range(1000000):
        s = str(i)
        for c1, c2 in zip(s[:-1], s[1:]):
            if c1 == c2:
                break
        else:
            assert win_first(s) == grundy(s)

def main():
    print("First" if win_first(input()) else "Second")

main()
Problem p02583 (python)

Fixed submission:
import itertools

n, *l = map(int, open(0).read().split())

def f(a,b,c):
    return a+b>c and b+c>a and a+c>b


a=0
for t in itertools.combinations(range(n), 3):
    s=[l[i] for i in t]
    if len(s) != len(set(s)):
        continue
    if f(*s):
        a+=1

print(a)

Buggy submission (verdict: Runtime Error):
import itertools

def f(a, b, c):
    return a+b > c


input()
l = tuple(map(int, input().split()))

a=0
for t in itertools.combinations(l, 3):
    if f(t):
        a += 1

print(a)
Problem p02705 (python)

Fixed submission:
from math import pi
i = input()
print(float(i) * pi * 2)

Buggy submission (verdict: Runtime Error):
from math import pi
i = input()
print(i * pi)
Problem p02713 (python)

Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
'''
l = []
for a in range(1,int(input())+1):
    for b in range(1, int(input())+1):
        for c in range(1,int(input())+1):
            l.append(gcd(a,b,c))
'''
N = input() 
N = int(N)+1
l = (gcd(a,b,c) for a in range(1,N) for b in range(1,N) for c in range(1,N))
print(sum(l))

Buggy submission (verdict: Runtime Error):
def gcd(a, b,c):
    while b:
        a, b = b, a % b
    while c:
        b,c = c, b % c
    return b

""" 
l = []
for a in range(1,int(input())+1):
    for b in range(1, int(input())+1):
        for c in range(1,int(input())+1):
            l.append(gcd(a,b,c))
"""
l = (gcd(a,b,c) for a in range(1,int(input())+1) for b in range(1,int(input())+1) for c in range(1,int(input())+1))

print(sum(l))
Problem p02730 (python)

Fixed submission:
iss = lambda x:x == x[::-1]
S = input()
N = len(S)
S1 = S[:(N-1)//2]
S2 = S[(N+3)//2-1:]
print("Yes" if iss(S) and iss(S1) and iss(S2) else "No")

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
S1 = S[:(N-1)//2]
S2 = S[(N+3)//2]
print("Yes" if S == S[::-1] and S1 == S1[::-1] and S2 == S2[::-1] else "No")
Problem p03029 (python)

Fixed submission:
print(eval("3*"+input().replace(" ","+"))//2)

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

debug = "a" in argv
n = int(input())
ls = []
la = ls.append
for i in range(1, n + 1):
    s = input().split()
    la((i, s[0], int(s[1])))
if debug:
    print("ls:",ls)
ls = sorted(ls, key=lambda x: x[2], reverse=1)
ls = sorted(ls, key=lambda x: x[1])
if debug:
    print("ls(sorted):",ls)
if debug:
    print("debug end")
for x in ls:
    print(x[0])
Problem p03030 (python)

Fixed submission:
from sys import argv

debug = "a" in argv
n = int(input())
ls = []
la = ls.append
for i in range(1, n + 1):
    s = input().split()
    la((i, s[0], int(s[1])))
if debug:
    print("ls:",ls)
ls = sorted(ls, key=lambda x: x[2], reverse=1)
ls = sorted(ls, key=lambda x: x[1])
if debug:
    print("ls(sorted):",ls)
if debug:
    print("debug end")
for x in ls:
    print(x[0])

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

debug = "a" in argv
n = int(input())
ls = []
la = ls.append
for i in range(1, n + 1):
    s = input().split()
    la((i, s[0], int(s[1])))
if debug:
    print(f"ls: {ls}")
ls = sorted(ls, key=lambda x: x[2], reverse=1)
ls = sorted(ls, key=lambda x: x[1])
if debug:
    print(f"ls(sorted): {ls}")
if debug:
    print("debug end")
for x in ls:
    print(x[0])
Problem p03493 (python)

Fixed submission:
print(input().count("1"))

Buggy submission (verdict: Runtime Error):
print(sum(int(input())))
Problem p03501 (python)

Fixed submission:
t,a,b=map(int,input().split())
if a*t>b:
    print(b)
else:
    print(a*t)

Buggy submission (verdict: Runtime Error):
t,a,b=map(int,input());print((t*a,b)[t*a>b])
Problem p03547 (python)

Fixed submission:
a,b = map(ord, input().split())
print("=" if a == b else ">" if a > b else "<")

Buggy submission (verdict: Runtime Error):
a,b = map(chr, input().split())
print("=" if a == b else ">" if a > b else "<")
Problem p03555 (python)

Fixed submission:
print("YNEOS"[input()!=input()[::-1]::2])

Buggy submission (verdict: Runtime Error):
print(int(int(input())**.5)**2)
Problem p03624 (python)

Fixed submission:
a=sorted(set(input())^set(chr(i)for i in range(97,123)));print(a and a[0]or None)

Buggy submission (verdict: Runtime Error):
a=sorted(set(input())^set(map(chr(range(97,123)))));print(a and a[0]or None)