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

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

N = int(raw_input())
A = map(int, raw_input().split())
B = [A[0]]
for ai in A[1:]:
    if B[-1] != ai:
        B.append(ai)
A = B[:]
N  = len(A)

ans = 1
i = 0
while i < N - 2:
    if A[i] <= A[i + 1] <= A[i + 2]:
        i += 1
    elif A[i] >= A[i + 1] >= A[i + 2]:
        i += 1
    else:
        ans += 1
        i += 2

print ans

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

N = int(raw_input())
A = map(int, raw_input().split())
B = [A[0]]
for ai in A[1:]:
    if B[-1] != ai:
        B.append(ai)
A = B[:]

ans = 1
i = 0
while i < N - 2:
    if A[i] <= A[i + 1] <= A[i + 2]:
        i += 1
    elif A[i] >= A[i + 1] >= A[i + 2]:
        i += 1
    else:
        ans += 1
        i += 2

print ans
Problem p03774 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N, M = map(int, raw_input().split())
ab = [map(int, raw_input().split()) for i in xrange(N)]
cd = [map(int, raw_input().split()) for i in xrange(M)]

for i, (a, b) in enumerate(ab):
    mn = 1e10
    p = -1
    for j, (c, d) in enumerate(cd, 1):
        tmp = abs(a - c) + abs(b - d)
        if tmp < mn:
            mn = tmp
            p = j
    print p

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N, M = map(int, raw_input().split())
ab = [map(int, raw_input().split()) for i in xrange(N)]
cd = [map(int, raw_input().split()) for i in xrange(N)]

for i, (a, b) in enumerate(ab):
    mn = 1e10
    p = -1
    for j, (c, d) in enumerate(cd, 1):
        tmp = abs(a - c) + abs(c - d)
        if tmp < mn:
            mn = tmp
            p = j
    print p
Problem p03075 (python)

Fixed submission:
a = int(input())
b = input()
c = input()
d = input()
e = int(input())
k = int(input())

if e - a <= k:
	print('Yay!')
else:
	print(':(')

Buggy submission (verdict: Runtime Error):
a = int(input())
b = input()
c = input()
d = input()
e = int(input())
k = int(input())

if e - a =< k:
	print('Yay!')
else:
	print(':(')
Problem p03295 (python)

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

paths = []

for i in range(M) :
    _a, _b = map(int, input().split())
    paths.append((_a, _b))

st = sorted(paths, key = lambda x : x[1])
cnt = 0
prev_b = -1

for i in st :
    if cnt == 0 :
        cnt += 1
        prev_b = i[1]
    else :
        if i[0] >= prev_b :
            cnt += 1
            prev_b = i[1]
    
print(cnt)

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

_a, _b = map(int, input().split())
dict_paths = {}
dict_paths[_a] = _b

for i in range(M - 1) :
    a, b = map(int, input().split())
    
    interleave_flg = False

    for k in dict_paths.keys() :
        k_tmp, k_val_tmp = k, dict_paths[k]
        
        # complete intersect
        if a >= k and b <= dict_paths[k] :
            dict_paths.pop(k)
            dict_paths[a] = b
            interleave_flg = True
            
        # nothing required
        elif a <= k and b >= dict_paths[k] :
            interleave_flg = True
            
        # left partial
        elif a < k and b > k and b <= dict_paths[k] :
            dict_paths.pop(k)
            dict_paths[a] = k_val_tmp
            interleave_flg = True
            
        # right partial
        elif a > k and a < dict_paths[k] and b >= dict_paths[k] :
            dict_paths.pop(k)
            dict_paths[k] = b
            interleave_flg = True
    
    if interleave_flg == False :
        dict_paths[a] = b
            
print(len(dict_paths))
Problem p03317 (python)

Fixed submission:
import math

N, K = map(int, input().split(" "))
a = map(int, input().split(" "))

# print(int((N - 1)/(K - 1)))

print(math.ceil((N - 1) / (K - 1)))

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

amin = min(a)

if len(myarr) == myarr.count(amin) :
    print("0")
else :
    if K == 1 : 
        print(N - myarr.count(amin))
    else :
        if (N - a.count(amin)) % (K - 1) == 0 :
            print((N - a.count(amin)) // (K - 1))
        else :
            print((N - a.count(amin)) // (K - 1) + 1)

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

amin = min(a)

if len(myarr) == myarr.count(amin) :
    print("0")
else :
    if K == 1 : 
        print(N - myarr.count(amin))
    else :
        if (N - a.count(amin)) % (K - 1) == 0 :
            print((N - a.count(amin)) // (K - 1))
        else :
            print((N - a.count(amin)) // (K - 1) + 1)
Problem p03805 (python)

Fixed submission:
from itertools import permutations

n, m = map(int, input().split())
paths = set()

for i in range(m) :
    _a, _b = map(int, input().split())
    paths.add((_a, _b))
    paths.add((_b, _a))
    
print(sum(all(s in paths for s in zip((1,) + p, p)) for p in permutations(range(2, n + 1))))

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

n, m = map(int, input().split())
paths = set()

for i in range(n) :
    _a, _b = map(int, input().split())
    # paths.add((_a, _b))
    # paths.add((_b, _a))
    
# print(sum(all(s in paths for s in zip((1,) + p, p)) for p in permutations(range(2, n + 1))))

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

n, m = map(int, input().split())
paths = set()

for i in range(n) :
    _a, _b = map(int, input().split())
    paths.add((_a, _b))
    paths.add((_b, _a))
    
# print(sum(all(s in paths for s in zip((1,) + p, p)) for p in permutations(range(2, n + 1))))

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

n, m = map(int, input().split())
paths = set()

for i in range(n) :
    _a, _b = map(int, input().split())
    paths.add((_a, _b))
    paths.add((_b, _a))
    
print(sum(all(s in paths for s in zip((1,) + p, p)) for p in permutations(range(2, n + 1))))

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

n, m = map(int, input().split())
# a, b = [], []
paths = set()

for i in range(n) :
    _a, _b = map(int, input().split())
    paths.add((_a, _b))
    paths.add((_b, _a))
    
print(sum(all((s, t) in paths for s, t in zip((1,) + p, p)) for p in permutations(range(2, n + 1))))

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

n, m = map(int, input().split())
a, b = [], []

for i in range(n) :
    _a, _b = map(int, input().split())
    a.append(_a)
    b.append(_b)

# create set
paths = set()
for i in range(m) :
    paths.add((a[i], b[i]))
    paths.add((b[i], a[i]))
    
print(sum(all((s, t) in paths for s, t in zip((1,) + p, p)) for p in permutations(range(2, n + 1))))
Problem p03107 (python)

Fixed submission:
S=input()
N=len(S)
c0=0;c1=0
for i in range(N):
  if "0"==S[i]:
    c0=c0+1
  elif "1"==S[i]:
    c1=c1+1
print(str(2*min(c0,c1)))

Buggy submission (verdict: Runtime Error):
S=print()
N=len(S)
c0=0;c1=0
for i in range(N):
  if "0"==S[i]:
    c0=c0+1
  elif "1"==S[i]:
    c1=c1+1
print(str(min(c0,c1)))
Problem p03127 (python)

Fixed submission:
import fractions
N=int(input())
As=input().split()
As=[int(a) for a in As]
count=As[0]
for i in As:
    count=fractions.gcd(count,i)
print(str(count))

Buggy submission (verdict: Runtime Error):
import fraction
N=int(input())
As=input().split()
As=[int(a) for a in As]
count=As[0]
for i in As:
    count=fraction.gcd(count,i)
print(str(count))

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
As=input().split()
As=[int(a) for a in As]
count=As[0]
for i in As:
    count=math.gcd(count,i)
print(str(count))

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
As=input().split()
As=[int(a) for a in As]
count=As[0]
for i in As:
    count=math.gcd(count,i)
print(str(count))
Problem p03135 (python)

Fixed submission:
all=input().split();T=int(all[0]);X=int(all[1]);print(str(round(T/X,10)))

Buggy submission (verdict: Runtime Error):
all=input().split()
T=all[0]
X=all[1]
round(T/X,10)
Problem p03307 (python)

Fixed submission:
N=input()
N=int(N)
if N%2==0:
    print(N)
else:
    print(N*2)

Buggy submission (verdict: Runtime Error):
N=input()
if N%2==0:
    print(N)
else:
    print(N*2)

Buggy submission (verdict: Runtime Error):
a=input()
a=int(a)
if a%2==0:
    print(a)
else
    print(a*2)

Buggy submission (verdict: Runtime Error):
a=input()
if a%2==0:
    print(a)
else
    print(a*2)

Buggy submission (verdict: Runtime Error):
a=input()
a=int(a)
d=a
if a<2:
    b=a
    a=2
else
    b=2
c=1
while c!=0:
    c=a%b
    a=b
    b=c
print(d*2/b)
#a=2,b=1,c=1,d=1

Buggy submission (verdict: Runtime Error):
a=input()
a=int(a)
d=a
if a<2:
    b=a
    a=2
else
    b=2
while c!=0:
    c=a%b
    a=b
    b=c
print(d*2/b)

Buggy submission (verdict: Runtime Error):
a=input()
a=int(a)
d=a
if a<2:
    b=a
    a=2
while c!=0:
    c=a%b
    a=b
    b=c
print(d*2/b)

Buggy submission (verdict: Runtime Error):
a=input()
d=a
if a>2:
else 
    b=a
    a=2
while c!=0:
    c=a%b
    a=b
    b=c
print(d*2/b)

Buggy submission (verdict: Runtime Error):
a=input()
if a>2:
else 
    b=a
    a=2
while c!=0:
    c=a%b
    a=b
    b=c
print(b)
Problem p03075 (python)

Fixed submission:
a=int(input())
b=input()
c=input()
d=input()
e=int(input())
k=int(input())
if e-a>k:
    print(":(")
else:
    print("Yay!")

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
c=input()
d=input()
e=input()
k=input()
if e-a>k:
    print(":(")
else:
    print("Yay!")
Problem p03107 (python)

Fixed submission:
s = input()
count_0 = s.count('0')
count_1 = s.count('1')
print(2*min(count_0,count_1))

Buggy submission (verdict: Runtime Error):
S = list(input())
S_len = len(S)


def dfs(S):
    slen = len(S)
    for i in range(slen -1 ):
        if S[i] != S[i+1]:
            del S[i+1:i+2]
            dfs(S)
            break;
    End_len = len(S)
    ans = S_len - End_len
    return ans

if __name__ == '__main__':
    print(dfs(S))

Buggy submission (verdict: Runtime Error):
S = list(input())
S_len = len(S)

def dfs(S):
    slen = len(S)
    for i in range(slen -1 ):
        if S[i] != S[i+1]:
            del S[i:i+2]
            dfs(S)
            break;
    End_len = len(S)
    ans = S_len - End_len
    return ans

if __name__ == '__main__':
    print(dfs(S))

Buggy submission (verdict: Runtime Error):
S = list(input())
S_len = len(S)

for i in range(S_len-1):
    S[i+1]
def dfs(S):
    slen = len(S)
    for i in range(slen -1 ):
        if S[i] != S[i+1]:
            del S[i:i+2]
            dfs(S)
            break;
    End_len = len(S)
    ans = S_len - End_len
    return ans

if __name__ == '__main__':
    print(dfs(S))
Problem p03072 (python)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
 
count = 0
for i, h in enumerate(H):
    if i == 0:
        count += 1
    elif i == 1:
        count += 1 if  H[1] >= H[0] else 0
    else:
        count += 1 if h >= max(H[:i]) else 0
print(count)

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

first = H[0]
for i, h in enumerate(H[1:]):
    if first > h:
        break
    first = h
print(i+1)
Problem p03104 (python)

Fixed submission:
A, B = map(int, input().split())
if A % 2 == 0:
    num = B - A
    result = 0
else:
    num = (B - (A + 1))
    result = A
if num // 2 % 2 == 0:
    result ^= 0
else:
    result ^= 1
if num % 2 == 1:
    result ^= (B-1)
result ^= B
print(result)

Buggy submission (verdict: Runtime Error):
import numpy as np
bins = np.array([list(map(int, list('{number:0>40}'.format(number=bin(i)[2:])))) for i in range(A, B+1)]).T
bins = np.sum(bins, axis=1) % 2
result = 0
for d, i in enumerate(bins[::-1]):
    if i == 1:
        result += 2 ** d
print(result)

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
digit_A = math.ceil(math.log2(A))
digit_B = math.ceil(math.log2(A))
result = A
for i in range(A+1, 2 ** digit_A):
    result = result ^ i
for i in range(2 ** (digit_B-1), B + 1):
    result = result ^ i
print(result)
Problem p03221 (python)

Fixed submission:
# ABC113 C
N, M = map(int, input().split())
cities = [list(map(int, input().split())) for _ in range(M)]

cities = [[i, city[0], city[1]] for i, city in enumerate(cities)]
city_count = [0]*(N+1)
cities.sort(key=lambda x: x[2])
ids = []
for city in cities:
    city_count[city[1]] += 1
    ids.append([city[0], '{:0>6}{:0>6}'.format(city[1], city_count[city[1]])])
ids.sort(key=lambda x: x[0])
for city in ids:
    print(city[1])

Buggy submission (verdict: Runtime Error):
# ABC113 C
N, M = map(int, input().split())
cities = [list(map(int, input().split())) for _ in range(M)]

cities = [[i, city[0], city[1]] for i, city in enumerate(cities)]
city_count = [0]*(M+1)
cities.sort(key=lambda x: x[2])
ids = []
for city in cities:
    city_count[city[1]] += 1
    ids.append([city[0], '{:0>6}{:0>6}'.format(city[1], city_count[city[1]])])
ids.sort(key=lambda x: x[0])
for city in ids:
    print(city[1])

Buggy submission (verdict: Runtime Error):
# ABC113 C
N, M = map(int, input().split())
cities = [list(map(int, input().split())) for _ in range(M)]

cities = [[city[0], city[1], i] for i, city in enumerate(cities)]
city_count = [0]*(M+1)
cities.sort(key=lambda x: x[1])
ids = []
for city in cities:
    city_count[city[0]] += 1
    ids.append(['{:0>6}{:0>6}'.format(city[0], city_count[city[0]]), city[2]])
ids.sort(key=lambda x: x[1])
for city in ids:
    print(city[0])

Buggy submission (verdict: Runtime Error):
# ABC113 C
N, M = map(int, input().split())
cities = [list(map(int, input().split())) for _ in range(M)]

cities = [[*city, i] for i, city in enumerate(cities)]
city_count = [0]*(M+1)
cities.sort(key=lambda x: x[1])
ids = []
for city in cities:
    city_count[city[0]] += 1
    ids.append(['{:0>6}{:0>6}'.format(city[0], city_count[city[0]]), city[2]])
ids.sort(key=lambda x: x[1])
for city in ids:
    print(city[0])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
cities = [list(map(int, input().split())) for _ in range(M)]

cities = [[*city, i] for i, city in enumerate(cities)]
city_count = [0]*(N+1)
cities.sort(key=lambda x: x[1])
ids = []
for city in cities:
    city_count[city[0]] += 1
    ids.append(['{:0>6}{:0>6}'.format(city[0], city_count[city[0]]), city[2]])
ids.sort(key=lambda x: x[1])
for city in ids:
    print(city[0])
Problem p03107 (python)

Fixed submission:

s = input()

n = len(s)

cnt0 = s.count('0')
cnt1 = s.count('1')

print(min(cnt0, cnt1)*2)

Buggy submission (verdict: Runtime Error):
# a, b, k = map(int, input().split())
s = input()

n = len(s)


def rep(str):
    ret = str.replace('01', '')
    ret = ret.replace('10', '')

    if ret != str:
        ret = rep(ret)

    return ret


input_str = s
# ret = None
#
# while ret is None or input_str != ret:
#     ret = input_str
#     input_str = rep(input_str)

ret = rep(s)

print(n - len(ret))
Problem p03075 (python)

Fixed submission:
import itertools
l = [int(input()) for i in range(5)]
k = int(input())
for i in itertools.combinations(l, 2):
  if i[1] - i[0] > k:
    print(':(')
    exit()
print('Yay!')

Buggy submission (verdict: Runtime Error):
import itertools
x, y, z, k = map(int, input().split())
al = list(map(int,input().split()))
bl = list(map(int,input().split()))
cl = list(map(int,input().split()))
sum_list = [sum(i) for i in itertools.product(al, bl, cl)]
sum_list.sort(reverse=True)
for i in sum_list[:k]:
  print(i)

Buggy submission (verdict: Runtime Error):
l = [int(input()) for i in range(5)]
k = int(input())
for i in itertools.combinations(l, 2):
  if i[1] - i[0] > k:
    print(':(')
    exit()
print('Yay!')
Problem p03135 (python)

Fixed submission:
T, X = map(int, input().split())

print(T / X)

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

N, K = [int(a) for a in input().split()]
A = [int(a) for a in input().split()]

K_str = format(K, 'b')
max_order = len(K_str)

B = np.array([list(format(a, '0{}b'.format(max_order)))
              for a in A]
             ).astype('i')[:, :max_order]
B = B.sum(axis=0)
B = np.where(B < N/2, 1, 0)

X_str = ''.join(map(str, B))
X = int(X_str, 2)

print(sum(map(lambda a: X ^ a, A)))
Problem p03221 (python)

Fixed submission:
from collections import defaultdict

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

city = []

for i in range(M):
    P, Y = map(int, input().split())
    city.append([i, P, Y])
city.sort(key=lambda x: x[2])

count = defaultdict(lambda: 0)
for c in city:
    count[c[1]] += 1
    c.append(count[c[1]])
city.sort(key=lambda x: x[0])

for _, P, _, n in city:
    print(format(P, '06') + format(n, '06'))

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

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

city = []

for i in range(M):
    P, Y = map(int, input().split())
    city.append([i, P, Y])
city.sort(key=lambda x: x[2])

count = defaultdict(lambda: 0)
for c in city:
    count[c[P]] += 1
    c.append(count[c[P]])
city.sort(key=lambda x: x[0])

for _, P, _, n in city:
    print(format(P, '06') + format(n, '06'))
Problem p03207 (python)

Fixed submission:
N=int(input())
p=[int(input()) for i in range(N)]
print(sum(p)-max(p)//2)

Buggy submission (verdict: Runtime Error):
N=int(input())
p=list(map(int,intput().split()))
sum=0
print(sum(p)-max(p)//2)

Buggy submission (verdict: Runtime Error):
N=int(input())
p=list(map(int,intput().split()))
sum=0
for i in range(N):
    sum+=p[i]
print(sum-(max(p)//2))
Problem p03242 (python)

Fixed submission:
n=input()
n=n.replace("1","X")
n=n.replace("9","1")
n=n.replace("X","9")
n=int(n)
print(n)

Buggy submission (verdict: Runtime Error):
s=input()
n=n.replace("1","X")
n=n.replace("9","1")
n=n.replace("X","9")
n=int(n)
print(n)
Problem p03265 (python)

Fixed submission:
x_1, y_1, x_2, y_2 = map(int, input().split())
x_3 = x_2 - y_2 + y_1
y_3 = y_2 + x_2 - x_1
x_4 = x_3 - x_2 + x_1
y_4 = y_3 - y_2 + y_1
print(x_3, y_3, x_4, y_4)

Buggy submission (verdict: Runtime Error):
x_1,y_1,x_2,y_2=map(int,input().split())
x_3=-(y_2-y_1)+x_1
y_3=(x_1-x_2)+y_1
x_4=(x_3-x_1)+(x_2-x_1)+x_1
y_4=(y_3-y_1)+(y_2-y_1)+y_1
print(x_3 y_3 x_4 y_4)
Problem p03327 (python)

Fixed submission:
N=int(input())
if N<1000:
    print("ABC")
else :
    print("ABD")

Buggy submission (verdict: Runtime Error):
N=int(intput())
if N<1000:
    print("ABC")
else :
    print("ABD")
Problem p03137 (python)

Fixed submission:
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
l = [x[i+1]-x[i] for i in range(m-1)]
l.sort(reverse=True)
print(sum(l[n-1:]))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = list(set(map(int, input().split())))
l = [x[i+1]-x[i] for i in range(n-1)]
l.sort(reverse=True)
print(sum(l[n-1:]))
Problem p03135 (python)

Fixed submission:
T, X = map(int, input().split())
print(float(T) / float(X))

Buggy submission (verdict: Runtime Error):
def napsach(N, W, v, w):
    if N == 0 or K == 0:
        return 0
    V = []
    for i in range(N):
        V.append([0] * W)

    for i in range(N):
        for j in range(W):
            if i == 0:
                if j + 1 >= w[i]:
                    V[i][j] = v[i]
            else:
                if j + 1 >= w[i]:
                    V[i][j] = max(V[i - 1][j], V[i - 1][j + 1 - w[i]] + v[i])
                else:
                    V[i][j] = V[i - 1][j]
    return V[-1][-1]

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

A_max = max(A)
max_val = max(A_max, K)

i = 0
tot_val = 0
w = []
v = []

while (1 << i) <= max_val:
    temp_w = 0
    for j in range(N):
        temp_w += (A[j] >> i) & 1
    temp_w = N - temp_w
    tot_val += (1 << i) * (N - temp_w)
    if temp_w * 2 > N:
        w.append(1 << i)
        v.append((1 << i) * (2 * temp_w - N))
    i += 1
print(tot_val + napsach(len(v), K, v, w))
Problem p03327 (python)

Fixed submission:
N = input()
num = int(N)
if num < 1000:
    print('ABC')
else:
    print('ABD')

Buggy submission (verdict: Runtime Error):
N=input()
num=int(N[3:])

if num>999:
    print("ABD")
else:
    print("ABC")
Problem p03242 (python)

Fixed submission:
N=input()

str_output=""

for i in range(3):
    if(N[i]=="1"):
        str_output+="9"
    elif(N[i]=="9"):
        str_output+="1"
        
print(int(str_output))

Buggy submission (verdict: Runtime Error):
for i in range(9):
    if(N>L[i] and N<=L[i+1]):
        print(L[i+1])
        break
    elif(N==L[i]):
        print(L[i])
        break
    elif(N<111):
        print(111)
        break
    else:
        continue
Problem p03137 (python)

Fixed submission:
n,m = map(int,input().split())
x = list(map(int, input().split()))
x_new = sorted(x)
intervals = [0]*(m-1)
for i in range(m-1):
  intervals[i] = abs(x_new[i+1] - x_new[i])
c = sorted(intervals, reverse=True)
s = 0
if n < m:
    for j in range(n-1):
        s += c[j]
    min = sum(intervals) - s
    print(min)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
x = list(map(int, input().split()))
x_new = sorted(x)
intervals = [0]*(m-1)
for i in range(m-1):
  intervals[i] = abs(x_new[i+1] - x_new[i])
c = sorted(intervals, reverse=True)
s = 0
for j in range(n-1):
  s += c[j]
 
min = sum(intervals) - s
print(min)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
x = list(map(int, input().split()))
x_new = sorted(x)
intervals = [0]*(m-1)
for i in range(m-1):
  intervals[i] = x[i+1] - x[i]
c = sorted(intervals, reverse=True)
s = 0
for j in range(n-1):
  s += c[j]

min = sum(intervals) - s
print(s)
Problem p03073 (python)

Fixed submission:
tile = input()

cor_list = ["10"*50000, "01"*50000]

diff_1 = int("0b"+tile, 2) ^ int("0b"+cor_list[0][:len(tile)], 2)  
diff_2 = int("0b"+tile, 2) ^ int("0b"+cor_list[1][:len(tile)], 2)

score = [0, 0]
score[0] = sum([int(s) for s in bin(diff_1)[2:]])
score[1] = sum([int(s) for s in bin(diff_2)[2:]])

print(min(score))

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

tile = input()

cor_list = ["10"*50000, "01"*50000]

diff_1 = int("0b"+tile, 2) ^ int("0b"+cor_list[0][:len(tile)], 2)  
diff_2 = int("0b"+tile, 2) ^ int("0b"+cor_list[1][:len(tile)], 2)

score_1 = sum([int(s) for s in bin(diff_1)[2:]])
score_2 = sum([int(s) for s in bin(diff_2)[2:]])
print(min[score_1, score_2])
Problem p03127 (python)

Fixed submission:
#gcdか....
def fgcd(a,b):
    while b:
        a,b = b,a%b
    return a

N = int(input())
aA = sorted(set(int(_) for _ in input().split()))
b = aA[0]
for a in aA[1:]:
    b = fgcd(a,b)
print(b)

Buggy submission (verdict: Runtime Error):
N = int(input())
aA=list(set(int(_) for _ in input().split()))
def ggg(i,j):
    if i < j :
        i,j = j,i
    i %= j
    if i == 0:
        return j
    else:
        return ggg(j,i)

if len(aA) == 1:
    print(aA[0])
else:
    iMin = min(aA)
    iMax = max(aA)
    if iMin  == 1:
        print(1)
    else:
        iDm = [i % iMin for i in aA]
        if max(iDm) == 0:
            print(iMin)
            exit()
        else:
            iM = iMax
            for i in range(N):
                iA = aA[i]
                for j in range(i+1,N):
                    iMt = ggg(iA,aA[j])
                    if 0 < iMt and iMt < iM:
                        iM = iMt
                    if iM == 1:
                        print(1)
                        exit()
            print(iM)
Problem p03242 (python)

Fixed submission:
print(input().rstrip().replace("1","a").replace("9","1").replace("a","9"))

Buggy submission (verdict: Runtime Error):
rint(input().rstrip().replace("1","a").replace("9","1").replace("a","9"))
Problem p03075 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if (e - a) <= k:
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
input_a = ()
input_b = ()
input_c = ()
input_d = ()
input_e = ()
input_k = ()
if (input_a - input_e) < input_k:
  print("Yay!")
else:
  print(":(")