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

Fixed submission:
A,B,C,D = map(int, input().split())
THP = A
AHP = C
while(True):
    #高橋のターン
    AHP -= B
    if(AHP <= 0):
        print("Yes")
        break
    #青木のターン
    THP -= D
    if(THP <= 0):
        print("No")
        break

Buggy submission (verdict: Runtime Error):
A,B,C,D = map(int, input().split())
#倒せるターン
TakahashiTrun = 0
AokiTurn = 0
if(C % B != 0):
    TakahashiTurn = C // B + 1
else:
    TakahashiTrun = C // B

if(A % D != 0):
    AokiTurn = A // D + 1
else:
    AokiTurn = A // D
    
if(TakahashiTurn - 1 >= AokiTurn):
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
A,B,C,D = map(int, input().split())
#倒せるターン
TakahashiTrun = 0
AokiTurn = 0
if(C % B != 0):
    TakahashiTurn = C / B + 1
else:
    TakahashiTrun = C / B

if(A % D != 0):
    AokiTurn = A / D + 1
else:
    AokiTurn = A / D
    
if(TakahashiTurn - 1 >= AokiTurn):
    print("No")
else:
    print("Yes")
Problem p02714 (python)

Fixed submission:
# 先に組み合わせの数を決める
# RとGとBの数を先に数え上げると、Rの数 * Gの数 * Bの数が組み合わせの数になる
# 累積和でもできる

#組み合わせの数は
kumiawase = 0
countR=0
countG=0
countB=0
N = int(input())
S = list(input())
for i in range(N):
    if(S[i] == "R"):
        countR += 1
    elif(S[i] == "G"):
        countG += 1
    elif(S[i] == "B"):
        countB += 1
kumiawase = countR * countG * countB

count = 0
#その組み合わせの数から、j-i = k-jをみたす数を引けばいい
#条件を満たし、かつ1つ目の条件を満たすものは
for i in range(N):
    for j in range(i+1, N):
        k = 2 * j - i
        if(k < N):
            if(S[i] != S[j] and S[i] != S[k] and S[j] != S[k]):
                count+=1

print(kumiawase - count)

Buggy submission (verdict: Runtime Error):
count = 0
N = int(input())
S = list(input())
# for i in range(N):
#     for j in range(i+1, N):
#         for k in range(j+1, N):
#             if(S[i] != S[j] and S[i] != S[k] and S[j] != S[k] and (j - i) != (k - j)):
#                 count+=1
# print(count)

countSecond = 1
countThird = 1
for i in range(N):
    while(S[i] == S[i+countSecond]):
        if(countSecond < N):
            countSecond+=1
        else:
            break
            
    while(S[i+countSecond] == S[i + countThird]):
        if(countThird < N):
            countThird += 1
        else:
            break
    if((countSecond - i) != (countThird - i)):
        count+=1
print(count)
Problem p02719 (python)

Fixed submission:
import math

NK = input().split();
N,K = int(NK[0]),int(NK[1]);
min = N;

#桁が大きい時の処理
if(K == 1):
    while(int(len(str(N))) > 2):
        N = int(N - K * (N / 2));
else:
    border = math.floor(N / K);
    N = N - K * border;
        
flag = True;
while flag == True:
    N = abs(N - K);
    if(N <= min):
        min = N;
    else:
        flag = False;
    
print(min);

Buggy submission (verdict: Runtime Error):
NK = input().split();
N,K = int(NK[0]),int(NK[1]);
min = N;

#桁が大きい時の処理
if(K == 1):
    while(int(len(str(N))) > 2):
        N = int(N - K * (N / 2));
else:
    border = math.floor(N / K);
    N = N - K * border;
        
flag = True;
while flag == True:
    N = abs(N - K);
    if(N <= min):
        min = N;
    else:
        flag = False;
    
print(min);

Buggy submission (verdict: Runtime Error):
NK = input().split();
N,K = int(NK[0]),int(NK[1]);
min = N;

#桁が大きい時の処理
while(int(len(str(N))) > 2):
    N = int(N - K * int(N / 2));
    print("N=");
    print(N);
    print("K=");
    print(K);

flag = True;
while flag == True:
    N = abs(N - K);
    if(N <= min):
        min = N;
    else:
        flag = False;
    
print(min);

Buggy submission (verdict: Runtime Error):
NK = input().split();
N,K = int(NK[0]),int(NK[1]);
min = N;

#桁が大きい時の処理
while(int(len(str(N))) > 2):
    N = int(N - K * (N / 2));

flag = True;
while flag == True:
    N = abs(N - K);
    if(N <= min):
        min = N;
    else:
        flag = False;
    
print(min);
Problem p02900 (python)

Fixed submission:
#4問目
import math
import fractions
import collections
A, B = map(int, input().split())

count = 0
gcd = fractions.gcd(A,B)

def devisor(num):
    array = []
    for i in range(1, math.floor(math.sqrt(num)) + 1):
        if(num % i == 0):
            array.append(i)
            array.append(math.floor(num / i))
    return array

def prime(n):
    prime = []
    while n % 2 == 0:
        prime.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            prime.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        prime.append(n)
    return prime

print(len(collections.Counter(prime(gcd))) + 1)

Buggy submission (verdict: Runtime Error):
#4問目
import math
import collections
A, B = map(int, input().split())

count = 0
gcd = fractions.gcd(A,B)

def devisor(num):
    array = []
    for i in range(1, math.floor(math.sqrt(num)) + 1):
        if(num % i == 0):
            array.append(i)
            array.append(math.floor(num / i))
    return array

def prime(n):
    prime = []
    while n % 2 == 0:
        prime.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            prime.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        prime.append(n)
    return prime

print(len(collections.Counter(prime(gcd))) + 1)

Buggy submission (verdict: Runtime Error):
#4問目
import math
A, B = map(int, input().split())

count = 0
gcd = math.gcd(A,B)

def devisor(num):
    array = []
    for i in range(1, math.floor(math.sqrt(num)) + 1):
        if(num % i == 0):
            array.append(i)
            array.append(math.floor(num / i))
    return array

def isPrime(n):
    if n <= 2:
        return True
    for p in range(2, n):
        if n % p == 0:
            return False
    return True

dev = devisor(gcd)
for i in dev:
    if isPrime(i):
        count += 1
print(count)
Problem p03220 (python)

Fixed submission:
#ABC 113 B - Palace
import numpy as np
def getNearestIndex(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
result = [0] * N

for i in range(N):
    result[i] = T - H[i] * 0.006

resultNum = getNearestIndex(result, A)
print(resultNum + 1)

Buggy submission (verdict: Runtime Error):
#ABC 113 B - Palace
import numpy as np
def getNearestIndex(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
result = [0] * N
resultNum = 0
Max = float("inf")
for i in range(N):
    result[i] = int(T - H[i] * 0.006)

resultNum = getNearestIndex(result, A)
print(resultNum + 1)
Problem p03294 (python)

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

answer = A[0]
Sum = 0

def gcd(A,B):
    if(B == 0):
        return A
    else:
        return gcd(B, A%B)

#最小公倍数-1がfに入る数なはず
for i in range(1, N):
    answer = answer * A[i] // gcd(answer, A[i])
    
for i in range(N):
    Sum += (answer-1) % A[i]

print(Sum)

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

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

#最小公倍数-1
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

MaxKoubai = lcm_list(a)
m = MaxKoubai - 1
result = 0

for i in range(N):
    result += m % a[i]
    
print(result)

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

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

#m = 最小公倍数 - 1
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

MaxKoubai = lcm_list(a)
m = MaxKoubai - 1
result = 0

for i in range(N):
    result += m % a[i]
    
print(result)
Problem p03448 (python)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if(i * 500 + j * 100 + k * 50 == X):
                count += 1

print(count)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A):
  for j in range(B):
    for k in range(C):
      if(i * 500 + j * 100 + k * 50 === X):
        count += 1

print(count)
Problem p03633 (python)

Fixed submission:
#5問目
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
T = []
for i in range(N):
    t = int(input())
    T.append(t)
    
print(lcm_list(T))

Buggy submission (verdict: Runtime Error):
#5問目
import math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
T = []
for i in range(N):
    t = int(input())
    T.append(t)
    
print(lcm_list(T))
Problem p03665 (python)

Fixed submission:
#3問目
import itertools
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N, P = map(int, input().split())
A = list(map(int, input().split()))
#偶数グループと奇数グループにわける
odd = []
even = []
c = 0
for i in A:
    if i % 2 == 0:
        even.append(i)
    else:
        odd.append(i)
#奇数グループは組み合わせの総数を出す
#もしP=1なら奇数グループから奇数個を出す組み合わせの数、P=0なら奇数グループから偶数個を出す組み合わせの数
if P == 1:
    #奇数グループから奇数個を出す組み合わせの数
    for i in range(1, len(odd)+1, 2):
        c += combinations_count(len(odd), i)
if P == 0:
    #奇数グループから偶数個を出す組み合わせの数
    for i in range(0, len(odd)+1, 2):
        c += combinations_count(len(odd), i)
        
print(2 ** len(even) * c)

Buggy submission (verdict: Runtime Error):
#3問目
import itertools

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N, P = map(int, input().split())
A = list(map(int, input().split()))
#偶数グループと奇数グループにわける
odd = []
even = []
c = 0
for i in A:
    if i % 2 == 0:
        even.append(i)
    else:
        odd.append(i)
#奇数グループは組み合わせの総数を出す
#もしP=1なら奇数グループから奇数個を出す組み合わせの数、P=0なら奇数グループから偶数個を出す組み合わせの数
if P == 1:
    #奇数グループから奇数個を出す組み合わせの数
    for i in range(1, len(odd)+1, 2):
        c += combinations_count(len(odd), i)
if P == 0:
    #奇数グループから偶数個を出す組み合わせの数
    for i in range(0, len(odd)+1, 2):
        c += combinations_count(len(odd), i)
        
print(2 ** len(even) * c)
Problem p02642 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
dp = [0]*(1000000+1)
cnt = 0
for i in range(len(a)):
  if dp[a[i]]==1:
    continue
  j = 2
  while(a[i]*j<=a[-1]):
    dp[a[i]*j] = 1
    j += 1
  if i!=len(a)-1 and a[i+1]==a[i]:
    dp[a[i]] = 1
    continue
  cnt += 1
  dp[a[i]] = 1
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.sort()
dp = [0]*(1000000+1)
cnt = 0
for i in range(len(a)):
  if dp[a[i]]==1:
    continue
  while(a[i]*j<=a[-1]):
    dp[a[i]*j] = 1
    j += 1
  if i!=len(a)-1 and a[i+1]==a[i]:
    dp[a[i]] = 1
    continue
  cnt += 1
  dp[a[i]] = 1
  j = 2
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.sort()
c = [0]*len(a)
cnt = len(a)
k = 1
for e in a:
  if c[k]==1:
    continue
  for i in range(k, len(a)):
    if a[i]%e!=0:
      continue
    else:
      c[i] = 1
      cnt -= 1
  k +=1
if c[1]==1 and a[0]!=0:
  print(0)
else:
  print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.sort()
c = [0]*len(a)
cnt = len(a)
k = 1
for e in a:
  if c[i]==1:
    continue
  for i in range(len(a)):
    if a[i]%e!=0:
      continue
    else:
      c[i] = 1
      cnt -= 1
  k +=1
if c[1]==1 and a[0]!=0:
  print(0)
else:
  print(cnt)
Problem p02660 (python)

Fixed submission:
n = int(input())
li = []
flg = 0
for i in range(1000000):
  if n==1:
    break
  if i==0 or i==1 or n%i!=0:
    continue
  j = i
  cnt = 0
  while(n%j==0):
    if flg==0:
      flg = 1
    n /= j
    cnt += 1
  li.append(cnt)
if flg==0 and n!=1:
  print(1)
elif flg==0 and n==1:
  print(0)
elif n==1:
  ans = 0
  for e in li:
    i = 1
    while(e-i>=0):
      e -= i
      i += 1
      ans += 1
  print(ans)
else:
  ans = 1
  for e in li:
    i = 1
    while(e-i>=0):
      e -= i
      i += 1
      ans += 1
  print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
li = []
if n==1:
  print(0)
else:
  for i in range(1000000):
    if n==1:
      break
    if i==0 or i==1 or n%i!=0:
      continue
    j = i
    cnt = 0
    while(n%j==0):
      if flg==0:
        flg = 1
      n /= j
      cnt += 1
    li.append(cnt)
  if flg==0:
    print(1)
  else:
    ans = 0
    for e in li:
      i = 1
      while(e-i>=0):
        e -= i
        i += 1
        ans += 1
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n==1:
  print(0)
else:
    cnt = 0
  flg = 0
  for i in range(1000000):
    if n<i:
      break
    if i==0 or i==1 or n%i!=0:
      continue
    j = i
    while(n%j==0):
      if flg==0:
        flg = 1
      n /= j
      j *= i
      cnt += 1


  if flg==0:
    print(1)
  else:
    print(cnt)
Problem p02684 (python)

Fixed submission:
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))
c = [0]*N

idx = 0
stp = 0
ans = 0
while(True):
  stp += 1
  idx = A[idx] - 1
  if c[idx]==0 and idx!=0:
    c[idx] = stp
  else:
    tmp1 = c[idx]
    tmp2 = stp - tmp1
    break
  if stp>=K:
    ans = idx + 1
    break

if(ans>0):
  print(ans)
else:
  k1 = K - tmp1
  k2 = k1%tmp2
  for _ in range(k2):
    idx = A[idx] - 1
  print(idx+1)

Buggy submission (verdict: Runtime Error):
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))
c = [0]*N

idx = 0
stp = 0
ans = 0
while(True):
  stp += 1
  idx = A[idx] - 1
  if c[idx]==0 and idx!=0:
    c[idx] = stp
  else:
    tmp1 = c[idx]
    tmp2 = stp - tmp1
    break
  if stp>=K:
    ans = idx + 1
    break

k1 = K - tmp1
k2 = k1%tmp2

for _ in range(k2):
  idx = A[idx] - 1
if(ans>0):
  print(ans)
else:
  print(idx+1)

Buggy submission (verdict: Runtime Error):
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))
c = [0]*N

idx = 0
stp = 0
while(True):
  stp += 1
  idx = A[idx] - 1
  if c[idx]==0 and idx!=0:
    c[idx] = stp
  else:
    tmp1 = c[idx]
    tmp2 = stp - tmp1
    break
  if stp>=K:
    break

k1 = K - tmp1
k2 = k1%tmp2

for _ in range(k2):
  idx = A[idx] - 1
print(idx+1)
Problem p02696 (python)

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

if B==1:
  print(0)
else:
  tb = B - 1
  tp_pre = 0
  while(True):
    tp = (A*tb)//B - A*(tb//B)
    if tp > tp_pre:
      tp_pre = tp
    tb += B
    if tb > N:
      break
  if (B > N):
    print((A*N)//B - A*(N//B))
  else:
    print(int(tp_pre))

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

if B==1:
  print(0)

tb = B - 1
tp_pre = 0
while(True):
  tp = (A*tb)//B - A*(tb//B)
  if tp > tp_pre:
    tp_pre = tp
  tb += B
  if tb > N:
    break

if (B > N):
  print((A*N)//B - A*(N//B))
else:
  print(int(tmp_pre))

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

tmp_pre = 0
for i in range(1, N+1):
  tmp = math.floor(A*i/B) - A*math.floor(i/B)
  if tmp > tmp_pre:
    tmp_pre = tmp
print(int(tmp_pre))
Problem p02761 (python)

Fixed submission:
N, M = list(map(int, input().split()))
num = [-1]*N
for i in range(M):
  s, c = list(map(int, input().split()))
  if num[s-1] >= 0 and num[s-1] != c:
    num[s-1] = 10
  else:
    num[s-1] = c
if N != 1 and num[0] == 0:
  num[0] = 10
num = [0 if num[i]<0 else num[i] for i in range(N)]
if N != 1 and num[0] == 0:
  num[0] = 1
tmp = 0
for i in range(N):
  tmp += num[i]*10**(N-1-i)
if 10 in num:
  print(-1)
else:
  print(tmp)

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
num = [0]*N
for i in range(M):
  s, c = list(map(int, input().split()))
  num[s-1] = c
if num[0] == 0:
  print(-1)
else:
  print(num[0]*100 + num[1]*10 + num[2]*1)
Problem p03030 (python)

Fixed submission:
N = int(input())
shops = []
for i in range(N):
    S, P = input().split()
    shops.append([S, int(P), i+1])
shops.sort(key=lambda x: x[1], reverse=True)
shops.sort(key=lambda x: x[0])
for shop in shops:
    print(shop[2])

Buggy submission (verdict: Runtime Error):
N = int(input())
shops = []
for i in range(N):
    S, P = input().split()
    shops.append([S, int(P), i])
shops.sort(key=1)
shops.sort()
for shop in shops:
    print(shop[2])
Problem p02573 (python)

Fixed submission:
import sys

N, M = map(int, input().split())

sys.setrecursionlimit(10**7)

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


v_visit = [False for _ in range(N)]

def search(n):
    count = 0
    for n_ in set(v_neighbor[n]):
        if not v_visit[n_]:
            v_visit[n_] = True
            count += 1
            count += search(n_)
    return count

res = 1
for i in range(N):
    if v_visit[i]:
        continue
    search_res = search(i)
    res = max(res, search_res)


print(res)

Buggy submission (verdict: Runtime Error):
import sys

N, M = map(int, input().split())

sys.setrecursionlimit(M+N)

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


v_visit = [False for _ in range(N)]

def search(n):
    count = 0
    for n_ in set(v_neighbor[n]):
        if not v_visit[n_]:
            v_visit[n_] = True
            count += 1
            count += search(n_)
    return count

res = 1
for i in range(N):
    if v_visit[i]:
        continue
    search_res = search(i)
    res = max(res, search_res)


print(res)

Buggy submission (verdict: Runtime Error):
import sys

N, M = map(int, input().split())

sys.setrecursionlimit(M+1)

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


v_visit = [False for _ in range(N)]

def search(n):
    count = 0
    for n_ in set(v_neighbor[n]):
        if not v_visit[n_]:
            v_visit[n_] = True
            count += 1
            count += search(n_)
    return count

res = 1
for i in range(N):
    if v_visit[i]:
        continue
    search_res = search(i)
    res = max(res, search_res)


print(res)

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

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


v_visit = [False for _ in range(N)]

def search(n):
    count = 0
    for n_ in v_neighbor[n]:
        if not v_visit[n_]:
            v_visit[n_] = True
            count += 1
            count += search(n_)
    return count

res = 0
for i in range(N):
    if v_visit[i]:
        continue
    search_res = search(i)
    res = max(res, search_res)


print(res)
Problem p04045 (python)

Fixed submission:
N, K = input().split()

dislike = set(list(map(int, input().split())))

next_map = {}
min_digit = 0
for i in range(10):
    for j in range(i,10):
        if j not in dislike:
            if i == 0:
                min_digit = j
            next_map.update({ i : j })
            break
        next_map.update({ i : min_digit })
max_digit = max(next_map.values())

num = len(list(N))
count = num
cand = []
for n in list(N):
    n = int(n)
    if n in dislike:
        n_ = next_map[n]
        cand.append(n_)
        count -= 1
        cand.extend(count*[min_digit])
        break
    else:
        cand.append(n)
        count -= 1
cand = int("".join(list(map(str, cand))))
if int(N) <= cand:
    print(cand)
else:
    if min_digit == 0:
        next_min = next_map[1]
        cand = [next_min] + num * [0]
    else:
        cand = (num + 1) * [min_digit]
    cand = int("".join(list(map(str, cand))))
    print(cand)

Buggy submission (verdict: Runtime Error):
N, K = input().split()

dislike = set(list(map(int, input().split())))


next_map = {}
for i in range(10):
    for j in range(i,10):
        if j not in dislike:
            if i == 0:
                min_digit = j
            next_map.update({ i : j })
            break
        next_map.update({ i : min_digit })
max_digit = max(next_map.values())

num = len(list(N))

count = num
cand = []
for n in list(N):
    n = int(n)
    if n in dislike:
        n_ = next_map[n]
        cand.append(n_)
        count -= 1
        cand.extend(count*[min_digit])
        break
    else:
        cand.append(n)
cand = int("".join(list(map(str, cand))))
if int(N) <= cand:
    print(cand)
else:
    if min_digit == 0:
        next_min = next_map[1]
        cand = [next_min] + num * [0]
    else:
        cand = (num + 1) * [min_digit]
    cand = int("".join(list(map(str, cand))))
    print(cand)
Problem p02556 (python)

Fixed submission:
n = int(input())

x = []
y = []
for i in range(n):
    a,b = map(int,input().split())
    x.append(a)
    y.append(b)
d1_max = x[0]+y[0]
d1_min = x[0]+y[0]
d2_max = x[0] - y[0]
d2_min = x[0]-y[0]
ans = -1
for i in range(1,n):
    d1_max = max(d1_max,x[i]+y[i])
    d1_min = min(d1_min,x[i]+y[i])
    d2_max = max(d2_max,x[i] - y[i])
    d2_min = min(d2_min,x[i]-y[i])
    ans = max((d1_max-d1_min),(d2_max-d2_min))
print(ans)

Buggy submission (verdict: Runtime Error):
def cost(x1,y1,x2,y2):
    return abs(x1-x2) + abs(y1-y2)


n = int(input())

x = []
y = []
for i in range(n):
    a,b = map(int,input().split())
    x.append(a)
    y.append(b)
ans = - math.inf
for i in range(n):
    for j in range(i+1,n):
        ans = max(ans,cost(x[i],y[i],x[j],y[j]))
print(ans)
Problem p02657 (python)

Fixed submission:

a,b = map(int,input().split())
print(a*b)

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

Fixed submission:
N = int(input())
nums = list(map(int, input().split()))
 
set_nums = sorted(list(set(nums)))
set_dup = set_nums.copy()
 
if N <= 2:
    print(0)
else:
    for i, d in enumerate(set_dup):
        count = 0
        for n in nums:
            if n == d:
                count += 1
        set_dup[i] = count
 
    count = 0
    for a in range(len(set_nums)):
        for b in range(a+1, len(set_nums)):
            for c in range(b+1, len(set_nums)):
                if set_nums[a] + set_nums[b] > set_nums[c]:
                    count += set_dup[a] * set_dup[b] * set_dup[c]
    print(count)

Buggy submission (verdict: Runtime Error):

if N <= 2:
    print(0)
else:
    for i, d in enumerate(set_dup):
        count = 0
        for n in nums:
            if n == d:
                count += 1
        set_dup[i] = count

    count = 0
    for a in range(len(set_nums)):
        for b in range(a+1, len(set_nums)):
            for c in range(b+1, len(set_nums)):
                if set_nums[a] + set_nums[b] > set_nums[c]:
                    count += set_dup[a] * set_dup[b] * set_dup[c]
    print(count)