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

Fixed submission:

n = int(input())
alist = []
for i in range(n):
    alist.append(int(input()))

amax = max(alist)
anslist = [amax]*n
if alist.count(amax)>=2:
    for i in anslist:
        print(i)
    exit()

if alist.count(amax)==1:
    maxindex = alist.index(amax)
    del alist[maxindex]
    anslist[maxindex]= max(alist)
    for i in anslist:
        print(i)
    exit()

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

n = int(input())
alist = deque()
for i in range(n):
    alist.append(int(input()))

amax = max(alist)
anslist = [amax]*n
if alist.count(amax)>=2:
    for i in anslist:
        print(i)
    exit()

if alist.count(amax)==1:
    maxindex = alist.index(amax)
    del alist[maxindex]
    anslist[maxindex]= max(alist)
    for i in anslist:
        print(i)
    exit()
Problem p02972 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
ans =[0 for _ in range(n)]
count=0
for i in range(n-1,-1,-1):
    if sum([ans[j]for j in range(i,n,i+1)])%2!=l[i]:
        ans[i]=1
        count +=1

print(count)
[print(i+1,end=" ") for i,x in enumerate(ans) if x==1]

Buggy submission (verdict: Runtime Error):
n = int(input())
alist = list(map(int,input().split()))
anslist =[]
def act(i,nowlist):
    now = i+1
    ai =alist[i]
    s = 1
    multisum =0
    while now * s <= n:
        multisum += nowlist[now*s-1]
        s +=1
    if multisum%2 ==ai:
        anslist.append(0)
    if multisum%2 !=ai:
        anslist.append(1)
    if i == n-1:
        return 
    act(i+1,nowlist)
    
numlist = [0 for i in range(n)]
act(0,numlist)
print(anslist.count(1))
if anslist.count(1)>0:
    indexes = [i+1 for i, x in enumerate(anslist) if x == 1]
    [print(i,end=" ") for i in indexes]

Buggy submission (verdict: Runtime Error):
n = int(input())
alist = list(map(int,input().split()))
anslist =[]
def act(i,nowlist):
    now = i+1
    ai =alist[i]
    s = 1
    multisum =0
    while now * s <= n:
        multisum += nowlist[now*s-1]
        s +=1
    if multisum%2 ==ai:
        anslist.append(0)
    if multisum%2 !=ai:
        anslist.append(1)
    if i == n-1:
        return 
    act(i+1,nowlist)
    
numlist = [0 for i in range(n)]
act(0,numlist)
print(anslist.count(1))
if anslist.count(1)>0:
    indexes = [i+1 for i, x in enumerate(anslist) if x == 1]
    [print(i,end=" ") for i in indexes]
Problem p02983 (python)

Fixed submission:
import numpy as np
a,b = map(int,input().split())
moda=np.mod(a,2019)
modb=np.mod(b,2019)
if (modb<=moda)or((b-a)>=673):
    print(0)
    exit()

num =list(range(moda,modb+1))

ans = 10000
for i,l in enumerate(num):
    if i == len(num)-1:
        break
    for r in num[i+1:]:
        ans = min(np.mod(l*r,2019),ans)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
a,b = map(int,input().split())
moda=np.mod(a,2019)
modb=np.mod(b,2019)
if (modb<=moda)or((b-a)>=2018):
    print(0)
    exit()

num =list(range(moda,modb+1))
ans = 10000
for i,l in enumerate(num):
    if i == len(num)-1:
        break
    for r in num[i+1:]:
        ans = min(np.mod(l*r,2019),ans)
print(ans)
Problem p03761 (python)

Fixed submission:
n = int(input())
strs = []
inter1 = {}
for _ in range(n):
    strs.append(input())

for char in strs[0]:
    if char in inter1:
        inter1[char] +=1
    else:
        inter1[char] = 1
        
for i in range(1,n):
    inter2 = {}
    for char in strs[i]:
        if (char in inter1):
            if char in inter2:
                if inter2[char] < inter1[char]:
                    inter2[char] +=1
            else:
                inter2[char] =1 
    inter1 = inter2

inter = sorted(inter1.items())
ans = ''
for char,i in inter:
    for _ in range(i):
        ans +=char
print(ans)

Buggy submission (verdict: Runtime Error):
strs = []
inter1 = {}
for _ in range(n):
    strs.append(input())

for char in strs[0]:
    if char in inter1:
        inter1[char] +=1
    else:
        inter1[char] = 1
        
for i in range(1,n):
    inter2 = {}
    for char in strs[i]:
        if (char in inter1):
            if char in inter2:
                if inter2[char] < inter1[char]:
                    inter2[char] +=1
            else:
                inter2[char] =1 
    inter1 = inter2

inter = sorted(inter1.items())
ans = ''
for char,i in inter:
    for _ in range(i):
        ans +=char
print(ans)
Problem p02641 (python)

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

ans = 0
for i in range(1, 102):
    if abs(X - i) < abs(X - ans) and i not in p:
        ans = i
print(ans)

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

ans = 0
for i in range(1, 102):
    if abs(X - i) < abs(ans - i) and i not in p and i != X:
        ans = i

print(ans)

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

ans = 0
for i in range(1, 102):
    if abs(X - i) < abs(ans - i) and i not in p and i != X:
        ans = i

print(ans)
Problem p03000 (python)

Fixed submission:
N,X = list(map(int, input().split()))
L = list(map(int, input().split()))
D = [0]*(N+2)
for i in range(N):
    D[i+1] = D[i] + L[i]
#print (D)
count = 0
for i in range(len(D)):
    if D[i] <= X:
        count += 1
print (count-1)

Buggy submission (verdict: Runtime Error):
N,X = list(map(int, input().split()))
L = list(map(int, input().split()))
D = [0]*(N+2)
for i in range(N):
    D[i+1] = D[i] + L[i]
#print (D)
count = 0
for i in range(len(D)):
    if D[i] <= X:
        count += 1
print count
Problem p02971 (python)

Fixed submission:
N = int(input())
a = [0]*N
b = [0]*N
for i in range(N):
    a[i] = int(input())
    b[i] = a[i]
m = max(b)
b.remove(m)
n = max(b)

for i in range(N):
    if a[i] == m:
        print(n)
    else:
        print(m)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [0]*N
b = [0]*N
for i in range(N):
    a[i] = int(input())
    b[i] = int(input())
m = max(b)
b.remove(m)
n = max(b)

for i in range(N):
    if a[i] == m:
        print(n)
    else:
        print(m)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [0]*N
for i in range(N):
    a[i] = int(input())
m = max(a)
a.remove(m)
n = max(a)


for i in range(N):
    if a[i] == m:
        print(n)
    else:
        print(m)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [0]*N
for i in range(N):
    a[i] = int(input())
b = set(a)
m = max(b)
b.remove(m)
n = max(b)
for i in range(N):
    if a[i] == m:
        print(n)
    else:
        print(m)
Problem p03049 (python)

Fixed submission:
ans = 0
first_b = 0
last_a = 0
same = 0

N = int(input())

for i in range(N):
    s = input()
    ans += s.count("AB")
    if s[0] == "B":
        first_b += 1
    if s[-1] == "A":
        last_a += 1
    if s[0] == "B" and s[-1] == "A":
        same +=1

ans += min(first_b, last_a)
if same > 0 and first_b ==  last_a and first_b == same:
    ans -=1
print(ans)

Buggy submission (verdict: Runtime Error):
ans = 0
first_b = 0
last_a = 0
same = 0

N = int(input())

for i in range(N):
    s = input()
    ans += s.count("AB")
    if s[0] == "B":
        first_b += 1
    if s[-1] == "A":
        last_a += 1
    if s[0] == "B" and s[-1] == "A":
        same +=1

ans += min(first_b, last_a)
if same > 0 and first_b ==  last_a and first_b = same:
    ans -=1
 print(ans)
Problem p03129 (python)

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

if k==1 or n/(k-1) > 2 :
    print("YES")
else:
    print("NO")

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

if n/(k-1) > 2 :
    print("YES")
else:
    print("NO")
Problem p03280 (python)

Fixed submission:
a,b = [int(x) for x in input().split()]
print((a-1)*(b-1))

Buggy submission (verdict: Runtime Error):
a,b = input().split()
print((a-1)*(b-1))
Problem p03469 (python)

Fixed submission:
print(input().replace("2017","2018"))

Buggy submission (verdict: Runtime Error):
print(input().replace("2017","2018"))
Problem p03493 (python)

Fixed submission:
print(sum([int(x) for x in input()]))

Buggy submission (verdict: Runtime Error):
n,k = [int(x) for x in input().split()]
s = {}

for i in input().split():
    if(i in s):
        s[i] += 1
    else:
        s[i] = 1


t = list(s.values())
t.sort()
a = 0

while len(t) > k:
    a += t.pop(0)

print(a)

Buggy submission (verdict: Runtime Error):
print(sum([int(x) for x in input().split()]))
Problem p03494 (python)

Fixed submission:
n = input()
b = [int(x) for x in input().split()]
c = 0
flg = True
while flg:
    for i,x in enumerate(b):
        if x!=0 and x%2 != 0:
            flg=False
            break
        b[i] = int(x/2)
    c += 1
print(c-1)

Buggy submission (verdict: Runtime Error):
n = input()
b = [int(x) for x in input().split()]
c = 0
while True:
    for i,x in enumerate(b):
        if x%2 != 0:
            break
        b[x] = int(x/2)
    c += 1
print(c)

Buggy submission (verdict: Runtime Error):
n = input()
b = ['{0:b}'.format(int(x)) for x in input().split()]
a = 0
for c in b:
    m = re.match(r'.*(10*)$',c)
    if m is None:
      continue
    a = max(a,len(m[1])-1)
print(a)

Buggy submission (verdict: Runtime Error):
n = input()
b = ['{0:b}'.format(int(x)) for x in input().split()]
a = 0
for c in b:
    m = re.match(r'.*(10*)$',c)
    print(m[1])   
    if m is None:
      continue
    a = max(a,len(m[1])-1)
print(a)
Problem p03495 (python)

Fixed submission:
n,k = [int(x) for x in input().split()]
s = {}

for i in input().split():
    if(i in s):
        s[i] += 1
    else:
        s[i] = 1


t = list(s.values())
t.sort()
a = sum(t[0:-k])

print(a)

Buggy submission (verdict: Runtime Error):
n,k = [int(x) for x in input().split()]
s = {}
for i in input().split():
    if(i in s):
        s[i] += 1
    else:
        s[i] = 1


t = list(s.values())
t.sort()
a = 0

while len(t) > k:
    a += t.pop(0)[1]

print(a)
Problem p03719 (python)

Fixed submission:
a,b,c = [int(x) for x in input().split()]

if c>=a and c<=b:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
a,b,c = [int(x) for x in input().split()]

if c>=a and c<=b:
	print("Yes")
else
	print("No")
Problem p03957 (python)

Fixed submission:
s = input()
c = s.find('C')
f = s.rfind('F')

if  c != -1 and f != -1 and (c < f):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import sys

n = int(input())
t = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

if t[n-1]!=a[0]:
    print(0)
    sys.exit()

m =[]
for i in range(n):
    mx = min(t[i],a[i])
    mn = 1
    if i == 0:
        mn = t[i]
    elif i == n-1:
        mn = a[i]
    else :
        if t[i]!=t[i-1]:
            mn=t[i]
        if a[i]!=a[i+1]:
            mn=a[i]
    m.append([mx,min(mx,mn)])

ans = 1
for i in range(n):
    ans = (ans * (m[i][0]-m[i][1]+1))%(10**9+7)
print(ans)
Problem p03970 (python)

Fixed submission:
s=input()
a="CODEFESTIVAL2016"
count=0
for a,b in zip(s,a) :
    if a != b :
        count+=1 
print(count)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=[0]*N
for i in range(N):
    a[i]=int(input())
minimum=1
count=0
for i in  a:
   if(minimum<i):
       if i%minimum:
           count+= i//minimum
       else :
           count+= (i//minimum-1)
   else:
       minimum=max(minimum,i+1)
print(count)
Problem p03973 (python)

Fixed submission:
N=int(input())
a=[0]*N
for i in range(N):
    a[i]=int(input())

minimum=2
count=a[0]-1
a.pop(0)
for i in  a:
   if(minimum<i):
       if i%minimum:
           count+= i//minimum
       else :
           count+= (i//minimum-1)
   else:
       minimum=max(minimum,i+1)
print(count)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=[0]*N
for i in range(N):
    a.[i]=int(input())
minimum=1
count=0
for i in  a:
   if(minimum<i):
       if i%minimum:
           count+= i//minimum
       else :
           count+= (i//minimum-1)
   else:
       minimum=max(minimum,i+1)
print(count)
Problem p03994 (python)

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

def toA(char):
    return (ord('z')-ord(char)+1)%26

def toC(char,k):
    if(ord('z')-ord(char)>=k%26):
        return chr(ord(char)+k%26)
    else:
        return chr(ord('a')+k-ord('z')-ord(char))
for i in range(len(s)):
    if(k==0):
        break
    if(k>=toA(s[i])):
        k-=toA(s[i])
        s[i]='a'
    if(i==len(s)-1) and k>0:
        s[i]= toC(s[i],k)
print("".join(s))

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

def toA(char):
    return (ord('z')-ord(char)+1)%26


def toC(char,k):
    if(ord('z')-ord(char)>=k):
        return chr(ord(char)+k)
    else:
        return chr(ord('a')+k-ord('z')-ord(char))


for i in range(len(s)):
    if(k==0):
        break
    if(k>=toA(s[i])):
        k-=toA(s[i])
        s[i]='a'
    if(i==len(s)-1) and k>0:
        s[i]= toC(s[i],k)
print("".join(s))
Problem p02899 (python)

Fixed submission:
n = int(input())
a=[]

b = list(map(int, input().split()))
for i in range(n):
    a+=[[i+1, b[i]] ]
    
    
import operator as op
a.sort(key = op.itemgetter(1))

x=""
for i in range(n):
    x+=str(a[i][0])
    if i!=n-1:
        x+=" "

print(x)

Buggy submission (verdict: Runtime Error):
n = int(input())
a=[]

b = list(map(int, input().split()))
for i in range(n):
    4a+=[[i+1, b[i]] ]
    
    
import operator as op
a.sort(key = op.itemgetter(1))

x=""
for i in range(n):
    x+=str(a[i][0])
    if i!=n-1:
        x+=" "
#a = [[3,-9],[2,3],[1,20]]
print(x)
Problem p02999 (python)

Fixed submission:
x, a = map(int,input().split())
if x<a:
    print(0)
else:
    print(10)

Buggy submission (verdict: Runtime Error):
x, a = map(int,rfile.readline().split())
if x<a:
    print(0)
    else:
    print(10)
Problem p03285 (python)

Fixed submission:
n=int(input())


ans=False

if n%7==0:
    ans=True


for i in range((int(1+(n/7)))):
    
    if (n-i*7)%4==0:
        ans=True
        

if ans:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
#4
#7
ans=False
if n%7==0:
    ans==True


for i in range(n/7):
    if (n-i*7)%4==0:
        ans=True
        

if ans:
    print("Yes")
else:
    print("No")
Problem p02702 (python)

Fixed submission:
s = input()
l = len(s)
c = 2019
tm = 1
ti = int(s[-1])
co = [0]*2019
co[ti] += 1
for i in range(1, l):
    tm = tm*10 % c
    ti += int(s[l-i-1]) * tm
    ti = ti % c
    co[ti] += 1
if co[0] != 0:
    co[0] += 1
print(sum([i*(i-1)//2 for i in co]))

Buggy submission (verdict: Runtime Error):
s = input()
l = len(s)
te = [1] * 20000
c = 2019
for i in range(1, len(te)):
    te[i] = te[i-1]*10 % c

ans = 0
for i in range(l-1, -1, -1):
    t = int(s[i])
    if t == 0:
        ans += 1
    for j in range(1, i+1):
        t = t + int(s[i-j])*te[j]
        t = t%c
        if t == 0:
            ans += 1
print(ans)
Problem p02715 (python)

Fixed submission:
def left_bin(a, n, c):
    ns = [int(i) for i in bin(n)[3:]]
    t = a
    for i in ns:
        t = t*t % c
        if i == 1:
            t = t*a % c
    return t


n, k = map(int, input().split())
c = 10**9+7
tm = [0] + [1]*k
a = k//2
ans = k*(k+1)//2 - a*(a+1)//2
for i in range(k//2, 0, -1):
    a = k//i
    t = (left_bin(a, n, c) - sum([tm[j*i] for j in range(2, a+1)])) % c
    ans = (ans + t*i) % c
    tm[i] = t
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
c = 10**9+7
tm = [0] + [1]*k
a = k//2
ans = k*(k+1)//2 - a*(a+1)//2
for i in range(k//2, 0, -1):
    a = k//i
    t = (left_bin(a, n, c) - sum([tm[j*i] for j in range(2, a+1)])) % c
    ans = (ans + t*i) % c
    tm[i] = t
print(ans)
Problem p02727 (python)

Fixed submission:
x, y, a, b, c = map(int, input().split())
p = [int(i) for i in input().split(" ")]
q = [int(i) for i in input().split(" ")]
r = [int(i) for i in input().split(" ")]
p = sorted(p)
q = sorted(q)
r = sorted(r)
x_ = a-x
y_ = b-y
flag = 0
ans = sum(p[x_:]) + sum(q[y_:])
for i in range(c-1, -1, -1):
    if p[x_] > q[y_]:
        if q[y_] < r[i]:
            ans += r[i] - q[y_]
            y_ += 1
            if y_>=b:
                flag = 1
                break
        else:
            break
    else:
        if p[x_] < r[i]:
            ans += r[i] - p[x_]
            x_ += 1
            if x_>=a:
                flag = 2
                break
        else:
            break
if flag == 1:
    for j in range(i-1, -1, -1):
        if x_>=a:
            break
        if p[x_] < r[j]:
            ans += r[j] - p[x_]
            x_ += 1
        else:
            break
elif flag == 2:
    for j in range(i-1, -1, -1):
        if y_>=b:
            break
        if q[y_] < r[j]:
            ans += r[j] - q[y_]
            y_ += 1
        else:
            break
            
print(ans)

Buggy submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
p = [int(i) for i in input().split(" ")]
q = [int(i) for i in input().split(" ")]
r = [int(i) for i in input().split(" ")]
p = sorted(p)
q = sorted(q)
r = sorted(r)
x_ = a-x
y_ = b-y
ans = sum(p[x_:]) + sum(q[y_:])
for i in r[::-1]:
    if p[x_] > q[y_]:
        if q[y_] < i:
            ans += i - q[y_]
            y_ += 1
        else:
            break
    else:
        if p[x_] < i:
            ans += i - p[x_]
            x_ += 1
        else:
            break
print(ans)
Problem p02733 (python)

Fixed submission:
def add(in1, in2):
    return [a + b for a, b in zip(in1, in2)]

def check_overk(in1, k):
    return len([i for i in in1 if i>k]) > 0

def split(ar, k, w):
    a = 0
    for i in ar:
        if check_overk(i, k):
            return -1
    tm = ar[0]
    for i in range(1, w):
        tm = add(tm, ar[i])
        if check_overk(tm, k):
            a += 1
            tm = ar[i]
    return a
            

h, w, k = map(int, input().split())
s = [[int(i) for i in input()] for j in range(h)]
ans = h*w

for i in range(2**(h-1)):
    data = []
    temp = s[0]
    sp = bin(i+2**h)[4:]
    if ans < sp.count("1"):
        continue
    for j in range(1, h):
        if sp[j-1] == "0":
            temp = add(temp, s[j])
        else:
            data.append(temp)
            temp = s[j]
    data.append(temp)
    ans_ = split([list(x) for x in zip(*data)], k, w)
    if ans_ == -1:
        continue
    ans_ += sp.count("1")
    if ans > ans_:
        ans = ans_
print(ans)

Buggy submission (verdict: Runtime Error):
def add(in1, in2):
    return [a + b for a, b in zip(in1, in2)]

def split(ar, k, w):
    a = 0
    if max(ar) > k:
      return -1
    tm = ar[0]
    for i in range(1, w):
        tm = add(tm, ar[i])
        if max(tm) > k:
            a += 1
            tm = ar[i]
    return a        

h, w, k = map(int, input().split())
s = [[int(i) for i in input()] for j in range(h)]
ans = h*w

for i in range(2**(h-1)):
    data = []
    temp = s[0]
    sp = bin(i+2**h)[4:]
    if ans < sp.count("1"):
        continue
    for j in range(1, h):
        if sp[j-1] == "0":
            temp = add(temp, s[j])
        else:
            data.append(temp)
            temp = s[j]
    data.append(temp)
    ans_ = split([list(x) for x in zip(*data)], k, w)
    if ans_ == -1:
        continue
    ans_ += sp.count("1")
    if ans > ans_:
        ans = ans_
print(ans)
Problem p02803 (python)

Fixed submission:
import numpy as np
def min_rounte(s, sta, path):
    move = [[0,1],[0,-1],[1,0],[-1,0]]
    for i in move:
        ax = [sta[0]+i[0], sta[1]+i[1]]
        if s[ax[0]][ax[1]] == -1:
            continue
        if s[ax[0]][ax[1]] > path:
            s[ax[0]][ax[1]] = path
    return s
 
def bfs(s, sta):
    s_ = np.array(s)
    s_[sta[0]][sta[1]] = 0
    tmp = sta
    for i in range(400):
        ind = np.where(s_==i)
        for j in range(len(ind[0])):
            s_ = min_rounte(s_, [ind[0][j], ind[1][j]], i+1)
        if len(ind[0]) == 0:
            break
        tmp = [[ind[0][k], ind[1][k]] for k in range(len(ind[0]))]
    return i-1, tmp
        

h, w = map(int, input().split())
#s_ = [[0 if i=="." else -1 for i in input()] for j in range(h)]
s = [[-1 for i in range(w+2)] for j in range(h+2)]
for i in range(h):
    a = input()
    for j in range(w):
        if a[j] == ".":
            s[i+1][j+1] = 512
        else:
            s[i+1][j+1] = -1

for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] == -1:
            continue
        temp, ax = bfs(s, [i,j])
        break
ans = 1
for i in ax:
    ans_, t = bfs(s, i)
    if ans_ > ans:
        ans = ans_

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
def min_rounte(s, sta, path):
    move = [[0,1],[0,-1],[1,0],[-1,0]]
    for i in move:
        ax = [sta[0]+i[0], sta[1]+i[1]]
        if s[ax[0]][ax[1]] == -1:
            continue
        if s[ax[0]][ax[1]] > path:
            s[ax[0]][ax[1]] = path
    return s
 
def bfs(s, sta):
    s_ = np.array(s)
    s_[sta[0]][sta[1]] = 0
    for i in range(400):
        ind = np.where(s_==i)
        for j in range(len(ind[0])):
            s_ = min_rounte(s_, [ind[0][j], ind[1][j]], i+1)
        if len(ind[0]) == 0:
            break
    return i-1
        

h, w = map(int, input().split())
#s_ = [[0 if i=="." else -1 for i in input()] for j in range(h)]
s = [[-1 for i in range(w+2)] for j in range(h+2)]
for i in range(h):
    a = input()
    for j in range(w):
        if a[j] == ".":
            s[i+1][j+1] = 512
        else:
            s[i+1][j+1] = -1
  
ans = 1

for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] == -1:
            continue
        temp = bfs(s, [i,j])
        if temp > ans:
            ans = temp
print(ans)
Problem p02928 (python)

Fixed submission:
tmp = [int(i) for i in input().split(" ")]
n = tmp[0]
k = tmp[1]
a = [int(i) for i in input().split(" ")]
import numpy as np
a = np.array(a)
uni = np.unique(a)
co = [np.sum(a==i) for i in uni]
ind = np.array([np.sum(co[:uni.tolist().index(i)]) for i in a]).astype(np.int32)
c = 0

for i in range(len(a)):
    c += np.sum(a[i:]<a[i])
m = 10**9+7
tm = int(c)*int(k) % m
if k % 2 == 0:
    t = k * (k//2-1) + k//2
    t %= m
else:
    t = k * (k//2)
    t %= m
print((int(np.sum(ind))*t+tm) % m)

Buggy submission (verdict: Runtime Error):
tmp = [int(i) for i in input().split(" ")]
n = tmp[0]
k = tmp[1]
a = [int(i) for i in input().split(" ")]
import numpy as np
uni, co = np.unique(a, return_counts=True)
ind = [np.sum(co[:uni.tolist().index(i)]) for i in a]
c = 0
a = np.array(a)
for i in range(len(a)):
    c += np.sum(a[i:]<a[i])
m = 10**9+7
tm = int(c)*int(k) % m
if k % 2 == 0:
    t = k * (k//2-1) + k//2
    t %= m
else:
    t = k * (k//2)
    t %= m
print((np.sum(ind)*t+tm) % m)