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

Fixed submission:
#coding: utf-8

N_list = list(input())

if N_list[0] == N_list[1] == N_list[2]:
	print("Yes")
elif N_list[1] == N_list[2] == N_list[3]:
	print("Yes")
else:
	print("No")

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

N_list = list(input())

if N_list[0] == N_list[1] == N_list[2]:
	print("Yes")
elif N_list[1] == N_list[2] == N_list[3]:
	print("Yes")
elif N_list[2] == N_list[3] == N_list[4]:
	print("Yes")
else:
	print("No")

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

N = input()
N_list = list(N)

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

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

N = input()
N_list = list(N)

if N_list[0] == N_list[1] == N_list[2]:
	print("Yes")
elif N_list[1] == N_list[2] == N_list[3]:
	print("Yes")
elif N_list[2] == N_list[3] == N_list[4]:
	print("Yes")
else:
	print("No")

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

N = input()
N_list = list(N)

if N_list[0] == N_list[1] == N_list[2]:
	print("Yes")
elif N_list[1] == N_list[2] == N_list[3]:
	print("Yes")
elif N_list[2] == N_list[3] == N_list[4]:
	print("Yes")
else :
	print("No")
Problem p03264 (python)

Fixed submission:
def get(n):
    z=((n//2)**2)+(n-1)//2
    if(n%2==0):
        return (n//2)**2
    elif(n==1):
        return 0
    else:
        return z
    
n=int(input())
x=get(n)
print(x)

Buggy submission (verdict: Runtime Error):
def get(n):
z=((n//2)*2)-(n-1)//2
if(n%2==0):
return (n//2)*2
elif(n==1):
return 0
else:
return z
Problem p03262 (python)

Fixed submission:
import functools
import fractions
N,X=map(int,input().split())
x=list(map(int,input().split()))
def minus(n):
  return n-X
x=list(map(minus, x)) 


gcd = functools.reduce(fractions.gcd, x)
print(abs(gcd))

Buggy submission (verdict: Runtime Error):
import functools
import math
N,X=map(int,input().split())
x=list(map(int,input().split()))
def minus(n):
  return n-X
x=list(map(minus, x)) 
gcd = functools.reduce(math.gcd, x)
print(gcd)
Problem p03544 (python)

Fixed submission:
n=int(input())
a=2
b=1
if n==1:
    print(1)
    exit()
else:
    for i in range(2,n+1):
        c=a+b
        a,b=b,c
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=2
b=1
if n==1:
    print(1)
else:
    for i in range(2,n+1):
        c=a+b
        a,b=b,c
print(c)
Problem p03605 (python)

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

Buggy submission (verdict: Runtime Error):
N=int(input())
b=set()
for i in range(N):
    a=int(input())
    if  a in b:
        b.remove(a)
    else:
        b.add(a)
print(len(b))

Buggy submission (verdict: Runtime Error):
N=int(input())
b=set()
for i in range(N):
    a=input()
    if  a in b:
        b.remove(a)
    else:
        b.add(a)
print(len(b))
Problem p03493 (python)

Fixed submission:
x = int(input())
ans = 0
if x//100==1:
    ans+=1
if x%100//10==1:
    ans+=1
if x%10//1 == 1:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
int x = input()
if x/100==1:
    ans++
if x/10==1:
    ans++
if x/1 == 1:
    ans++
print ans
Problem p03647 (python)

Fixed submission:
N,M=map(int,input().split())
a=[]
b=[]
for i in range(0,M):
	c,d=map(int,input().split())
	a.append(c)
	b.append(d)

pos=0
i=0
g=[0 for i in range(0,200000)]
e=[]
f=[]
k=0
l=0
while i < M and pos == 0:
	if a[i] == 1:
		g[b[i]] = 1
	if b[i] == 1:
		g[a[i]] = 1
	i=i+1
i=0
while i < M and pos == 0:
	if a[i] == N:
		if g[b[i]] == 1:
			pos=1
	if b[i] == N:
		if g[a[i]] == 1:
			pos=1
	i = i + 1
if pos == 1:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
a=[]
b=[]
for i in range(0,M):
	c,d=map(int,input().split())
	a.append(c)
	b.append(d)

pos=0
i=0
g=[0 for i in range(0,M)]
print(g)
e=[]
f=[]
k=0
l=0
while i < M and pos == 0:
	if a[i] == 1:
		g[b[i]] = 1
	if b[i] == 1:
		g[a[i]] = 1
	i=i+1
i=0
print(g)
while i < M and pos == 0:
	if a[i] == N:
		if g[b[i]] == 1:
			pos=1
	if b[i] == N:
		if g[a[i]] == 1:
			pos=1
	i = i + 1
if pos == 1:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")
Problem p03243 (python)

Fixed submission:
num=input()
num_list=list(num)
n=len(num)
ans_num=0
element=int(num_list[0])
for i in range(n):
    if element<int(num_list[i]):
        tf=False
        element+=1
        break
print(str(element)*n)

Buggy submission (verdict: Runtime Error):
num=input()
num_list=list(num)
n=len(num)
ans_num=0
element=num_list[0]
while True:
    tf=True
    for i in range(n):
        if element<num_list[i]:
            tf=False
            element+=1
            break
    if tf:
        ans_num=element
        break
print(ans_num*n)

Buggy submission (verdict: Runtime Error):
num=input()
num_list=list(num)
n=len(num)
ans_num=0
element=num_list[0]
while True:
    tf=True
    for i in range(n):
        if element<num_list[i]:
            tf=False
            element+=1
            break
    if tf:
        ans_num=element
        break
print(ans_num*element)

Buggy submission (verdict: Runtime Error):
num=input()
num_list=list(num)
n=len(num)
ans_num=0
element=num_list[0]
while True:
    tf=True
    for i in range(n):
        if element<num_list[i]:
            tf=False
            element+=1
            break
    if tf:
        ans_num=element
        break
print(ans_num*n)
Problem p03260 (python)

Fixed submission:
import math
num=input().split()
a=int(num[0])
b=int(num[1])

if a!=2 and b!=2:
    print("Yes")
else:
    print("No")

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

if a!=2 and b!=2:
    print("Yes")
else:
    print("No")

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

if a!=2 and b!=2:
    print("Yes")
else:
    print("No")

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

if a%2!=0 and b%2!=0:
    print("Yes")
else:
    print("No")

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

if a%2!=0 and b%2!=0:
    print("Yes")
else
    print("No")

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

if a%2==0 and b%2==0:
    print("Yes")
else
    print("No")
Problem p03261 (python)

Fixed submission:
n=int(input())
list=[]
word=input()
list.append(word)
key=word[-1]
flag=True
for i in range(1,n):
    word=input()
    if key==word[0] and (word not in list):
        list.append(word)
        key=word[-1]
    else:
        print("No")
        flag=False
        break
if flag:
    print("Yes")

Buggy submission (verdict: Runtime Error):

n=int(input())
list=[]
word=input()
list.append(list,word)
key=word[-1]
for i in range(1,n):
    word=input()
    if key==word[0] and (word not in list):
        list.append(list,word)
        key=word[-1]
    else:
        print("No")
print("Yes")

Buggy submission (verdict: Runtime Error):

n=input()
word=input()
key=word[-1]
for i in range(1,n):
    word=input()
    if key==word[0]:
        key=word[-1]
    else:
        print("No")
print("Yes")
Problem p03262 (python)

Fixed submission:
num_str=input().split()
num=list(map(int, num_str))
n=num[0]
x=num[1]
num2_str=input().split()
distance=list(map(int, num2_str))

first_distance=list(map(lambda y:abs(y-x),distance))
min_distance=min(first_distance)

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


if n==1:
    print(first_distance[0])
else:
    element = gcd(first_distance[0], first_distance[1])
    if n==2:print(element)
    else:
        for i in range(2,n):
            element=gcd(element,first_distance[i])
        print(element)

Buggy submission (verdict: Runtime Error):
num_str=input().split()
num=list(map(int, num_str))
n=num[0]
x=num[1]
num2_str=input().split()
distance=list(map(int, num2_str))

first_distance=list(map(lambda y:abs(y-x),distance))
min_distance=min(first_distance)

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

gcd=gcd(first_distance[0],first_distance[1])
for i in range(2,n):
    gcd=gcd(gcd,first_distance[i])
print(gcd)

Buggy submission (verdict: Runtime Error):
num_str=input().split()
num=list(map(int, num_str))
n=num[0]
x=num[1]
num2_str=input().split()
distance=list(map(int, num2_str))

first_distance=list(map(lambda y:abs(y-x),distance))
min_distance=min(first_distance)

gcd=gcd(first_distance[0],first_distance[1])
for i in range(2,n):
    gcd=gcd(gcd,first_distance[i])
print(gcd)
Problem p03303 (python)

Fixed submission:
s=input().split()
num=int(input())
ans = ""
for i in range(0, len(s[0]), num):
  ans=ans+s[0][i]
print(ans)

Buggy submission (verdict: Runtime Error):
s=input().split()
num=int(input())
ans = ""
for i in range(0, len(s[0]) + 1, num ):
  ans=ans+s[0][i]
print(ans)

Buggy submission (verdict: Runtime Error):
s=input().split()
num=int(input())
ans = []
for i <= len(s) in range(0, len(s) / num + 1):
  ans = ans.append(s[i])
print(ans)
Problem p03308 (python)

Fixed submission:
n=int(input())
num_str=input().split()
num=list(map(int, num_str))
print(max(num)-min(num))

Buggy submission (verdict: Runtime Error):
n=int(input())
num=int(input().split())
print(max(num)-min(num))

Buggy submission (verdict: Runtime Error):
n=int(input())
num=input().split()
print(max(num)-min(num))

Buggy submission (verdict: Runtime Error):
n=int(input())
num=input.split()
print(num.max()-num.min())
Problem p03243 (python)

Fixed submission:
N=int(input())
 
ans=0

while(True):
  ans+=111
  if(ans>=N):
    print(ans)
    break

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

ans=0
while(True):
   ans+=111
  if(ans>=N):
    print(ans)
    break
Problem p03289 (python)

Fixed submission:
#!/usr/bin/env python3


def main():
    S = list(input())
    judge = True
    if S[0] == "A":
        S[0] = S[0].lower()
    else:
        judge = False
    if S[1] == "C":
        judge = False
    if S[2:-1].count("C") == 1:
        for n, i in enumerate(S):
            if 2 <= n <= len(S) - 1:
                if i == "C":
                    S[n] = S[n].lower()
    else:
        judge = False
    if S[-1] == "C":
        judge = False
    S = "".join(S)
    if S.islower() == False:
        judge = False
    if judge:
        print("AC")
    else:
        print("WA")


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    S = input()
    judge = True
    if S[0] == "A":
        S[0] = S[0].lower()
    else:
        judge = False
    if S[1] == "C":
        judge = False
    if S[2:-2].count("C") == 1:
        for n, i in enumerate(S):
            if 2 <= n <= len(S) - 1:
                if i == "C":
                    S[n] = S[n].lower()
    else:
        judge = False
    if S[-1] == "C":
        judge = False
    if S.islower() == False:
        judge = False
    if judge:
        print("AC")
    else:
        print("WA")


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3


def main():
    S = input()
    judge = 0
    t = S
    if S[0] == "A":
        judge += 1
        S[0] = S[0].lower()
    else:
        print("WA")
        exit()
    if S[1] == "C":
        print("WA")
        exit()
    if S[2:-2].count("C") == 1:
        judge += 1
        for n, i in enumerate(S[2:-2]):
            n += 3
            if i == "C":
                S[n] = S[n].lower()
    else:
        print("WA")
        exit()
    if S[-1] == "C":
        print("WA")
        exit()
    if S.islower():
        judge += 1
    else:
        print("WA")
        exit()
    if judge == 3:
        print("AC")
    else:
        print("WA")
        exit()


if __name__ == '__main__':
    main()
Problem p03273 (python)

Fixed submission:
import math

H,W=(int(i) for i in input().split())
li=[]
for i in range(0,H):
    li2=[]
    S1=input()
    for j in range(0,W):
        li2.append(S1[j])
        #print(li2)

    li.append(li2)
    
#print(li)
Flag=False
#横探索
for i in range(0,H):
    
    for j in range(0,W):
        if (li[i][j]=="." or li[i][j]=="Remove"):
            Flag=True
        else:
            Flag=False
            break

    if Flag==True:
         for j in range(0,W):
            li[i][j]="Remove"
          


    
#横探索
for i in range(0,W):
    
    for j in range(0,H):
         if (li[j][i]=="." or li[j][i]=="Remove"):
            Flag=True
         else:
            Flag=False
            break

    if Flag==True:
         for j in range(0,H):
            li[j][i]="Remove"
       
for i in range(0,H):
    for j in range(0,W):
        if (li[i][j]=="Remove"):
            li[i][j]=""

#print("ans")
for i in range(0,H):
    count=0
    for j in range(0,W):
        
        if (li[i][j]==""):
            Flag=True
            count+=1
        else:
            Flag=False
        
        print(str(li[i][j]),end="")

    if count!=W:
        print("")

Buggy submission (verdict: Runtime Error):
import math



H,W=(int(i) for i in input().split())
li=[]
for i in range(0,H):
    li2=[]
    S1=input()
    for j in range(0,W):
        li2.append(S1[j])
        #print(li2)

    li.append(li2)
    
#print(li)
Flag=False
#横探索
for i in range(0,H):
    
    for j in range(0,W):
        if (li[i][j]=="." or li[i][j]=="Remove"):
            Flag=True
        else:
            Flag=False
            break

    if Flag==True:
         for j in range(0,W):
            li[i][j]="Remove"
          


    
#横探索
for i in range(0,W):
    
    for j in range(0,H):
         if (li[j][i]=="." or li[j][i]=="Remove"):
            Flag=True
         else:
            Flag=False
            break

    if Flag==True:
         for j in range(0,H):
            li[j][i]="Remove"
       
for i in range(0,H):
    for j in range(0,W):
        if (li[i][j]=="Remove"):
            li[i][j]=""

#print("ans")
for i in range(0,H):
    for j in range(0,W):
        if (li[j][i]=="."):
            Flag=True
        else:
            Flag=False
        print(str(li[i][j]),end="")

    if Flag==False:
        print("")
Problem p03316 (python)

Fixed submission:
N=int(input())
Nstring=str(N)
i=0
S=0#各桁の輪
while i<len(Nstring):
    S+=int(Nstring[i])
    i+=1

if N%S==0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N=input()
Nstring=str(N)
i=0
S=0#各桁の輪
while i<len(Nstring):
    S+=int(Nstring[i])
    i+=1

if N%S==0:
    print("Yes")
else:
    print("No")
Problem p03261 (python)

Fixed submission:
import sys
n = int (input())
words = []
No=" "
for i in range (n) :
    words.append(input())
for x in range(len(words)-1):
    if words.count(words[x]) > 1 or words[x+1][0] != words[x][-1]:
        No="No"
        print (No)
        sys.exit() 
if No != "No":
     print ("Yes")

Buggy submission (verdict: Runtime Error):
import sys
n = int (input())
words = []
for i in range (n) :
    words.append(input())
for x in range(len(words)):
    if words.count(words[x]) > 1 or words[x+1][0] != words[x][-1]:
        print("No")
        sys.exit()
    else:
        "Yes"

Buggy submission (verdict: Runtime Error):
import sys
n = int (input())
words = []
for i in range (n) :
    words.append(input())
for x in range(len(words)):
    if words.count(words[x]) > 1 or words[x+1][0] != words[x][-1]:
        print("No")
        sys.exit()
    else:
        "Yes"
Problem p03243 (python)

Fixed submission:
n = int(input())
q = int(n / 111)
if n % 111 == 0:
  i = q
else:
  i = q + 1
print(i * 111)

Buggy submission (verdict: Runtime Error):
 n = int(input())
q = int(n / 111)
if n % 111 == 0:
  i = q
else:
  i = q + 1
print(i * 111)
Problem p03262 (python)

Fixed submission:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def main():
    N,X = (int(i) for i in input().split())
    x=list(map(int,input().split()))

    gcd_l = []
    #gcd_l.append(abs(X-x[0]))

    for i in range(0,N):
        gcd_l.append(abs(X-x[i]))
    if N==1:
        ans = gcd_l[0]
    else:
        a = [gcd_l[0],gcd_l[1]]
        ans = gcd(max(a),min(a))
        for n in range(2,len(gcd_l)):
            a = [ans,gcd_l[n]]
            ans = gcd(max(a),min(a))
    print(ans)

main()

Buggy submission (verdict: Runtime Error):
import math
import functools

def main():
    N,X = (int(i) for i in input().split())
    x=list(map(int,input().split()))

    gcd_l = []
    gcd_l.append(abs(X-x[0]))

    for i in range(1,N):
        gcd_l.append(abs(x[i-1]-x[i]))

    print(functools.reduce(math.gcd,gcd_l))

main()

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def main():
    N,X = (int(i) for i in input().split())
    x=list(map(int,input().split()))

    gcd_l = []
    gcd_l.append(abs(X-x[0]))

    for i in range(1,N):
        gcd_l.append(abs(x[i-1]-x[i]))

    print(reduce(math.gcd,gcd_l))

main()

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

N,X = (int(i) for i in input().split())
x=list(map(int,input().split()))

gcd_l = []
gcd_l.append(abs(X-x[0]))

for i in range(1,N):
    gcd_l.append(abs(x[i-1]-x[i]))

print(reduce(math.gcd,gcd_l))
Problem p03269 (python)

Fixed submission:
import math
L=int(input())-1
  
if L==0:
  print(2,2)
  print(1,2,0)
  exit()
elif L==1:
  print(2,2)
  print(1,2,0)
  print(1,2,1)
  exit()

L2=int(math.log2(L))
LLL=2**(L2-1)
lll=LLL*2-1

branch_list=[]
for x in range(1,L2+1):
  branch_list.append([x,x+1,0])
  branch_list.append([x,x+1,LLL])
  LLL//=2


lll+=1
while True:
  ls=L-lll
  if ls<=0:
    branch_list.append([1,L2+1,lll])
    break
  else:
    ls2=int(math.log2(ls))
    branch_list.append([1,L2+1-ls2,lll])
    lll+=2**ls2

print (L2+1,len(branch_list))
for x,y,z in branch_list:
  print (x,y,z)

Buggy submission (verdict: Runtime Error):
import math
L=int(input())-1
  
if L==0:
  print(2,2)
  print(1,2,0)
  print(1,2,1)
  exit()
LLL=2**(L2-1)
L2=int(math.log2(L))
lll=LLL*2-1

branch_list=[]
for x in range(1,L2+1):
  branch_list.append([x,x+1,0])
  branch_list.append([x,x+1,LLL])
  LLL//=2


lll+=1
while True:
  ls=L-lll
  if ls<=0:
    branch_list.append([1,L2+1,lll])
    break
  else:
    ls2=int(math.log2(ls))
    branch_list.append([1,L2+1-ls2,lll])
    lll+=2**ls2

print (L2+1,len(branch_list))
for x,y,z in branch_list:
  print (x,y,z)

Buggy submission (verdict: Runtime Error):
import math
L=int(input())-1
L2=int(math.log2(L+1))
LLL=2**(L2-1)
lll=LLL*2-1

amount_of_branch=0

branch_list=[]
for x in range(1,L2+1):
  branch_list.append([x,x+1,0])
  branch_list.append([x,x+1,LLL])
  LLL//=2


lll+=1
while True:
  ls=L-lll
  if ls==0:
    branch_list.append([1,L2+1,lll])
    break
  else:
    ls2=int(math.log2(ls))
    branch_list.append([1,L2+1-ls2,lll])
    lll+=2**ls2

print (L2+1,len(branch_list))
for x,y,z in branch_list:
  print (x,y,z)

Buggy submission (verdict: Runtime Error):
import math
L=int(input())-1
L2=int(math.log2(L+1))
LLL=2**(L2-1)
lll=LLL*2-1

amount_of_branch=0

branch_list=[]
for x in range(1,L2+1):
  branch_list.append([x,x+1,0])
  branch_list.append([x,x+1,LLL])
  LLL//=2

print(L2)

lll+=1
while True:
  ls=L-lll
  print (lll)
  if ls==0:
    branch_list.append([1,L2+1,lll])
    break
  else:
    ls2=int(math.log2(ls))
    branch_list.append([1,L2+1-ls2,lll])
    lll+=2**ls2

print (L2+1,len(branch_list))
for x,y,z in branch_list:
  print (x,y,z)
Problem p04044 (python)

Fixed submission:
import sys
t_list = []
for i in sys.stdin.readlines():
    t_list.append(i.rstrip())
t_list.pop(0)

def solution(t_list):
    t_list.sort()
    ans_str = ""
    for i in t_list:
        ans_str += i
    return ans_str
    
def main():
    print(solution(t_list))
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
d = input().rstrip()
d_list = d.split(" ")
t_list = []
for i in range(int(d_list[1])):
    t_list.append(str(input().rstrip()))


def solution(t_list):
    t_list.sort()
    ans_str = ""
    for i in t_list:
        ans_str += i
    return ans_str
    
def main():
    print(solution(t_list))
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
d = input().rstrip()
d_list = d.split(" ")
t_list = []
for i in range(int(d_list[1])):
    t_list.append(input().rstrip())


def solution(t_list):
    t_list.sort()
    ans_str = ""
    for i in t_list:
        ans_str += i
    return ans_str
    
def main():
    print(solution(t_list))
    
if __name__ == '__main__':
    main()
Problem p03246 (python)

Fixed submission:
from collections import Counter


def check(A):
    N = len(A)
    even = Counter()
    odd = Counter()
    for i, a in enumerate(A):
        if i % 2 == 0:
            odd[a] += 1
        else:
            even[a] += 1
    
    even = even.most_common() + [(None, 0)]
    odd = odd.most_common() + [(None, 0)]
    
    if even[0][0] != odd[0][0]:
        return N - even[0][1] - odd[0][1]
    else:
        return min(N - even[0][1] - odd[1][1], N - odd[0][1] - even[1][1])

N = int(raw_input())
A = map(int, raw_input().split())

ans = check(A)
print ans

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

def check(A):
    N = len(A)
    even = Counter()
    odd = Counter()
    for i, a in enumerate(A):
        if i % 2 == 0:
            odd[a] += 1
        else:
            even[a] += 1
    
    even = even.most_common() + [(None, 0)]
    odd = odd.most_common() + [(None, 0)]
    
    if even[0][0] != odd[0][0]:
        return N - even[0][1] - odd[0][1]
    else:
        return min(N - even[0][1] - odd[1][1], N - odd[0][1] - even[1][1])
    
A = map(int, raw_input.split())
ans = check(A)
print A
Problem p03569 (python)

Fixed submission:
import sys

S = sys.stdin.readline().strip()

N = len(S)

pl = 0
pr = N

res = 0

while pl < pr:
    cnt = 0

    while pl < N and S[pl] == 'x':
        cnt += 1
        pl += 1

    while 0 < pr and S[pr - 1] == 'x':
        cnt -= 1
        pr -= 1

    res += abs(cnt)

    if 0 < pr and pl < N and S[pl] != S[pr - 1]:
        print(-1)
        sys.exit()

    pl += 1
    pr -= 1

print(res)

Buggy submission (verdict: Runtime Error):
import sys

S = sys.stdin.readline().strip()

pl = 0
pr = len(S)

res = 0

while pl < pr:
    cnt = 0

    while S[pl] == 'x':
        cnt += 1
        pl += 1

    while S[pr - 1] == 'x':
        cnt -= 1
        pr -= 1

    res += abs(cnt)

    if S[pl] != S[pr - 1]:
        print(-1)
        sys.exit()

    pl += 1
    pr -= 1

print(res)