Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 17:19:32 2020

@author: NEC-PCuser
"""

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            while temp%i==0:
                temp //= i
                arr.append(i)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    return arr

if __name__ == "__main__":
    N = int(input())
    l = factorization(N)
    minimu = 10 ** 10
    ans = 0
    for i in range(0, 2**len(l)):
        a = 1
        b = 1
        for j in range(0, len(l)):
            if ((i >> j) & 1):
                a *= l[j]
            else:
                b *= l[j]
        if (abs(a - b) < minimu):
            minimu = abs(a - b)
            ans = max([len(str(a)), len(str(b))])
    print(ans)
            
                

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 17:19:32 2020

@author: NEC-PCuser
"""

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            while temp%i==0:
                temp //= i
                arr.append(i)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    return arr

def multiplication(n):
    ans = len(str(n))
    for i in range(2, int(-(-n**0.5//1))+1):
        if (n % i == 0):
            ans = max([len(str(i)), len(str(n // i))])
    return ans
        

if __name__ == "__main__":
    N = int(input())
    """
    l = factorization(N)
    """
    print(multiplication(N))
    """
    minimu = 10 ** 10
    ans = 0
    for i in range(0, 2**len(l)):
        a = 1
        b = 1
        for j in range(0, len(l)):
            if ((i >> j) & 1):
                a *= l[j]
            else:
                b *= l[j]
        if (abs(a - b) < minimu):
            minimu = abs(a - b)
            ans = max([len(str(a)), len(str(b))])
    print(ans)
    """
Buggy python submission (verdict: Time Limit Exceeded):
li=list(map(int,input().split()))

ans=-1e9

for i in range(li[0],li[1]+1):
  for j in range(li[2],li[3]+1):
    xy=i*j
    ans=max(xy,ans)
    
print(ans)


Fixed submission:
li=list(map(int,input().split()))
ans=[]
a=li[0]*li[2]
b=li[0]*li[3]
c=li[1]*li[2]
d=li[1]*li[3]
ans.append(a)
ans.append(b)
ans.append(c)
ans.append(d)

print(max(ans))

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

if (li[0] or li[1])>0:
  if (li[2] or li[3])>0:
    x=min(li[0],li[1]+1)
    y=max(li[2],li[3]+1)
    print(x*y)
  else:
    x=max(li[0],li[1]+1)
    y=max(li[2],li[3]+1)
    print(x*y)
else:
  if (li[2] or li[3])>0:
    x=mix(li[0],li[1]+1)
    y=man(li[2],li[3]+1)
    print(x*y)
  else:
    x=min(li[0],li[1]+1)
    y=min(li[2],li[3]+1)
    print(x*y)

Fixed submission:
li=list(map(int,input().split()))
ans=[]
a=li[0]*li[2]
b=li[0]*li[3]
c=li[1]*li[2]
d=li[1]*li[3]
ans.append(a)
ans.append(b)
ans.append(c)
ans.append(d)

print(max(ans))

Buggy python submission (verdict: Time Limit Exceeded):
li=list(map(int,input().split()))

ans=[]
for i in range(li[0],li[1]+1):
  for j in range(li[2],li[3]+1):
    a=i*j
    ans.append(a)
    
print(max(ans))

Fixed submission:
li=list(map(int,input().split()))
ans=[]
a=li[0]*li[2]
b=li[0]*li[3]
c=li[1]*li[2]
d=li[1]*li[3]
ans.append(a)
ans.append(b)
ans.append(c)
ans.append(d)

print(max(ans))
Buggy python submission (verdict: Runtime Error):
S=input()
T=input()

ans=10000

for i inrange(len(S)-len(T)+1):
  score=0
  U=S[i:i+len(T)]#Sのi文字目から{i+len(T)}文字目までがU->部分文字列を抜き出している
  for j in range(len(T)):
    if U[j] != T[J]:
      score += 1
  ans = min(ans, score)

print(ans)

Fixed submission:
S=input()
T=input()

ans=10000

for i in range(len(S)-len(T)+1):
  score=0
  U=S[i:i+len(T)]#Sのi文字目から{i+len(T)}文字目までがU->部分文字列を抜き出している
  for j in range(len(T)):
    if U[j] != T[j]:
      score += 1
  ans = min(ans, score)

print(ans)

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

ans=10000

for i inrange(len(S)-len(T)+1):
  score=0
  U=S[i:i+len(T)]#Sのi文字目から{i+len(T)}文字目までがU->部分文字列を抜き出している
  for j in range(len(T)):
    if U[j] != T[J]:
      score += 1
  ans = min(ans, score)

print(ans)  

Fixed submission:
S=input()
T=input()

ans=10000

for i in range(len(S)-len(T)+1):
  score=0
  U=S[i:i+len(T)]#Sのi文字目から{i+len(T)}文字目までがU->部分文字列を抜き出している
  for j in range(len(T)):
    if U[j] != T[j]:
      score += 1
  ans = min(ans, score)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=input()
sum=0

for i in range(len(n)):
  sum=sum+(int(n))
  
if sum%9==0:
  print('Yes')
else:
  print('No')

Fixed submission:
n=int(input())

if n%9==0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n=input()
l=[2,4,5,7,9]
l2=[0,1,6,8]
l3=[3]

if (n%10) in l:
  print('hon')
elif (n%10) in l2:
  print('pon')
else:
  print('bon')
  

Fixed submission:
n=input()
l1=['2','4','5','7','9']
l2=['0','1','6','8']
l3=['3']
if (n[-1] in l1):
  print('hon')
elif (n[-1] in l2):
  print('pon')
else:
  print('bon')
Buggy python submission (verdict: Runtime Error):
s=input()

if (s=='ABC'):
  print('ARC')
else:
  prin('ABC')

Fixed submission:
s=input()

if (s=='ABC'):
  print('ARC')
else:
  print('ABC')
Buggy python submission (verdict: Runtime Error):
li=[input() for i in range(4)]

while ((li[0]>0) and (li[2]>0)):
  li[2]=li[2]-li[1]
   if li[2]<=0:
      print('Yes')
  li[0]=li[0]-li[3]
   if li[0]<=0:
      print('No')


Fixed submission:
li=list(map(int,input().split()))

A=li[0]
B=li[1]
C=li[2]
D=li[3]

while ((A>0) and (C>0)) :
  C=C-B
  if C<=0:
    print('Yes')
    break
  A=A-D
  if A<=0:
    print('No')
    break

Buggy python submission (verdict: Runtime Error):
li=[input() for i in range(4)]

while ((li[0]>0) and (li[2]>0)):
  li[2]=li[2]-li[1]
   if li[2]<=0:
      print('Yes')
  li[0]=li[0]-li[3]
   if li[0]<=0:
      print('No')

Fixed submission:
li=list(map(int,input().split()))

A=li[0]
B=li[1]
C=li[2]
D=li[3]

while ((A>0) and (C>0)) :
  C=C-B
  if C<=0:
    print('Yes')
    break
  A=A-D
  if A<=0:
    print('No')
    break
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N.count(7)>0:
	print('Yes')
else:
	print('No')

Fixed submission:
N=str(input())
if N.count('7')>0:
	print('Yes')
else:
	print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
K=int(input())
sum=0

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans=fractions.gcd(fractions.gcd(i,j),k)
      sum=sum+ans
      
print(sum)

Fixed submission:
import math

K=int(input())
sum=0


for i in range(1,K+1):
    for j in range(1,K+1):
        a=math.gcd(i,j)
        for k in range(1,K+1):
            b=math.gcd(a, k)
            sum = sum + b

print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
K=int(input())
sum=0

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans=fractions.gcd(fractions.gcd(i,j),k)
      sum=sum+ans
      
print(sum)

Fixed submission:
import math

K=int(input())
sum=0


for i in range(1,K+1):
    for j in range(1,K+1):
        a=math.gcd(i,j)
        for k in range(1,K+1):
            b=math.gcd(a, k)
            sum = sum + b

print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
import math
K=int(input())
sum=0

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans=math.gcd(math.gcd(i,j),k)
      sum=sum+ans
      
print(sum)

Fixed submission:
import math

K=int(input())
sum=0


for i in range(1,K+1):
    for j in range(1,K+1):
        a=math.gcd(i,j)
        for k in range(1,K+1):
            b=math.gcd(a, k)
            sum = sum + b

print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
import math
K=int(input())
sum=0

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans=math.gcd(math.gcd(i,j),k)
      sum=sum+ans
      
print(sum)

Fixed submission:
import math

K=int(input())
sum=0


for i in range(1,K+1):
    for j in range(1,K+1):
        a=math.gcd(i,j)
        for k in range(1,K+1):
            b=math.gcd(a, k)
            sum = sum + b

print(sum)
Buggy python submission (verdict: Runtime Error):
S=(str(input())
if S.count('A')>=1:
    print('Yse')
else:
  print('No')

Fixed submission:
s = str(input())
station_a = s.count('A')
station_b = s.count('B')
if station_a != 3 and station_b != 3:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n,l=map(int,input().split())
li=[input() for i in range(n)]

sortli=sorted(li)
print("{}{}{}".format(sortli[0],sortli[1],sortli[2]))

Fixed submission:
n,l=map(int,input().split())
li=[input() for i in range(n)]

sortli=sorted(li)
print(''.join(sortli))
Buggy python submission (verdict: Time Limit Exceeded):
X,K,D = list(map(int , input().split()))
ans = 0
if (X >=0):
    a = K*D
    if (X >= a):
        ans = X-a
    else:
        time = 0
        while (True):
            X -= D
            time += 1
            if X <= 0:
                break
        nokori = (K - time) % 2
        ans = X + D*nokori
else:
    a = -(K*D)
    if (X <= a):
        ans = X-a
    else:
        time = 0
        while (True):
            X += D
            time += 1
            if X >= 0:
                break
        nokori = (K - time) % 2
        ans = X - D*nokori
Answ = abs(ans)
print(Answ)


Fixed submission:
X,K,D = list(map(int , input().split()))
ans = 0
if (X >=0):
    a = K*D
    if (X >= a):
        ans = X-a
    else:
        time = 0
        while (True):
            X -= D
            time += 1
            if X <= 0:
                break
        nokori = (K - time) % 2
        ans = X + D*nokori
else:
    a = -(K*D)
    if (X <= a):
        ans = X-a
    else:
        time = 0
        while (True):
            X += D
            time += 1
            if X >= 0:
                break
        nokori = (K - time) % 2
        ans = X - D*nokori
Answ = abs(ans)
print(Answ)
Buggy python submission (verdict: Runtime Error):
import collections
N = int(input())
D = [0]*100000
A = list(map(int, input().split()))
a = sum(A)
for j in A:
    D[j] += 1
Q = int(input())
start = sum(A)
for i in range(Q):
    x,y=[int(i) for i in input().split()]
    a += D[x]*(y-x)
    print(a)
    D[y] +=D[x]
    D[x] = 0
            


Fixed submission:
import collections
N = int(input())
D = [0]*100001
A = list(map(int, input().split()))
a = sum(A)
for j in A:
    D[j] += 1
Q = int(input())
start = sum(A)
for i in range(Q):
    x,y=[int(i) for i in input().split()]
    a += D[x]*(y-x)
    print(a)
    D[y] +=D[x]
    D[x] = 0
Buggy python submission (verdict: Runtime Error):
A,B,N = list(map(int , input().split()))

if N>B:
    x = B -1
else:
    x = N
D = []

if N > 10:
    w = N % 10
else:
    w = N-1
for i in range(w):
    F1 = (A*(x-i))//B
    F2 = A * ((x-i)//B)
    S = F1 - F2
    D.append(S)

ans = max(D)
print(ans)

Fixed submission:
A,B,N = list(map(int , input().split()))

if N>B:
    x = B -1
else:
    x = N
D = []

if N > 20:
    w = N % 15 + 5
elif N > 4:
    w = N-1
else:
    w = N
for i in range(w):
    F1 = (A*(x-i))//B
    F2 = A * ((x-i)//B)
    S = F1 - F2
    D.append(S)

ans = max(D)
print(ans)

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

if N>B:
    x = B -1
else:
    x = N
D = []

for i in range(N//2):
    F1 = (A*(x-i))//B
    F2 = A * ((x-i)//B)
    S = F1 - F2
    D.append(S)

ans = max(D)
print(ans)

Fixed submission:
A,B,N = list(map(int , input().split()))

if N>B:
    x = B -1
else:
    x = N
D = []

if N > 20:
    w = N % 15 + 5
elif N > 4:
    w = N-1
else:
    w = N
for i in range(w):
    F1 = (A*(x-i))//B
    F2 = A * ((x-i)//B)
    S = F1 - F2
    D.append(S)

ans = max(D)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = 0
for i in range(N):
    s = i % 3
    t = i % 5
        if s !=0 and t != 0:
            K += i

print(K)

Fixed submission:
N = int(input())
K = 0
for i in range(N):
    s = (i+1) % 3
    t = (i +1) % 5
    if s !=0 and t != 0:
        K +=( i+1)
print(K)

Buggy python submission (verdict: Runtime Error):
N = int(input())
K = 0
for i in range(N)
    s = i % 3
    t = i % 5
    if s !=0 and t != 0:
        K += i
print(K)


Fixed submission:
N = int(input())
K = 0
for i in range(N):
    s = (i+1) % 3
    t = (i +1) % 5
    if s !=0 and t != 0:
        K +=( i+1)
print(K)
Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
s = ((N-1)**2)*3  + (N-1) * 3 + 1
p = 0
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
for i in range (N-1):
    for j in range(N-1):
        k = gcd((i+2), (j+2))
        for l in range (N-1):
            m = gcd(k, (l+2))
            p += m
print(p + s)

Fixed submission:
N = int(input())
s = ((N-1)**2)*3  + (N-1) * 3 + 1
p = 0
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
for i in range (N-1):
    for j in range(N-1):
        k = gcd((i+2), (j+2))
        for l in range (N-1):
            if k != 1:
                m = gcd(k, (l+2))
                p += m
            else:
                p +=1
            
print(p + s)
Buggy python submission (verdict: Runtime Error):
import math
a,b,c = list(map(int , input().split()))
A = math.sqrt(a)
B = math.sqrt(b)
C = math.sqrt(C)
sahen = A + B
if sahen < C:
    print("Yes")
else:
    print("No")

Fixed submission:
a,b,c = list(map(int , input().split()))
x = c - a - b
X = x ** 2
Y = a * b * 4
Z = X - Y
if Z > 0 and x > 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from collections import Counter
int = int(input())
word = [input() for i in range(int)]
s = Counter(word)
u = a.most_common()
u.sort()
for j in range(len(u)):
    print(u[j])


Fixed submission:
from collections import Counter
int = int(input())
word = [input() for i in range(int)]
s = Counter(word).most_common()
u = s[0][1]
v = []
for i, j in s:
  if j == u:
    v.append(i)
v.sort()
print(*v)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
int = int(input())
word = [input() for i in range(int)]
s = Counter(word)
u = [k for k, v in s.items() if v == max(s.values())]
u.sort()
for j in range(len(u)):
    print(u[j])

Fixed submission:
from collections import Counter
int = int(input())
word = [input() for i in range(int)]
s = Counter(word).most_common()
u = s[0][1]
v = []
for i, j in s:
  if j == u:
    v.append(i)
v.sort()
print(*v)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
int = int(input())
word = [input() for i in range(int)]
s = Counter(word)
t = list(s.values())
u = [k for k, v in s.items() if v == max(t)]
u.sort()
for i in range(len(u)):
    print(u[i])

Fixed submission:
from collections import Counter
int = int(input())
word = [input() for i in range(int)]
s = Counter(word).most_common()
u = s[0][1]
v = []
for i, j in s:
  if j == u:
    v.append(i)
v.sort()
print(*v)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = sorted(A)
for i in range (N):
    if B[i] != A[i]:
        k += 1
if k >= 3:
    print("NO")
else:
    print("YES")

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = sorted(A)
k = 0
for i in range (N):
    if B[i] != A[i]:
        k += 1
if k >= 3:
    print("NO")
else:
    print("YES")
Buggy python submission (verdict: Runtime Error):
S = list(input())
if len(list(set(S))) != 0:
    i =0
    count = 0
    while True:
        if S[i] != S[i+1]:
            count += 1
            S[i] = S[i + 1]
        i += 1
        if i == (len(S)-1):
            break
else:
    count = 0
print(count)
            

Fixed submission:
S = list(input())
if len(list(set(S))) != 1:
    i =0
    count = 0
    while True:
        if S[i] != S[i+1]:
            count += 1
            S[i] = S[i + 1]
        i += 1
        if i == (len(S)-1):
            break
else:
    count = 0
print(count)

Buggy python submission (verdict: Runtime Error):
S = list(input())
if len(list(set(S))) != 0:
    i =0
    count = 0
    while True:
        if S[i] != S[i+1]:
            count += 1
            S[i] = S[i + 1]
        i += 1
        if i == (len(S)-1):
            break
print(count)
            

Fixed submission:
S = list(input())
if len(list(set(S))) != 1:
    i =0
    count = 0
    while True:
        if S[i] != S[i+1]:
            count += 1
            S[i] = S[i + 1]
        i += 1
        if i == (len(S)-1):
            break
else:
    count = 0
print(count)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
h = int(input())
k = (a + b)* h /2
print(round(k)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())
k = (a + b)* h /2
print(round(k))
Buggy python submission (verdict: Runtime Error):
n = int(input())
w = []
for i in range(n):
    x, y = map(int, input().split())
    z.append(x + y)
    w.append(x - y)
z.sort()
w.sort()
print(max(z[-1]-z[0], w[-1]-w[0]))

Fixed submission:
n = int(input())

z = []
w = []
for i in range(n):
    x, y = map(int, input().split())
    z.append(x + y)
    w.append(x - y)
z.sort()
w.sort()
print(max(z[-1]-z[0], w[-1]-w[0]))
Buggy python submission (verdict: Time Limit Exceeded):
l=int(input())
a=list(map(int,input().strip().split()))
q=int(input())
for i in range(q):
  m,n=map(int,input().strip().split())
  for i in range(len(a)):
    if a[i]==m:
        a[i]=n
  print(sum(a))
        


Fixed submission:
t=int(input())
import math
a=list(map(int,input().strip().split()))
q=int(input())
h=[0]*(1000000+1)
sumi=0
for i in range(len(a)):
    h[a[i]]+=1
    sumi+=a[i]
 
for i in range(q):
    b,c=map(int,input().strip().split())
    #print(h)
    sumi+=h[b]*(c-b)
    h[c]+=h[b]
    h[b]=0
    #print(h)
    print(sumi)
        
        
        
    #a=list(map(int,input().strip().split()))

Buggy python submission (verdict: Runtime Error):
t=int(input())
for i in range(t):
  a=list(map(int,input().strip().split()))
  q=int(input())
  for i in range(q):
    m,n=map(int,input().strip().split())
    for i in range(len(a)):
      if a[i]==m:
        a[i]=n
    print(sum(a))
        

Fixed submission:
t=int(input())
import math
a=list(map(int,input().strip().split()))
q=int(input())
h=[0]*(1000000+1)
sumi=0
for i in range(len(a)):
    h[a[i]]+=1
    sumi+=a[i]
 
for i in range(q):
    b,c=map(int,input().strip().split())
    #print(h)
    sumi+=h[b]*(c-b)
    h[c]+=h[b]
    h[b]=0
    #print(h)
    print(sumi)
        
        
        
    #a=list(map(int,input().strip().split()))
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int, input().split()))
ans=sum(l)**2
sq=0
for i in range(n):
  sq+=l[i]**2
ans=(ans-sq)/2

import numpy as np
print(int(np.mod(ans, 10**9+7)))

Fixed submission:
n=int(input())
l=list(map(int, input().split()))
ans=sum(l)**2

sq=0
for i in range(n):
  sq+=l[i]**2
ans=(ans-sq)//2

import numpy as np
print(np.mod(ans, 10**9+7))
Buggy python submission (verdict: Runtime Error):
k=int(input())
s=str(input())
if len(s)>k:
  print(s[0:k]+"...")
elif:
  print(s)

Fixed submission:
k=int(input())
s=str(input())
if len(s)>k:
  print(s[0:k]+"...")
else:
  print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int, input().split()))
m=max(l)
for i in range(1, n+1):
  if i<=m:
    print(l.count(i))
  else:
    print(0)

Fixed submission:
n=int(input())
l=list(map(int, input().split()))
import collections

c = collections.Counter(l)

# Counter({'a': 4, 'c': 2, 'b': 1})
for i in range(1, n+1):
  if i in c:
    print(c[i])
  else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
import itertools
import math
from functools import reduce
def gcd(*numbers):
  return reduce(math.gcd, numbers)
ans=0
for i in range(1, k+1):
  for h in range (1, k+1):
    for j in range (1, k+1):
      ans+=gcd(*[i, h, j])
print(ans)

Fixed submission:
k=int(input())
l=list(range(1, k+1))
import itertools
import math
from functools import reduce
def gcd(*numbers):
  return reduce(math.gcd, numbers)
ans=0
for v in itertools.combinations_with_replacement(l, 3):
  if v[0]==v[1]==v[2]:
    ans+=gcd(*v)
  elif v[0]==v[1]:
    ans+=gcd(*v)*3
  elif v[1]==v[2]:
    ans+=gcd(*v)*3
  elif v[0]==v[2]:
    ans+=gcd(*v)*3
  else:
    ans+=gcd(*v)*6
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
p=list(map(int, input().split()))
def chk(i, cnt, m):
  if p[i]==1:
    return cnt+1
  elif i==n-1: 
    return cnt
  else:
    if p[i]<=m:
      return chk(i+1, cnt+1, p[i])
    else:
      return chk(i+1, cnt, m)
if p[0]==1:
  print(1)
else:
  print(chk(1, 1, p[0]))

Fixed submission:
n=int(input())
p=list(map(int, input().split()))
ans=0
m=p[0]
for i in p:
  if i<=m:
    m=i
    ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
p=list(map(int, input().split()))
def chk(i, cnt, m):
  if p[i]==1:
    return cnt+1
  elif i==n-1: 
    return cnt
  else:
    if p[i]<m:
      return chk(i+1, cnt+1, p[i])
    else:
      return chk(i+1, cnt, m)
if p[0]==1:
  print(1)
else:
  print(chk(1, 1, p[0]))

Fixed submission:
n=int(input())
p=list(map(int, input().split()))
ans=0
m=p[0]
for i in p:
  if i<=m:
    m=i
    ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=str(input())
import itertools
l=[]
for v in itertools.combinations(s, 3):
  l.append(v)
print(len(set(l)))

Fixed submission:
n=int(input())
s=str(input())
ans=0
for _ in range(1000):
  t=str(_).zfill(3)
  #print(t)
  if s.find(t[0])==-1:
    continue
  check=s[s.find(t[0])+1:]
  if check.find(t[1])==-1:
    continue
  fin=check[check.find(t[1])+1:]
  if fin.find(t[2])==-1:
    continue
  ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=[]
for _ in range(n):
  l.append(int(input()))
m=max(l)
mc=l.count(m)
s=sorted(set(l))[-2]
for i in l:
  if i==m:
    if mc>1:
      print(m)
    else:
      print(s)
  else:
    print(m)


Fixed submission:
n=int(input())
l=[]
for _ in range(n):
  l.append(int(input()))
m=max(l)
mc=l.count(m)
tin=set(l)
if len(tin)==1:
  s=m
else:
  s=sorted(tin)[-2]
for i in l:
  if i==m:
    if mc>1:
      print(m)
    else:
      print(s)
  else:
    print(m)
Buggy python submission (verdict: Runtime Error):
n, m=map(int, input().split())
l=[]
for i in range(n):
  l.append(list(map(int, input().split())))
l = sorted(l, reverse=False)  
print(l)
def fns(hon, n, mon):
  if hon==m:
    return mon
  elif hon>m:
    return mon-(hon-m)*l[n-1][0]
  else:
    return fns(hon+l[n][1], n+1, mon+l[n][1]*l[n][0])
print(fns(0, 0, 0))


Fixed submission:
n, m=map(int, input().split())
l=[]
for i in range(n):
  l.append(list(map(int, input().split())))
l = sorted(l, reverse=False)  
#print(l)
drinks=0
ttl=0
add=0
for i in range(n):
  add=min(m-drinks, l[i][1])
  ttl=ttl+add*l[i][0]
  drinks+=add
  if drinks==m:
    print(ttl)
    exit()

Buggy python submission (verdict: Runtime Error):
n, m=map(int, input().split())
#for i in range(n):
l=[]

for i in range(n):
  l.append(list(map(int, input().split())))
l = sorted(l, reverse=False)  
def fns(hon, n, mon):
  if hon==m:
    return mon
  elif hon>m:
    return mon-(hon-m)*l[n-1][0]
  else:
    return fns(hon+l[n][1], n+1, mon+l[n][1]*l[n][0])
print(fns(0, 0, 0))


Fixed submission:
n, m=map(int, input().split())
l=[]
for i in range(n):
  l.append(list(map(int, input().split())))
l = sorted(l, reverse=False)  
#print(l)
drinks=0
ttl=0
add=0
for i in range(n):
  add=min(m-drinks, l[i][1])
  ttl=ttl+add*l[i][0]
  drinks+=add
  if drinks==m:
    print(ttl)
    exit()
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int, input().split()))
ans=[l[0]]
for i in range(1, n):
  if i%2==1:
    ans.append(l[i])
  else:
    ans.insert(0, l[i])
if n%2==0:
  ans.reverse()
  print(*ans)
else:
  print(*ans)

Fixed submission:
n=int(input())
l=list(map(int, input().split()))
if n%2==0:
  for i in range(n-1, 0, -2):
    print(str(l[i]), end=' ')
  for i in range(0, n, 2):
    print(str(l[i]), end=' ')
else:
  for i in range(n-1, -1, -2):
    print(str(l[i]), end=' ')
  for i in range(1, n, 2):
    print(str(l[i]), end=' ')