Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int, input().split())
for i in range(N+1):
    for j in range(N-i+1):
        for k in range(N-i-j+1):
            t = (i, j, k)
            if i+j+k == N:
                if Y == i*10000 + j*5000 + k*1000:
                    print(i, j, k)
                    exit()
print('-1 -1 -1')

Fixed submission:
N, Y = map(int, input().split())
for i in range(N+1):
    for j in range(N-i+1):
        k = N - i - j
        t = (i, j, k)
        if Y == i*10000 + j*5000 + k*1000:
           print(*t)
           exit()
print('-1 -1 -1')

Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int, input().split())
x = 0
for i in range(N+1):
    for j in range(N-i+1):
        for k in range(N-i-j+1):
            if i+j+k == N:
                if Y == i*10000 + j*5000 + k*1000:
                    while x == 0:
                        print(i, j, k)
                        x += 1
if x == 0:
    print('-1 -1 -1')

Fixed submission:
N, Y = map(int, input().split())
for i in range(N+1):
    for j in range(N-i+1):
        k = N - i - j
        t = (i, j, k)
        if Y == i*10000 + j*5000 + k*1000:
           print(*t)
           exit()
print('-1 -1 -1')

Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int, input().split())
x = 0
otoshidama = {}
for i in range(N+1):
    for j in range(N-i+1):
        for k in range(N-i-j+1):
            if i+j+k == N:
                if Y == i*10000 + j*5000 + k*1000:
                    while x == 0:
                        print(i, j, k)
                        x += 1
if x == 0:
    print('-1 -1 -1')

Fixed submission:
N, Y = map(int, input().split())
for i in range(N+1):
    for j in range(N-i+1):
        k = N - i - j
        t = (i, j, k)
        if Y == i*10000 + j*5000 + k*1000:
           print(*t)
           exit()
print('-1 -1 -1')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N, K= map(int, input().split())
A = list(map(int, input().split()))


x = deque([1])
point = 1
count = 0
while True:
  next_point = A[point-1]
  if next_point in x :
    x.append(next_point)
    break
  x.append(next_point)
  point = next_point
  
f = x.index(next_point)

if K <=f:
    print(x[K])
else :
    num = len(x) - f -1
    x = list(x)[f+1:]
    dic = {(n+1+f) %(num): i for n, i in enumerate(x)}
    print(dic[K%num])

  

Fixed submission:
N, K= map(int, input().split())
A = list(map(int, input().split()))
x = {1:0}
point = 1
count = 0
while True:
  next_point = A[point-1]
  count +=1
  if next_point in x :
    flag=next_point
    break
  x[next_point] =count
  point = next_point
  
#print(count, x[flag])
c = count - x[flag]
f = x[flag]
#print(c)
if K <f:
    print([i for i in x if x[i] == K ][0])
else :
    dic = {j-f: i for i,j in x.items()}
    print(dic[(K-f) % c])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

N, K= map(int, input().split())
A = { n+1:int(i) for n,i in enumerate(input().split())} 

x = deque([1])
point = 1
while True:
  next_point = A[point]
  if next_point in x :
    x.append(next_point)
    break
  x.append(next_point)
  point = next_point
f = x.index(x[-1])
if K <=f:
    print(x[K])
else :
    num = len(x) - f -1
    x = list(x)
    dic = {(n+1+f) %(num): i for n, i in enumerate(x[ f+1:])}
    print(dic[K%num])


Fixed submission:
N, K= map(int, input().split())
A = list(map(int, input().split()))
x = {1:0}
point = 1
count = 0
while True:
  next_point = A[point-1]
  count +=1
  if next_point in x :
    flag=next_point
    break
  x[next_point] =count
  point = next_point
  
#print(count, x[flag])
c = count - x[flag]
f = x[flag]
#print(c)
if K <f:
    print([i for i in x if x[i] == K ][0])
else :
    dic = {j-f: i for i,j in x.items()}
    print(dic[(K-f) % c])

Buggy python submission (verdict: Time Limit Exceeded):
N, K= map(int, input().split())
A = { n+1:int(i) for n,i in enumerate(input().split())}

x = [1]
point = 1
while True:
  next_point = A[point]
  if next_point in x :
    x.append(next_point)
    break
  x.append(next_point)
  point = next_point

#print(x)
f = x.index(x[-1])
if K <=f:
    print(x[K])
else :
    num = len(x) - f -1
    dic = {(n+1+f) %(num): i for n, i in enumerate(x[ f+1:])}
    print(dic[K%num])

Fixed submission:
N, K= map(int, input().split())
A = list(map(int, input().split()))
x = {1:0}
point = 1
count = 0
while True:
  next_point = A[point-1]
  count +=1
  if next_point in x :
    flag=next_point
    break
  x[next_point] =count
  point = next_point
  
#print(count, x[flag])
c = count - x[flag]
f = x[flag]
#print(c)
if K <f:
    print([i for i in x if x[i] == K ][0])
else :
    dic = {j-f: i for i,j in x.items()}
    print(dic[(K-f) % c])
Buggy python submission (verdict: Time Limit Exceeded):
import itertools,numpy as np
n = int(input())
X = np.array(list(map(int,input().split(' '))))
Y = np.array(list(map(int,input().split(' '))))
Z = X - Y
import itertools,numpy as np
a = list(itertools.product([0,1], repeat=n))
r = 0
print(max([(Z*np.array(i)).sum() for i in a]))


Fixed submission:
import numpy as np
n = int(input())
X = np.array(list(map(int,input().split(' '))))
Y = np.array(list(map(int,input().split(' '))))
Z = X -Y
Z = Z[np.where(Z >= 0)]
print(Z.sum())
Buggy python submission (verdict: Runtime Error):
import math 
a = [int(input())for i in range(5)]
rest = []
t = 0
for i in a:
  if i%10 == 0 :
    t+=i
  else:
    rest.append(i)

f = sorted(rest, key=lambda x:str(x)[-1] ,reverse=True)
c = [math.ceil(i/10)*10for i in f[:-1]]

t += sum(c)+f[-1]

print(t)

Fixed submission:
import math 
a = [int(input())for i in range(5)]
rest = []
t = 0
for i in a:
  if i%10 == 0 :
    t+=i
  else:
    rest.append(i)
if rest == [] :
  print(t)
else :
  f = sorted(rest, key=lambda x:str(x)[-1] ,reverse=True)
  c = [math.ceil(i/10)*10for i in f[:-1]]
  t += sum(c)+f[-1]
  print(t)
Buggy python submission (verdict: Runtime Error):
a,b,c = input()

if (a == b)  & (b == c) &(c == a):
    print('yes')
else :
    print( 'no')

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

if (a == b)  & (b == c) &(c == a):
    print('Yes')
else :
    print( 'No')
Buggy python submission (verdict: Runtime Error):
import re 
S = input()

p = re.compile('[ATCG]+')
f = p.finditer

candidate = [i.span()[1]- i.span()[0] for i in f]
if candidate == [] :
    print(0)
else :
    print(max(candidate))

Fixed submission:
import re 
S = input()
 
p = re.compile('[ATCG]+')
f = p.finditer(S)
 
candidate = [i.span()[1]- i.span()[0] for i in f]
if candidate == [] :
    print(0)
else :
    print(max(candidate))
Buggy python submission (verdict: Time Limit Exceeded):
import re
def count_ac(s):
    p = re.compile('AC')
    return len(p.findall(s))

N, Q = input().split(' ')
s = input()

for i in range(int(Q)):
  a,b = map(int,input().split(' '))
  #print(s[a-1:b])
  if b-a <=1 :
    print(0)
  else :
    print(count_ac(s[a-1:b]))#, s[a-1:b])

Fixed submission:
N, Q = input().split(' ')
s = input()

f = [0]
for i in range(1,int(N)):
  if (s[i-1]== 'A')&(s[i] == 'C'):
    f.append(f[i-1]+1)
  else :
    f.append(f[i-1])
  
for i in range(int(Q)):
  a,b = map(int,input().split(' '))
  print(f[b-1]-f[a-1])
Buggy python submission (verdict: Runtime Error):
N, M, C = map(int,input().split(' '))
import numpy as np
B = np.array(list(map(int,input().split(' '))))
def f(A, B, C):
    A = np.array(list(map(int,A.split(' '))))
    return np.sum(A*B) +C >  0
print(

Fixed submission:
N, M, C = map(int,input().split(' '))
import numpy as np
B = np.array(list(map(int,input().split(' '))))
def f(A, B, C):
    A = np.array(list(map(int,A.split(' '))))
    return np.sum(A*B) +C >  0
print(np.sum([f(input(), B, C) for i in range(N)]))
Buggy python submission (verdict: Runtime Error):
a,b = input().split(' ')

if b%a == 0 :
  print(b+a)
else :
  print(b -a)

Fixed submission:
a,b = map(int, input().split(' '))
 
if b%a == 0 :
  print(b+a)
else :
  print(b -a)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
i = input()
N = list(map(int, input().split(' ')))
def one_turn(l):
  l.sort()
  n = l[0]
  n2 = l[1]
  
  return np.array([n,n2]+[ i-n for i in l[2:] if ((i%n != 0)or(i%n2 != 0)) ])

if len(set(N)) == 1 :
  print(N[0])
else :
  N = np.array(N)
  while True :
    N = one_turn(N)
    if N[0] == 1 :
      print(1)
      break
    if len(N) == 1 :
      print(N[0])
      break

Fixed submission:
import numpy as np
i = input()
N = list(set(map(int, input().split(' '))))
def one_turn(l):
  l.sort()
  n = l[0]
  return np.array(list(set([n]+[ l[i]%n for i in range(1,len(l)) if ((l[i]%n != 0))])))

if len(set(N)) == 1 :
  print(N[0])
else :
  N = np.array(N)
  while True :
    N = one_turn(N)
    if N[0] == 1 :
      print(1)
      break
    if len(N) == 1 :
      print(N[0])
      break

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
i = input()
N = list(map(int, input().split(' ')))
def one_turn(l):
  l.sort()
  n = l[0]
  
  return np.array([n]+[ i-n for i in l[1:] if i%n != 0])

if len(set(N)) == 1 :
  print(N[0])
else :
  N = np.array(N)
  while True :
    N = one_turn(N)
    if N[0] == 1 :
      print(1)
      break
    if len(N) == 1 :
      print(N[0])
      break

Fixed submission:
import numpy as np
i = input()
N = list(set(map(int, input().split(' '))))
def one_turn(l):
  l.sort()
  n = l[0]
  return np.array(list(set([n]+[ l[i]%n for i in range(1,len(l)) if ((l[i]%n != 0))])))

if len(set(N)) == 1 :
  print(N[0])
else :
  N = np.array(N)
  while True :
    N = one_turn(N)
    if N[0] == 1 :
      print(1)
      break
    if len(N) == 1 :
      print(N[0])
      break
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
def chack(s):
    def f(s):
        return s == '5' or s == '3' or s == '7'
    if ('5' in s) & ('3' in s) & ('7' in s) :
        return all([ f(i) for i in s])
    return False
print(np.array([chack(str(i)) for i in range(0,N+1)]).sum())

Fixed submission:
from itertools import product
N = int(input())
ans = 0
for l in range(1, 10):
    for p in product("357", repeat=l):
        v = "".join(p)
        if "3" in v and "5" in v and "7" in v and int(v) <= N:
            ans += 1
            continue
        elif int(v) > N :
            break
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m = map( int, input().split())
  input_list = [[] for i in range(n)]

for i in range(m):
  p,y = map(int, input().split())
  input_list[p-1].append((y,i))
  
for i in input_list :
  i.sort()

result = [None]*m

for p,i in enumerate(input_list) :
  for n, (a,b) in enumerate(i):
    result[b] = str(p+1).zfill(6)+str(n+1).zfill(6)
    
print(*result, sep = '\n')

Fixed submission:
n,m = map( int, input().split())
  
result= {}
input_list = [[] for i in range(n)]


for i in range(m):
  p,y = map(int, input().split())
  input_list[p-1].append((y,i))
  
for i in input_list :
  i.sort()

result = [None]*m

for p,i in enumerate(input_list) :
  for n, (a,b) in enumerate(i):
    result[b] = str(p+1).zfill(6)+str(n+1).zfill(6)
    
print(*result, sep = '\n')
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
x = list(map(int, input().split()))

s = 10**9
for i in range(n-k+1) :
  f = x[i:i+k] 
  m = min(abs(f[0]) +abs(f[-1] - f[0]) , abs(f[-1]) + abs(f[-1] - f[0]))
  if s >m :
    s = m
print(s)

Fixed submission:
n,k = map(int, input().split())
x = list(map(int, input().split()))

s = 10**9
for i in range(n-k+1) :
  f1 = x[i]
  f2 = x[i+k-1]
  m = min(abs(f1) +abs(f2 - f1) , abs(f2) + abs(f2 - f1))
  if s >m :
    s = m
print(s)
Buggy python submission (verdict: Runtime Error):
import numpy as np
A=  np.array(list(map(int, input().split())))
n = int(input())
f = np.argmax(A)c
A[f] = A[f]*2**n
print(A.sum())

Fixed submission:
A=  sorted(list(map(int, input().split())))
n = int(input())

print(sum(A[:-1]) + A[-1] *2**n )
Buggy python submission (verdict: Runtime Error):
a,b,k = list(map( int, input().split()))
x = list(range(a,b+1))
x = sorted(list(set(x[:k])|set(x[-k:])))
for i in x:
  print(i)

Fixed submission:
a,b,k=map(int,input().split())
l=range(a,b+1)
ans=sorted(set(l[:k])|set(l[-k:]))
for i in ans:
    print(i)

Buggy python submission (verdict: Runtime Error):
a,b,k = list(map( int, input().split()))
x = list(range(a,b+1))
x = sorted(list(set(x[:k]+x[-k:])))
for i in x:
  print(i)

Fixed submission:
a,b,k=map(int,input().split())
l=range(a,b+1)
ans=sorted(set(l[:k])|set(l[-k:]))
for i in ans:
    print(i)

Buggy python submission (verdict: Runtime Error):
a,b,k = list(map( int, input().split()))
x = list(range(a,b+1))

x = sorted(list(set(x[:k]+x[-k:])))
for i in x:
  print(i)

Fixed submission:
a,b,k=map(int,input().split())
l=range(a,b+1)
ans=sorted(set(l[:k])|set(l[-k:]))
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
def main(a,b,s):
  if len(s) != a+1+b :
    return 'No'
 
  for n,i in enumerate(s) :
    if n == a :
      
      if i != '-' :
        return 'No'
    else :
      try :
        int(i)
      except :
        return 'No'
  return 'Yes'
              
print(main(a,b,s))

Fixed submission:
a,b =map(int, input().split())
s =input()
 
def main(a,b,s):
  if len(s) != a+1+b :
    return 'No'
 
  for n,i in enumerate(s) :
    if n == a :
      
      if i != '-' :
        return 'No'
    else :
      try :
        int(i)
      except :
        return 'No'
  return 'Yes'
              
print(main(a,b,s))
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
nums = list(map(int, input().split()))

s = 0
while True :
  f = [ i%2 == 0 for i in nums]
  if all(f) :
    s+=1
    nums = [ i%2 for i in nums]
  else :
    break
print(s)

Fixed submission:
n = input()
A= set(map(int, input().split()))

result = []
for i in A:
  r = 0
  while i %2 == 0 :
    i = i/2
    r += 1
  result.append(r)

print(min(result))
Buggy python submission (verdict: Runtime Error):
 int( input())
k = int( input())
 
a = 1
for i in range(n):
  a = min(a+k, a*2)  
print(a)

Fixed submission:
n = int( input())
k = int( input())

a = [1]
b = [1]
x = 10**6
for i in range(n+1):
  for j in range(n-i,n-i+1):
    f = 1*2**i+j*k
    if x > f:
      x = f
      
print(x)
Buggy python submission (verdict: Runtime Error):
#include<iostream>
using namespace std;

main(){
	string s ;
  	cin >> s; 
  	cout << s.front()<<to_string(s.length() -2 )<<s.back()<< endl;
  	return 0;
}

Fixed submission:
x,*y,z=input()
print(x+str(len(y))+z)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
a = 0
for x in range(K+1):
  for y in range(K+1):
    if x+y>S :
      continue
    for z in range(K+1):
      if x+y+z == S :
        a +=1
      
      
print(a)

Fixed submission:
K, S = map(int, input().split())
a = 0
for x in range(K+1):
  for y in range(K+1):
    if 0<=S-x-y<=K :
      a+=1   
print(a)
Buggy python submission (verdict: Runtime Error):
N=int(input())
a=0
if N<1000:
    print(N)
    exit()
else:
    while 1:
        if a*1000-N>=0:
            prit(a*1000-N)
            exit()
        else:
            a+=1

Fixed submission:
N=int(input())
a=0
if N<1000:
    print(1000-N)
    exit()
else:
    while 1:
        if a*1000-N>=0:
            print(a*1000-N)
            exit()
        else:
            a+=1

Buggy python submission (verdict: Runtime Error):
N = input()
if N[-3] == '0':
  print(0)
else:
  print((10 - int(N[-3]))*100)

Fixed submission:
N = input()
if N[-3:] == '000':
  print(0)
else:
  print(1000 - int(N[-3:]))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = []
for i in range(0, M):
    a = tuple(map(int, input().split()))
    A.append(a)
for x in range(10**(N-1)-1, 10**N):
    ans = str(x)
    flag = True
    for a in A:
        if ans[a[0]-1] != str(a[1]):
            flag = False
    if flag:
        print(x)
        exit(0)
print(-1)


Fixed submission:
N, M = map(int, input().split())
A = []
for i in range(0, M):
    a = tuple(map(int, input().split()))
    A.append(a)
start = 10**(N-1)
if N == 1:
    start = 0
for x in range(start, 10**N):
    ans = str(x)
    flag = True
    for a in A:
        if ans[a[0]-1] != str(a[1]):
            flag = False
    if flag:
        print(x)
        exit(0)
print(-1)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
if M == 0:
    print(10**(N-1))
    exit(0)
A = [[] for i in range(0, N)]
for i in range(0, M):
    x, y = map(int, input().split())
    if y in A[x-1]:
        continue
    A[x-1].append(y)
for a in A:
    if len(a) > 1:
        print(-1)
        exit(0)
ans = ''
if A[0][0] == 0:
    print(-1)
    exit(0)
for i in range(0, N):
    if len(A[i]) == 1:
        ans += str(A[i][0])
    else:
        ans += '0'
print(ans)


Fixed submission:
N, M = map(int, input().split())
A = []
for i in range(0, M):
    a = tuple(map(int, input().split()))
    A.append(a)
start = 10**(N-1)
if N == 1:
    start = 0
for x in range(start, 10**N):
    ans = str(x)
    flag = True
    for a in A:
        if ans[a[0]-1] != str(a[1]):
            flag = False
    if flag:
        print(x)
        exit(0)
print(-1)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [[] for i in range(0, N)]
for i in range(0, M):
    x, y = map(int, input().split())
    if y in A[x-1]:
        continue
    A[x-1].append(y)
for a in A:
    if len(a) > 1:
        print(-1)
        exit(0)
ans = ''
if A[0][0] == 0:
    print(-1)
    exit(0)
for i in range(0, N):
    if len(A[i]) == 1:
        ans += str(A[i][0])
    else:
        ans += '0'
print(ans)


Fixed submission:
N, M = map(int, input().split())
A = []
for i in range(0, M):
    a = tuple(map(int, input().split()))
    A.append(a)
start = 10**(N-1)
if N == 1:
    start = 0
for x in range(start, 10**N):
    ans = str(x)
    flag = True
    for a in A:
        if ans[a[0]-1] != str(a[1]):
            flag = False
    if flag:
        print(x)
        exit(0)
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))
A = [0, 1.0]
for i in range(2, 1001):
    A.append(A[i-1]+0.5)
index = 0
tmp = 0
for i in range(0, N-K+1):
    total = sum(P[i:i+K])
    if tmp < total:
        index = i
        tmp = total
ans = 0
for i in range(index, index+K):
    ans += A[P[i]]
print(ans)


Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
A = [0, 1.0]
for i in range(2, 1001):
    A.append(A[i-1]+0.5)
index = 0
tmp = sum(P[0:K])
B = [tmp]
for i in range(K, N):
    total = B[-1]-P[i-K]+P[i]
    if tmp < total:
        index = i-K+1
        tmp = total
    B.append(total)
ans = 0
for i in range(index, index+K):
    ans += A[P[i]]
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
P = []
S = []
flag = [False for i in range(0, N)]
for i in range(0, M):
    x, y = map(str, input().split())
    P.append(int(x-1))
    S.append(y)
ans = [0, 0]
for i in range(0, M):
    if flag[P[i]]:
        continue
    else:
        if S[i] == 'AC':
            flag[P[i]] = True
            ans[0] += 1
        else:
            ans[1] += 1
print(*ans)


Fixed submission:
N, M = map(int, input().split())
P = []
S = []
flag = [False for i in range(0, N)]
for i in range(0, M):
    x, y = map(str, input().split())
    P.append(int(x)-1)
    S.append(y)
ans = [0, 0]
wa = [0 for i in range(0, N)]
for i in range(0, M):
    if not flag[P[i]]:
        if S[i] == 'AC':
            flag[P[i]] = True
            ans[0] += 1
            ans[1] += wa[P[i]]
        else:
            wa[P[i]] += 1
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = str(input())
ans = set()
for i in range(7, 2**(N-1)+2**(N-2)+2**(N-3)+1):
    tmp = ''
    cnt = 0
    for j in range(0, N):
        if (i >> j) & 1:
            tmp += S[j]
            cnt += 1
        if cnt > 3:
            break
    if cnt == 3:
        ans.add(tmp)
print(len(ans))


Fixed submission:
N = int(input())
S = str(input())
ans = 0
for i in range(0, 1000):
    x = str(i).zfill(3)
    try:
        idx1 = S.index(x[0])
        idx2 = S.index(x[1], idx1+1)
        idx3 = S.index(x[2], idx2+1)
        ans += 1
    except ValueError:
        continue
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(0, N):
    if i == 0:
        tmp = A[1]
    else:
        tmp = A[0]
    for j in range(0, N):
        if i != j:
            tmp = gcd(A[j], tmp)
        if tmp < ans:
            break
    ans = max(ans, tmp)
print(ans)


Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
L = [0]
for i in range(1, N):
    L.append(gcd(A[i-1], L[i-1]))
R = [0]
for i in range(1, N):
    R.append(gcd(R[i-1], A[N-i]))
R.reverse()
ans = []
for i in range(0, N):
    ans.append(gcd(L[i], R[i]))
print(max(ans))

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(0, N):
    if i == 0:
        tmp = A[1]
    else:
        tmp = A[0]
    for j in range(0, N):
        if i != j:
            tmp = gcd(A[j], tmp)
        if tmp == 1:
            break
    ans = max(ans, tmp)
print(ans)


Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
L = [0]
for i in range(1, N):
    L.append(gcd(A[i-1], L[i-1]))
R = [0]
for i in range(1, N):
    R.append(gcd(R[i-1], A[N-i]))
R.reverse()
ans = []
for i in range(0, N):
    ans.append(gcd(L[i], R[i]))
print(max(ans))

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(0, N):
    if i == 0:
        tmp = A[1]
    else:
        tmp = A[0]
    for j in range(0, N):
        if i != j:
            tmp = gcd(A[j], tmp)
    ans = max(ans, tmp)
print(ans)


Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
L = [0]
for i in range(1, N):
    L.append(gcd(A[i-1], L[i-1]))
R = [0]
for i in range(1, N):
    R.append(gcd(R[i-1], A[N-i]))
R.reverse()
ans = []
for i in range(0, N):
    ans.append(gcd(L[i], R[i]))
print(max(ans))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = str(input())
K = int(input())
ans = ""
for i in range(0, N):
    if(S[i] != S[K]):
        ans += "*"
    else:
        ans += S[K]
print(ans)


Fixed submission:
N = int(input())
S = str(input())
K = int(input())
ans = ""
for i in range(0, N):
    if(S[i] != S[K-1]):
        ans += "*"
    else:
        ans += S[K-1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
T = S
flag = True
while(flag):
    flag = False
    for i in range(1, len(T)):
        if int(T[i-1]) ^ int(T[i]):
            flag = True
            T = T[:i-1]+T[i+1:]
            break
print(len(S)-len(T))


Fixed submission:
S = str(input())
print(len(S)-abs(S.count('0')-S.count('1')))

Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
A = S
flag = True
while(flag):
    T = ""
    flag = False
    for i in range(1, len(S)):
        if int(S[i-1]) ^ int(S[i]):
            flag = True
            T = S[:i-1]+S[i+1:]
            S = T
            break
print(len(A)-len(S))


Fixed submission:
S = str(input())
print(len(S)-abs(S.count('0')-S.count('1')))