Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def read():
	return [int(i) for i in input().split(' ')]
W, H, N = read()
x = [0] * N
y = [0] * N
a = [0] * N
for i in range(N):
	x[i], y[i], a[i] = read()
new_x = [0] + x + [W]
new_y = [0] + y + [H]
for inx in range(N):
	if(a[inx] == 1):
		new_x = [num for num in new_x if num >= x[inx]] 
	elif(a[inx] == 2):
		new_x = [num for num in new_x if num <= x[inx]] 
	elif(a[inx] == 3):
		new_y = [num for num in new_y if num >= y[inx]] 
	else:
		new_y = [num for num in new_y if num <= y[inx]] 
area = (max(new_x) - min(new_x)) * (max(new_y) - min(new_y))
print(area)


Fixed submission:
def read():
	return [int(i) for i in input().split(' ')]
W, H, N = read()
x = [0] * N
y = [0] * N
a = [0] * N
for i in range(N):
	x[i], y[i], a[i] = read()
new_x = [0] + x + [W]
new_y = [0] + y + [H]
for inx in range(N):
	if(a[inx] == 1):
		new_x = [num for num in new_x if num >= x[inx]] 
	elif(a[inx] == 2):
		new_x = [num for num in new_x if num <= x[inx]] 
	elif(a[inx] == 3):
		new_y = [num for num in new_y if num >= y[inx]] 
	else:
		new_y = [num for num in new_y if num <= y[inx]] 
if(not(new_x) or not(new_y)):
	print(0)
	exit()
area = (max(new_x) - min(new_x)) * (max(new_y) - min(new_y))
print(area)
Buggy python submission (verdict: Time Limit Exceeded):
def read():
	return [int(i) for i in input().split(' ')]
N, T = read()
A = read()
expect = 0
route = set()
length = len(A)
for i in range(length):
	buy = A[i]
	for j in range(i + 1, length):
		benefit = A[j] - buy
		if(benefit > expect):
			expect = benefit
			route = set([i, j])
		elif(benefit == expect):
			if(i not in route and j not in route):
				route.add(i)
				route.add(j)
cost = len(route) >> 1
print(cost)


Fixed submission:
def read():
	return [int(i) for i in input().split(' ')]
N, T = read()
A = read()
t_min = A[0]
cost = 1
profit = 0

for p in A:
	if(p < t_min):
		t_min = p
	elif(p - t_min == profit):
		cost += 1
	elif(p - t_min > profit):
		cost = 1
		profit = p - t_min
print(cost)
Buggy python submission (verdict: Runtime Error):
def read():
	return [int(i) for i in input().split(" ")]
N = int(input())
T = read()
A = read()
L = [0] * N
unknowL = [0] * N
tempT, tempA = 0, 0
for i in range(N):
	if(T[i] > tempT):
		tempT = L[i] = T[i]
	else:
		unknowL[i] = T[i]
for i in range(N-1, -1, -1):
	if(A[i] > tempA):
		if(L[i] != 0 and L[i] != A[i]):
			print(0)
			exit()
		tempA = L[i] = A[i]
		unknowL[i] = 0
	else:
		unknowL[i] = min(unknowL[i], A[i])
P = 1 
for i in unknowL:
	if(i != 0):
		P *= i	
print(P % (10**9 +7))

Fixed submission:
import re
s = input()
pattern = re.compile(r'C.*F')
match = pattern.search(s)
if match:
	print('Yes')
else:
	print('No')
Buggy python submission (verdict: Runtime Error):
num = int(input())
str = input()
Li = list(map(int,str.split(' ')))
CoupleNum = 0
for pointer in range(len(Li):
     ai = Li[pointer]
     if (ai > pointer+1):
         if (Li[ai-1]=pointer+1):
             CoupleNum++
print(CoupleNum)

Fixed submission:
#B-Friendly Rabbits
num = int(input())
str = input()
Li = list(map(int,str.split(' ')))
CoupleNum = 0
for pointer in range(len(Li)):
	ai = Li[pointer]
	if (ai > pointer+1):
		if (Li[ai-1]==pointer+1):
			CoupleNum += 1
print(CoupleNum)
Buggy python submission (verdict: Runtime Error):
#C-Next Letter
str = input()
K = int(input())
tempK = K
result = ""
for i in range(len(str)-1):
	changeNum = 122-ord(str[i])+1
	if (changeNum <= tempK):
		result += "a"
		tempK -= changeNum
		if (tempK == 0):
			result += str[i+:]
			print(result)
			break
	else:
		result += str[i]
tempK %= 26
if (tempK > 0):
	changeNum = ord(str[-1]) + tempK
	if (changeNum > 122):
		changeNum = changeNum -122 + 97 -1
	else:
		changeNum = changeNum
	result += chr(changeNum)
else:
	result += str[-1]
print(result)

Fixed submission:
#C-Next Letter
str = input()
K = int(input())
tempK = K
result = ""
for i in range(len(str)-1):
	changeNum = 122-ord(str[i])+1
	if (changeNum <= tempK and str[i] != "a"):
		result += "a"
		tempK -= changeNum
	else:
		result += str[i]
tempK %= 26
if (tempK > 0):
	changeNum = ord(str[-1]) + tempK
	if (changeNum > 122):
		changeNum = changeNum -122 + 97 -1
	else:
		changeNum = changeNum
	result += chr(changeNum)
else:
	result += str[-1]
print(result)
Buggy python submission (verdict: Runtime Error):
str = input()
num = list(map(int,str.split(' ')))
if (num[0]%2)and(num[1]%2)and(num[2])==0:
	print(0)
else:
	num.sort()
        print(num[0]*num[1])


Fixed submission:
str = input()
num = list(map(int,str.split(' ')))
if ((num[0]%2)and(num[1]%2)and(num[2]%2))==0:
	print(0)
else:
	num.sort()
	print(num[0]*num[1])

Buggy python submission (verdict: Runtime Error):
str = input()
num = list(map(int,str.split(' ')))
if (num[0]%2)*(num[1]%2)*(num[2])==1:
	num.sort()
        print(num[0]*num[1])
else:
        print(0)


Fixed submission:
str = input()
num = list(map(int,str.split(' ')))
if ((num[0]%2)and(num[1]%2)and(num[2]%2))==0:
	print(0)
else:
	num.sort()
	print(num[0]*num[1])

Buggy python submission (verdict: Runtime Error):
str = input()
num = list(map(int,str.split(' ')))
if !(num[0]%2)*(num[1]%2)*(num[2]):
	print(0)
else:
	num.sort()
print(num[0]*num[1])


Fixed submission:
str = input()
num = list(map(int,str.split(' ')))
if ((num[0]%2)and(num[1]%2)and(num[2]%2))==0:
	print(0)
else:
	num.sort()
	print(num[0]*num[1])
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
S=input()
S[K-1]=S.lower()[K-1]
print(S)

Fixed submission:
N,K=map(int,input().split())
S=list(input())
S[K-1]=S[K-1].lower()
S="".join(S)
print(S)

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
S=input()
S[K-1]=lower(S[K-1])
print(S)

Fixed submission:
N,K=map(int,input().split())
S=list(input())
S[K-1]=S[K-1].lower()
S="".join(S)
print(S)
Buggy python submission (verdict: Runtime Error):
A,B,K=list(map(int,input().split()))
count=0
z=[A,B]
for i in range(max(z),0,-1):
  if (A%i==0)and(B%i==0):
    count+=1
    if count==K:
      ans=i
      break
print(ans)

Fixed submission:
a=list(map(int,input().split()))
A=a[0]
B=a[1]
C=a[2]
if B>=A*C:
  answer=C
else:
  answer=B//A
print(answer)

Buggy python submission (verdict: Runtime Error):
A,B,K=list(map(int,input().split()))
count=0
z=[A,B]
for i in range(1,max(z)+1):
  if (A%i==0)and(B%i==0):
    count+=1
    if count==K:
      ans=count
      break
print(ans)

Fixed submission:
a=list(map(int,input().split()))
A=a[0]
B=a[1]
C=a[2]
if B>=A*C:
  answer=C
else:
  answer=B//A
print(answer)
Buggy python submission (verdict: Runtime Error):
A,B,K=list(map(int,input().split()))
count=0
z=[A,B]
for i in range(max(z)):
  if (A%i==0)and(B%i==0):
    count+=1
    if count==K:
      ans=count
      break
print(ans)

Fixed submission:
A,B,K=list(map(int,input().split()))
count=0
z=[A,B]
for i in range(max(z),0,-1):
  if (A%i==0)and(B%i==0):
    count+=1
    if count==K:
      ans=i
      break
print(ans)

Buggy python submission (verdict: Runtime Error):
A,B,K=list(map(int,input().split()))
count=0
for i in max(A,B):
  if (A%i==0)and(B%i==0):
    count+=1
    if count==K:
      ans=count
      break
print(ans)

Fixed submission:
A,B,K=list(map(int,input().split()))
count=0
z=[A,B]
for i in range(max(z),0,-1):
  if (A%i==0)and(B%i==0):
    count+=1
    if count==K:
      ans=i
      break
print(ans)
Buggy python submission (verdict: Runtime Error):
X=int(input())
print("YES" if X==3or5or7 else "NO")

Fixed submission:
X=int(input())
print("YES" if (X==3)or(X==5)or(X==7) else "NO")
Buggy python submission (verdict: Runtime Error):
x=input()
n=[x[i] for i in range(len(n))]
for i in range(len(n)):
  if n[i]=="1"or"9":
    if n[i]=="1":
      n[i]="9"
    else:
      n[i]=="1"
print(int("".join(n)))

Fixed submission:
x=input()
n=[x[i] for i in range(len(x))]
for i in range(len(n)):
  if n[i]=="1":
    n[i]="9"
  elif n[i]=="9":
    n[i]="1"
print(int("".join(n)))

Buggy python submission (verdict: Runtime Error):
n=input()
for i in range(len(n)):
  if n[i]=="1"or"9":
    if n[i]=="1":
      n[i]="9"
    else:n[i]=="1"
print(int(n))
    

Fixed submission:
x=input()
n=[x[i] for i in range(len(x))]
for i in range(len(n)):
  if n[i]=="1":
    n[i]="9"
  elif n[i]=="9":
    n[i]="1"
print(int("".join(n)))
Buggy python submission (verdict: Runtime Error):
A,B=int(input().split())
print("Yes" if (A*B)%1==0 else "No")

Fixed submission:
A,B=map(int,input().split())
print("Yes" if (A*B)%2==1 else "No")
Buggy python submission (verdict: Runtime Error):
K=int(input())
if K%2==0:
  print((K//2)**2)
else:
  print(K//2*(k//2+1))

Fixed submission:
K=int(input())
if K%2==0:
  print((K//2)**2)
else:
  print(K//2*(K//2+1))
Buggy python submission (verdict: Runtime Error):
*cost_list=map(int,input().split())
cost_list.sort(reverse=True)
sum=0
for i in range(len(cost_list)-1):
  sum+=(cost_list[i]-cost_list[i+1])
print(sum)

Fixed submission:
cost_list=list(map(int,input().split()))
cost_list.sort(reverse=True)
sum=0
for i in range(len(cost_list)-1):
  sum+=(cost_list[i]-cost_list[i+1])
print(sum)

Buggy python submission (verdict: Runtime Error):
cost_list=list(map(int,input().split())
cost_list.sort(reverse=True)
sum=0
for i in range(len(cost_list)-1):
  sum+=(cost_list[i]-cost_list[i+1])
print(sum)

Fixed submission:
cost_list=list(map(int,input().split()))
cost_list.sort(reverse=True)
sum=0
for i in range(len(cost_list)-1):
  sum+=(cost_list[i]-cost_list[i+1])
print(sum)

Buggy python submission (verdict: Runtime Error):
cost_list=list(map(int,input().split())
cost_list.sort(reverse=True)
sum=0
for i in range(len(cost_list)-1):
  sum+=cost_list[i]-cost_list[i+1]
print(sum)

Fixed submission:
cost_list=list(map(int,input().split()))
cost_list.sort(reverse=True)
sum=0
for i in range(len(cost_list)-1):
  sum+=(cost_list[i]-cost_list[i+1])
print(sum)
Buggy python submission (verdict: Runtime Error):
print("Yes" if len(set(input())))==3 else "No")

Fixed submission:
print("Yes" if len(set(input()))==3 else "No")
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print("Yes" if (10a+b)**.5==int((10a+b)**.5) else "No")

Fixed submission:
a,b=input().split()
z=int(a+b)
print("Yes" if z**.5==int(z**.5) else "No")
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=list(map(int,input().split()))
counter=0
exist_odd=False
while True:
  count=0
  while count<=a-1:
    if b[count]%2==1:
      exist_odd=True
      break
    else:
      b[count]=b[count]//2
      count+=1
  if exist_odd:
    break
  else:
    counter+=1
print(counter)
    

Fixed submission:
S=input()
print(S.count("1"))
Buggy python submission (verdict: Runtime Error):
##いろいろやってみよう
import functools
def mod(a,b):
  c=a%b
  return c
N=int(input())
*A,=map(mod,input().split())
count=0
for j in range(len(bin(max(A)))-2):
  if 1 in map(functools.partial(mod,b=2),A)):
    break
  else:
    A=[A[i]//2 for i in range(N)]
    count+=1
print(count)

Fixed submission:
##いろいろやってみよう
import functools
def mod(a,b):
  c=a%b
  return c
N=int(input())
*A,=map(int,input().split())
count=0
for j in range(len(bin(max(A)))-2):
  if 1 in map(functools.partial(mod,b=2),A):
    break
  else:
    A=[A[i]//2 for i in range(N)]
    count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
print("Yes" if (N[0]==N[1]==N[2])or(N[1]==N[2]==N[3]) else "No" )

Fixed submission:
N=input()
answer="No"
for i in range(len(N)-2):
  if N[i]==N[i+1]:
    if N[i+1]==N[i+2]:
      answer="Yes"
print(answer)

Buggy python submission (verdict: Runtime Error):
N=input()
answer="No"
for i in range(len(N)-2)
  if N[i]==N[i+1]:
    if N[i+1]==N[i+2]:
      answer="Yes"
print(answer)

Fixed submission:
N=input()
answer="No"
for i in range(len(N)-2):
  if N[i]==N[i+1]:
    if N[i+1]==N[i+2]:
      answer="Yes"
print(answer)

Buggy python submission (verdict: Runtime Error):
N=list(input())
answer="no"
for i in range(len(N)-2)
  if N[i]==N[i+1]:
    if N[i+1]==N[i+2]:
      answer="yes"
print(answer)

Fixed submission:
N=input()
answer="No"
for i in range(len(N)-2):
  if N[i]==N[i+1]:
    if N[i+1]==N[i+2]:
      answer="Yes"
print(answer)

Buggy python submission (verdict: Runtime Error):
N=list(input())
answer="no"
for i in range(len(N)-2)
  if N[i]==N[i+1]:
    if N[i+1]==N[i+2]:
      if N[i+2]==N[i+3]:
        answer="yes"
print(answer)


Fixed submission:
N=input()
answer="No"
for i in range(len(N)-2):
  if N[i]==N[i+1]:
    if N[i+1]==N[i+2]:
      answer="Yes"
print(answer)
Buggy python submission (verdict: Runtime Error):
N=int(input())
while for i in range(1,N+1):
  if i**2>N:
    break
  answer=i**2
print(answer)

Fixed submission:
N=int(input())
for i in range(1,N+1):
  if i**2>N:
    break
  answer=i**2
print(answer)

Buggy python submission (verdict: Runtime Error):
N=int(input())
while for i in N:
  if i**2>N:
    break
  answer=i**2
print(answer)

Fixed submission:
N=int(input())
for i in range(1,N+1):
  if i**2>N:
    break
  answer=i**2
print(answer)
Buggy python submission (verdict: Runtime Error):
*a,=map(int,input().split())
print(sum(a.remove(max(a)))

Fixed submission:
*a,=map(int,input().split())
a.remove(max(a))
print(sum(a))

Buggy python submission (verdict: Runtime Error):
*a,=map(int,input().split())
print(sum(a.remove(max(a))))

Fixed submission:
*a,=map(int,input().split())
a.remove(max(a))
print(sum(a))
Buggy python submission (verdict: Runtime Error):
a,b=input().split()
if a="H":
  print(b)
else:
  if b="H":
    print("D")
  else:
    print("H")


Fixed submission:
a,b=input().split()
if a=="H":
  print(b)
else:
  if b=="H":
    print("D")
  else:
    print("H")
Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
print(math.factorial(N)/(10**9+7))

Fixed submission:
import math
N=int(input())
print(math.factorial(N)%(7+10**9))

Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
print(int(math.factorial(N)%(7+1e9)))

Fixed submission:
import math
N=int(input())
print(math.factorial(N)%(7+10**9))

Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
print(math.factorial(N)%(7+1e9))

Fixed submission:
import math
N=int(input())
print(math.factorial(N)%(7+10**9))

Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
print(math.factorial(N)%(7+1e9)

Fixed submission:
import math
N=int(input())
print(math.factorial(N)%(7+10**9))

Buggy python submission (verdict: Runtime Error):
from math import factorial
N=int(input())
print(factorial(N)%(7+1e9)

Fixed submission:
import math
N=int(input())
print(math.factorial(N)%(7+10**9))
Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
K = list(map(int, input().split()))
del K[0]
for i in range(N):
    k = list(map(int, input().split()))
    del k[0]
    K = list(set(k) & set(K))
print(len(K))


Fixed submission:
N,M = map(int, input().split())
K = list(map(int, input().split()))
del K[0]
for i in range(N - 1):
    k = list(map(int, input().split()))
    del k[0]
    K = list(set(k) & set(K))
print(len(K))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,(input().split()))
X = list(map(int,(input().split())))
X.sort()
if M > N:
    dist = [X[i+1]-X[i] for i in range(M - 1)]
    dist.sort(reverse = True)
        del dist[0:N]
    print(sum(dist))
else:
 print(0)

Fixed submission:
N,M = map(int,(input().split()))
X = list(map(int,(input().split())))
X.sort()
if M > N:
    dist = [X[i+1]-X[i] for i in range(M - 1)]
    dist.sort(reverse = True)
    for i in range(N - 1):
        del dist[0]
    print(sum(dist))
else:
 print(0)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,(input().split()))
X = list(map(int,(input().split())))
X.sort()
if M > 1:
    dist = [X[i+1]-X[i] for i in range(M - 1)]
    dist.sort(reverse = True)
    for i in range(N - 1):
        del dist[0]
    print(sum(dist))
else:
 print(0)

Fixed submission:
N,M = map(int,(input().split()))
X = list(map(int,(input().split())))
X.sort()
if M > N:
    dist = [X[i+1]-X[i] for i in range(M - 1)]
    dist.sort(reverse = True)
    for i in range(N - 1):
        del dist[0]
    print(sum(dist))
else:
 print(0)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,(input().split()))
X = list(map(int,(input().split())))
X.sort()
if len(X) > 1:
    dist = [X[i+1]-X[i] for i in range(len(X) - 1)]
    dist.sort(reverse = True)
    for i in range(N - 1):
        del dist[0]
    print(sum(dist))
else:
 print(0)

Fixed submission:
N,M = map(int,(input().split()))
X = list(map(int,(input().split())))
X.sort()
if M > N:
    dist = [X[i+1]-X[i] for i in range(M - 1)]
    dist.sort(reverse = True)
    for i in range(N - 1):
        del dist[0]
    print(sum(dist))
else:
 print(0)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,(input().split()))
X = list(map(int,(input().split())))
X.sort()
dist = [X[i+1]-X[i] for i in range(len(X) - 1)]
dist.sort(reverse = True)
for i in range(N - 1):
    del dist[0]
print(sum(dist))

Fixed submission:
N,M = map(int,(input().split()))
X = list(map(int,(input().split())))
X.sort()
if M > N:
    dist = [X[i+1]-X[i] for i in range(M - 1)]
    dist.sort(reverse = True)
    for i in range(N - 1):
        del dist[0]
    print(sum(dist))
else:
 print(0)
Buggy python submission (verdict: Runtime Error):
S = input()

formar = int(S[:2])
latter = int(S[2:])

if has_month_potential(formar) and not has_month_potential(latter):
    print('MMYY')
elif not has_month_potential(formar) and has_month_potential(latter):
    print('YYMM')
elif has_month_potential(formar) and has_month_potential(latter):
    print('AMBIGUOUS')
elif not has_month_potential(formar) and not has_month_potential(latter):
    print('NA')

Fixed submission:
def has_month_potential(num):
    return num >= 1 and num <= 12

S = input()

formar = int(S[:2])
latter = int(S[2:])

if has_month_potential(formar) and not has_month_potential(latter):
    print('MMYY')
elif not has_month_potential(formar) and has_month_potential(latter):
    print('YYMM')
elif has_month_potential(formar) and has_month_potential(latter):
    print('AMBIGUOUS')
elif not has_month_potential(formar) and not has_month_potential(latter):
    print('NA')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

cs = [a,b,c,d,e]

min_idx = cs.index(min(cs))

if min_idx == 0:
    t = int(n / cs[min_idx]) + 1
elif min_idx == 1:
    amari = n % cs[min_idx-1]
    t = int(cs[min_idx-1] / (cs[min_idx-1] - cs[min_idx])) + 1
    if amari <= cs[min_idx]:
        t = t - 1
else:
    amari = cs[min_idx-2] % cs[min_idx-1]
    t = int(cs[min_idx-1] / (cs[min_idx-1] - cs[min_idx])) + 1
    if aamari <= cs[min_idx]:
        t = t - 1

print(4 + t)

Fixed submission:
import math
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
 
cs = [a,b,c,d,e]
 
min_cs = min(cs)
 
t = math.ceil(n / min_cs)

print(t + 4)
Buggy python submission (verdict: Time Limit Exceeded):
import re
n, q = map(int, input().split(' '))
s = input()
l_r = []
for _ in range(q):
    l_r.append(tuple(map(int, input().split(' '))))
for (l, r) in l_r:
    agct_substr = re.findall(r'AC', s[l-1:r])
    print(len(agct_substr))

Fixed submission:
n, q = map(int, input().split(' '))
s = input()
l_r = []
for _ in range(q):
    l_r.append(tuple(map(int, input().split(' '))))

n = [0]
c = 0
for i in range(1, len(s)):
    if s[i-1:i+1] == 'AC':
        c += 1
    n.append(c)

for (l, r) in l_r:
    print(n[r - 1] - n[l - 1])
Buggy python submission (verdict: Runtime Error):
import numpy as np

N, M, C = map(int, input().split(' '))
B = np.array(tuple(map(int, input().split(' ')))).reshape((-1, 1))
A = np.zeros((N, M))
for i in range(N):
    A[i, :] = np.array(tuple(map(int, input().split(' '))))

print(np.where((np.matmul(A, B) + C) > 0, 1, 0).sum())

Fixed submission:
N, M, C = map(int, input().split(' '))
B = list(map(int, input().split(' ')))
A = []
for i in range(N):
    A.append(list(map(int, input().split(' '))))
AB = []
for i in range(len(A)):
    matmul = C
    for j in range(len(B)):
        matmul += A[i][j] * B[j]
    AB.append(1 if matmul > 0 else 0)
print(sum(AB))
Buggy python submission (verdict: Runtime Error):
S = input()

if len(S) < 2:
    print('0')

else:
    # 最初に攻めていくパターンを仮ぎめ
    i = 0
    while True:
        if S[i] != S[-1-i]:
            left = S[i]
            right = S[-1-i]
            break
        i += 1
    pattern = right + left

    # マッチングして取り除いていく
    count = 0
    curr_S = S

    while True:
        count_increased = False
        new_S = ''
        j = 0
        while True:
#             print(curr_S, j, curr_S[j:j+2], new_S, pattern, count)
            if curr_S[j:j+2] == pattern:
                count += 2
                j += 2
                count_increased = True
            else:
                new_S += curr_S[j]
                j += 1
            if j == len(curr_S):
                break
        # １個も見つからなかった場合はパターンを反転させて継続
        if not count_increased:
            pattern = pattern[::-1]

        # 全てが0または1になったら終了
        if '0' not in new_S or '1' not in new_S:
            break
        curr_S = new_S

    print(count)

Fixed submission:
from collections import Counter
S = input()
c = Counter(S)
print(min(c['0'], c['1']) * 2)

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

if len(S) < 2:
    print('0')

else:
    # 最初に攻めていくパターンを仮ぎめ
    i = 0
    while True:
        if S[i] != S[-1-i]:
            left = S[i]
            right = S[-1-i]
            break
        i += 1
    pattern = right + left

    # マッチングして取り除いていく
    count = 0
    curr_S = S

    while True:
        count_increased = False
        new_S = ''
        j = 0
        while True:
            print(curr_S, j, curr_S[j:j+2], new_S, pattern, count)
            if curr_S[j:j+2] == pattern:
                count += 2
                j += 2
                count_increased = True
            else:
                new_S += curr_S[j]
                j += 1
            if j == len(curr_S):
                break
        # １個も見つからなかった場合はパターンを反転させて継続
        if not count_increased:
            pattern = pattern[::-1]

        # 全てが0または1になったら終了
        if '0' not in new_S or '1' not in new_S:
            break
        curr_S = new_S

    print(count)

Fixed submission:
from collections import Counter
S = input()
c = Counter(S)
print(min(c['0'], c['1']) * 2)
Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
a = []
tmp = input().split()
for i in range(n):
    a.append(int(tmp[i]))

if n == 2:
    if a[0] > a[1]:
        print(a[0])
    else:
        print(a[1])
    exit()

rev = []
rev.append(a[n-1])
prev_gcd = a[n-1]
for i in range(n-2, 0, -1):
    prev_gcd = math.gcd(prev_gcd, a[i])
    rev.append(prev_gcd)

ans = math.gcd(a[0], rev[-2])
if ans < rev[-1]:
    ans = rev[-1]
        
prev_gcd = a[0]
for i in range(1, n-1):
    prev_gcd = math.gcd(prev_gcd, a[i])
    cand_ans = math.gcd(prev_gcd, rev[-1 - i])
    if cand_ans > ans:
        ans = cand_ans

print(ans)
                  


Fixed submission:
elem = input().split()
a = int(elem[0])
b = int(elem[1]) 
t = int(elem[2])
    
ans = (t // a) * b


print(ans)