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

Fixed submission:
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
count = 0
ans = 0
for i in range(n):
  l = list(map(int,input().split()))
  for j in range(m):
    ans += b[j]*l[j]
  if ans +c > 0:
    count += 1
    
  ans = 0
print(count)

Buggy submission (verdict: Runtime Error):
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
count = 0
ans = 0
for i in range(n):
  l = list(map(int,input().split()))
  for j in range(m):
    ans += b[j]*a[j]
  if ans +c > 0:
    count += 1
    
  ans = 0
print(count)

Buggy submission (verdict: Runtime Error):
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
count = 0
ans = 0
for i in range(n):
  l = list(map(int,input().split()))
  for j in range(m):
    ans += b[j]*a[j]
  if ans +c > 0:
    count += 1
    
  ans = 0
print(count
Problem p03106 (python)

Fixed submission:
a,b,k = map(int,input().split())
if b > a:
  a,b = b,a
ans = []
for i in range(b):
  if b % (i+1) == 0:
    if a % (i+1) == 0:
      ans.append(i+1)
print(ans[-k])

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
if b > a:
  a,b = b,a
ans = []
for i in range(b//2+1):
  if b % (i+1) == 0:
    if a % (i+1) == 0:
      ans.append(i+1)
print(ans[-k])
Problem p03126 (python)

Fixed submission:
n,m = map(int,input().split())
ans = [0]*(m+1)
count = 0
for i in range(n):
  l = list(map(int,input().split()))
  for j in range(1,l[0]+1):
    ans[l[j]] += 1
        
for i in ans:
  if i == n:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
ans = [0]*(m+1)
for i in range(n):
  l = list(map(int,input().split()))
  for j in range(1,l[1]+1):
    ans[l[j]] += 1
        
for i in ans:
  if i == n:
    count += 1
print(count)
Problem p03136 (python)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
if 2*max(l)>= sum(l):
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
n = int(input())
l - list(map(int,input().split()))
if max(l)>= sum(l)-2*max(l):
  print("No")
else:
  print("Yes")
Problem p03150 (python)

Fixed submission:
l = list(input())
ans = list("keyence")

minus = len(l)-7

for i in range(len(l)-minus):
  l1 = l[:i]+l[i+minus:]
  
  if l1 == ans:
    print("YES")
    exit()
    
print("NO")

Buggy submission (verdict: Runtime Error):
l = list(input())
ans = list("keyence")
count = 0
check = 0
check2 = 0
for i in range(len(l)):
  if l[i] == ans[count]:
    check2 = 0
    count += 1
  else:
    if check2 == 1:
      continue
    else:
      check += 1
      check2 = 1
  if count == 7 and 1 >= check:
    print("YES")
    exit()
\
print("NO")
Problem p03162 (python)

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
dp = [[0]*3 for i in range(n+1)]

for i in range(n):
    dp[i+1][0] = max(dp[i][1],dp[i][2])+l[i][0]
    dp[i+1][1] = max(dp[i][0],dp[i][2])+l[i][1]
    dp[i+1][2] = max(dp[i][1],dp[i][0])+l[i][2]
    
print(max(dp[n]))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
dp = [[0,-1] for i in range(n+1)]

for i in range(n):
    a = l[i].index(max(l[i]))
    if dp[i][1] == a:
        b = l[i].index(min(l[i]))
        dp[i+1][0],dp[i+1][1] = dp[i][0]+l[i][3-a-b],3-a-b
    else:
        dp[i+1][0],dp[i+1][1] = dp[i][0]+l[i][a],a
    
print(dp[n][0])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
dp = [[0,-1] for i in range(n+1)]

for i in range(n):
    a = l[i].index(max(l[i]))
    if dp[i][1] == a:
        b = l[i].index(min(l[i]))
        dp[i+1][0],dp[i+1][1] = dp[i][0]+l[i][3-a-b],3-a-b
    else:
        dp[i+1][0],dp[i+1][1] = dp[i][0]+l[i][a],a
    
print(dp[n][0])
Problem p03163 (python)

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    n,w = map(int,input().split())
    l = [list(map(int,input().split())) for i in range(n)]

    dp = [[0]*(w+1) for i in range(n+1)]
    for i in range(1,n+1):
        for j in range(w+1):
            if j-l[i-1][0] >= 0:
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-l[i-1][0]]+l[i-1][1])
            else:
                dp[i][j] = dp[i-1][j]
    print(dp[n][w])
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import numpy as np
    import sys
    input = sys.stdin.readline

    n,w = map(int,input().split())
    l = [list(map(int,input().split())) for i in range(n)]

    dp = np.zeros(n+1,w+1)
    for i in range(n):
        dp[i+1,l[i][0]:] = np.maximum(dp[i,l[i][0]:],dp[i,-l[i][0]]+l[i][1])
    print(dp[n][w])

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main()
    import numpy as np
    import sys
    input = sys.stdin.readline

    n,w = map(int,input().split())
    l = [list(map(int,input().split())) for i in range(n)]

    dp = np.zeros(n+1,w+1)
    for i in range(n):
        dp[i+1,l[i][0]:] = np.maximum(dp[i,l[i][0]:],dp[i,-l[i][0]]+l[i][1])
    print(dp[n][w])

if __name__ == "__main__":
    main()
Problem p03169 (python)

Fixed submission:
N=int(input())
A=[int(i) for i in input().split()]
I,J,K=0,0,0
for a in A:
    if a==1:
        I+=1
    if a==2:
        J+=1
    if a==3:
        K+=1
L=I+J+K
M=J+K
dp=[[[0.0]*(K+1) for i in range(M+1)] for i in range(L+1)]
for n in range(1,L+1):#n=i+j+k
    for m in range(min(n,M)+1):#m=j+k
        for k in range(min(m,K)+1):
            j=m-k
            i=n-m
            #print(i,j,k)
            ret=N/(i+j+k)
            if i>0:
                ret+=dp[i-1][j][k]*(i/(i+j+k))
            if j>0:
                ret+=dp[i+1][j-1][k]*(j/(i+j+k))
            if k>0:
                ret+=dp[i][j+1][k-1]*(k/(i+j+k))
            dp[i][j][k]=ret
print(dp[I][J][K])

Buggy submission (verdict: Runtime Error):
def main():
  	import sys
    input = sys.stdin.readline
    
    n = int(input())
    
    l1 = l2 = l3 = 0
    for i in map(int,input().split()):
        if i == 1:
            l1 += 1
        elif i == 2:
            l2 += 1
        else:
            l3 += 1

    a = l2+l3
  	dp = [[[0.0]*(l3+1) for i in range(a+1)] for j in range(n+1)]

  	for i in range(1,n+1):
      	for j in range(min(i,a)+1):
          	for k in range(min(j,l3)+1):
              	s = i-j
              	t = j-k
              	count = n/(s+t+k)
              	if s > 0:
                  	count += dp[s-1][t][k]*(s/(s+t+k))     
              	if t > 0 :
                  	count += dp[s+1][t-1][k]*(t/(s+t+k))
              	if k > 0 :
                	count += dp[s][t+1][k-1]*(k/(s+t+k))

              	dp[s][t][k] = count

	print(dp[l1][l2][l3])
if __name__ == "__main__":
    main()
Problem p03244 (python)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
dic1={}
dic2={}
for i in range(n):
  if i%2==0:
    if l[i] in dic1:
      dic1[l[i]] += 1
    else:
      dic1[l[i]]=1
  else:
    if l[i] in dic2:
      dic2[l[i]] += 1
    else:
      dic2[l[i]]=1
dic1a = sorted(dic1.items(),key = lambda x:x[1])
dic2a = sorted(dic2.items(),key = lambda x:x[1]) 
 
if dic1a[-1][0] == dic2a[-1][0]:
    if len(dic1a) == len(dic2a) == 1:
        print(n//2)
    else:
        if dic1a[-2][1] >= dic2a[-2][1]:
            print(sum(dic2.values())-dic2a[-1][1]+sum(dic1.values())-dic1a[-2][1])
        else:
            print(sum(dic1.values())-dic1a[-1][1]+sum(dic2.values())-dic2a[-2][1])
else:
    print(sum(dic1.values())-dic1a[-1][1]+sum(dic2.values())-dic2a[-1][1])

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
dic1={}
dic2={}
for i in range(n):
  if i%2==0:
    if l[i] in dic1:
      dic1[l[i]] += 1
    else:
      dic1[l[i]].append(1)
  else:
    if l[i] in dic2:
      dic2[l[i]] += 1
    else:
      dic2[l[i]].append(1)
      
count = 0
ma = 0
check=0
for i in dic1.values():
  ma = max(ma,i)
  check += i
count += check-ma
ma = 0
check=0
for i in dic2.values():
  ma = max(ma,i)
  check += i
count += check-ma

print(count)
Problem p03263 (python)

Fixed submission:
h,w = map(int,input().split())
l = [list(map(int,input().split())) for i in range(h)]
count = 0
ans =[]
for i in range(h):
    for j in range(w-1):
        if l[i][j] %2 == 1:
            l[i][j+1] += 1
            ans.append([i+1,j+1,i+1,j+2])
            count += 1
for i in range(h-1):
    if l[i][w-1] %2 == 1:
        count += 1
        l[i+1][w-1] += 1
        ans.append([i+1,w,i+2,w])
print(count)
for i in ans:
    print(*i)

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
l = [list(map(int,input().split())) for i in range(h)]
count = 0
ans =[]
for i in range(h):
    for j in range(w-1):
        if l[i][j] %2 == 1:
            l[i][j+1] += 1
            ans.append([i+1,j+1,i+1,j+2])
            count += 1
for i in range(h-1):
    if l[i][w-1] %2 == 1:
        count += 1
        l[i+1][w-1] += 1
        ans.append([i+1,w,i+2,w])
print(count)
for i in ans:
    print(*i,)
Problem p03282 (python)

Fixed submission:
n = list(input())
k = int(input())
if len(n) == 1:
    print(int(n[0]))
    exit()
x = 0
for i in range(len(n)):
    if n[i] != "1":
        x = i
        break
if x+1 > k:
    print(1)
    exit()
else:
    print(n[x])

Buggy submission (verdict: Runtime Error):
n = list(input())
k = int(input())
if len(n) == 1:
    print(int(n[0]))
    exit()
for i in range(len(n)):
    if n[i] != "1":
        x = i
        break
if i+1 > k:
    print(1)
    exit()
else:
    print(n[x])
Problem p03284 (python)

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

Buggy submission (verdict: Runtime Error):
a,b  map(int,input().split())
if a % b == 0:
  print(0)
else:
  print(1)
Problem p03288 (python)

Fixed submission:
n = int(input())
if n < 1200:
  print("ABC")
elif 1200 <= n < 2800:
  print("ARC")
else:
  print("AGC")

Buggy submission (verdict: Runtime Error):
n = int(input())
if n < 1199:
  print("ABC")
elif n < 2800:
  print("ARC")
else:
  print("AGC)
Problem p03293 (python)

Fixed submission:
s = list(input())
t = list(input())
for i in range(len(s)):
  check = True
  for j in range(len(s)):
    if t[j] != s[(i+j)%len(s)]:
      check = False
  if check:
    print("Yes")
    exit()
      
print("No")

Buggy submission (verdict: Runtime Error):
s = list(input())
t = list(input())
for i in range(len(s)):
  check = True:
    for j in range(len(s)):
      if t[j] != s[(i+j)%len(s)]:
        check = False
    if check:
      print("Yes")
      exit()
      
print("No")
Problem p03318 (python)

Fixed submission:
k = int(input())

l = []
for i in range(17):
    ten = 10**i
    for j in range(1,1000):
        a = ten
        b = j
        n = a*b-1
        if n == 0:
            continue
        s = sum(map(int,str(n)))
        l.append([n/s,n])
l.sort()
now = 0
count = 0
i = 0
while count < k:
    if l[i][1] > now:
        now = l[i][1]
        count += 1
        print(l[i][1])
    i += 1

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

l = []
for i in range(5):
    ten = 10**i
    for j in range(1,100):
        a = ten
        b = j
        n = a*b-1
        if n == 0:
            continue
        s = sum(map(int,str(n)))
        l.append([n/s,n])
l.sort()
now = 0
count = 0
i = 0
while count < k:
    if l[i][1] > now:
        now = l[i][1]
        count += 1
        print(l[i][1])
    i += 1

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

l = []
for i in range(17):
    ten = 10**i
    for j in range(2,11):
        a = ten
        b = j
        n = a*b-1
        s = sum(map(int,str(n)))
        l.append([s,n])
l.sort()

for i in range(k):
    print(l[i][1])
Problem p03323 (python)

Fixed submission:
a,b = map(int,input().split())
if a <= 8 and b <= 8:
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a > 9 or b > 9:
  print(":(")
else:
  print(""Yay!")
Problem p03337 (python)

Fixed submission:
a,b = map(int,input().split())
print(max(a+b,a-b,a*b))

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
print(max(a+b,a-ba*b))
Problem p03370 (python)

Fixed submission:
n,x = map(int,input().split())
l = [int(input()) for i in range(n)]
print((x-sum(l))//min(l)+n)

Buggy submission (verdict: Runtime Error):
n,x = map(int,input().split())
l = [int(input()) for i in range(n)]
print((x-sum(l)//min(l)+n)
Problem p03379 (python)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
l1=sorted(l)
a = l1[n//2-1]
b = l1[n//2]
if a == b:
  for i in range(n):
    print(a)
else:
  for i in l:
    if i <= a:
      print(b)
    else:
      print(a)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [int(input()) for i in range(n)]
l1=sorted(l)
a = l1[n//2]
b = l1[n//2+1]
if a == b:
  for i in range(n):
    print(a)
else:
  for i in l:
    if i <= a:
      print(b)
    else:
      print(a)
Problem p03399 (python)

Fixed submission:
l = [int(input()) for i in range(4)]
print(min(l[0],l[1])+min(l[2],l[3]))

Buggy submission (verdict: Runtime Error):
l = [int(input() for i in range(4)]
print(min(l[0],l[1])+min(l[2],l[3]))

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
print(min(a,b)+min(c,d))
Problem p03416 (python)

Fixed submission:
a,b = map(int,input().split())
count = 0
for i in range(a,b+1):
  l = list(str(i))
  if l == l[::-1]:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
count = 0
for i in range(a,b+1):
  l = list(i)
  if l == l[::-1]:
    count += 1
print(count)
Problem p03425 (python)

Fixed submission:
n = int(input())
l = [0]*5
for i in range(n):
    a = input()
    if a[0] == "M":
        l[0] += 1
    elif a[0] == "A":
        l[1] += 1
    elif a[0] == "R":
        l[2] += 1
    elif a[0] == "C":
        l[3] += 1
    elif a[0] == "H":
        l[4] += 1
    
    
ans = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans += l[i]*l[j]*l[k]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [0]*5
for i in range(n):
  if input()[0] == "M":
    l[0] += 1
  elif input()[0] == "A":
    l[1] += 1
  elif input()[0] == "R":
    l[2] += 1
  elif input()[0] == "C":
    l[3] += 1
  elif input()[0] == "H":
    l[4] += 1
ans = 0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      ans += l[i]*l[j]*l[k]
print(ans)
Problem p03434 (python)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
a = 0
b = 0
l.sort(reverse=True)
for i in range(n):
  if i % 2 == 0:
    a += l[i]
  else:
    b += l[i]
print(a-b)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
a = 0
b = 0
l.sort(reverser=True)
for i in range(n):
  if i % 2 == 0:
    a += l[i]
  else:
    b += l[i]
print(a-b)
Problem p03437 (python)

Fixed submission:
x,y = map(int,input().split())
if x % y:
    print(x)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
if m == n-1:
  print(0)
  exit()
if 2*(n-m-1) > n:
    print("Impossible")
    exit()

class Unionfind:
     
    def __init__(self,n):
        self.uf = [-1]*n
 
    def find(self,x):
        if self.uf[x] < 0:
            return x
        else:
            self.uf[x] = self.find(self.uf[x])
            return self.uf[x]
 
    def same(self,x,y):
        return self.find(x) == self.find(y)
 
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.uf[x] > self.uf[y]:
            x,y = y,x
        self.uf[x] += self.uf[y]
        self.uf[y] = x
        return True
 
    def size(self,x):
        x = self.find(x)
        return -self.uf[x]

u = Unionfind(n)
a = list(map(int,input().split()))
for i in range(m):
    x,y = map(int,input().split())
    u.union(x,y)
count = 2*(n-m-1)
l = [[] for i in range(n)]
for i in range(n):
    x = u.find(i)
    if x < 0:
        l[i].append(a[i])
    else:
        l[x].append(a[i])

ans = 0
h = []
for i in range(n):
    if l[i]:
        l[i].sort()
        ans += l[i][0]
        count -= 1
        for j in l[i][1:]:
            h.append(j)
h.sort()
ans += sum(h[:count])
print(ans)
Problem p03438 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
sa = sum(a)
sb = sum(b)
counta = 0
countb = 0
for i,j in zip(a,b):
    if j > i:
        if (j-i)%2:
            countb += 1
        counta += (j-i+1)//2
    elif i > j:
        countb += i-j
if counta <= sb-sa and countb <= sb-sa:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
sa = sum(a)
sb = sum(b)
counta = 0
countb = 0
for i,j in zip(a,b):
    if j > i:
        if j%i:
            countb += 1
        counta += (j-i+1)//2
    elif i > j:
        countb += i-j
if counta <= sb-sa and countb <= sb-sa:
    print("Yes")
else:
    print("No")
Problem p03448 (python)

Fixed submission:
l = [int(input()) for i in range(3)]
x = int(input())
count = 0
for i in range(l[0]+1):
  for j in range(l[1]+1):
    for k in range(l[2]+1):
      if 500*i+100*j+50*k == x:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
l = [int(input()) for i in range(3)]
x = int(input())
count = 0
for i in range(l[0]+1):
  for j in range(l[1]+1):
    for k in range(l[2]+1):
      if 500*i+100*j+50*c == x:
        count += 1
print(count)
Problem p03456 (python)

Fixed submission:
a,b = input().split()
s = int(a+b)
for i in range(int(s**0.5)+1):
  if s == i**2:
    print("Yes")
    exit()
print("No")

Buggy submission (verdict: Runtime Error):
a,b = input().split()
s = int(a+b)
for i in range(s**0.5+1):
  if s == i**2:
    print("Yes")
    exit()
print("No")
Problem p03474 (python)

Fixed submission:
a,b = map(int,input().split())
l = list(input())
for i in range(a+b+1):
    if i == a:
        if l[i] != "-":
            print("No")
            exit()
    else:
        if l[i] == "-":
            print("No")
            exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
l = list(input())
count = 0
for i in range(a):
  if 0<= int(l[i]) <= 9:
    count += 1
if l[a] != "-":
  print("No")
  exit()
for i in range(a+1,a+b+1):
  if 0<= int(l[i]) <= 9:
    count += 1
if count == a+b:
  print("Yes")
else:
  print("No")
Problem p03477 (python)

Fixed submission:
a,b,c,d = map(int,input().split())
if a+b > c+d:
    print("Left")
elif a+b < c+d:
    print("Right")
else:
    print("Balanced")

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
print("Left" if a+b > c+d elif a+b == c+d "Balanced" else "Right")
Problem p03486 (python)

Fixed submission:
a = list(input())
b = list(input())
a.sort()
b.sort(reverse = True)
if a < b:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a = list(input())
b = list(input())
a.sort()
b.sort(reverse = True)
if a < b:
  print("Yes")
else:
  print("No)
Problem p03502 (python)

Fixed submission:
s = input()
print("Yes" if int(s)%sum(map(int,s))==0 else "No")

Buggy submission (verdict: Runtime Error):
x = int(input())
if x % (sum(map(str(x)))) == 0:
  print("Yes")
else:
  print("No")
Problem p03543 (python)

Fixed submission:
l = list(input())
for i in range(2):
  a = l[i]
  count = 0
  for j in range(i,i+3):
    if a == l[j]:
      count += 1
  if count == 3:
    print("Yes")
    exit()
print("No")

Buggy submission (verdict: Runtime Error):
l = list(input())
for i in range(2):
  a = l[i]
  count = 0
  for j in range(i,i+3):
    if a == l[l]:
      count += 1
  if count == 3:
    print("Yes")
    exit()
print("No")
Problem p03556 (python)

Fixed submission:
print(int(int(input())**0.5)**2)

Buggy submission (verdict: Runtime Error):
print(int(int(input()))**0.5)**2)
Problem p03567 (python)

Fixed submission:
print("Yes" if "AC" in input() else "No")

Buggy submission (verdict: Runtime Error):
print("YES" if "AC" in input() else "NO)
Problem p03569 (python)

Fixed submission:
s = list(input())
ans = 0
l = 0
r = len(s)-1
while l < r:
    if s[l] != s[r]:
        if s[l] == "x":
            ans += 1
            r += 1
        elif s[r] == "x":
            ans += 1
            l -= 1
        else:
            print(-1)
            exit()
    l += 1
    r -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
s = list(input())
n = len(s)
x = s.count("x")
a = n-x
if a%2:
    count = 0
    for i in range(n):
        if s[i] != "x":
            count += 1
        if count == a-a//2:
            ind = i
            break
    count = 0
    l = ind-1
    r = ind+1
    c1 = a//2
    while c1 > 0:
        lc = 0
        while l >= 0 and s[l] == "x":
            l += 1
            lc += 1
        rc = 0
        while r < n and s[r] == "x":
            r += 1
            rc += 1
        if s[l] == s[r]:
            count += abs(lc-rc)
            l -= 1
            r += 1
        else:
            print(-1)
            exit()
        c1 -= 1
    count += abs(n-r-(l+1))
    print(count)
else:
    count = 0
    for i in range(n):
        if s[i] != "x":
            count += 1
        if count == a//2:
            l = i
        elif count == a//2+1:
            r = i
            break
    count = 0
    if s[l] != s[r]:
        print(-1)
        exit()
    c1 = a//2-1
    while c1 > 0:
        lc = 0
        while l >= 0 and s[l] == "x":
            l += 1
            lc += 1
        rc = 0
        while r < n and s[r] == "x":
            r += 1
            rc += 1
        if s[l] == s[r]:
            count += abs(lc-rc)
            l -= 1
            r += 1
        else:
            print(-1)
            exit()
        c1 -= 1
    count += abs(n-r-(l+1))
    print(count)

Buggy submission (verdict: Runtime Error):
s = list(input())
n = len(s)
x = s.count("x")
a = n-x
if a%2:
    count = 0
    for i in range(n):
        if s[i] != "x":
            count += 1
        if count == a-a//2:
            ind = i
            break
    count = 0
    l = ind-1
    r = ind+1
    c1 = a//2
    while c1 > 0:
        lc = 0
        while l >= 0 and s[l] == "x":
            l += 1
            lc += 1
        rc = 0
        while r < n and s[r] == "x":
            r += 1
            rc += 1
        if s[l] == s[r]:
            count += abs(lc-rc)
            l -= 1
            r += 1
        else:
            print(-1)
            exit()
        c1 -= 1
    count += abs(n-r-(l+1))
    print(count)
else:
    count = 0
    for i in range(n):
        if s[i] != "x":
            count += 1
        if count == a//2:
            l = i
        elif count == a//2+1:
            r = i
            break
    count = 0
    c1 = a//2-1
    while c1 > 0:
        lc = 0
        while l >= 0 and s[l] == "x":
            l += 1
            lc += 1
        rc = 0
        while r < n and s[r] == "x":
            r += 1
            rc += 1
        if s[l] == s[r]:
            count += abs(lc-rc)
            l -= 1
            r += 1
        else:
            print(-1)
            exit()
        c1 -= 1
    count += abs(n-r-(l+1))
    print(count)
Problem p03636 (python)

Fixed submission:
l = list(input())
print("{}{}{}".format(l[0],len(l)-2,l[-1]))

Buggy submission (verdict: Runtime Error):
l = list(input())
print("{}{}{}".format(l[0],len(l)-2,l[-1])