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

Fixed submission:
import numpy as np

def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)

def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g
n,x = map(int,input().split())
arr = list(map(int,input().split()))
arr = np.array(arr)
arr -= x
arr = np.abs(arr)
# print(arr)

if len(arr) == 1:
    print(arr[0])
else:
    print(gcd(arr))

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

def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)

def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g
n,x = map(int,input().split())
arr = list(map(int,input().split()))
arr = np.array(arr)
arr -= x
arr = np.abs(arr)
# print(arr)

if len(arr) == 0:
    print(arr[0])
else:
    print(gcd(arr))

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

def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)

def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g
n,x = map(int,input().split())
arr = list(map(int,input().split()))
arr = np.array(arr)
arr -= x
arr = np.abs(arr)
# print(arr)

print(gcd(arr))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,x = map(int,input().split())
arr = list(map(int,input().split()))
arr = np.array(arr)
arr -= x
arr = np.abs(arr)
# print(arr)

print(np.gcd.reduce(arr))

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
n,x = map(int,input().split())
arr = list(map(int,input().split()))
arr = np.array(arr)
arr -= x
arr = np.abs(arr)
# print(arr)

print(np.gcd.reduce(arr))

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
n,x = map(int,input().split())
arr = list(map(int,input().split()))
arr = np.array(arr)
arr -= x
arr = np.abs(arr)
# print(arr)

ans = arr[0]
for i in range(1,n):
    ans = math.gcd(ans,arr[i])
print(ans)
Problem p03282 (python)

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

num1 = 0

for c in s:
    if c == "1":
        num1 += 1
    else:
        break

if num1 == len(s):
    nex = s[num1-1]
else:
    nex = s[num1]
if k <= num1:
    print(1)
else:
    print(nex)

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

num1 = 0

for c in s:
    if c == "1":
        num1 += 1
    else:
        break

nex = s[num1]

if k <= num1:
    print(1)
else:
    print(nex)
Problem p03284 (python)

Fixed submission:
m,k = map(int,input().split())
if m%k==0:
  print(0)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
print(list(map(int,input().split()))[0]%list(map(int,input().split()))[1])

Buggy submission (verdict: Runtime Error):
print(int(list(input.split())[0]) %int(list(input.split())[1]))
Problem p03353 (python)

Fixed submission:
s = input()
k = int(input())
n = len(s)
heads = []
d = set()
for c in s:
    d.add(c)

for key in d:
    heads.append(key)

heads.sort()
ind = 0
ans = []
while True:
    if ind > len(heads)-1:
        break
    head = heads[ind]
    p = set()
    for i in range(len(s)):
        if s[i] == head:
            p.add(i)
    # print(head)
    ext = 0
    while True:
        flag = False
        dis = -1
        for key in p:
            if key+ext > n-1:
                flag = True
                dis = key
        if flag:
            p.discard(dis)
            # print(ext)
            # print(p)
        if not p:
            break
        for key in p:
            temp = s[key]
            for j in range(1,ext+1):
                temp += s[key+j]
            # print(temp)
            if temp not in ans:
                ans.append(temp)
        ext += 1
        if ext > 5:
            break
        if len(ans) >= 500:
            break
    if len(ans) >= 500:
        break
    else:
        ind += 1

# print(ans)
ans.sort()
print(ans[k-1])

# for i in range(len(s)):
#     if

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
n = len(s)
heads = []
d = set()
for c in s:
    d.add(c)

for key in d:
    heads.append(key)

heads.sort()
ind = 0
ans = []
while True:
    if ind > len(heads)-1:
        break
    head = heads[ind]
    p = set()
    for i in range(len(s)):
        if s[i] == head:
            p.add(i)
    # print(head)
    ext = 0
    while True:
        flag = False
        dis = -1
        for key in p:
            if key+ext > n-1:
                flag = True
                dis = key
        if flag:
            p.discard(dis)
        if not p:
            break
        for key in p:
            temp = s[key]
            for j in range(1,ext):
                temp += s[key+j]
            if temp not in ans:
                ans.append(temp)
        ext += 1
        if len(ans) >= 500:
            break
    if len(ans) >= 500:
        break
    else:
        ind += 1
# print(ans)
ans.sort()
print(ans[k-1])

# for i in range(len(s)):
#     if
Problem p03359 (python)

Fixed submission:
import numpy as np
a,b = map(int,input().split())
ans = 0
for i in range(1,13):
    if i < a:
        ans += 1
    elif i == a:
        if i <= b:
            ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
a,b = map(int,input().split())

ans = 0
for i in range(1,13):
    if i <= a and i <= b:
        ans += 1

print(ans)
Problem p03364 (python)

Fixed submission:
n = int(input())
arr = []
for i in range(n):
    a = list(map(ord,list(input())))
    arr.append(a)


ans = 0

for i in range(n):
    ok = True
    for j in range(n):
        for k in range(n):
            if j == k:
                continue
            l = j + i
            if l > n-1:
                l = l-n

            m = k + i
            if m > n-1:
                m = m-n
            # print(l,k,i)
            # print(arr[l][k],arr[k][l])
            if arr[l][k] != arr[m][j]:
                ok = False
                break

    # print("####")
    if ok:
        ans += n



print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
arr = []
for i in range(n):
    a = list(map(ord,list(input())))
    arr.append(a)

import numpy as np
# print(np.array(arr))

ans = 0

for i in range(n):
    ok = True
    for j in range(n):
        for k in range(n):
            if j == k:
                continue
            l = j + i
            if l > n-1:
                l = l-n
            m = k + i
            if m > n-1:
                m = m-n
            # print(l,k,i)
            # print(arr[l][k],arr[k][l])
            if arr[l][k] != arr[m][j]:
                ok = False
                break

    # print("####")
    if ok:
        ans += n



print(ans)
Problem p03409 (python)

Fixed submission:
import numpy as np

n = int(input())
r = []
b = []

for i in range(n):
    x,y = map(int,input().split())
    r.append([x,y])

for i in range(n):
    x,y = map(int,input().split())
    b.append([x,y])



r.sort(key=lambda x:[x[0],x[1]])
b.sort(key=lambda x:[x[1],x[0]])


ans = 0
for i in range(n):
    x,y = b[i][0],b[i][1]
    tar = 0
    flag = False
    # print(r)
    # print(b)
    for j in range(len(r)):
        if r[j][0] < x and r[j][1] < y:
            flag = True
            tar = j
    if flag:
        ans += 1
        r.pop(tar)

print(ans)

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

n = int(input())
r = []
b = []

for i in range(n):
    x,y = map(int,input().split())
    r.append([x,y])

for i in range(n):
    x,y = map(int,input().split())
    b.append([x,y])



r.sort(key=lambda x:[x[0],-x[1]])
b.sort(key=lambda x:[x[0],-x[1]])

r2 = r.copy()
b2 = b.copy()

r2.sort(key=lambda x:[x[1],-x[0]])
b2.sort(key=lambda x:[x[1],-x[0]])
# print(r)
# print(b)

ans = 0
for i in range(n):
    x,y = b[i][0],b[i][1]
    # print(x,y)
    tar = 0
    flag = False
    for j in range(len(r)):
        if r[j][0] < x and r[j][1] < y:
            flag = True
            tar = j
    if flag:
        ans += 1
        r.pop(tar)


ans2 = 0

for i in range(n):
    x,y = b2[i][0],b2[i][1]
    # print(x,y)
    tar = 0
    flag = False
    for j in range(len(r)):
        if r2[j][0] < x and r2[j][1] < y:
            flag = True
            tar = j
    if flag:
        ans2 += 1
        r2.pop(tar)

print(max(ans,ans2))

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

n = int(input())
r = []
b = []

for i in range(n):
    x,y = map(int,input().split())
    r.append([x,y])

for i in range(n):
    x,y = map(int,input().split())
    b.append([x,y])



r.sort(key=lambda x:[x[0],x[1]])
b.sort(key=lambda x:[x[0],x[1]])

r2 = r.copy()
b2 = b.copy()

r2.sort(key=lambda x:[x[1],x[0]])
b2.sort(key=lambda x:[x[1],x[0]])
# print(r)
# print(b)

ans = 0
for i in range(n):
    x,y = b[i][0],b[i][1]
    # print(x,y)
    tar = 0
    flag = False
    for j in range(len(r)):
        if r[j][0] < x and r[j][1] < y:
            flag = True
            tar = j
    if flag:
        ans += 1
        r.pop(tar)


ans2 = 0

for i in range(n):
    x,y = b2[i][0],b2[i][1]
    # print(x,y)
    tar = 0
    flag = False
    for j in range(len(r)):
        if r2[j][0] < x and r2[j][1] < y:
            flag = True
            tar = j
    if flag:
        ans2 += 1
        r2.pop(tar)

print(max(ans,ans2))
Problem p03543 (python)

Fixed submission:
ct = input()


if ct[1] == ct[2] and (ct[0]==ct[1] or ct[2]==ct[3]):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = input()
ct = {}

if ct[1] == ct[2] and (ct[0]==ct[1] or ct[2]==ct[3]):
  print("Yes")
else:
  print("No")
Problem p03547 (python)

Fixed submission:
x,y = input().split()

if x < y:
  print("<")
elif x > y:
  print(">")
else:
  print("=")

Buggy submission (verdict: Runtime Error):
x,y = input()

if x < y:
  print("<")
elif x > y:
  print(">")
else:
  print("=")
Problem p03569 (python)

Fixed submission:
import numpy as np
s = input()
temp = s
temp = temp.replace("x","")
is_rev = True

mirro = []

if len(temp) == 0:
    print(0)
else:
    for i in range(len(temp)//2):
        if temp[i] == temp[-i-1]:
            mirro.append(temp[i])
            continue
        else:
            is_rev = False
    if len(temp) %2 == 1:
        mirro.append(temp[len(temp)//2])

    if is_rev:
        ind = 0
        i = 0
        lx = np.array([0 for i in range(len(temp)//2+len(temp)%2)])
        rx = np.array([0 for i in range(len(temp)//2+len(temp)%2)])
        temp = 0
        while (True):
            if s[i] == mirro[ind]:
                lx[ind] = temp
                temp = 0
                ind += 1
                i += 1
            else:
                temp += 1
                i += 1

            if ind > len(mirro)-1:
                break
        ind = 0
        i = -1
        temp = 0
        while (True):
            if s[i] == mirro[ind]:
                rx[ind] = temp
                temp = 0
                ind += 1
                i -= 1
            else:
                temp += 1
                i -= 1

            if ind > len(mirro)-1:
                break
        # print(lx)
        # print(rx)
        print(np.sum(np.abs(lx-rx)))
    else:
        print(-1)

Buggy submission (verdict: Runtime Error):
import numpy as np
s = input()
temp = s
temp = temp.replace("x","")
is_rev = True

mirro = []
for i in range(len(temp)//2):
    if temp[i] == temp[-i-1]:
        mirro.append(temp[i])
        continue
    else:
        is_rev = False
if len(temp) %2 == 1:
    mirro.append(temp[len(temp)//2])

if is_rev:
    ind = 0
    i = 0
    lx = np.array([0 for i in range(len(temp)//2+len(temp)%2)])
    rx = np.array([0 for i in range(len(temp)//2+len(temp)%2)])
    temp = 0
    while (True):
        if s[i] == mirro[ind]:
            lx[ind] = temp
            temp = 0
            ind += 1
            i += 1
        else:
            temp += 1
            i += 1

        if ind > len(mirro)-1:
            break
    ind = 0
    i = -1
    temp = 0
    while (True):
        if s[i] == mirro[ind]:
            rx[ind] = temp
            temp = 0
            ind += 1
            i -= 1
        else:
            temp += 1
            i -= 1

        if ind > len(mirro)-1:
            break
    # print(lx)
    # print(rx)
    print(np.sum(np.abs(lx-rx)))
else:
    print(-1)
Problem p03633 (python)

Fixed submission:
n = int(input())
s = int(input())
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)
for i in range(1,n):
    t = int(input())
    s = (s*t)//gcd_core(s,t)

print(s)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
s = int(input())
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)
for i in range(1,n):
    t = int(input())
    s = (s*t)//math.gcd_core(s,t)

print(s)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
s = int(input())
for i in range(1,n):
    t = int(input())
    s = (s*t)//math.gcd(s,t)

print(s)
Problem p03645 (python)

Fixed submission:
n,m = map(int,input().split())
path = {}
for i in range(m):
    a,b = map(int,input().split())
    if a not in path:
        path[a] = [b]
    else:
        path[a].append(b)

ns = []
if 1 in path:
    for p in path[1]:
        ns.append(p)

    flag = False
    for mid in ns:
        if mid in path:
            if n in path[mid]:
                flag = True
                break

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

else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
path = {}
for i in range(m):
    a,b = map(int,input().split())
    if a not in path:
        path[a] = [b]
    else:
        path[a].append(b)

ns = []
if 1 in path:
    for p in path[1]:
        ns.append(p)

    flag = False
    for mid in ns:
        if n in path[mid]:
            flag = True
            break

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

else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
path = {}
for i in range(m):
    a,b = map(int,input().split())
    if a not in path:
        path[a] = [b]
    else:
        path[a].append(b)

ns = []
for p in path[1]:
    ns.append(p)

flag = False
for mid in ns:
    if n in path[mid]:
        flag = True
        break

if flag:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Problem p03815 (python)

Fixed submission:
x = int(input())

y = int(x/11)

z = x-11*y

if z == 0:
    print(2*y)
elif z <= 6:
    print(2*y+1)
else:
    print(2*y+2)

Buggy submission (verdict: Runtime Error):
x = int(iuput())

y = int(x/11)
if x-y*11 < 7:
  print(2*y+1):
else:
  print(2*(y+2))
Problem p04045 (python)

Fixed submission:

input_array = list(map(int,input().split()))
N = input_array[0]
input_array = list(map(int,input().split()))

num = [1,1,1,1,1,1,1,1,1,1]
ok = []
out = []

for l in range(len(input_array)):
    num[input_array[l]] = 0

for i in range(len(num)):
    if num[i] == 0:
        ok.append(i)

while True:
    key = 0
    for n in list(str(N)):
        if int (n) in ok:
            key += 1
    if key == 0:
        print(N)
        break
    else:
        N+=1

Buggy submission (verdict: Runtime Error):

input_array = list(map(int,input().split()))
N = input_array[0]
input_array = list(map(int,input().split()))

num = [1,1,1,1,1,1,1,1,1,1]
ok = []
out = []

for l in range(len(input_array)):
    num[input_array[l]] = 0

for i in range(len(num)):
    if num[i] == 1:
        ok.append(i)

N = list(str(N))

for n in N:
    for m in ok:
        if m >= int(n):
            out.append(m)
            break

for i in range(len(out)-1):
    print(out[i],end="")

print(out[-1])
Problem p02609 (python)

Fixed submission:
from functools import lru_cache

N = int(input())
X = input()


@lru_cache(maxsize=None)
def popcount(x):
    return x % bin(x).count('1')


def f(x):
    cnt = 1
    while x > 0:
        x = popcount(x)
        cnt += 1

    return cnt


count = X.count('1')
mod_one = count - 1
if mod_one == 0:
    mod_one = 1
mod_zero = count + 1
ones = [1 % mod_one]
zeros = [1 % mod_zero]
x_mod_one = 0 if X[-1] == '0' else 1 % mod_one
x_mod_zero = 0 if X[-1] == '0' else 1 % mod_zero

for xi in reversed(X[:-1]):
    ones.append(ones[-1] * 2 % mod_one)
    zeros.append(zeros[-1] * 2 % mod_zero)
    if xi == '1':
        x_mod_one += ones[-1]
        x_mod_one %= mod_one
        x_mod_zero += zeros[-1]
        x_mod_zero %= mod_zero

ones = list(reversed(ones))
zeros = list(reversed(zeros))

for i in range(N):
    if count == 1 and X[i] == '1':
        print(0)
    elif X[i] == '1':
        x = (x_mod_one - ones[i]) % mod_one
        print(f(x))
    else:
        x = (x_mod_zero + zeros[i]) % mod_zero
        print(f(x))

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

N = int(input())
X = input()


@lru_cache(maxsize=None)
def popcount(x):
    return x % bin(x).count('1')


def f(x):
    cnt = 1
    while x > 0:
        x = popcount(x)
        cnt += 1

    return cnt


count = X.count('1')
mod_one = count - 1
mod_zero = count + 1
ones = [1 % mod_one]
zeros = [1 % mod_zero]
x_mod_one = 0 if X[-1] == '0' else 1 % mod_one
x_mod_zero = 0 if X[-1] == '0' else 1 % mod_zero

for xi in reversed(X[:-1]):
    ones.append(ones[-1] * 2 % mod_one)
    zeros.append(zeros[-1] * 2 % mod_zero)
    if xi == '1':
        x_mod_one += ones[-1]
        x_mod_one %= mod_one
        x_mod_zero += zeros[-1]
        x_mod_zero %= mod_zero

ones = list(reversed(ones))
zeros = list(reversed(zeros))

for i in range(N):
    if count == 1 and X[i] == '1':
        print(0)
    elif X[i] == '1':
        x = (x_mod_one - ones[i]) % mod_one
        print(f(x))
    else:
        x = (x_mod_zero + zeros[i]) % mod_zero
        print(f(x))
Problem p02705 (python)

Fixed submission:
import math

R = int(input())

print(R * 2 * math.pi)

Buggy submission (verdict: Runtime Error):
import math

R = int(input())

print(R * 2 * math.PI)
Problem p02866 (python)

Fixed submission:
import collections


def mod_pow(a, n, mod):
    result = 1
    a_n = a
    while n > 0:
        if n & 1:
            result = result * a_n % mod
        a_n = a_n * a_n % mod
        n >>= 1
    return result


def main(n, d):
    MOD = 998244353
    counter = collections.Counter(d)
    if counter[0] != 1 or d[0] != 0:
        return 0
    pows = [mod_pow(a=counter[i - 1], n=counter[i], mod=MOD) for i in
            range(1, max(counter.keys()) + 1)]
    patterns = 1
    for p in pows:
        patterns *= p
        patterns %= MOD
    return patterns


if __name__ == '__main__':
    N = int(input())
    D = list(map(int, input().split()))
    print(main(n=N, d=D))

Buggy submission (verdict: Runtime Error):
import collections


def mod_pow(a, n, mod):
    result = 1
    a_n = a
    while n > 0:
        if n & 1:
            result = result * a_n % mod
        a_n = a_n * a_n % mod
        n >>= 1
    return result


def main(n, d):
    MOD = 998244353
    counter = collections.Counter(d)
    if counter[0] != 1:
        return 0
    if 0 in counter.values:
        return 0
    pows = [mod_pow(a=counter[i - 1], n=counter[i], mod=MOD) for i in
            range(1, max(counter.keys()) + 1)]
    patterns = 1
    for p in pows:
        patterns *= p
        patterns %= MOD
    return patterns


if __name__ == '__main__':
    N = int(input())
    D = list(map(int, input().split()))
    print(main(n=N, d=D))

Buggy submission (verdict: Runtime Error):
import collections


def mod_pow(a, n, mod):
    result = 1
    a_n = a
    while n > 0:
        if n & 1:
            result = result * a_n % mod
        a_n = a_n * a_n % mod
        n >>= 1
    return result


def main(n, d):
    MOD = 998244353
    counter = collections.Counter(d)
    pows = [mod_pow(a=counter[i - 1], n=counter[i], mod=MOD) for i in
            max(counter.keys()) + 1]
    patterns = 1
    for p in pows:
        patterns *= p
        patterns %= MOD
    return patterns


if __name__ == '__main__':
    N = int(input())
    D = list(map(int, input().split()))
    print(main(n=N, d=D))
Problem p02885 (python)

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

print(max(0, A - 2 * B))

Buggy submission (verdict: Runtime Error):
A, B = map(int, input())

print(max(0, A - 2 * B))
Problem p03109 (python)

Fixed submission:
ymd = tuple(map(int, input().split('/')))

if ymd <= (2019, 4, 30):
    print('Heisei')
else:
    print('TBD')

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split(' '))
ymd = tuple(map(int, input().split('/')))

if ymd <= (2019, 4, 30):
    print('Heisei')
else:
    print('TBD')
Problem p03164 (python)

Fixed submission:
import numpy as np


def main(n, w, items):
    MAX_VALUE = 100100
    dp = np.ones((n + 1, MAX_VALUE), dtype=int)
    dp = dp * (1 << 30)
    dp[0][0] = 0
    for i in range(0, n):
        weight, value = items[i]
        dp[i + 1][:value] = np.minimum(dp[i][:value], dp[i + 1][:value])
        dp[i + 1][value:] = np.minimum(dp[i][value:], dp[i][:MAX_VALUE - value] + weight)

    result = 0
    for v in range(MAX_VALUE):
        if dp[-1][v] <= w:
            result = v
    return result


if __name__ == '__main__':
    N, W = map(int, input().split())
    I = []
    for _ in range(N):
        I.append(tuple(map(int, input().split())))
    print(main(N, W, I))

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


def main(n, w, items):
    dp = np.zeros((n + 1, w + 1), dtype=int)
    for i in range(1, n + 1):
        weight, value = items[i - 1]
        dp[i][:weight] = dp[i - 1][:weight]
        dp[i][weight:] = np.maximum(dp[i - 1][weight:], dp[i - 1][:w - weight + 1] + value)
    return dp[n][w]


if __name__ == '__main__':
    N, W = map(int, input().split())
    I = []
    for _ in range(N):
        I.append(tuple(map(int, input().split())))
    print(main(N, W, I))
Problem p03264 (python)

Fixed submission:
K = int(input())

odd = [0 for i in range(1, K + 1) if i % 2 == 1]
even = [0 for i in range(1, K + 1) if i % 2 == 0]

print(len(odd) * len(even))

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

odd = [0 for i in range(1, K + 1) if i % 2 == 1]
even = [0 for i in range(1, K + 1) if i % 2 == 0]

print(len(odd) * len(event))
Problem p03289 (python)

Fixed submission:
S = list(input())

if S[0] != 'A':
    print('WA')
elif S[2:-1].count('C') != 1:
    print('WA')
else:
    S = list(S[1:])
    S.remove('C')
    S = ''.join(S)
    if S.islower():
        print('AC')
    else:
        print('WA')

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

if S[0] != 'A':
    print('WC')
elif 'C' not in S[2:-1]:
    print('WC')
else:
    S.remove('A')
    S.remove('C')
    for c in S:
        if c.is_upper():
            print('WC')
    else:
        print('AC')
Problem p03309 (python)

Fixed submission:
from functools import lru_cache
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split(' '))))
i = np.arange(1, N + 1)

left = -(10 ** 10)
right = (10 ** 10)


@lru_cache(maxsize=None)
def cost(b):
    return np.sum(np.abs(A - (i + b)))


while True:
    mid = (left + right) // 2
    c_left = cost(left)
    c_right = cost(right)
    if left == mid or right == mid:
        print(min(c_left, c_right))
        break
    elif c_left < c_right:
        right = mid
    else:
        left = mid

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

N = int(input())
A = np.array(list(map(int, input().split(' '))))
B = np.arange(1, N + 1)

C = A - B
mean = int(np.mean(C))

print(min(np.sum(np.abs(C - mean))), np.sum(np.abs(C + mean)))