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

Fixed submission:
a, b = map(int,input().split(' '))
if a % 2 == 0 or b % 2 == 0:
  print('Even')
else:
  print('Odd')

Buggy submission (verdict: Runtime Error):
a, b = map(int,input().split(''))
if a % 2 == 0 or b % 2 == 0:
  print('Even')
else:
  print('Odd')
Problem p03474 (python)

Fixed submission:
A,B = map(int,input().split())
S = input()
if S.count('-')==1 and S[A]=='-':
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
S = input()
if S.count('-')==1 and s[A]=='-':
    print('Yes')
else:
    print('No')
Problem p03477 (python)

Fixed submission:
A,B,C,D = map(int,input().split(' '))
X = A + B
Y = C + D
if X == Y:
  print('Balanced')
elif X > Y:
  print('Left')
else:
  print('Right')

Buggy submission (verdict: Runtime Error):
A,B,C,D = map(int,input().split(' '))
A + B = X
C + D = Y
if X == Y:
  print('Balanced')
elif X > Y:
  print('Left')
else:
  print('Right')
Problem p03502 (python)

Fixed submission:
import copy
S = input()
N = int(copy.copy(S))
X = 0
for i in range(len(S)):
  res = S[i]
  X += int(res)
if N % X == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S = input()
N = int(S)
X = 0
for i in len(S):
  res = S[i]
  X += int(res)
if N % X == 0:
  print('Yes')
else:
  print('No')
Problem p03547 (python)

Fixed submission:
dict = {'A':10,'B':11,'C':12,'D':13,'E':14,'F':15}
X, Y = map(str,input().split(' '))
if dict[X] < dict[Y]:
  print('<')
elif dict[X] == dict[Y]:
  print('=')
else:
  print('>')

Buggy submission (verdict: Runtime Error):
dict = {'A':10,'B':11,'C':12,'D':13,'E':14,'F':15}
X, Y = map(int(input().split(' ')))
if dict[X] < dict[Y]:
  print('<')
elif dict[X] == dict[Y]:
  print('=')
else:
  print('>')
Problem p03563 (python)

Fixed submission:
R = int(input())
G = int(input())
print(2*G-R)

Buggy submission (verdict: Runtime Error):
R = int(input())
G = int(input())
print(2G-R)
Problem p03574 (python)

Fixed submission:
H,W=map(int,input().split())
S = [ input() for _ in range(H) ]
for h in range(H):
  L = ''
  for w in range(W):
    if S[h][w] == '#':
      L += '#'
    else:
      x = 0
      for dh in [ -1, 0, 1]:
        for dw in [-1, 0, 1]:
          if 0 <= h + dh < H and 0 <= w + dw < W and S[h+dh][w+dw] == '#':
            x += 1
      L += str(x)
  print(L)

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
S = [ input() for _ in range(H) ]
for h in range(H):
  L = ''
  for w in range(W):
    if S[h][w] == '#':
      L += '#'
    else:
      x = 0
      for dh in [ -1, 0, 1]:
        for dw in [-1, 0, 1]:
          if 0 <= h + dh < H and 0 <= w + dw < W and S[h+dh][w+dw] == '#':
            x += 1
      L += str(x)
  print(l)
Problem p03605 (python)

Fixed submission:
S = input()
if S.count('9') >= 1:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S = input()
if S.count('9') >= 1:
  print('Yes')
elss:
  print('No')
Problem p03644 (python)

Fixed submission:
N = int(input())
L = [(N,0),(1,0), (2,1), (4,2), (8,3), (16,4), (32,5), (64,6),(128,7)]
sorted_L = sorted(L,key=lambda x:x[0])
for i,j in enumerate(sorted_L):
  if j[0] == N:
    if sorted_L[i][0] == sorted_L[i+1][0]:
      print(sorted_L[i][0])
      break
    else:
      print(sorted_L[i-1][0])
      break

Buggy submission (verdict: Runtime Error):
N = int(input())
L = [(N,0),(1,0), (2,1), (4,2), (8,3), (16,4), (32,5), (64,6)]
sorted_L = sorted(L,key=lambda x:x[0])
for i,j in enumerate(sorted_L):
  if j[0] == N:
    if sorted_L[i][0] == sorted_L[i+1][0]:
      print(sorted_L[i][0])
      break
    else:
      print(sorted_L[i-1][0])
      break

Buggy submission (verdict: Runtime Error):
N = int(input())
L = [(N,0),(1,0), (2,1), (4,2), (8,3), (16,4), (32,5), (64,6)]
sorted_L = sorted(L,key=lambda x:x[0])
print(sorted_L)
for i,j in enumerate(sorted_L):
  if j[0] == N:
    if sorted_L[i][0] == sorted_L[i+1][0]:
      print(sorted_L[i][0])
      break
    else:
      print(sorted_L[i-1][0])
      break

Buggy submission (verdict: Runtime Error):
N = int(input())
L = [(N,0),(1,0), (2,1), (4,2), (8,3), (16,4), (32,5), (64,6)]
sorted_L = sorted(L,key=lambda x:x[0])
print(sorted_L)
for i,j in enumerate(sorted_L):
  if j[0] == N:
    if sorted_L[i][0] == sorted_L[i+1][0]:
      print(sorted_L[i][0])
    else:
      print(sorted_L[i-1][0])
      break
Problem p03680 (python)

Fixed submission:
N = int(input())
list = [int(input()) for i in range(N)]
c = 0
x = 1
while x != 2 and c < N:
    x = list[x - 1]
    c += 1
if x == 2:
    print(c)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N = int(input())
list = [int(input()) for i in range(n)]
c = 0
x = 1
while x != 2 and c < N:
    x = list[x - 1]
    c += 1
if x == 2:
    print(c)
else:
    print(-1)
Problem p03731 (python)

Fixed submission:
N, T= map(int, input().split(' '))
X = [int(i) for i in input().split()]
num = T
for i in range(1, N):
    num += min(T, X[i] - X[i - 1])
print(num)

Buggy submission (verdict: Runtime Error):
N, T= map(int, input().split(' '))
X = [int(i) for i in input().split()]
num = T
for i in range(1, n):
  num += min(T, X[i] - X[i - 1])
print(num)

Buggy submission (verdict: Runtime Error):
N, T= map(int, input().split(' '))
X = [int(i) for i in input().split()]
num = T
for i in range(1, n):
    num += min(T, X[i] - X[i - 1])
print(num)
Problem p03738 (python)

Fixed submission:
A = int(input())
B = int(input())
if A > B:
  print('GREATER')
elif B > A:
  print('LESS')
else:
  print('EQUAL')

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split(' '))
if A > B:
  print('GREATER')
elif B > A:
  print('LESS')
else:
  print('EQUAL')
Problem p03777 (python)

Fixed submission:
a,b = map(str,input().split(' '))
if a == 'H':
  print(b)
elif a == 'D' and b == 'H':
  print('D')
else:
  print('H')

Buggy submission (verdict: Runtime Error):
a,b = map(str,input().split(' '))
if a == 'H':
  print(b)
elif a == 'D' and b == 'H':
  print('D')
else
:print('H')
Problem p03844 (python)

Fixed submission:
A,X,B = map(str,input().split(' '))
if X == '+':
  print(int(A) + int(B))
else:
  print(int(A) - int(B))

Buggy submission (verdict: Runtime Error):
A X B = map(str,input().split(' '))
if X == '+':
  print(int(A) + int(B))
else:
  print(int(A) - int(B))

Buggy submission (verdict: Runtime Error):
A X B = map(int,input().split(' '))
if X == '+':
  print(int(A) + int(B))
else:
  print(int(A) - int(B))
Problem p03846 (python)

Fixed submission:
import collections

N = int(input())
A = list(map(int,input().split(' ')))
C = collections.Counter(A)
L = C.most_common()

if N % 2 == 0:
  for i, j in L:
    if j == 2:
      pass
    else:
      print(0)
      exit()
else:
   for i, j in L:
    if j == 2:
      pass
    else:
      if i == 0:
        pass
      else:
        print(0)
        exit()
print(int((2**(N//2) % (10**9+7))))

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
A = list(map(int,input().split(' ')))
C = collections.Counter(A)
L = C.most_common()

if N % 2 == 0:
  for i, j in L:
    if j == 2:
      pass
    else:
      print(0)
      exit()
else:
   for i, j in L:
    if j == 2:
      pass
    else:
      if i == 0:
        pass
      else:
        print(0)
        exit()
print(int(2**(N//2 / (10**9+7)))
Problem p04030 (python)

Fixed submission:
S = input()

t = ""
for i in range(len(S)):
  if S[i] == "B":
    if t != "":
      t = t[:-1]
  else:
    t += S[i]
print (t)

Buggy submission (verdict: Runtime Error):
S = input()
L = []
for i in S:
  if i == 'B':
    L.pop()
  else:
    L.append(i)
print(*L)
Problem p04044 (python)

Fixed submission:
N, L = map(int,input().split(' '))
S = []
for i in range(N):
  x = input()
  S.append(x)
X = sorted(S)
print(''.join(X))

Buggy submission (verdict: Runtime Error):
N, L = map(int,input().split(' '))
S = []
for i in range(N):
  S.append(i)
X = sorted(S)
print(''.join(X))
Problem p02953 (python)

Fixed submission:
import sys
N=int(input())
H=list(map(int,input().split()))
if N==1:
  print('Yes')
else:
  M=1
  for i in range(N-1):
    M=max(M,H[i])
    if H[i]<=H[i+1]:
      pass
    elif H[i]-H[i+1]==1:
      H[i]-=1
      if M-H[i]>1:
        print('No')
        sys.exit()
      else:
        pass
    elif H[i]-H[i+1]>=2:
      print('No')
      sys.exit()
  print('Yes')

Buggy submission (verdict: Runtime Error):
import sys
N=int(input())
H=list(map(int,input().split()))
if N==1:
  print('Yes')
  sys.exit()
for i in range(N-1):
  if H[i]<H[i+1]:
    pass
  elif H[i]-H[i+1]==1:
    H[i]-=1
    if N>=3 and H[i+1]-H[i+2]>=1:
      print('No')
      sys.exit()
    else:
      pass
  elif H[i]-H[i+1]>=2:
    print('No')
    sys.exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
import sys
N=int(input())
H=list(map(int,input().split()))
if N==1:
  print('Yes')
  sys.exit()
for i in range(N-1):
  if H[i]<H[i+1]:
    pass
  elif H[i]-H[i+1]==1:
    H[i]-=1
    if H[i+1]-H[i+2]>=1:
      print('No')
      sys.exit()
    else:
      pass
  elif H[i]-H[i+1]>=2:
    print('No')
    sys.exit()
print('Yes')
Problem p02971 (python)

Fixed submission:
N=int(input())
A=[int(input()) for i in range(N)]
max_val=max(A)

def f(A):
  for i in range(N):
    if A[i]==max_val:
      n=i
    else:
      pass
   
  return n
n=f(A)
l=[max_val]*N
A.pop(n)
second_max=max(A)
l[n]=second_max

for i in range(N):
  print(l[i])

Buggy submission (verdict: Runtime Error):

def f(A):
  for i in range(N):
    if A[i]==max_val:
      n=i
    else:
      pass
   
  return n
n=f(A)
l=[max_val]*N
A.pop(n)
second_max=max(A)
l[n]=second_max

for i in range(N):
  print(l[i])
Problem p02993 (python)

Fixed submission:
S=input()
s=str(S)
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
  print('Bad')
else:
  print('Good')

Buggy submission (verdict: Runtime Error):
S=int(input())
l=[]
while S>0:
  l.append(S%10)
  S//=10
if l[0]==l[1] or l[1]==l[2] or l[2]==l[3]:
  print('Bad')
else:
  print('Good')
Problem p03030 (python)

Fixed submission:
N=int(input())
l=[]
for i in range(N):
  s,p=input().split(" ")
  l.append((s,-int(p),i+1))
 
l2=sorted(l,key=lambda x:(x[0],x[1]))
for l in l2:
  print(l[2])

Buggy submission (verdict: Runtime Error):
N=int(input())
l=[]
for i in range(N):
  s,p=input(i).split()
  l.append((s,-int(p),i+1))

list=sorted(l,key=lambda x:(x[0],x[1]))
for i in list:
  print(l[2])
Problem p03608 (python)

Fixed submission:
from itertools import permutations
N,M,R=map(int,input().split())
r=list(map(int,input().split()))
inf=10**9
d=[[inf]*N for i in range(N)]
for i in range(M):
  A,B,C=map(int,input().split())
  d[A-1][B-1]=C
  d[B-1][A-1]=C
for k in range(N):
  for i in range(N):
    for j in range(N):
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])
ans=inf      
for l in permutations(r):
  start=0
  for j in range(R-1):
    start+=d[l[j]-1][l[j+1]-1]
  ans=min(start,ans)
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import permutations
N,M,R=map(int,input().split())
r=[int(i) for i in range(R)]
inf=10**9
d=[[inf]*N for i in range(N)]
for i in range(M):
  A,B,C=map(int,input().split())
  d[A-1][B-1]=C
  d[B-1][A-1]=C
for k in range(N):
  for i in range(N):
    for j in range(N):
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])
ans=inf      
for l in permutations(r):
  start=0
  for j in range(R-1):
    start+=d[l[j]-1][l[j+1]-1]
  ans=min(start,ans)
print(ans)
Problem p02957 (python)

Fixed submission:
def getIntList(): return [int(x) for x in input().split()]

x = getIntList()
if((x[0]+x[1])%2==0):
    print(int((x[0]+x[1])/2))
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
def getInt(): return int(input())

def getIntList(): return [int(x) for x in input().split()]

N = getInt()
A = getIntList()
B = getIntList()
sum = 0
sum += min(A[0],B[0])
sum += min(A[1],B[0]-min(A[0],B[0]))
for i in range(N-1):
    sum += min(A[i+1],B[i+1])
    sum += min(A[i+2],B[i+1]-min(A[i+1],B[i+1]))
print(sum)
Problem p03282 (python)

Fixed submission:
S = int(input())
K = int(input())

lst = [0]*100
while S > 0:
    lst.append(S%10)
    S //= 10 # 必須
lst.reverse()
#print(lst)
j = 0
n = 0
while lst[j] == 1:
    n = j+1
    j += 1
#print('n =',n)
if K <= n:
    print(1)
else:
    print(lst[n])

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

lst = []
while S > 0:
    lst.append(S%10)
    S //= 10 # 必須
lst.reverse()
#print(lst[0])
j = 0
n = 0
while lst[j] == 1:
    n = j+1
    j += 1
#print('n =',n)
if K <= n:
    print(1)
else:
    print(lst[n])

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

lst = []
while S > 0:
    lst.append(S%10)
    S //= 10 # 必須
lst.reverse()
#print(lst[0])
j = 0
n = 0
while lst[j] == 1:
    n = j+1
    j += 1
print('n =',n)
if K <= n:
    print(1)
else:
    print(lst[n])

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

lst = []
i = int(S)
while i > 0:
    lst.append(i%10)
    i //= 10 # 必須
lst.reverse()
print(lst[0])
if K == 1:
    print(lst[0])
else:
    if lst[0] == 1:
        print(lst[1])
    else:
        print(lst[0])
Problem p03455 (python)

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

if (a%2 + b%2)==2:
    print("Odd")
else:
    print("Even")

Buggy submission (verdict: Runtime Error):
a, b = input().split(" ")
a = int(a)
b = int(b)

if a%2 + b%2)==2:
    print("Odd")
else:
    print("Even")
Problem p03766 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from random import *

def readln():
    _res = list(map(int,str(input()).split(' ')))
    return _res

p = 1000000000 + 7

n = readln()[0]
f = [0 for i in range(0,n+10)]
f[1] = n
f[2] = n * n
s = f[:]
s[2] = f[1] + f[2]
for i in range(3,n+1):
    f[i] = f[i-1] + (n - 1) * (n - 1)
    f[i] = f[i] + s[i - 3] + (n - i + 2)
    f[i] = f[i] % p
    s[i] = s[i - 1] + f[i]
    s[i] = s[i] % p
print(f[n])

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from random import *

def readln():
    _res = list(map(int,str(input()).split(' ')))
    return _res

p = 1000000000 + 7

n = readln()[0]
f = [0 for i in range(0,n+1)]
f[1] = n
f[2] = n * n
s = f[:]
s[2] = f[1] + f[2]
for i in range(3,n+1):
    f[i] = f[i-1] + (n - 1) * (n - 1)
    f[i] = f[i] + s[i - 3] + (n - i + 2)
    f[i] = f[i] % p
    s[i] = s[i - 1] + f[i]
    s[i] = s[i] % p
print(f[n])
Problem p03812 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from fractions import gcd

def readln():
    _res = list(map(int,str(input()).split(' ')))
    return _res

def calc(x,line):
    if line == 0:
        for l in v[x]:
            if e[l][0] == x: son = e[l][1]
            else: son = e[l][0]
            if a[son-1] < a[x-1] and calc(son,l) == -1:
                return 1
        return -1
    else:
        if e[line][0] == x: y = 0
        else: y = 1
        if f[line][y] != 0: return f[line][y]
        for l in v[x]:
            if l != line:
                if e[l][0] == x: son = e[l][1]
                else: son = e[l][0]
                if a[son-1] < a[x-1] and calc(son,l) == -1:
                    f[line][y] = 1
                    return 1
        f[line][y] = -1
        return -1

n = int(input())
v = [set([]) for i in range(0,n+1)]
e = [0 for i in range(0,n)]
a = readln()
for i in range(1,n):
    s = readln()
    v[s[0]].add(i)
    v[s[1]].add(i)
    e[i] = s

f = [[0,0] for i in range(0,n)]
ans = []
for i in range(1,n+1):
    if calc(i,0) == 1:
        ans.append(i)
ans = list(map(str,ans))
print(' '.join(ans))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from fractions import gcd

def readln():
    _res = list(map(int,str(input()).split(' ')))
    return _res

def calc(x,line):
    if line == 0:
        for l in v[x]:
            if e[l][0] == x: son = e[l][1]
            else: son = e[l][0]
            if a[son-1] < a[x-1] and calc(son,l) == -1:
                return 1
        return -1
    else:
        if e[line][0] == x: y = 0
        else: y = 1
        if f[x][y] != 0: return f[x][y]
        if len(v[x]) == 1:
            f[x][y] = -1
            return -1
        for l in v[x]:
            if l != line:
                if e[l][0] == x: son = e[l][1]
                else: son = e[l][0]
                if a[son-1] < a[x-1] and calc(son,l) == -1:
                    f[x][y] = 1
                    return 1
        f[x][y] = -1
        return -1

n = int(input())
v = [set([]) for i in range(0,n+1)]
e = [0 for i in range(0,n)]
a = readln()
for i in range(1,n):
    s = readln()
    v[s[0]].add(i)
    v[s[1]].add(i)
    e[i] = s

f = [[0,0] for i in range(0,n)]
ans = []
for i in range(1,n+1):
    if calc(i,0) == 1:
        ans.append(i)
ans = list(map(str,ans))
print(' '.join(ans))
Problem p03005 (python)

Fixed submission:

input_data = input()
n,  k = input_data.split()

n = int(n)
k = int(k)

i  = n - k
max = i + 1
min = 1

if k == 1:
    print(0)
else:
    print(max - min)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = input().split()

for i in range(len(a)):
    a[i] = int(a[i])

x = 0
y = 0

operations = []

for i in range(n-2):
    a_sorted = sorted(a)
    x = a_sorted[0]
    y = a_sorted[1]

    a.remove(x)
    a.remove(y)
    a.append(x-y)
    operations.append(str(x) + " " + str(y))
a_sorted = sorted(a)
a_sorted_reverse = sorted(a_sorted, reverse=True)
x = a_sorted_reverse[0]
a_sorted_reverse.remove(x)
a_sorted = sorted(a_sorted_reverse)
y = a_sorted[0]
operations.append(str(x) + " " + str(y))


a.remove(x)
if y in a:
    a.remove(y)
a.append(x-y)

print(sorted(a, reverse=True)[0])
for i in operations:
    print(i)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = input().split()

for i in range(len(a)):
    a[i] = int(a[i])

x = 0
y = 0

operations = []

for i in range(n-2):
    a_sorted = sorted(a)
    x = a_sorted[0]
    y = a_sorted[1]

    a.remove(x)
    a.remove(y)
    a.append(x-y)
    operations.append(str(x) + " " + str(y))

a_sorted_reverse = sorted(a_sorted, reverse=True)
x = a_sorted_reverse[0]
a.remove(x)
y = sorted(a)[0]
operations.append(str(x) + " " + str(y))


a.remove(x)
if y in a:
    a.remove(y)
a.append(x-y)

print(sorted(a, reverse=True)[0])
for i in operations:
    print(i)
Problem p02993 (python)

Fixed submission:
t=input()
print("Bad") if (t[0]==t[1])or(t[1]==t[2])or(t[2]==t[3]) else print("Good")

Buggy submission (verdict: Runtime Error):
t=input():
print("Bad") if ((t[0]==t[1])or(t[1]==t[2])or(t[2]==t[3])) else print("Good")

Buggy submission (verdict: Runtime Error):
t=input():
print("Bad") if (t[0]==t[1])or(t[1]==t[2])or(t[2]==t[3]) else print("Good")
Problem p02999 (python)

Fixed submission:
a,b=map(int,input().split())
print("10"[1 if a<b else 0:])

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
print("10"[1 if a<b else 2])
Problem p03014 (python)

Fixed submission:
import numpy as np

h,w=map(int,input().split())
s=[]
for i in range(h):
    s.append(list(input()))
grid=(np.array(s) ==".") *1

l=np.zeros((h,w),dtype=int)
r=np.zeros((h,w),dtype=int)
u=np.zeros((h,w),dtype=int)
d=np.zeros((h,w),dtype=int)

for j in range(w):
    if j == 0:
        l[:,j] = grid[:,j]
    else:
        l[:,j] = (l[:,j-1]+1) * grid[:,j]
for j in range(w-1,-1,-1):
    if j == (w-1):
        r[:,j] = grid[:,j]
    else:
        r[:,j] = (r[:,j+1] +1)*grid[:,j]

for i in range(h):
    if i == 0:
        u[i,:]=grid[i,:]
    else:
        u[i,:]=(u[i-1,:]+1)*grid[i,:]
for i in range(h-1,-1,-1):
    if i==(h-1):
        d[i,:]=grid[i,:]
    else:
        d[i,:]=(d[i+1,:]+1)*grid[i,:]


ans=np.max(l+r+u+d-3)
print(ans)

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

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

l=[[0 for i in range(w)] for j in range(h)]
r=[[0 for i in range(w)] for j in range(h)]
d=[[0 for i in range(w)] for j in range(h)]
u=[[0 for i in range(w)] for j in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            if j == o:
                l[i][j]=1
            else:
                l[i][j]=l[i][j-1]+1

for i in range(h):
    for i in range(h-1,-1,-1):
        if s[i][j]==".":
            if j == w-1:
                r[i][j]=1
            else:
                r[i][j]=r[i][j+1]+1

for j in range(w):
    for i in range(h-1,-1,-1):
        if s[i][j]==".":
            if i == h-1:
                d[i][j]=1
            else:
                d[i][j]=d[i+1][j]+1

for j in range(w):
    for i in range(h):
        if s[i][j]=".":
            if i == 0:
                u[i][j]=1
            else:
                i[i][j]=u[i-1][j]+1

ans=0
x=[[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        x[i][j] = l[i][j]+r[i][j]+u[i][j]+d[i][j]-3
    ans=max(ans,max(x[i]))

print(ans)
Problem p03158 (python)

Fixed submission:
n,q = map(int,input().split())
a = list(map(int,input().split()))
x = [int(input()) for _ in range (q)]

sort_x = sorted(x)
ans = {}
if n % 2 == 1:
    small_position = 0
    border_position = int((n-1)/2)
else:
    small_position = 1
    border_position = int(n/2)
sum_all = sum(a[border_position:])
a.append(1000000000)
a.append(1000000000)
x_index = 0
flag = False

for compare in a[border_position:]:
    compare_x = sort_x[x_index]
    small_a = a[small_position]
    while 2*sort_x[x_index] - small_a <= compare:
        ans[sort_x[x_index]] = sum_all
        x_index += 1
        if x_index == q:
            flag = True
            break
    sum_all = sum_all + small_a - compare
    small_position += 2
    if flag:
        break
for x_i in x:
    print(ans[x_i])

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
a = list(map(int,input().split()))
x =[]
for n in range(q):
    x.append(int(input()))

for i in range(q):
    ans = 0
    atemp = a.copy()
    for j in range(n+1):
        if (j % 2) == 0:
            ans += max(atemp)
            atemp.remove(max(atemp))
        else:
            atemprmv = max(atemp)
            deltmin =abs(max(atemp)-x[i])
            for k in range(len(atemp)):
                deltemp = abs(atemp[k]-x[i])
                if deltemp <= deltmin:
                    atemprmv = min(atemprmv,atemp[k])
            atemp.remove(atemprmv)
    print(int(ans))
Problem p02928 (python)

Fixed submission:
N, K = list(map(int, input().split()))
A  = list(map(int, input().split()))
MOD = 10**9+7

#　そのブロック内での転倒数
ans1 = 0
for i in range(N):
    for j in range(i+1,N):
        if A[i] > A[j]:
            ans1 += 1

#　２つのブロック内での転倒数
ans2 = 0
B = sorted(A)
now = B[0]
cnt = 0
for i in range(1,N):
    if now != B[i]:
        cnt = i
        ans2 += cnt
        now = B[i]
    else:
        ans2 += cnt

ans11 = ans1 * K
ans22 = ans2 * (K * (K-1) // 2)
ans = ans11 + ans22
print(ans % MOD)

Buggy submission (verdict: Runtime Error):
N, K = list(map(int, input().split()))
A  = list(map(int, input().split()))
MOD = 10**9+7N, K = list(map(int, input().split()))
A  = list(map(int, input().split()))
MOD = 10**9+7

#　そのブロック内での転倒数
ans1 = 0
for i in range(N):
    for j in range(i+1,N):
        if A[i] > A[j]:
            ans1 += 1

#　２つのブロック内での転倒数
ans2 = 0
B = sorted(A)
now = B[0]
cnt = 0
for i in range(1,N):
    if now != B[i]:
        cnt = i
        ans2 += cnt
        now = B[i]
    else:
        ans2 += cnt

ans11 = ans1 * K
ans22 = ans2 * (K * (K-1) // 2)
ans = ans11 + ans22
print(int(ans % MOD))


#　そのブロック内での転倒数
ans1 = 0
for i in range(N):
    for j in range(i+1,N):
        if A[i] > A[j]:
            ans1 += 1

#　２つのブロック内での転倒数
ans2 = 0
B = sorted(A)
now = B[0]
cnt = 0
for i in range(1,N):
    if now != B[i]:
        cnt = i
        ans2 += cnt
        now = B[i]
    else:
        ans2 += cnt

ans11 = ans1 * (K + 1)
ans22 = ans2 * (K * (K-1) / 2)
ans = ans11 + ans22
print(int(ans % MOD))
Problem p03068 (python)

Fixed submission:
N =int(input())
S = list(input())
K = int(input())

for i in range(N):
    if S[i] == S[K-1]:
        pass
    else:
        S[i] = '*'

print(''.join(S))

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

for i in range(N):
    if S[i] == S[K]:
        pass
    else:
        S[i] = '*'

print(''.join(S))