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

Fixed submission:
N=int(input())
X=0
for i in range(1,1000):
  X+=i
  if X==N:
    P=[[] for j in range(i+1)]
    X=0
    for j in range(i):
      for k in range(i-j):
        P[j].append(k+X+1)
      for k in range(i-j):
        P[k+j+1].append(k+X+1)
      X+=i-j
    print('Yes')
    print(i+1)
    for j in range(i+1):
      print(len(P[j]),end=' ')
      print(*P[j])
    exit()
print('No')

Buggy submission (verdict: Runtime Error):
N=int(input())
if N==1:
  print('''Yes
2
1
1'''
elif N==3:
  print('''Yes
3
2 1 2
2 3 1
2 2 3''')
else:
  print('No')
Problem p03330 (python)

Fixed submission:
N,C=map(int,input().split())
D=[list(map(int,input().split())) for i in range(C)]
A=[list(map(int,input().split())) for i in range(N)]
X=[[0]*C for i in range(3)]
for c in range(C):
  for i in range(N):
    for j in range(N):
      X[(i+j)%3][c]+=D[A[i][j]-1][c]
P=10**20
for i in range(C):
  for j in range(C):
    for k in range(C):
      if len(set([i,j,k]))==3:
        P=min(P,X[0][i]+X[1][j]+X[2][k])
print(P)

Buggy submission (verdict: Runtime Error):
N,C=map(int,input().split())
D=[list(map(int,input().split())) for i in range(C)]
A=[list(map(int,input().split())) for i in range(N)]
X=[[0]*C for i in range(3)]
for c in range(C):
  for i in range(N):
    for j in range(N):
      X[(i+j)%3][c]+=D[A[i][j]][c]
P=10**20
for i in range(C):
  for j in range(C):
    for k in range(C):
      if len(set([i,j,k]))==3:
        P=min(P,X[0][i]+X[1][j]+X[2][k])
print(P)
Problem p03421 (python)

Fixed submission:
N,A,B=map(int,input().split())
if A+B-1>N or A*B<N:
  print(-1)
  exit()
Q=[[] for i in range(B)]
for i in range(N):
  Q[i//A].append(i+1)
Q=Q[::-1]
X=N-1
for i in range(B):
  if len(Q[i])==0:
    Q[i].append(Q[-(X//A+1)][-1])
    del Q[-(X//A+1)][-1]
    X-=1
  else:
    break
P=[]
for i in range(B):
  for j in range(len(Q[i])):
    P.append(Q[i][j])
print(*P)

Buggy submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
if A+B-1>N or A*B<N:
  print(-1)
  exit()
Q=[[] for i in range(B)]
for i in range(N):
  Q[i//A].append(i+1)
Q=Q[::-1]
X=N-1
for i in range(B):
  if len(Q[i])==0:
    Q[i].append(Q[-(X//A+1+i)][-1])
    X+=1
    del Q[-((N-1)//A+1+i)][-1]
  else:
    break
P=[]
for i in range(B):
  for j in range(len(Q[i])):
    P.append(Q[i][j])
print(*P)
Problem p03780 (python)

Fixed submission:
N,K=map(int,input().split())
A=sorted(filter(lambda x:x<K,list(map(int,input().split()))))
N=len(A)
if N==0:
  print(0)
  exit()
def judge(x):
  DP=1
  Z=(1<<K)-1
  for i in range(N):
    if i!=x:
      DP=((DP|(DP<<A[i]))&Z)
  r=0
  for i in range(K-A[x],K):
    r|=(DP&(1<<i))
  return r

if judge(0):
  print(0)
  exit()
L,R,M=1,N,0
while L!=R:
  M=(L+R)//2
  if judge(M)==0:
    L=max(L+1,M)
  else:
    R=M
print(L)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=sorted(filter(lambda x:x<K,list(map(int,input().split()))))
N=len(A)
def judge(x):
  DP=1
  Z=(1<<K)-1
  for i in range(N):
    if i!=x:
      DP=((DP|(DP<<A[i]))&Z)
  r=0
  for i in range(K-A[x],K):
    r|=(DP&(1<<i))
  return r

if judge(0):
  print(0)
  exit()
L,R,M=1,N,0
while L!=R:
  M=(L+R)//2
  if judge(M)==0:
    L=max(L+1,M)
  else:
    R=M
print(L)
Problem p02586 (python)

Fixed submission:
R, C, K = map(int, input().split())
points_dict = dict()
for _ in range(K):
    r, c, v = map(int, input().split())
    points_dict[r * 30000 + c] = v

dp = [[[0] * (C+1) for _ in range(R+1)] for _ in range(4)] # dp[4][R+1][C+1]
index = 0
for i in range(1, R+1):
    for j in range(1, C+1):
        #移動
        for k in range(4):
            if dp[0][i][j] < dp[k][i-1][j]:
                dp[0][i][j] = dp[k][i-1][j]
            if dp[k][i][j] < dp[k][i][j-1]:
                dp[k][i][j] = dp[k][i][j-1]
        #あれば、拾うかどうか
        if i * 30000 + j in points_dict:
            v = points_dict[i * 30000 + j]
            for k in range(3, 0, -1):
                if dp[k][i][j] < dp[k-1][i][j] + v:
                    dp[k][i][j] = dp[k-1][i][j] + v
"""
for i in range(4):
    print(i)
    print(*dp[i], sep = '\n')
"""
print(max((dp[i][R][C] for i in range(4))))

Buggy submission (verdict: Runtime Error):
R, C, K = map(int, input().split())
rcvs = [tuple(map(int, input().split())) for _ in range(K)]

rcvs.sort(key = lambda t: t[1] * 30000 + t[0])

dp = [[0] * (R+1) for _ in range(4)]
index = 0
for c in range(C+1):
    while index < K and rcvs[index][1] == c:
        x, _, v = rcvs[index]
        if dp[3][x] < dp[2][x] + v:
            dp[3][x] = dp[2][x] + v
        if dp[2][x] < dp[1][x] + v:
            dp[2][x] = dp[1][x] + v
        if dp[1][x] < dp[0][x] + v:
            dp[1][x] = dp[0][x] + v
        if dp[0][x+1] < max((dp[i][x] + v for i in range(4))):
            dp[0][x+1] = max((dp[i][x] + v for i in range(4)))
        index += 1
        #print(dp)   
    
print(max(max(row) for row in dp))
Problem p02588 (python)

Fixed submission:
N = int(input())

two_fives = []
mapping = [[0] * 19 for _ in range(19)]
ans = 0
for _ in range(N):
    s = input()
    if '.' in s:
        m, x = s.split('.')
        A = int(m) * 10 ** 9 + int(x.ljust(9, '0'))
    else:
        A = int(s) * 10 ** 9

    for two in range(19):
        if A % 2 == 0:
            A //= 2
        else:
            break
    for five in range(19):
        if A % 5 == 0:
            A //= 5
        else:
            break
        
    two_fives.append((two, five))
    mapping[18 - two][18 - five] += 1
    if two >= 9 and five >= 9:
        ans -= 1 # excluding ai * ai

for i in range(18):
    for j in range(19):
        mapping[i+1][j] += mapping[i][j]

for i in range(19):
    for j in range(18):
        mapping[i][j+1] += mapping[i][j]


for two, five in two_fives:
    ans += mapping[two][five]

#print(ans)
ans //= 2
print(ans)

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

root = 10000
MOD = 2 ** 61 - 1
def rolling_hash(s):
    hs = [0] * (len(s) + 1)
    for i in range(len(s)):
        hs[i + 1] = hs[i] * root + ord(s[i]) % MOD
    return hs

#"""
N = int(input())
S_list = [input() for _ in range(N)]
"""
def to_alpha(n):
    ret = ''
    while n > 0:
        n -= 1
        ret += chr(n % 26 + ord('a'))
        n //= 26
    return ret

N = 10 ** 5
S_list = [to_alpha(i) for i in range(2, 2 * N + 2, 2)]
#"""


S_list.sort(key=len)

ans = 0
wanted = {chr(i): set() for i in range(ord('a'), ord('z') + 1)}
for S in S_list:
    alpha_set = set()
    hash_of_S = rolling_hash(S)
    for i in range(len(S)):
        alpha_set.add(S[i])
        suffix_hash = (hash_of_S[len(S)] - hash_of_S[i+1] * pow(root, (len(S) - i - 1), MOD)) % MOD
        for alpha in alpha_set:
            if suffix_hash in wanted[alpha]:
                ans += 1

    suffix_of_S = (hash_of_S[len(S)] - hash_of_S[1] * pow(root, (len(S) - 1), MOD)) % MOD
    wanted[S[0]].add(suffix_of_S)

print(ans)
Problem p02603 (python)

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

money = 1000
stock = 0
for i in range(N):
    if i == 0:
        if As[0] < As[1]:
            stock = money // As[0]
            money %= As[0]
    elif i == N - 1:
        money += As[i] * stock
        stock = 0
    else:
        if As[i-1] >= As[i] and As[i+1] >= As[i]:
            stock += money // As[i]
            money %= As[i]
        elif  As[i-1] <= As[i] and As[i+1] <= As[i]:
            money += As[i] * stock
            stock = 0

print(money)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline
N, K = map(int, input().split())
As = list(map(int, input().split()))
for i in range(K, N):
    print("Yes" if As[i] > As[i-K] else "No")
Problem p02626 (python)

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

added = As[0] + As[1]
xored = 0
for A in As[2:]:
    xored ^= A

anded = added - xored
if anded % 2 == 1:
    print(-1)
    exit()
else:
    anded >>= 1

left_stones_l_A0 = '' # <= A[0] for sure.
left_stones_e_A0 = '' #not sure if this is <= A[0].
for i, (a, x) in enumerate(zip(format(anded, '045b'), format(xored, '045b'))):
    if x == '0':
        if a == '0':
            left_stones_l_A0 += '0'
            left_stones_e_A0 += '0'
        else:
            left_stones_l_A0 += '1'
            left_stones_e_A0 += '1'
    else:
        if a == '0':
            if int(left_stones_l_A0 + '1' + '1' * (44 - i), base = 2) <= As[0]:
                left_stones_l_A0 += '1'
            else:
                left_stones_l_A0 += '0'
            if int(left_stones_e_A0 + '1' + '1' * (44 - i), base = 2) <= As[0]:
                left_stones_e_A0 += '1'
                left_stones_l_A0 = left_stones_e_A0
            elif int(left_stones_e_A0 + '1' + '0' * (44 - i), base = 2) <= As[0]:
                left_stones_l_A0 = left_stones_e_A0 + '0'
                left_stones_e_A0 += '1'
            elif int(left_stones_e_A0 + '0' + '0' * (44 - i), base = 2) <= As[0]:
                left_stones_e_A0 += '0'
            else:
                left_stones_e_A0 = left_stones_l_A0
        else:
            print(-1)
            exit()

if int(left_stones_e_A0, base = 2) <= As[0]:
    ans = As[0] - int(left_stones_e_A0, base = 2)
else:
    ans = As[0] - int(left_stones_l_A0, base = 2)

if 0 <= ans < As[0]:
    print(ans)
else:
    print(-1)

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

added = As[0] + As[1]
xored = 0
for A in As[2:]:
    xored ^= A

anded = added - xored
if anded % 2 == 1:
    print(-1)
    exit()
else:
    anded >>= 1

left_stones_l_A0 = '' # <= A[0] for sure.
left_stones_e_A0 = '' #not sure if this is <= A[0].
for i, (a, x) in enumerate(zip(format(anded, '045b'), format(xored, '045b'))):
    if x == '0':
        if a == '0':
            left_stones_l_A0 += '0'
            left_stones_e_A0 += '0'
        else:
            left_stones_l_A0 += '1'
            left_stones_e_A0 += '1'
    else:
        if a == '0':
            if int(left_stones_l_A0 + '1' + '1' * (44 - i), base = 2) <= As[0]:
                left_stones_l_A0 += '1'
            else:
                left_stones_l_A0 += '0'
            if int(left_stones_e_A0 + '1' + '0' * (44 - i), base = 2) <= As[0]:
                left_stones_e_A0 += '1'
            elif int(left_stones_e_A0 + '0' + '0' * (44 - i), base = 2) <= As[0]:
                left_stones_e_A0 += '0'
            else:
                left_stones_e_A0 = left_stones_l_A0
                raise ValueError
        else:
            print(-1)
            exit()

if int(left_stones_e_A0, base = 2) <= As[0]:
    ans = As[0] - int(left_stones_e_A0, base = 2)
else:
    ans = As[0] - int(left_stones_l_A0, base = 2)

if 0 <= ans < As[0]:
    print(ans)
else:
    print(-1)
Problem p02645 (python)

Fixed submission:
print(input()[:3])

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from numba import njit
input = sys.stdin.buffer.readline

N = int(input())
vws = np.array([tuple(map(int, input().split())) for _ in range(N)], np.int32)

n = min(2**11, N)

@njit("i4[:, :](i4[:, :], )", cache = True)
def precompute(vws):
    dp = np.zeros((n, 10**5+1), np.int32)
    dp[0, vws[0, 1]:] = vws[0, 0]
    for i in range(1, n):
        v, w = vws[i]
        dp[i] = dp[(i-1)//2]
        dp[i, w:] = np.maximum(dp[(i-1)//2, :-w]+v, dp[i, w:])
    return dp

@njit("i4(i4[:], i4[:], i4, i4[:])", cache = True)
def func(vs, ws, L, dp_):
    bits = np.arange(1 << len(vs))
    values = np.zeros_like(bits, np.int32)
    weights = np.zeros_like(bits, np.int32)
    for i in range(len(vs)):
        indices = np.nonzero(np.bitwise_and(bits, 1<<i))
        values[indices] += vs[i]
        weights[indices] += ws[i]

    mask = (weights <= L)     
    return np.amax(dp_[L - weights[mask]] + values[mask])

dp = precompute(vws)

Q = int(input())
for _ in range(Q):
    V, L = map(int, input().split())
    V -= 1
    if V < n:
        print(dp[V, L])
    else:
        Vs = []
        while V >= n:
            Vs.append(V)
            V = (V-1) // 2
        vs = vws[Vs, 0]
        ws = vws[Vs, 1]
        print(func(np.array(vs, np.int32), np.array(ws, np.int32), L, dp[V]))

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from numba import njit
input = sys.stdin.buffer.readline

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

n = min(2**10, N)

dp = np.zeros((n, 10**5+1), np.int32)
dp[0, vws[0][1]:] = vws[0][0]
for i in range(1, n):
    v, w = vws[i]
    dp[i] = dp[(i-1)//2]
    dp[i, w:] = np.maximum(dp[(i-1)//2, :-w]+v, dp[i, w:])

@njit("(i4[::], i4[::], i4, i4)", cache = True)
def func(vs, ws, V, L):
    bits = np.arange(1 << len(vs))
    values = np.zeros_like(bits, np.int32)
    weights = np.zeros_like(bits, np.int32)
    for i in range(len(vs)):
        indices = np.nonzero(np.bitwise_and(bits, 1<<i))
        values[indices] += vs[i]
        weights[indices] += ws[i]

    mask = (weights <= L)     
    print(np.amax(dp[V][L - weights[mask]] + values[mask]))


Q = int(input())
for _ in range(Q):
    V, L = map(int, input().split())
    V -= 1
    if V < n:
        print(dp[V][L])
    else:
        vws_choose = []
        while V >= n:
            vws_choose.append(vws[V])
            V = (V-1) // 2
        vs, ws = zip(*vws_choose)
        func(np.array(vs, np.int32), np.array(ws, np.int32), V, L)
Problem p02715 (python)

Fixed submission:
from functools import lru_cache


mod = 10 ** 9 + 7
N, K = map(int, input().split())

@lru_cache
def gcd1_tuples(k):
    if k == 1:
        return 1
    tmp = pow(k, N, mod)
    for j in range(2, k+1):
        tmp -= gcd1_tuples(k//j)
        tmp %= mod
    return tmp

s = 0
for i in range(1, K+1):
    s += gcd1_tuples(K//i) * i
    s %= mod

print(s)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
mod = 10 ** 9 + 7

s = 0
tmp = 1
for _ in range(N):
    tmp *= K
    tmp %= mod
s = tmp
for i in range(K+1):
    baisuu = K % i
    tmp = 1
    for _ in range(N):
        tmp *= baisuu
        tmp %= mod
    s += tmp * (i - 1)

print(s)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
mod = 10 ** 9 + 7

s = 0
tmp = 1
for _ in range(N)
    tmp *= K
    tmp %= mod
s = tmp
for i in range(K+1):
    baisuu = K % i
    tmp = 1
    for _ in range(N)
        tmp *= baisuu
        tmp %= mod
    s += tmp * (i - 1)

print(s)
Problem p02774 (python)

Fixed submission:
from bisect import bisect_left, bisect_right

N, K = map(int, input().split())
As = sorted(map(int, input().split()))
        
l = - (10 ** 18 + 10)
r = 10 ** 18 + 10
while True:
    mid = (l + r) // 2
    count = 0
    for i, A in enumerate(As):
        if A > 0:
            count += bisect_right(As, mid//A, lo = i+1) - (i+1)
        elif A < 0:
            count += N - bisect_left(As, -((-mid)//A), lo = i+1)
        else:
            if mid >= 0:
                count += N - i - 1
    if count < K:
        l = mid
    else:
        r = mid
    if r - l == 1:
        break

print(r)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right

N, K = map(int, input().split())
As = sorted(map(int, input().split()))
        
l = - (10 ** 18 + 10)
r = 10 ** 18 + 10
while True
    mid = (l + r) // 2
    count = 0
    for i, A in enumerate(As):
        if A > 0:
            count += bisect_right(As, mid//A, lo = i+1) - (i+1)
        elif A < 0:
            count += N - bisect_left(As, -((-mid)//A), lo = i+1)
        else:
            if mid >= 0:
                count += N - i - 1
    if count < K:
        l = mid
    else:
        r = mid
    if r - l == 1:
        break

print(r)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
As = sorted(map(int, input().split()))

def check(t):
    "if the number of the pairs (i, j) that satisfies Ai * Aj <= t is < K, return True"
    count = 0
    for i, A in enumerate(As):
        if A > 0:
            index = bisect_right(As, t//A, lo = i+1) - (i+1)
        elif A < 0:
            index = N - bisect_left(As, -(t//(-A)), lo = i+1)
        else:
            if t < 0:
                index = 0
            else:
                index = N - i - 1
        count += index
        if count >= K:
            return False
    return (count < K)

m_count = 0
p_count = 0
for A in As:
    if A < 0:
        m_count += 1
    if A > 0:
        p_count += 1

if K <= m_count * p_count:
    l = A[0] * A[-1] - 1
    r = 0
elif K > N * (N-1) // 2 - p_count * (p_count-1) // 2 - m_count * (m_count-1) // 2 :
    l = 0
    r = max(A[-1] * A[-2], A[0] * A[1])
else:
    print(0)
    exit()

while r - l > 1:
    mid = (l + r) // 2
    if check(mid):
        l = mid
    else:
        r = mid

print(r)
Problem p02782 (python)

Fixed submission:
MOD = 10 ** 9 + 7
table_len = 2 * 10 ** 6 + 10

fac = [1, 1]
for i in range(2, table_len):
    fac.append(fac[-1] * i % MOD)
    
finv = [0] * table_len
finv[-1] = pow(fac[-1], MOD - 2, MOD)
for i in range(table_len-1, 0, -1):
    finv[i-1] = finv[i] * i % MOD

def comb(a, b):
    return fac[a+b] * finv[a] * finv[b] % MOD


r1, c1, r2, c2 = map(int, input().split())
ans = (comb(r1, c1) + comb(r2+1, c2+1) - comb(r1, c2+1) - comb(r2+1, c1)) % MOD
print(ans)

Buggy submission (verdict: Runtime Error):
MOD = 10 ** 9 + 7
table_len = 10 ** 6 + 10

fac = [1, 1]
for i in range(2, table_len):
    fac.append(fac[-1] * i % MOD)
    
finv = [0] * table_len
finv[-1] = pow(fac[-1], MOD - 2, MOD)
for i in range(table_len-1, 0, -1):
    finv[i-1] = finv[i] * i % MOD

def comb(a, b):
    return fac[a+b] * finv[a] * finv[b] % MOD


r1, c1, r2, c2 = map(int, input().split())
ans = (comb(r1, c1) + comb(r2+1, c2+1) - comb(r1, c2+1) - comb(r2+1, c1)) % MOD
print(ans)
Problem p02913 (python)

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

ans = 0
while S:
    Z = [0] * N
    i = 1
    j = 0
    while i < N:
        while i + j < N and S[j] == S[i + j]:
            j += 1

        Z[i] = j

        if j == 0:
            i += 1
        else:
            k = 1
            while k < j and k + Z[k] < j:
                Z[i + k] = Z[k]
                k += 1
            i += k
            j -= k    

    ans = max(ans, max(min(i, z) for i, z in enumerate(Z)))

    S = S[1:]
    N -= 1

print(ans)

Buggy submission (verdict: Runtime Error):
class RollingHash:

    def __init__(self, string, root, mod):
        self.root = root
        self.mod = mod
        self.hs = [0] * (len(string) + 1)
        self.pw = [1] * (len(string) + 1)
        for i in range(len(string)):
            self.hs[i + 1] = (self.hs[i] * self.root + ord(string[i])) % self.mod
            self.pw[i + 1] = self.pw[i] * self.root % self.mod

    def get_hash(self, l, r):
        "get the hash of s[l:r] (0 <= l <= r <= len(s))"
        return (self.hs[r] - self.hs[l] * self.pw[r - l]) % self.mod

    def __getitem__(self, index):
        if isinstance(index, slice):
            return self.get_hash(index.start, index.stop)
        else:
            return 0


RHMOD = (1 << 61) - 1
POSITIVIZER = RHMOD << 20
class RollingHashMOD61:
    """
    MOD == 2 ** 61 - 1
    参考: https://qiita.com/keymoon/items/11fac5627672a6d6a9f6
    """


    def __init__(self, string, root):
        self.root = root
        self.hs = [0] * (len(string) + 1)
        self.pw = [1] * (len(string) + 1)
        for i in range(len(string)):
            tmp = self.hs[i] * self.root + ord(string[i])
            self.hs[i + 1] = (tmp >> 61) + (tmp & RHMOD)
            tmp = self.pw[i] * self.root
            self.pw[i + 1] = (tmp >> 61) + (tmp & RHMOD)

    def get_hash(self, l, r):
        "get the hash of s[l:r] (0 <= l <= r <= len(s))"
        ret = (self.hs[r] - self.hs[l] * self.pw[r - l] + POSITIVIZER)
        ret = (ret >> 61) + (ret & RHMOD)
        if ret >= RHMOD:
            ret -= RHMOD
        assert 0 <= ret < RHMOD
        return ret

    def __getitem__(self, index):
        if isinstance(index, slice):
            return self.get_hash(index.start, index.stop)
        else:
            return 0
        
if __name__ == "__main__":
    N = int(input())
    S = input()

    MOD = 2 ** 61 - 1
    root = 10000

    rh = RollingHashMOD61(S, root)

    ok = 0
    ng = N
    while ng - ok > 1:
        mid = (ok + ng) // 2
        hashes = dict()
        flg = False
        for i in range(N - mid + 1):
            hashofsub = rh[i:i+mid]
            if hashofsub in hashes:
                if i >= hashes[hashofsub] + mid:
                    flg = True
                    break
            else:
                hashes[hashofsub] = i
        
        if flg:
            ok = mid
        else:
            ng = mid

    print(ok)
Problem p02957 (python)

Fixed submission:
t = sum(map(int, input().split()))
if t % 2 == 0:
        print(t//2)
else:
        print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
t = sum(map(int, input())
if t % 2 == 0:
    print(t//2)
else:
    print("IMPOSSIBLE")
Problem p03148 (python)

Fixed submission:
import sys
from operator import itemgetter
input = sys.stdin.buffer.readline

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

tds.sort(key = itemgetter(1), reverse = True)

ate = {t:False for t, _ in tds}
variety = 0
deliciousness = 0
will_be_replaced = []
for t, d in tds[:K]:
    if ate[t] == False:
        ate[t] = True
        variety += 1
    else:
        will_be_replaced.append((t, d))
    deliciousness += d

max_point = deliciousness + variety ** 2

i = K
while will_be_replaced:
    t, d = will_be_replaced.pop()
    while i < N:
        if ate[tds[i][0]]:
            i += 1
        else:
            ate[tds[i][0]] = True
            deliciousness -= d
            deliciousness += tds[i][1]
            variety += 1
            point = deliciousness + variety ** 2
            max_point = max(max_point, point)
            break

print(max_point)

Buggy submission (verdict: Runtime Error):
import sys
from operator import itemgetter
input = sys.stdin.buffer.readline

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

tds.sort(key = itemgetter(1), reverse = True)

ate = {t:False for t, _ in tds}
variety = 0
deliciousness = 0
will_be_replaced = []
for t, d in tds[:K]:
    if ate[t] == False:
        ate[t] = True
        variety += 1
    else:
        will_be_replaced.append((t, d))
    deliciousness += d

max_point = deliciousness + variety ** 2

i = K
while will_be_replaced:
    t, d = will_be_replaced.pop()
    while i < N and ate[tds[i][0]]:
        i += 1
    deliciousness -= d
    deliciousness += tds[i][1]
    variety += 1
    point = deliciousness + variety ** 2
    max_point = max(max_point, point)

print(max_point)
Problem p03160 (python)

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

costs1 = 0
costs2 = abs(hs[1] - hs[0])
for i in range(2, N):
  costs1, costs2 = costs2, min(costs1 + abs(hs[i] - hs[i - 2]), costs2 + abs(hs[i] - hs[i - 1])),
  
print(costs2)

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

costs_1 = 0
costs_2 = abs(hs[1] - hs[0])
for i in range(2, N):
  costs1, costs2 = min(costs1 + abs(hs[i] - hs[i - 2]), costs2 + abs(hs[i] - hs[i - 1])), costs1
  
print(costs2)

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

costs_1 = 0
costs_2 = abs(hs[1] - hs[0])
for i in range(2, N):
  costs1, costs2 = min(costs1 + abs(h[i] - h[i - 2]), costs2 + abs(h[i] - h[i - 2])), costs1
  
print(costs2)