Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(input())
for i in range(n):
    if a[i] == 'E':
        a[i] = 1
    else:
        a[i] = 0

ans = 99999999999999999999
# print(a)
for i in range(n-1):
    l = 0
    r = 0
    if i > 0:
        l = sum(a[0:i])
        # print("l",a[0:i])
        l = abs(i-l)
    if i < n-1:
        # print("r",a[i+1:])
        r = sum(a[i+1:])
    # print(i,l,r)
    ans = min(l+r,ans)
print(ans)



Fixed submission:
n = int(input())
a = list(input())
for i in range(n):
    if a[i] == 'E':
        a[i] = 1
    else:
        a[i] = 0

ans = 99999999999999999999
# print(a)
l = 0
r = sum(a)
for i in range(n):

    if i == 0:
        if a[i] == 1:
            r -= a[i]
            a[i] = 0
        else:
            a[i] = 1
        l = 0
    else:
        if a[i] == 1:
            a[i] = 0
            r -= 1
        else:
            a[i] = 1
        l += a[i-1]

    ans = min(l+r,ans)
    # print(i,l,r,ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0] * n
b = [0]*n
for i in range(n):
    a[i],b[i] = list(map(int,input().split()))
amax = max(a)
bmin = min(b)
ans = 0

for i in range(bmin):
    amax += 1

print(amax)


Fixed submission:
n = int(input())
a = [0] * n
b = [0] * n
amax = 1
bmin = 9999999990
for i in range(n):
    a[i],b[i] = list(map(int,input().split()))
amax = max(a)
bmin = min(b)
ans = amax +bmin

print(ans)
Buggy python submission (verdict: Runtime Error):
s = list(input())
if len(s) < 4:
    print('No')
    exit

if s[0] == 'Y' and s[1] == 'A' and s[2] == 'K' and s[3] == 'I':
    print('Yes')
else:
    print('No')

Fixed submission:
s = list(input())
if len(s) < 4:
    print('No')
    exit()

if s[0] == 'Y' and s[1] == 'A' and s[2] == 'K' and s[3] == 'I':
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
s = list(input())
if s[0] == 'Y' and s[1] == 'A' and s[2] == 'K' and s[3] == 'I':
    print('Yes')
else:
    print('No')


Fixed submission:
s = list(input())
if len(s) < 4:
    print('No')
    exit()

if s[0] == 'Y' and s[1] == 'A' and s[2] == 'K' and s[3] == 'I':
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
ans = 0
if k in l:
    print("POSSIBLE")
    exit()
if n == 1:
    l[0] == k

la = []
while True:
    for i in range(n):
        x = l[i] - k
        xx = l[i] + k
        if x in l or xx in l :
            ans = 1
            break
        else:
            if x not in la:
                la.append(x)
            if xx not in la:
                la.append(x)
        for j in range(i,n):
            a = abs(l[j] - l[i])
            if a == k:
                ans = 1
                break
            else:
                if a in la:
                    ans = 1
                    break
                if a not in l:
                    l.append(a)
                x = a - k
                xx = a + k
                if x in l or xx in l :
                    ans = 1
                    break
                else:
                    if x not in la:
                        la.append(x)
                    if xx not in la:
                        la.append(x)

    _n = n
    n = len(l)
    if n == _n:
        break

if ans == 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
m = max(l)
for i in range(1,n):
    l[i] = gcd(max(l[i],l[i-1]),min(l[i],l[i-1]))
if k%l[-1] == 0 and k <= m:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
ans = 0
if k in l:
    print("POSSIBLE")
    exit()

while True:
    for i in range(n-1):
        for j in range(i+1,n):
            a = abs(l[j] - l[i])
            if a == k:
                ans = 1
                break
            else:
                if a not in l:
                    l.append(a)
    _n = n
    n = len(l)
    if n == _n:
        break

if ans == 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
m = max(l)
for i in range(1,n):
    l[i] = gcd(max(l[i],l[i-1]),min(l[i],l[i-1]))
if k%l[-1] == 0 and k <= m:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
def sa(_a,_b):
    a = max(_a,_b)
    b = min(_a,_b)
    return a-b

n = int(input())
l = list(map(int,input().split()))
m = sum(l)
a = l[0]
b = m - a
ans = sa(a,b)
for i in range(1,len(l)-1):
    a += l[i]
    b -= l[i]
    ans = min(ans,sa(a,b))
print(ans)


Fixed submission:
a,b = list(map(int,input().split()))
if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:
    print('Possible')
else:
    print('Impossible')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
even = n%2
ans = []
s = list(map(int,(input().split())))
for i in range(n):
    if i%2 != even:
        ans.insert(0,s[i])
    else:
        ans.append(s[i])
print(" ".join(map(str,ans)))


Fixed submission:
n = int(input())
even = 0
if n % 2 == 0:
    even = 1

el = []
ol = []
#n偶数のとき逆順奇数列＋普通の偶数列
s = list(map(int,(input().split())))
for i in range(n):
    if i%2 ==0:#guusuu
        el.append(s[i])
    else:
        ol.append(s[i])
if even == 1:#偶数のとき
    ol.reverse()
    ol.extend(el)
    print(" ".join(map(str,ol)))
else:
    el.reverse()
    el.extend(ol)
    print(" ".join(map(str,el)))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

N = int(input())
A = list(map(int,input().split()))

l_max = len(A)
#print(l_max)
r = 0
count = l_max

for l in range(0, l_max):
    bitSums = A[l]
    Sums = A[l]
    for r in range(l+1, l_max):
        bitSums = bitSums ^ A[r]
        Sums = Sums + A[r]
        #print(Sums)
        if bitSums == Sums:
            count += 1

print(count)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ps=0
xs=0
c=0
j=0
for i in range(n):
  ps+=a[i]
  xs^=a[i]
  while ps!=xs:
    ps-=a[j]
    xs^=a[j]
    j+=1
  c+=i-j+1
print(c)
Buggy python submission (verdict: Runtime Error):
inputs = split(input())
ans = inputs[0] - inputs[1] if inputs[3] % 2 == 0 else inputs[1] - inputs[0]
if ans > 10**18:
  print("Unfair")
else:
  print(ans)

Fixed submission:
inputs = [int(c) for c in input().split()]
ans = inputs[0] - inputs[1] if inputs[3] % 2 == 0 else inputs[1] - inputs[0]
if ans > 10**18:
  print("Unfair")
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = []
for i in range(N):
    a.append(input()) 
R=int(a[0])
G=int(a[1])
print(2*G-R)

Fixed submission:
a = []
for i in range(2):
    a.append(input()) 
R=int(a[0])
G=int(a[1])
print(2*G-R)

Buggy python submission (verdict: Runtime Error):
hoge=[]
for i in range(0,1):
  a=int(input())
  hoge.append(a)
R=hoge[0]
G=hoge[1]
print(2*G-R)

Fixed submission:
a = []
for i in range(2):
    a.append(input()) 
R=int(a[0])
G=int(a[1])
print(2*G-R)

Buggy python submission (verdict: Runtime Error):
hoge=[]
for i in range(0,1):
  a=int(input())
  hoge.append(a)
N=2*G-R
print(N)

Fixed submission:
a = []
for i in range(2):
    a.append(input()) 
R=int(a[0])
G=int(a[1])
print(2*G-R)

Buggy python submission (verdict: Runtime Error):
R=input()
G=input()
N=2*G-R
print(N)

Fixed submission:
a = []
for i in range(2):
    a.append(input()) 
R=int(a[0])
G=int(a[1])
print(2*G-R)

Buggy python submission (verdict: Runtime Error):
R,G=(float(i) for i in input().split())
N=2*G-R
print(N)

Fixed submission:
a = []
for i in range(2):
    a.append(input()) 
R=int(a[0])
G=int(a[1])
print(2*G-R)
Buggy python submission (verdict: Runtime Error):
X,A,B=(int(i) for i in input().split())
c=int(B-A)
if c<0:
  print('delicious')
elif c<X+1:
  print('safe')
elif: c>X+1:
  print('dangerous')

Fixed submission:
X,A,B=(int(i) for i in input().split())
c=int(B-A)
if c<=0:
  print('delicious')
elif 0<c<=X:
  print('safe')
elif c>X:
  print('dangerous')
Buggy python submission (verdict: Runtime Error):
K,S=map(int,input().split())
b=sum(0<=S-x-y<=K  for x in range(K+1)for y in range(K+1))
print(sum

Fixed submission:
K,S=map(int,input().split())
b=sum(0<=S-x-y<=K  for x in range(K+1)for y in range(K+1))
print(b)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
K,S = (int(i) for i in input().split()) 
A=()
for i in range(K+1):
    A=A+(i,)

L=list(itertools.combinations_with_replacement(A,3))
SUM=0
for i in range(len(L)):
    if L[i][0]+L[i][1]+L[i][2]==S:
        if len(L[i]) == len(set(L[i])) + 2:
            SUM = SUM + 1  # sonomama! 3tu tyouhuku
        if len(L[i]) == len(set(L[i])) + 1:
            SUM = SUM + 3  # kakeru3 2tu tyouhuku
        if len(L[i]) == len(set(L[i])):  # kakeru6 tyouhuku 0
            SUM = SUM + 6

print(SUM)

Fixed submission:
K,S=map(int,input().split())
b=sum(0<=S-x-y<=K  for x in range(K+1)for y in range(K+1))
print(b)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,x=(int(i) for i in input().split())
c=0#count the devider
for i in range(a,b+1):
       if i%x==0:
       	c+=1
print(c)

Fixed submission:
a,b,x=(int(i) for i in input().split())
print(b//x-(a-1)//x)
Buggy python submission (verdict: Runtime Error):
#-*-cording:utf-8-*-
N = int(input())
A = input().split()
A.sort()
A.reverse()
a=list(map(int,A))
Alice = a[1::2]
Bob = a[0::2]
allA=sum(Alice)
allB=sum(Bob)
Ans=allA-allB
print(Ans)
~            

Fixed submission:
#-*-cording:utf-8-*-
N = int(input())
A = int(input())

num=N//500
NUM=N-500*num
if NUM <= A:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
a,b =map(int,input().split())
N =str(a)+str(b)
int(ans)= math.sqrt(int(N))
if int(N)==ans*ans:
    print("Yes")
else:
    print("No")

Fixed submission:
# -*- coding: utf-8 -*-
a,b =map(int,input().split())
N=a*b
if 0==N%2:
    print("Even")
else:
    print("Odd")
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
a,b =map(int,input().split())
N =str(a)+str(b)
c=2
while True:
    if int(N)/c==c:
        ANS=1
        break
    else:
        c+=1
if ANS==1:
    print("Yes")
else:
    print("No")

Fixed submission:
# -*- coding: utf-8 -*-
import math
a,b =map(int,input().split())
N =str(a)+str(b)
ans= math.sqrt(int(N))
ans = math.floor(ans)
if int(N)==ans*ans:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
A,B,C,D = map(int, input().split())
L = A + B
if L == R:
    print("Balanced")
elif L <= R:
    print("Right")
else :
    print("Left")

Fixed submission:
# -*- coding: utf-8 -*-
A,B,C,D = map(int, input().split())
L = A + B
R = C + D
if L == R:
    print("Balanced")
elif L < R:
    print("Right")
else :
    print("Left")

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
A = input()
B = input()
C = input()
D = input()
L = A + B
R = C + D
if L == R:
    print("Balanced")
elif L <= R:
    print("Right")
else :
    print("Left")

Fixed submission:
# -*- coding: utf-8 -*-
A,B,C,D = map(int, input().split())
L = A + B
R = C + D
if L == R:
    print("Balanced")
elif L < R:
    print("Right")
else :
    print("Left")

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
  2 
  3 A = input()
  4 B = input()
  5 C = input()
  6 D = input()
  7 L = A + B
  8 R = C + D
  9 if L == R:
 10     print("Balanced")
 11 elif L <= R:
 12     print("Right")
 13 else :
 14     print("Left")

Fixed submission:
# -*- coding: utf-8 -*-
A,B,C,D = map(int, input().split())
L = A + B
R = C + D
if L == R:
    print("Balanced")
elif L < R:
    print("Right")
else :
    print("Left")
Buggy python submission (verdict: Runtime Error):
print(r.text[:300] + '...')

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

Buggy python submission (verdict: Runtime Error):
A

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

Buggy python submission (verdict: Runtime Error):
CODE

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

Buggy python submission (verdict: Runtime Error):
from sys import exit
r, s = map(int, input().split())
a = [input() for i in range(r)]

def check(x):
    cnt = [0 for i in range(300)]
    for i in x:
        cnt[ord(i)] += 1
    odd = sum(i % 2 for i in cnt)
    if odd != len(x) % 2:
        print('NO')
        exit(0)

midr, mids = None, None

dr = dict()
for i in range(r):
    b = tuple(sorted(a[i]))
    if b not in dr:
        dr[b] = 1
    else:
        dr[b] += 1
odd = 0
for k in dr:
    if dr[k] % 2 == 1:
        odd += 1
        midr = k
if odd != r % 2:
    print('NO')
    exit(0)
if odd == 1:
    check(midr)

ds = dict()
for j in range(s):
    b = tuple(sorted([a[i][j] for i in range(r)]))
    if b not in ds:
        ds[b] = 1
    else:
        ds[b] += 1
odd = 0
for k in ds:
    if ds[k] % 2 == 1:
        odd += 1
        mids = k
if odd != s % 2:
    print('NO')
    exit(0)
if odd == 1:
    check(mids)

if mids:
    for k in dr:
        indeksi = [i for i in range(r) if tuple(sorted(a[i])) == k]
        check([mids[i] for i in indeksi])
if midr:
    for k in ds:
        indeksi = [j for j in range(s) if tuple(
            sorted([a[i][j] for i in range(r)])) == k]
        check([midr[j] for j in indeksi])

print('YES')


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
i, j = b[n // 2 - 1], b[n // 2]
for x in a:
    if x <= i:
        print(j)
    else:
        print(i)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [[] for i in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    a[l].append((r, d))
    a[r].append((l, -d))

bio = [None for i in range(n)]
def dfs(x):
    for y, d in a[x]:
        if bio[y] is None:
            bio[y] = bio[x] + d
            if not dfs(y):
                return False
        elif bio[y] != bio[x] + d:
            return False
    return True

for i in range(n):
    if bio[i] is None:
        bio[i] = 0
        if not dfs(i):
            print('No')
            exit(0)
print('Yes')


Fixed submission:
import sys
sys.setrecursionlimit(200002)

n, m = map(int, input().split())
a = [[] for i in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    a[l].append((r, d))
    a[r].append((l, -d))

bio = [None for i in range(n)]
def dfs(x):
    for y, d in a[x]:
        if bio[y] is None:
            bio[y] = bio[x] + d
            if not dfs(y):
                return False
        elif bio[y] != bio[x] + d:
            return False
    return True

for i in range(n):
    if bio[i] is None:
        bio[i] = 0
        if not dfs(i):
            print('No')
            exit(0)
print('Yes')
Buggy python submission (verdict: Runtime Error):
n, _, y = map(int, input().split())
a = list(map(int, input().split()))
a = [y] + a

memo = [[-1 for i in range(n + 1)] for j in range(2)]
def sol(i, turn):
    # ovaj drugi ima a[i]
    if memo[turn][i] != -1:
        return memo[turn][i]
    best = abs(a[i] - a[n])
    for j in range(i + 1, n):
        pot = sol(j, 1 - turn)
        if turn == 0:
            best = max(best, pot)
        else:
            best = min(best, pot)
    memo[turn][i] = best
    return best

print(sol(0, 0))

Fixed submission:
import sys
sys.setrecursionlimit(10**4)
n, _, y = map(int, input().split())
a = list(map(int, input().split()))
a = [y] + a

memo = [[-1 for i in range(n + 1)] for j in range(2)]
def sol(i, turn):
    # ovaj drugi ima a[i]
    if memo[turn][i] != -1:
        return memo[turn][i]
    best = abs(a[i] - a[n])
    for j in range(i + 1, n):
        pot = sol(j, 1 - turn)
        if turn == 0:
            best = max(best, pot)
        else:
            best = min(best, pot)
    memo[turn][i] = best
    return best

print(sol(0, 0))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = sorted(list(map(int, input().split())))
m = int(input())
b = sorted(list(map(int, input().split())))
i = 0
for x in b:
    while i < n and a[i] < x:
        i += 1
    if i < n and a[i] == x:
        i += 1
    else:
        print('NO')
        exit(0)
print('YES')
satja@satja:~/k

Fixed submission:
n = int(input())
a = sorted(list(map(int, input().split())))
m = int(input())
b = sorted(list(map(int, input().split())))
i = 0
for x in b:
    while i < n and a[i] < x:
        i += 1
    if i < n and a[i] == x:
        i += 1
    else:
        print('NO')
        exit(0)
print('YES')
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
sus = [[] for i in range(n)]
eq = [1 for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    sus[a - 1].append(b - 1)
    sus[b - 1].append(a - 1)

valid = [True for i in range(n)]

def dfs(x):
    ret = 1
    valid[x] = False
    for y in sus[x]:
        if valid[y]:
            valid[y] = False
            ret += dfs(y)
    return ret

color = [-1 for i in range(n)]
sol = 0
cnt = [0, 0]

def boji(x):
    global cnt
    cnt[color[x]] += 1
    for y in sus[x]:
        if color[y] == -1:
            color[y] = 1 - color[x]
            if boji(y):
                return True
        elif color[y] == color[x]:
            return True
    return 0

for i in range(n):
    if color[i] == -1 and valid[i]:
        cnt = [0, 0]
        color[i] = 0
        if boji(i) == 0:
            sol += cnt[0] * cnt[1]
        else:
            d = dfs(i)
            sol += d * (d - 1) // 2
print(sol - m)


Fixed submission:
import sys
sys.setrecursionlimit(10**5 + 1)

n, m = map(int, input().split())
sus = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    sus[a - 1].append(b - 1)
    sus[b - 1].append(a - 1)

valid = [True for i in range(n)]

def dfs(x):
    ret = 1
    valid[x] = False
    for y in sus[x]:
        if valid[y]:
            valid[y] = False
            ret += dfs(y)
    return ret

color = [-1 for i in range(n)]
sol = 0
cnt = [0, 0]

def boji(x):
    global cnt
    cnt[color[x]] += 1
    for y in sus[x]:
        if color[y] == -1:
            color[y] = 1 - color[x]
            if boji(y):
                return True
        elif color[y] == color[x]:
            return True
    return 0

for i in range(n):
    if color[i] == -1 and valid[i]:
        cnt = [0, 0]
        color[i] = 0
        if boji(i) == 0:
            sol += cnt[0] * cnt[1]
        else:
            d = dfs(i)
            sol += d * (d - 1) // 2
print(sol - m)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
a = [int(i) for i in input().split(" ")]
a = np.array(a,dtype='int')
def count(a):
    return [1 if i==1 or i== 0 or i == -1 else 0 for i in a]
if N == 1:
    print(1)
else:
    min_ = min(a)-1
    max_ = max(a)+1
    ans = -1
    for K in range(min_,max_):
        b = a - K
        tmp = sum(count(b))
        if ans < tmp:
            ans = tmp
    print(ans)


Fixed submission:
from collections import defaultdict
N = int(input())
a = [int(i) for i in input().split(" ")]
dic_num=defaultdict(int)

for i in a:
    dic_num[i] += 1
ans = -1
for X in range(min(a),max(a)+1):
    tmp = (dic_num[X-1] + dic_num[X] + dic_num[X+1])
    if ans < tmp:
        ans = tmp
print(ans)

Buggy python submission (verdict: Runtime Error):
rt numpy as np
N = int(input())
a = [int(i) for i in input().split(" ")]
a = np.array(a,dtype='int')
def count(a):
    return [1 if i==1 or i== 0 or i == -1 else 0 for i in a]
if N == 1:
    print(1)
else:
    min_ = min(a)-1
    max_ = max(a)+1
    ans = -1
    for K in range(min_,max_):
        b = a - K
        tmp = sum(count(b))
        if ans < tmp:
            ans = tmp
    print(ans)

Fixed submission:
from collections import defaultdict
N = int(input())
a = [int(i) for i in input().split(" ")]
dic_num=defaultdict(int)

for i in a:
    dic_num[i] += 1
ans = -1
for X in range(min(a),max(a)+1):
    tmp = (dic_num[X-1] + dic_num[X] + dic_num[X+1])
    if ans < tmp:
        ans = tmp
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = [int(i) for i in input().split(" ")]
a_sum = sum(a)
ans = 100000000000

for i in range(1,N):
    x = sum(a[0:i])
    y = a_sum - x
    tmp = abs(x-y)
    if ans >= tmp :
        ans = tmp
print(ans)


Fixed submission:
N = int(input())
a = [int(i) for i in input().split(" ")]
a_sum = sum(a)
ans = 100000000000
x = a[0]
y = a_sum - x
if N == 2:
    print(abs(x-y))
else:
    ans = abs(x-y)
    for i in range(1,N-1):
        x += a[i]
        y -= a[i]
        tmp = abs(x-y)
        if ans >= tmp :
            ans = tmp
    print(ans)
Buggy python submission (verdict: Runtime Error):
S = list(input())
length = len(S)
if length == 2:
    ans = 0
if length % 2 == 1:
    length -= 1
    ans = 0
else:
    length -= 2

def hantei(list_str,n):
    k = int(n/2)
    if list_str[0:k] == list_str[k:n]:
        return n
    else:
        return 0

while length != 2:
        ans = hantei(S,length)
        if ans != 0:
            break
        length -= 2

if ans == 0 :
    print(1)
else:
    print(ans)

Fixed submission:
def hantei(list_str,n):
    k = int(n/2)
    if list_str[0:k] == list_str[k:n]:
        return n
    else:
        return 0
S = list(input())
length = len(S)
flag = 0
if length == 2:
    print(0)
    flag = 1
elif length == 3:
    length -= 1
    ans = hantei(S,2)
    print(ans)
    flag = 1
elif length % 2 == 1:
    length -= 1
    ans = 0
else:
    length -= 2
    ans = 0
while length >= 2:
        ans = hantei(S,length)
        if ans != 0:
            break
        length -= 2

if flag == 0:
    if ans == 0:
        print(1)
    else:
        print(ans)

Buggy python submission (verdict: Runtime Error):
S = list(input())
length = len(S)
if length % 2 == 1:
    length -= 1
else:
    length -= 2

def hantei(list_str,n):
    k = int(n/2)
    if list_str[0:k] == list_str[k:n]:
        return n
    else:
        return 0

while length != 2:
        ans = hantei(S,length)
        if ans != 0:
            break
        length -= 2

if ans == 0 :
    print(1)
else:
    print(ans)

Fixed submission:
def hantei(list_str,n):
    k = int(n/2)
    if list_str[0:k] == list_str[k:n]:
        return n
    else:
        return 0
S = list(input())
length = len(S)
flag = 0
if length == 2:
    print(0)
    flag = 1
elif length == 3:
    length -= 1
    ans = hantei(S,2)
    print(ans)
    flag = 1
elif length % 2 == 1:
    length -= 1
    ans = 0
else:
    length -= 2
    ans = 0
while length >= 2:
        ans = hantei(S,length)
        if ans != 0:
            break
        length -= 2

if flag == 0:
    if ans == 0:
        print(1)
    else:
        print(ans)