Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
S = input()
pos_a = -1
pos_z = -1
for i in range(len(S)):
  if S[i] == 'A' and pos_a < 0:
    pos_a = i
  if S[len(S)-i] == 'Z' and pos_z < 0:
    pos_z = len(S)-i
  if pos_a >= 0 and pos_z > 0:
    break
print(pos_z-pos_a+1)

Fixed submission:
S = input()
pos_a = -1
pos_z = -1
for i in range(len(S)):
  if S[i] == 'A' and pos_a < 0:
    pos_a = i
  if S[len(S)-i-1] == 'Z' and pos_z < 0:
    pos_z = len(S)-i-1
  if pos_a >= 0 and pos_z > 0:
    break
print(pos_z-pos_a+1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for a, b in AB[::-1]:
  if (a+ans)%b == 0:
    continue
  if a >= b:
    cnt = 0
    while 2*b-a+b*cnt < ans:
      cnt += 1
    # print(ans)
    ans += 2*b-a+b*cnt-ans
  else:
    cnt = 0
    while b-a+b*cnt < ans:
      cnt += 1
    # print(b-a+b*cnt-ans)
    ans += b-a+b*cnt-ans
print(ans)


Fixed submission:
import math

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for a, b in AB[::-1]:
  if (a+ans)%b == 0:
    continue
  if a+ans >= b:
    ans += math.ceil(abs(a+ans)/b)*b-a-ans
  else:
    ans += b-a-ans
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
times = map(int, input().split())
M = int(input())
sum_t = sum(times)
for _ in range(M):
  dist, time = map(int, input().split())
  if times[dist-1] >= time:
    print(sum_t-(times[dist-1]-time))
  else:
    print(sum_t+(time-times[dist-1]))

Fixed submission:
N = int(input())
times = list(map(int, input().split()))
M = int(input())
sum_t = sum(times)
for _ in range(M):
  dist, time = map(int, input().split())
  if times[dist-1] >= time:
    print(sum_t-(times[dist-1]-time))
  else:
    print(sum_t+(time-times[dist-1]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
nums = list(map(int, input().split()))
n_dict = {}
idx = 0
mod = !(N%2)
while True:
  if 2*idx + mod > N:
    break
  else:
    n_dict[2*idx+mod] = 0
for num in nums:
  if num in n_dict:
    n_dict[num] += 1
  else:
    print(0)
    exit()
for key, value in n_dict.items():
  if value != 2:
    print(0)
    exit()
print((2**(N//2))%(10**9+7))

Fixed submission:
N = int(input())
nums = list(map(int, input().split()))
n_dict = {}
idx = 0
mod = ((N%2)+1)%2
while True:
  if 2*idx + mod > N:
    break
  else:
    n_dict[2*idx+mod] = 0
  idx += 1
for num in nums:
  if num in n_dict:
    n_dict[num] += 1
  else:
    print(0)
    exit()
for key, value in n_dict.items():
  if value != 2 and key != 0:
    print(0)
    exit()
print((2**(N//2))%(10**9+7))
Buggy python submission (verdict: Runtime Error):
N, K, L = map(int, input().split())
par = list(range(N+1))
rank = [0] * (N+1)
cnt = [1] * (N+1)
def root(x):
  if par[x] == x:
    return x
  else:
    par[x] = root(par[x])
    return par[x]

def same(x, y):
  return root(x) == root(y)

def unite(x, y):
  xr = root(x)
  yr = root(y)
  if xr == yr:
    return
  if rank[xr] < rank[yr]:
    par[xr] = yr
  else:
    par[yr] = xr
    if rank[xr] == rank[yr]:
      rank[xr] += 1

for _ in range(K):
  x, y = map(int, input().split())
  unite(x, y)
par_r = par[:]
par = list(range(N+1))
for _ in range(L):
  x, y = map(int, input().split())
  unite(x, y)
ans = [1] * (N)
r_dict = {}

for i in range(1, N+1):
  if (par_r[i], par[i]) in r_dict:
    r_dict[(par_r[i], par[i])] += 1
  else:
    r_dict[(par_r[i], par[i])] = 1
ans = []
for i in range(1, N+1):
  ans.append(r_dict[(par_r[i], par[i])])
print(' '.join(map(str, ans)))


Fixed submission:
c = input()
if c in ['a', 'i', 'u', 'e', 'o']:
  print('vowel')
else:
  print('consonant')
Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split())
nums = list(map(int, input().split()))
INF = 10**10
min_num = INF
max_diff = 0
cnt = 0
for num in nums:
  if num-min_num > max_diff:
    cnt = 1
    max_diff = num-min_num
  elif num-min_num == max_diff:
    cnt += 1
  if num < min_num:
    min_num = num
print(min(cnt, T//2))

Fixed submission:
a, b, c = map(int, input().split())
if a+b == c or c+a == b or b+c == a:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
nums = list(map(int, input().split()))
answer = 0
for i, num in enumerate(nums, start=1):
  if i == nums[num] and i < num:
    answer += 1
print(answer)

Fixed submission:
N = int(input())
nums = list(map(int, input().split()))
answer = 0
for i, num in enumerate(nums, start=1):
  if i == nums[num-1] and i < num:
    answer += 1
print(answer)
Buggy python submission (verdict: Runtime Error):
sa = input()
sb = input()
sc = input()
ia = 0
ib = 0
ic = 0
next = 'a'
while True:
  if ia == len(sa)-1:
    print('A')
    break
  if ib == len(sb)-1:
    print('B')
    break
  if ic == len(sc)-1:
    print('C')
    break
  if next == 'a':
    next = S[ia]
    ia += 1
  if next == 'b':
    next = S[ib]
    ib += 1
  if next == 'c':
    next = S[ic]
    ic += 1
  

Fixed submission:
sa = input()
sb = input()
sc = input()
next = sa[0]
while True:
  if next == 'a':
    if len(sa) == 0:
      print('A')
      break
    else:
      next = sa[0]
      sa = sa[1:]
  elif next == 'b':
    if len(sb) == 0:
      print('B')
      break
    else:
      next = sb[0]
      sb = sb[1:]
  else:
    if len(sc) == 0:
      print('C')
      break
    else:
      next = sc[0]
      sc = sc[1:]
Buggy python submission (verdict: Runtime Error):
S = input()
stack = [S]
ans = int(S)
checked = []
while True:
  str_num = stack.pop()
  if len(str_num) <= 1:
    continue
  for i in range(len(str_num)):
    str1 = str_num[:i]
    str2 = str_num[i:]
    if not str1 in checked:
      checked.append(str1)
      ans += int(str1)
      stack.append(str1)
    if not str2 in checked:
      checked.append(str2)
      ans += int(str2)
      stack.append(str2)
print(ans)


Fixed submission:
S = input()
ans = 0
for num in range(2**((len(S)-1))):
  before = 0
  nums = []
  for i in range(len(S)-1):
    if num>>i&1:
      nums.append(int(S[before:i+1]))
      before = i+1
  nums.append(int(S[before:]))
  ans += sum(nums)
print(ans)
Buggy python submission (verdict: Runtime Error):
N, L = map(int, input())
strings = [input() for _ in range(N)]
strings.sort()
print(''.join(strings))

Fixed submission:
N, L = map(int, input().split())
strings = [input() for _ in range(N)]
strings.sort()
print(''.join(strings))
Buggy python submission (verdict: Runtime Error):
N = int(input())
C = 'ACL'
print(ACL*N)

Fixed submission:
N = int(input())
C = 'ACL'
print(C*N)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))
MOD = 10 ** 9 + 7
ret = 0
for i in range(n-1):
  for j in range(i+1,n):
    ret += ((A[i] %MOD) * A[j]) % MOD
    ret = ret % MOD
print(ret)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
MOD = 10 ** 9 + 7
ret = 0
S = [A[0]]
for i in range(1, n):
  S.append(S[i-1] +A[i])

for i in range(n):
  ret += A[i] * (S[-1]-S[i])
  ret = ret % MOD
print(ret)
Buggy python submission (verdict: Runtime Error):
N = input()
ret = 0
for c in N:
  ret += (ret + int(c)) % 9
  
if ret  == 0:
  print(Yes)
else:
  print(No)

Fixed submission:
import collections 

N = input()
D = collections.Counter(N)
ret = 0
for c in D.keys():
  ret += int(c) * D[c]
  ret = ret % 9
  
if ret  == 0:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
N = input()
ret = 0
for c in N:
  ret += ret + int(c) % 9

if ret % 9 == 0:
  print(Yes)
else:
  print(No)

Fixed submission:
import collections 

N = input()
D = collections.Counter(N)
ret = 0
for c in D.keys():
  ret += int(c) * D[c]
  ret = ret % 9
  
if ret  == 0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
 
L = map(int, input().split())
L.sort()
ret = 0
if N >= 3:
  for i in range(N - 2):
    for j in range(i + 1, N - 1):
      if L[i] != L[j]:
        for k in range(j + 1, N):
          if L[i] != L[k] and L[j] != L[k] and L[i] + L[j] > L[k]:
            ret += 1
print(ret)

Fixed submission:
N = int(input())
 
L = list(map(int, input().split()))
L.sort()
ret = 0
if N >= 3:
  for i in range(N - 2):
    for j in range(i + 1, N - 1):
      if L[i] != L[j]:
        for k in range(j + 1, N):
          if L[i] != L[k] and L[j] != L[k] and L[i] + L[j] > L[k]:
            ret += 1
print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
N = 7 % K
i = 1
modl = [N]
ret = -1
while True:
  if N == 0:
    ret = i
    break
  N = ((N * 10) % K + 7 )% K
  if N in modl:
    break
  modl.append(N)
  i += 1
print(ret)

Fixed submission:
K = int(input())
i = 1
ret = -1
if K % 5 != 0 and K % 2 != 0:
  N = 10
  if K % 7 == 0:
    L = K * 9 // 7
  else:
    L = K * 9
  while True:
    if N % L == 1:
      ret = i
      break
    N = (N * 10 )% L
    i += 1
print(ret)
Buggy python submission (verdict: Runtime Error):
ret = 0
S = input()
T = input()
print(len[S[i] for i in range(len(S)) if S[i] != T[i]])

Fixed submission:
ret = 0
S = input()
T = input()
print(len([S[i] for i in range(len(S)) if S[i] != T[i]]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
MAX = 10**18
ret = 1
if 0 in A:
    print(0)
else:
    for a in A:
    ret *= a
    if ret > MAX:
        print(-1)
        break
    if ret < MAX:
    print(ret)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
MAX = 10**18
ret = 1
flag = True
if 0 in A:
    print(0)
else:
    for a in A:
        ret *= a
        if ret > MAX:
            print(-1)
            flag = False
            break
    if flag and ret <= MAX:
        print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
MAX = 10**18
ret = 1
for a in A:
  ret *= a
if ret > MAX:
  print(-1)
else:
  print(ret)
         

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
MAX = 10**18
ret = 1
flag = True
if 0 in A:
    print(0)
else:
    for a in A:
        ret *= a
        if ret > MAX:
            print(-1)
            flag = False
            break
    if flag and ret <= MAX:
        print(ret)
Buggy python submission (verdict: Runtime Error):
N = int(input())
m = N % 10
if m == 2 or m == 4 or m == 5 or m == 7 or　m == 9:
  ret = 'hon'
elif m == 0 or m == 1 or m == 6 or m == 8:
  ret = 'pon'
else:
  ret = 'bon'
  
print(ret)

Fixed submission:
N = int(input())
m = N % 10
if m == 2 or m == 4 or m == 5 or m == 7 or m == 9:
  ret = 'hon'
elif m == 0 or m == 1 or m == 6 or m == 8:
  ret = 'pon'
else:
  ret = 'bon'
  
print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
def modpow(a, n, mod):
    ret = 1
    while n > 0:
        if n % 2 == 1:
            ret = ret * a % mod
        a *= a
        a = a % mod
    return ret
i = 0
L = list()
while True:
    num = modpow(i,5,X)
    if num in L:
        j = L.index(num)
        ret = '{} {}'.format(i,j)
        print(ret)
        break
    else:
        L.append(num)
        i += 1

Fixed submission:
X = int(input())
L = list()
i = 0
while True:
    if i ** 5 > 10 ** 11:
        break
    L.append(i ** 5)
    i += 1
flag = False
ret = ''
for i in range(len(L)):
    if flag:
        break
    for j in range(i+1, len(L)):
        if L[j] - L[i] == X :
            ret ='{} {}'.format(j,i)
            flag = True
            break
        if L[j] + L[i] == X :
            ret ='{} {}'.format(j,-i)
            flag = True
            break
print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
def modpow(a, n, mod):
    ret = 1
    while n > 0:
        if n % 2 == 1:
            ret = ret * a % mod
        a *= a
        a = a % mod
    return ret
i = 0
L = list()
while True:
    num = modpow(i,5,X)
    if num in L:
        j = L.index(num)
        ret = '{} {}'.format(i,j)
        print(ret)
        break
    else:
        L.append(num)

Fixed submission:
X = int(input())
L = list()
i = 0
while True:
    if i ** 5 > 10 ** 11:
        break
    L.append(i ** 5)
    i += 1
flag = False
ret = ''
for i in range(len(L)):
    if flag:
        break
    for j in range(i+1, len(L)):
        if L[j] - L[i] == X :
            ret ='{} {}'.format(j,i)
            flag = True
            break
        if L[j] + L[i] == X :
            ret ='{} {}'.format(j,-i)
            flag = True
            break
print(ret)
Buggy python submission (verdict: Runtime Error):
K = int(input())
A, B = map(int, input().split())

l = 0
ret = 'NG"
while l <= B:
  if l >= A:
    ret = 'OK'
  l += K
  
print(ret)

Fixed submission:
K = int(input())
A, B = map(int, input().split())
 
l = 0
ret = 'NG'
while l <= B:
  if l >= A:
    ret = 'OK'
  l += K
  
print(ret)
Buggy python submission (verdict: Runtime Error):
S = input()S = input()

if len(S) >= 6:
    if S[2]==S[3] and S[4]==S[5]:
        ret = 'Yes'
    else:
        ret = 'No'
else:
    ret = 'No'
print(ret)

Fixed submission:
S = input()
 
if len(S) >= 6:
    if S[2]==S[3] and S[4]==S[5]:
        ret = 'Yes'
    else:
        ret = 'No'
else:
    ret = 'No'
print(ret)
Buggy python submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p = p.sort(reverse=True)
q = q.sort(reverse=True)
r = r.sort(reverse=True)
p = p[:X]
q = q[:Y]
sumlist = list()
sumlist.extend(p)
sumlist.extend(q)
sumlist.extend(r)
sumlist = sumlist.sort(reverse=True)
print(sum(sumlist[:X+Y]))

Fixed submission:
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p = p[:X]
q = q[:Y]
sumlist = list()
sumlist.extend(p)
sumlist.extend(q)
sumlist.extend(r)
sumlist.sort(reverse=True)
print(sum(sumlist[:X+Y]))
Buggy python submission (verdict: Runtime Error):
N, S = map(int, input().split())
A = list(map(int, input().split()))
MOD = 998244353
L = 0
R = 0
ret = 0

while R < N:
  if L > R:
    R = L
  if sum(A[L:R + 1]) < S:
    R += 1
  elif sum(A[L:R + 1]) > S:
    L += 1
  elif sum(A[L:R + 1]) == S:
    ret += (L + 1) * (N - R - 1) % MOD
    R += 1
print(ret)

Fixed submission:
N, M = map(int, input().split())
ret = N * (N - 1) // 2 + M * (M - 1)// 2
print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
  if i < N - 1:
    A_ = A[:i]
    A_.extend(A[i+1:])
  else:
    A_ = A[:-1]
  c = collections.Counter(A_)
  nums = [c[c_] for c_ in c.keys() if c[c_]  > 1]
  lennum = 0
  for n in nums:
    lennum += n*(n-1) // 2
  print(lennum)

Fixed submission:
import collections
N = int(input())
A = list(map(int, input().split()))
wlists = collections.Counter(A)
sum_num = 0
for i in wlists:
  sum_num += wlists[i] * (wlists[i] - 1) // 2
for i in range(N):
  num = sum_num - wlists[A[i]] * (wlists[A[i]] - 1) // 2
  if wlists[A[i]] > 1:
    num += (wlists[A[i]] - 1) * (wlists[A[i]] - 2) // 2
  print(num)
Buggy python submission (verdict: Runtime Error):
ret = -1

for i in range(1,1010):
  if int(i * 0.08) == A and int(i * 0.1) == B:
    ret = i
    break
print(ret)

Fixed submission:
A, B = map(int, input().split())
ret = -1

for i in range(1,1010):
  if int(i * 0.08) == A and int(i * 0.1) == B:
    ret = i
    break
print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
def reverse(s):
  ret = ''
  len_ = len(s) - 1
  for i in range(len(s)):
    ret += s[len_ - i]
  return ret

S = input()
N = int(input())
one_flag = False
for i in range(N):
  str_ = input()
  if ' ' in str_:
    c = str_.split()
    if c[1] == '2':
      if one_flag == False:
      	S = S + c[2]
      else:
        S = c[2] + S
    else:
      if one_flag == False:
      	S = c[2] + S
      else:
        S = S + c[2]
  else:
    one_flag = not one_flag
if one_flag == True:
  S = reverse(S)
print(S)

Fixed submission:
import queue
def reverse(s):
  ret = ''
  len_ = len(s) - 1
  for i in range(len(s)):
    ret += s[len_ - i]
  return ret

S = input()
N = int(input())


p_a = queue.LifoQueue()
rp_a = queue.Queue()
p_b = queue.Queue()
rp_b = queue.LifoQueue()
flag = False
for i in range(N):
  s = input()
  if s[0] == '1':
    flag = not flag   
  else:
    if (s[2] == '2' and not flag) or (s[2] == '1' and flag) :
      p_b.put(s[4])
    elif (s[2] == '2' and flag) or (s[2] == '1' and not flag) :
  	  p_a.put(s[4])
s_a = ''
s_b = ''
while not p_a.empty():
  s_a += p_a.get()
while not p_b.empty():
  s_b += p_b.get()
ret = s_a + S + s_b
if flag:
  ret = reverse(ret)

print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
def reverse(s):
  ret = ''
  len_ = len(s) - 1
  for i in range(len(s)):
    ret += s[len_ - i]
  return ret

S = input()
N = int(input())
for i in range(N):
  str_ = input()
  if ' ' in str_:
    c = str_.split()
    if c[1] == '2':
      S = S + c[2]
    else:
      S = c[2] + S
  else:
    S = reverse(S)
print(S)

Fixed submission:
import queue
def reverse(s):
  ret = ''
  len_ = len(s) - 1
  for i in range(len(s)):
    ret += s[len_ - i]
  return ret

S = input()
N = int(input())


p_a = queue.LifoQueue()
rp_a = queue.Queue()
p_b = queue.Queue()
rp_b = queue.LifoQueue()
flag = False
for i in range(N):
  s = input()
  if s[0] == '1':
    flag = not flag   
  else:
    if (s[2] == '2' and not flag) or (s[2] == '1' and flag) :
      p_b.put(s[4])
    elif (s[2] == '2' and flag) or (s[2] == '1' and not flag) :
  	  p_a.put(s[4])
s_a = ''
s_b = ''
while not p_a.empty():
  s_a += p_a.get()
while not p_b.empty():
  s_b += p_b.get()
ret = s_a + S + s_b
if flag:
  ret = reverse(ret)

print(ret)
Buggy python submission (verdict: Runtime Error):
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = [A1,A2,A3]
bingomap = [[0,0,0],[0,0,0],[0,0,0]]
print(A)
N = int(input())
b = list()
ret = 'No'
for i in range(N):
  b.append(int(input()))
  print(b)
  for i in range(N):
    for j in range(3):
      if b[i] in A[j]:
        bingomap[j][A[j].index(b[i])] = 1
        break
    if i >= 2 :
      if checkbingo(bingomap) == True:
        ret = 'Yes'
        break
print(ret)

def checkbingo(map_):
  for i in range(3):
    if map_[i][0] * map_[i][1] * map_[i][2] == 1:
      return True
    if map_[0][i] * map_[0][i] * map_[0][i] == 1:
      return True
  if map_[0][0] * map_[1][1] * map_[2][2] == 1:
    return True
  if map_[0][2] * map_[1][1] * map_[2][0] == 1:
    return True
  return False 

Fixed submission:
def checkbingo(map_):
  for i in range(3):
    if map_[i][0] * map_[i][1] * map_[i][2] == 1:
      return True
    if map_[0][i] * map_[1][i] * map_[2][i] == 1:
      return True
  if map_[0][0] * map_[1][1] * map_[2][2] == 1:
    return True
  if map_[0][2] * map_[1][1] * map_[2][0] == 1:
    return True
  return False 

A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = [A1,A2,A3]
bingomap = [[0,0,0],[0,0,0],[0,0,0]]
N = int(input())
b = list()
ret = 'No'
for i in range(N):
  b.append(int(input()))
for i in range(N):
  for j in range(3):
    if b[i] in A[j]:
      bingomap[j][A[j].index(b[i])] = 1
      break
  if i >= 2 :
    if checkbingo(bingomap) == True:
      ret = 'Yes'
      break
print(ret)
Buggy python submission (verdict: Runtime Error):
H = int(input())
if H == 1:
  ret = 1
else:
  count = 0
  while True:
	H = H // 2
    count += 1
    if H == 0:
      break
  ret = 2 **( count + 1) - 1

Fixed submission:
H = int(input())
if H == 1:
  ret = 1
else:
  count = 0
  while True:
    H = H // 2
    count += 1
    if H == 0:
      break
  ret = 2 **( count ) - 1
print(ret)
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())
print str(min(a**b, b**a))

Fixed submission:
a,b = map(int, input().split())
if a < b:
  print(str(a) * b)
else:
  print(str(b) * a)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))
ret = 0
for i in range(len(P)):
  if min(P[:i+1]) == P[i]:
    ret += 1
print(ret)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
ret = 0
minval = 0
for i in range(len(P)):
  if i == 0:
    minval = P[i]
  if minval >= P[i]:
    ret += 1
    minval = P[i]
print(ret)

Buggy python submission (verdict: Runtime Error):
N = int(input())
P = list(map(int, input().split()))
ret = N
for i in range(len(P)):
  if min(P[:i+1]) != P[i]:
    ret = i + 1
  	break
print(ret)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
ret = 0
minval = 0
for i in range(len(P)):
  if i == 0:
    minval = P[i]
  if minval >= P[i]:
    ret += 1
    minval = P[i]
print(ret)

Buggy python submission (verdict: Runtime Error):
N = int(input())
P = list(map(int, input().split()))

for i in range(len(P)):
  if min(P[:i+1]) != P[i]:
    return i
  return len(P)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
ret = 0
minval = 0
for i in range(len(P)):
  if i == 0:
    minval = P[i]
  if minval >= P[i]:
    ret += 1
    minval = P[i]
print(ret)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A=[]  
A=[int(x) for x in input().split()]
num = 1
count = 0
for i in range(N):
  if A[i] == num:
    num += 1
  else:
    count += 1
if count >= N-1:
  print(-1)
else:
  print(count)
  

Fixed submission:
print(6 - int(input())-int(input()))

Buggy python submission (verdict: Runtime Error):
N,S = map(int, input().split())
tmp = 1
a = 2
while (True):
  if N % a == 0 and S % a == 0:
    N,S = int(N / a), int(S / a)
    tmp *= a
    a = 1
  a += 1
  if N / 2 <= a or S / 2 <= a:
    break
print(tmp * S * N)

Fixed submission:
print(6 - int(input())-int(input()))

Buggy python submission (verdict: Runtime Error):
N = int(input())
tmp = input()
S,T =tmp.split()
out = ''
for i in range(N):
  out += S[i] + T[i]
print(out)

Fixed submission:
print(6 - int(input())-int(input()))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(i) for i in input().split()]
prod=1
for i in a:
    prod*=i
if prod>10**18:
    print(-1)
else:
    print(prod)


Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
prod=1
for i in a:
    prod*=i
    if prod>10**18:
        break
if prod>10**18:
    print(-1)
else:
    print(prod)