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

Fixed submission:
n,m = map(int,input().split())
student = []
Coodinate = []
for i in range(n):
    student.append(list(map(int,input().split())))
for j in range(m):
    Coodinate.append(list(map(int,input().split())))
ans = []
#print(student)
#print(Coodinate)
for k in student:
    manhattan = 100000000000
    number = 0
    for u in range(m):
        manhattann = abs(k[0]-Coodinate[u][0])+abs(k[1]-Coodinate[u][1])
        if manhattann < manhattan:
            manhattan = manhattann
            number = u+1
    ans.append(number)
for y in ans:
    print(y)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
x = [0]*n
y = [0]*n
mx = [0]*m
my = [0]*m
for i in range(n):
    x[i],y[i] = map(int,input().split())
for j in range(m):
    mx[j],my[j] = map(int,input().split())
#print(x)
#print(y)
#print(mx)
#print(my)
ans = [0]*n
#print(ans)
for k in range(n):
    dis = 1000000000
    cnt = 1
    for l in range(n):
        if abs(x[k]-mx[l])+abs(y[k]-my[l]) < dis:
            dis = abs(x[k]-mx[l])+abs(y[k]-my[l])
            cnt = l+1
    ans[k] = cnt
for h in ans:
    print(h)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
x = [0]*n
y = [0]*n
mx = [0]*m
my = [0]*m
for i in range(n):
    x[i],y[i] = map(int,input().split())
for j in range(m):
    mx[j],my[j] = map(int,input().split())
ans = [0]*n
for k in range(n):
    dis = 1000000000
    cnt = 1
    for l in range(n):
        if abs(x[k]-mx[l])+abs(y[k]-my[l]) < dis:
            dis = abs(x[k]-mx[l])+abs(y[k]-my[l])
            cnt = l+1
    ans[k] = cnt
for h in ans:
    print(h)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
x = [0]*n
y = [0]*n
mx = [0]*m
my = [0]*m
for i in range(n):
    x[i],y[i] = map(int,input().split())
for j in range(m):
    mx[j],my[j] = map(int,input().split())
ans = [0]*n
for k in range(n):
    dis = 0
    cnt = 1
    for l in range(n):
        if abs(x[k]-xs[l])+abs(y[k]-ys[l]) > dis:
            dis = abs(x[k]-xs[l])+abs(y[k]-ys[l])
            cnt = l+1
    ans[k] = cnt
for h in ans:
    print(h)
Problem p02831 (python)

Fixed submission:
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

def lcm(a,b):
  return a*b//gcd(a,b)

a, b = fetch_int_input()
print(lcm(a, b))

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


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]

def lcm(x, y):
    return (x * y) // gcd(x, y)

from math import gcd
a, b = fetch_int_input()
print(lcm(a, b))
Problem p02835 (python)

Fixed submission:
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


nums = fetch_int_input()
echo_result = ["win", "bust"]

print(echo_result[sum(nums) > 21])

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


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


length = int(fetch_one_line())
nums = fetch_int_input()

bit_nums = [bin(i)[2:] for i in nums]
max_length = max([len(i) for i in bit_nums])

bit_nums = [list(i.zfill(max_length)) for i in bit_nums]
bit_nums = list(zip(*bit_nums))
sum_ones = [lst.count("1") for lst in bit_nums]
sum_zeros = [length - o for o in sum_ones]
multiples = [i * (length - i) for i in zip(sum_ones)]

result = sum([pow(2, i) * m for i, m in enumerate(reversed(multifrom sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


length = int(fetch_one_line())
nums = fetch_int_input()

bit_nums = [bin(i)[2:] for i in nums]
max_length = max([len(i) for i in bit_nums])

bit_nums = [list(i.zfill(max_length)) for i in bit_nums]
bit_nums = list(zip(*bit_nums))
sum_ones = [lst.count("1") for lst in bit_nums]
sum_zeros = [length - o for o in sum_ones]
multiples = [i * (length - i) for i in sum_ones]

result = sum([pow(2, i) * m for i, m in enumerate(reversed(multiples))])
print(result % (pow(10, 9) + 7))

ples))])
print(result % (pow(10, 9) + 7))
Problem p02847 (python)

Fixed submission:
s=input()
if s[0]=="S" or s[0]=="T":
  if s[2]=="E":
    print('5')
  elif s[2]=='U':
    print('3')
  elif s[2]=='T':
    print('1')
  else:
    print('7')
else:
  if s[1]=='R':
    print('2')
  elif s[1]=='O':
    print('6')
  else:
    print('4')

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
out_str=''
for i in s:
  m=ord(i)+n
  if m>90:
    m-=26
  out_str+=chr(m)

print(out_str)
Problem p02847 (python)

Fixed submission:
date = input()

List = ['SAT', 'FRI', 'THU', 'WED', 'TUE', 'MON', 'SUN']

for i in range(len(List)):
    if List[i] == date:
        print(i+1)

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

alphabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
            'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
            'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']

#Generate empty output
output = ''

for i in range(len(S)):
    #Get the index of an alphabet in the list
    ind1 = alphabet.index(string[i])
    #Divide N by 26 and get the remainder
    ind2 = (int(ind1) + N) % 26
    #Update the letter and keep adding it to the list
    output += alphabet[ind2]

print(output)
Problem p02859 (python)

Fixed submission:
r = int(input())
r2 = r**2

ans = r**2 / 1
print(int(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = str(input())
if S[:N//2] == S[N//2:]:
    print('YES')
else:
    print('NO')

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

if N % 2 != 0:
    print('NO')
else:
    num =int( N / 2)
    f = S[0:num]
    if S == f+f:
        print('YES')
    else:
        print('NO')
Problem p02785 (python)

Fixed submission:
N, K = map(int, input().split())
Hs = list(map(int, input().split()))
Hs.sort(reverse=True)
if K > N:
  print(0)
else:
  for i in range(K):
    Hs[i] = 0
  print(sum(Hs))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
Hs = list(map(int, input().split()))
Hs.sort(reverse=True)
if K == 0:
  print(sum(Hs))
else:
  for i in range(K):
    Hs[i] = 0
  print(sum(Hs))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
Hs = list(map(int, input().split()))
Hs.sort(reverse=True)
for i in range(K):
  Hs[i] = 0
print(sum(Hs))
Problem p02990 (python)

Fixed submission:
def comb(n, r):
	from math import factorial
	return factorial(n) // (factorial(n - r) * factorial(r))

def main():
	import sys
	input = sys.stdin.readline
	N, K = map(int, input().split())
	num = 10 ** 9 + 7
	a = N - K + 1
	print(a)
	if K > 1:
		if 2 * K <= N + 1:
			for j in range(2, K+1):
				b1 = comb(a, j) % num
				b2 = comb(K-1, j-1) % num
				ans = (b1 * b2) % num
				print(ans)
		else:
			for j in range(2, N-K+2):
				b1 = comb(a, j) % num
				b2 = comb(K-1, j-1) % num
				ans = (b1 * b2) % num
				print(ans)
			for j in range(N-K+2, K+1):
				print(0)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def comb(n, r):
	from math import factorial
	return factorial(n) // (factorial(n - r) * factorial(r))

def main():
	import sys
	input = sys.stdin.readline
	N, K = map(int, input().split())
	num = 10 ** 9 + 7
	a = N - K + 1
	print(a)
	if K > 1:
		for j in range(2, K+1):
			b1 = comb(a, j) % num
			b2 = comb(K-1, j-1) % num
			ans = b1 * b2 % num
			print(ans)
			if ans == 0:
				sys.exit()

if __name__ == '__main__':
    main()
Problem p02933 (python)

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

if a >= 3200:
  print(s)
else:
  print('red')

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

if a >= 3200:
  print(s)
else:
  print('red')
Problem p02891 (python)

Fixed submission:
s = input()
k = int(input())
c = 1
i = 1
l = []
c2 = 0
while i < len(s):
    if i == len(s)-1:
        if s[i] == s[i-1]:
            c = c+1
            l.append(c)
            i = i+1
        else:
            l.append(c)
            l.append(1)
            i = i+1
    elif s[i] == s[i-1]:
        c = c + 1
        i = i + 1
    else:
        l.append(c)
        c = 1
        i = i+1
if len(l) == 1:
    print((len(s)*k)//2)
elif s[0] == s[len(s)-1]:
    if len(s)==1:
        print(k//2)
    else:
        for i in range(1,len(l)-1):
            c2 = c2 + l[i]//2
        print(c2*k+((l[0]+l[len(l)-1])//2)*(k-1)+l[0]//2+l[len(l)-1]//2)
else:
    for i in range(0,len(l)):
        c2 = c2 + l[i]//2
    print(c2*k)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
c = 1
i = 1
l = []
c2 = 0
while i < len(s):
    if i == len(s)-1:
        if s[i] == s[i-1]:
            c = c+1
            l.append(c)
            i = i+1
        else:
            l.append(c)
            l.append(1)
            i = i+1
    elif s[i] == s[i-1]:
        c = c + 1
        i = i + 1
    else:
        l.append(c)
        c = 1
        i = i+1
if len(l) == 1:
    print((len(s)*k)//2)
elif s[0] == s[len(s)-1]:
    for i in range(1,len(l)-1):
        c2 = c2 + l[i]//2
    print(c2*k+((l[0]+l[len(l)-1])//2)*(k-1)+l[0]//2+l[len(l)-1]//2)
else:
    for i in range(0,len(l)):
        c2 = c2 + l[i]//2
    print(c2*k)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
c = 1
i = 1
l = []
c2 = 0
while i < len(s):
    if i == len(s)-1:
        if s[i] == s[i-1]:
            c = c+1
            l.append(c)
            i = i+1
        else:
            l.append(c)
            l.append(1)
            i = i+1
    elif s[i] == s[i-1]:
        c = c + 1
        i = i + 1
    else:
        l.append(c)
        c = 1
        i = i+1
if len(l) == 1:
    print(len(s)*k//2)
elif s[0] == s[len(s)-1]:
    for i in range(1,len(l)-1):
        c2 = c2 + l[i]//2
    print(c2*k+((l[0]+l[len(l)-1])//2)*(k-1)+l[0]//2+l[len(l)-1]//2)
else:
    for i in range(0,len(l)):
        c2 = c2 + l[i]//2
    print(c2*k)
Problem p02959 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = 0
for i in range(0,n):
  if a[i] > b[i]:
    c = c + b[i]
  elif a[i] <= b[i]:
    c = c + a[i]
    b[i] = b[i] - a[i]
    if b[i] < a[i+1]:
      c = c + b[i]
      a[i+1] = a[i+1] - b[i]
    else:
      c = c + a[i+1]
      a[i+1] = 0
print(c)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = 0
for i in range(0,n+1):
  if a[i] > b[i]:
    c = c + b[i]
  elif a[i] <= b[i]:
    c = c + a[i]
    b[i] = b[i] - a[i]
    if b[i] < a[i+1]:
      c = c + b[i]
      a[i+1] = a[i+1] - b[i]
    else:
      c = c + a[i+1]
      a[i+1] = 0
print(c)
Problem p02970 (python)

Fixed submission:
l = list(map(int,input().split()))
n = l[0]
d = l[1]

if n % (2*d+1) == 0:
  print(n // (2*d+1))
else:
  print(n // (2*d+1) + 1)

Buggy submission (verdict: Runtime Error):
l = list(map(int,input().split()))
n = l[0]
d = l[1]

if n % (2d+1) == 0:
  print(n // (2d+1))
else:
  print(n // (2d+1) + 1)
Problem p02989 (python)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
a = l[n//2 - 1]
b = l[n//2]
 
print(b-a)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split())).sort()
a = l[n//2]
b = l[n//2 + 1]

print(b-a)
Problem p02990 (python)

Fixed submission:
n, k = map(int, input().split())
import math
def Fa(x):
    return math.factorial(x)

for i in range(1,k+1):
    if k-i < 0 or n-k+1-i < 0:
        print(0)
    else:
        print((Fa(n-k+1)*Fa(k-1)//(Fa(i-1)*Fa(k-i)*Fa(n-k+1-i)*Fa(i)))%(10**9 +7))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
import math
def Fa(x):
    return math.factorial(x)

for i in range(1,k+1):
    print((Fa(n-k+1)*Fa(k-1)//(Fa(i-1)*Fa(k-i)*Fa(n-k+1-i)*Fa(i)))%(10**9 +7))
Problem p03011 (python)

Fixed submission:
l = list(map(int,input().split()))
p = l[0]
q = l[1]
r = l[2]
print(min(p+q,q+r,r+p))

Buggy submission (verdict: Runtime Error):
l = list(map(int,input().split()))
p = list[0]
q = list[1]
r = list[2]
print(min([p+q,q+r,r+p]))

Buggy submission (verdict: Runtime Error):
l = list(map(int,input().split()))
p = list[0]
q = list[1]
r = list[2]
print(min(p+q,q+r,r+p))
Problem p02831 (python)

Fixed submission:
import fractions

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

print(int(a[0]*a[1]/fractions.gcd(a[0],a[1])))

Buggy submission (verdict: Runtime Error):
import math

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

print(int(a[0]*a[1]/math.gcd(a[0],a[1])))
Problem p02781 (python)

Fixed submission:
import math
N = int(input())
l = len(str(N))
K = int(input())
def calc(a, b, c):
    t = 0
    if a-b-1>=0:
        t = (math.factorial(a-1) // (math.factorial(a-b-1) * math.factorial(b)))*(9**(b))
    if b==1:
        t2 = int(str(c)[0])
    else:
        t2 = (math.factorial(a-1) // (math.factorial(a-b) * math.factorial(b-1)))*(9**(b-1))*(int(str(c)[0])-1)
    t3 = 0
    try:
        n = int(str(c)[1:])
        if 2<=b<=len(str(n))+1:
            t3 = calc(len(str(n)), b-1, n)
    except:
        pass
    return t+t2+t3

if l>=K:
    print(calc(l, K, N))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import math
N = len(str(input()))
K = int(input())
print((math.factorial(N) // (math.factorial(N-K) * math.factorial(K)))*(9**K))
Problem p02819 (python)

Fixed submission:
x=int(input())

import math

def trial_division(target):
    dest = int(math.sqrt(target))
 
    for i in range(2,dest):
        if target % i == 0:
            #print("False")
            return
    print(x)
    exit()

while 1:
    trial_division(x)
    x+=1

Buggy submission (verdict: Runtime Error):
from sympy import nextprime
x = int(input())
if x==2:
	print(2)
elif x==3:
	print(3)
else:
	print(nextprime(x))

Buggy submission (verdict: Runtime Error):
from sympy import nextprime
x = int(input())
if x==2:
	print(int(2))
elif x==3:
	print(int(3))
else:
	print(nextprime(x))

Buggy submission (verdict: Runtime Error):
from sympy import nextprime
x = int(input())
if x==2:
	print(int(2))
elif x ==3:
	print(int(3))
else:
	print(int(nextprime(x)))
Problem p02859 (python)

Fixed submission:
r=int(input())
r=r*r
print(r)

Buggy submission (verdict: Runtime Error):
r=input()
print(r*r)
Problem p03265 (python)

Fixed submission:
import numpy as np

x_1, y_1, x_2, y_2 = map(int, input().split())

P_1 = np.array([x_1, y_1])
P_2 = np.array([x_2, y_2])
vec_12 = P_2 - P_1
vec_13 = np.array([-vec_12[1], vec_12[0]])
P_3 = P_1 + vec_13
P_4 = P_2 + vec_13
print(P_4[0], P_4[1], P_3[0], P_3[1])

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

x_1, y_1, x_2, y_2 = map(int, input().split())

P_1 = np.array([x_1, y_1])
P_2 = np.array([x_2, y_2])
vec_12 = P_2 - P_1
vec_13 = np.array([-vec_12[1], vec_12[0]])
P_3 = P_1 + vec_13
P_4 = P_2 + vec_13
print(P_3[0], P_3[1], P_4[1], P_4[2])
Problem p02831 (python)

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

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


def lcm(a, b):
	return a * b // gcd (a, b)


print(lcm(a,b))

Buggy submission (verdict: Runtime Error):
import math

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

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

print(lcm(a, b))
Problem p02912 (python)

Fixed submission:
import heapq as hq

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

#ヒープキューのために符号逆転
A=list(map(lambda x: x * (-1), A))
hq.heapify(A)

for i in range(M):
    a = hq.heappop(A) * (-1)
    hq.heappush(A, a // 2 * (-1))

print(sum(A) * (-1))

Buggy submission (verdict: Runtime Error):
import math

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

#B=list(map(lambda x: int(math.log2(x)), A))

#どこに何枚適用するか
D=[0 for _ in range(N)]

for i in range(M):
    A.index(max(A)) = A.index(max(A)) // 2

print(sum(A))
Problem p02792 (python)

Fixed submission:
N = int(input())

A = [list(0 for i in range(9)) for _ in range(9)]

for i in range(1,N+1):
    new = [int(d) for d in str(i)]
    if  new[-1]!=0:
        A[new[0]-1][new[-1]-1]+=1

cnt=0
for i in range(9):
    for j in range(9):
        cnt+=A[i][j]*A[j][i]

print(cnt)

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

cnt=0
for i in range(1,N+1):
    new = [int(d) for d in str(i)]
    print(new)
    sento=new[0]
    matu=new[-1]
    keta=len(new)

    if matu!='0':
        new[0]=matu
        new[-1]=sento
        comb=''.join(new)
        if matu==sento:
            cnt+=max(0,len(new)-1)
        elif comb>N:
            for j in range(0,keta-2):
                cnt+=9**j
        elif comb<N:
            for j in range(0,keta-1):
                cnt+=9**j







print(cnt)
Problem p03785 (python)

Fixed submission:
import sys
N, C, K = list(map(int, input().split()))
listT = [int(input()) for _ in range(N)]

listT.sort(reverse = True)

count=0
while listT != []:
    bus =[]
    time = listT[0]
    count += 1
    while len(bus) != C and time - K <= listT[0]:
        bus.append(listT.pop(0))
        if listT ==[]:
            break

print(count)

Buggy submission (verdict: Runtime Error):
import sys
N, C, K = list(map(int, input().split()))
listT = [int(input()) for _ in range(N)]

listT.sort()

def func(listT,bus):
    if len(listT)<2:
            print(bus+1)
            sys.exit()

    elif len(listT)>=2:
        for i in range(1,max(C,len(listT))):

            if listT[i]-listT[0]>K:
                bus += 1
                return func(listT[i:],bus)

        bus += 1

        if len(listT)<C:
            print(bus)
            sys.exit()


        return func(listT[C:],bus)

func(listT,0)
Problem p02951 (python)

Fixed submission:
a, b, c = map(int, input().split())
kotae = c - (a - b)
if kotae > 0:
  print(kotae)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input())
kotae = c - (a - b)
if kotae > 0:
  print(kotae)
else:
  print(0)
Problem p03045 (python)

Fixed submission:
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * (n)
        self.total = n
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    def unite(self, x, y):
        if self.same_check(x, y):
            return
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.total -= 1
        else:
            self.par[y] = x
            self.total -= 1
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
n,m = map(int, input().split())
union = UnionFind(n)
for i in range(m):
    x,y,z = map(int, input().split())
    union.unite(x-1, y-1)
print(union.total)

Buggy submission (verdict: Runtime Error):
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * (n)
        self.total = n
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def same_check(self, x, y):
        return self.find[x] == self.find[y]
    def unite(self, x, y):
        if self.same_check(x, y):
            return
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.total -= 1
        else:
            self.par[y] = x
            self.total -= 1
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
n,m = map(int, input().split())
union = UnionFind(n)
for i in range(m):
    x,y,z = map(int, input().split())
    union.unite(x-1, y-1)
print(union.total)
Problem p03012 (python)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
diff = []
for t in range(1,n):
    diff.append(abs(sum(l[:t])-sum(l[t:])))
print(min(diff))

Buggy submission (verdict: Runtime Error):
n = input()
l = list(map(int,input().split()))
diff = []
for t in range(1,n):
  diff.append(abs(sum(l[:t])-sum(l[t:]))))
print(min(diff))
Problem p03104 (python)

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

def f(x):
    i = 0
    res = 0 
    while (x>>i)>0:
        r = 1<<i
        if i == 0:
            if x%4 == 1 or x%4 == 2:
                res |= 1
            else:
                res |= 0
        else:
            d = x % (r<<1)
            if d >= r:
                res |= ((d-1)%2)<<i
        i += 1      
    return res

print(f(b)^f(a)^a)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
c=0
d=0
res=0
i=0
while a>0 or b>0:
  r=1<<i
  c<<=1
  d<<=1
  c |= a&1
  d |= b&1
  if c<r:
    if d>=r:
      res |= ((d-r+1)%2)<<i
    else:
      res |= 0
  else:
    if d<r:
      res |= ((r<<1-c)%2)<<i
    else:
      res |= (((d-c+1)%r)%2)<<i
  a>>=1
  b>>=1
  i+=1
  
print(res)
Problem p03137 (python)

Fixed submission:
n,m = map(int,input().split())
l = [int(x) for x in input().split()]

if(n>=m):
  print('0')
  exit(0)
l.sort()
 
gap = [l[i+1]-l[i] for i in range(m-1)]
 
gap.sort()

print(sum(gap[:m-n]))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
l = [int(x) for x in input().split()]

l.sort()

gap = [l[i]-l[i-1] for i in range(1,len(l))]

gap = gap.sort()

print(sum(gap[:-(m-1)]))
Problem p03252 (python)

Fixed submission:
str1 = input()
str2 = input()

n = len(str1)
d1 = dict()
d2 = dict()
for i in range(26):
    d1[chr(97+i)] = ''
    d2[chr(97+i)] = ''
res = "Yes"
for i in range(n):
    if d1[str1[i]] != '' and d1[str1[i]]!=str2[i]:
        res = "No"
        break
    if d2[str2[i]] != '' and d2[str2[i]]!=str1[i]:
        res = "No"
        break
    if d1[str1[i]] == '':
        d1[str1[i]] = str2[i]
    if d2[str2[i]] == '':
        d2[str2[i]] = str1[i]
print(res)

Buggy submission (verdict: Runtime Error):
str1 = list(input())
str2 = list(input())

n = len(str1)

str1 = ''.join(str1)
str2 = ''.join(str2) 
if (str1 == str2):
    print("No")
    exit(0)
for i in range(n):
    if str1[i]==str2[i]:
        continue
    for j in range(i+1,n):
        if str1[j]==str1[i]:
            tmp = str2[i]
            str2[i] = str1[j]
            str1[j] = tmp
            break
        elif str2[j] == str1[i]:
            tmp = str2[j]
            str2[j] = str1[i+1]
            str1[i+1] = str2[i]
            str2[i] = tmp
            break
str1 = ''.join(str1)
str2 = ''.join(str2) 

if(str1 == str2):
    print("Yes")
else:
    print("No")