Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = [int(j) for j in input().split()]
maximum = 0
i = 0
for i in range(N-1):
    cnt = 0

    while H[i] >= H[i+1] and i < N-1:

        cnt+=1
        i += 1
        if maximum < cnt:
            maximum = cnt
            
        if i == N-1:
            break
        
print(maximum)

Fixed submission:
N = int(input())
H = [int(j) for j in input().split()]
maximum = 0
cnt = 0
for i in range(0,N-1):
    
    if H[i] >=H[i+1]:
        cnt+=1
        if maximum < cnt:
            maximum = cnt
    else:
        cnt=0
        
print(maximum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_List =[]
for i in range(N):
    A = int(input())
    A_List.append(A)
for i in range(N):
    print(max(A_List[:i]+A_List[i+1:]))

Fixed submission:
N = int(input())
A_List =[]
for i in range(N):
    A = int(input())
    A_List.append(A)
A_List2 = A_List.copy()
A_List2 = sorted(A_List2)

A_max = A_List2[-1]
A_max2 = A_List2[-2]

for a in A_List:
    if a ==A_max:
        print(A_max2)
    else:
        print(A_max)
Buggy python submission (verdict: Runtime Error):
#ABC 130 B
N,X=map(int,input().split())
L= [int(j) for j in input().split()]
cnt=0
d = 0

for l in L :
    d+=l
    if d <= X:
        cnt+=1
    else:
        break
print(cnt+1)

Fixed submission:
# ABC 130
X ,A =map(int,input().split(" "))
if X < A:
    print(0)
elif A<=X:
    print(10)
Buggy python submission (verdict: Time Limit Exceeded):
#ABC 127 C Prison
N,M= map(int,input().split())
ans=None
for i in range(M):
    L,R= map(int,input().split())
    tmp=set([i for i in range(L,R+1)])
    if ans is None:
        ans=tmp
    else:
        ans=ans & tmp
print(len(ans))

Fixed submission:
#ABC 127 C Prison
N,M= map(int,input().split())
MIN=0
MAX=N
for i in range(M):
    L,R= map(int,input().split())
    MAX=min(MAX,R)
    MIN=max(MIN,L)
ans =MAX-MIN+1
if ans <0:
    print(0)
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#C
N=int(input())
S=input()
even = "#"*N
odd = "."*N
eve_c=N-S.count('#')
odd_c=N-S.count('.')
ans=[]
for i in range(N):
    ans.append(S[:i+1].count('#')+S[i+1:].count('.'))

ans.append(eve_c)
ans.append(odd_c)
print(min(ans))

Fixed submission:
#https://atcoder.jp/contests/tenka1-2019-beginner/submissions/5063821
from itertools import accumulate
N=int(input())
S=input()
black=[0]*N
white=[0]*N

for i,s in enumerate(S):
    if s=="#":
        black[i]=1
    elif s==".":
        white[i]=1
#累積和を取る
black =[0]+black
black =list(accumulate(black))
white =[0]+white[::-1]
white =list(accumulate(white))[::-1]

ans =[]

for i in range(N+1):
    ans.append(black[i]+white[i])
print(min(ans))

Buggy python submission (verdict: Time Limit Exceeded):
#C
N=int(input())
S=input()
even = "#"*N

odd = "."*N
eve_c=0
odd_c=0
ans=[]
for i in range(N):
    ans.append(S[0:i+1].count('#')+S[i+1:].count('.'))
    if S[i]!=even[i]:
        eve_c+=1

    if S[i]!=odd[i]:
        odd_c+=1

ans.append(eve_c)
ans.append(odd_c)
print(min(ans))

Fixed submission:
#https://atcoder.jp/contests/tenka1-2019-beginner/submissions/5063821
from itertools import accumulate
N=int(input())
S=input()
black=[0]*N
white=[0]*N

for i,s in enumerate(S):
    if s=="#":
        black[i]=1
    elif s==".":
        white[i]=1
#累積和を取る
black =[0]+black
black =list(accumulate(black))
white =[0]+white[::-1]
white =list(accumulate(white))[::-1]

ans =[]

for i in range(N+1):
    ans.append(black[i]+white[i])
print(min(ans))
Buggy python submission (verdict: Runtime Error):
S = input()
N = len(S)
jogai = 'BDEFHIJKLMNOPQRSUVWXYZ'
cnt = []
for i in range(0,N):
    for j in range(1,N+1):
        tmp = S[i:j]
        flg = 1
        for a in jogai:
            if a in tmp:
                flg = 0
        if flg:
            cnt.append(len(tmp))
print(max(cnt))

Fixed submission:
S = input()
N = len(S)
ans =0
for i in range(0, N):
    for j in range(i, N+1):
        tmp = S[i:j]
        if len(tmp)==tmp.count('A')+tmp.count('G')+tmp.count('C')+tmp.count('T'):
            ans = max(ans,len(tmp))
print(ans)

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

jogai = 'BDEFHIJKLMNOPQRSUVWXYZ'
cnt = []
for i in range(0,len(S)):
    for j in range(1,len(S)+1):
        tmp = S[i:j]
        flg = 1
        for a in jogai:
            if a in tmp:
                flg = 0
        if flg:
            cnt.append(len(tmp))
print(max(cnt))

Fixed submission:
S = input()
N = len(S)
ans =0
for i in range(0, N):
    for j in range(i, N+1):
        tmp = S[i:j]
        if len(tmp)==tmp.count('A')+tmp.count('G')+tmp.count('C')+tmp.count('T'):
            ans = max(ans,len(tmp))
print(ans)

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

jogai = "ZXVBNMLKJHFDSQWERYUIOP"
cnt = []
for i in range(0,len(S)):
    for j in range(1,len(S)+1):
        tmp = S[i:j]
        flg = 1
        for a in jogai:
            if a in tmp:
                flg = 0
        if flg:
            cnt.append(len(tmp))
print(max(cnt))

Fixed submission:
S = input()
N = len(S)
ans =0
for i in range(0, N):
    for j in range(i, N+1):
        tmp = S[i:j]
        if len(tmp)==tmp.count('A')+tmp.count('G')+tmp.count('C')+tmp.count('T'):
            ans = max(ans,len(tmp))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#122 C

N,Q= map(int,input().split())
S=input()
ans=[0]*len(S)
for i in range(len(S)):
    ans[i]=S[0:i+1].count('AC')
    
for i in range(Q):
    l,r=map(int,input().split())
    print(ans[r-1]-ans[l-1])

Fixed submission:
#122 C
N,Q= map(int,input().split())
S=input()
ans=[0]*(N+1)

for i in range(2,N+1):
    ans[i]=ans[i-1]
    if S[i-2:i]=='AC':
        ans[i]+=1
    
for i in range(Q):
    l,r=map(int,input().split())
    print(ans[r]-ans[l])

Buggy python submission (verdict: Runtime Error):
#122 C
from itertools import accumulate
N,Q= map(int,input().split())
S=input()
ans=[0]*(N)

for i,s in enumerate(list(accumulate(S))):
    ans[i]=s.count('AC')
ans
for i in range(Q):
    L1,L2= map(int,input().split())
    print(ans[L2-1]-ans[L1-1])


Fixed submission:
#122 C
N,Q= map(int,input().split())
S=input()
ans=[0]*(N+1)

for i in range(2,N+1):
    ans[i]=ans[i-1]
    if S[i-2:i]=='AC':
        ans[i]+=1
    
for i in range(Q):
    l,r=map(int,input().split())
    print(ans[r]-ans[l])

Buggy python submission (verdict: Time Limit Exceeded):
import re
# パターンにマッチしたすべてをリストとして返す
N,Q =map(int,input().split())
S = input()
List=[[int(j) for j in input().split()] for i in range(1,Q+1)]
for i in range(Q):
    matchedList = re.findall(r"AC",S[List[i][0]-1:List[i][1]])
    print(len(matchedList))

Fixed submission:
#122 C
N,Q= map(int,input().split())
S=input()
ans=[0]*(N+1)

for i in range(2,N+1):
    ans[i]=ans[i-1]
    if S[i-2:i]=='AC':
        ans[i]+=1
    
for i in range(Q):
    l,r=map(int,input().split())
    print(ans[r]-ans[l])

Buggy python submission (verdict: Time Limit Exceeded):
#C

N,Q =map(int,input().split())
S = input()
List=[[int(j) for j in input().split()] for i in range(1,Q+1)]
for i in range(Q):
    print(S[List[i][0]-1:List[i][1]].count("AC"))

Fixed submission:
#122 C
N,Q= map(int,input().split())
S=input()
ans=[0]*(N+1)

for i in range(2,N+1):
    ans[i]=ans[i-1]
    if S[i-2:i]=='AC':
        ans[i]+=1
    
for i in range(Q):
    l,r=map(int,input().split())
    print(ans[r]-ans[l])

Buggy python submission (verdict: Time Limit Exceeded):
#C
import collections



N,Q =map(int,input().split())
S = input()
List=[[int(j) for j in input().split()] for i in range(1,Q+1)]

for i in range(Q):
    print(S[List[i][0]-1:List[i][1]].count("AC"))

Fixed submission:
#122 C
N,Q= map(int,input().split())
S=input()
ans=[0]*(N+1)

for i in range(2,N+1):
    ans[i]=ans[i-1]
    if S[i-2:i]=='AC':
        ans[i]+=1
    
for i in range(Q):
    l,r=map(int,input().split())
    print(ans[r]-ans[l])
Buggy python submission (verdict: Runtime Error):
lists=[]
lists.append(s)
for i in range(2,1000000):
    print("A",i)
    if lists[-1]%2==0:
        tmp=int(lists[-1]/2)
        lists.append(tmp)
        if lists.count(tmp)==2:
            print(i)
            exit()
    else:
        tmp=(3*lists[-1])+1
        lists.append(tmp)
        if lists.count(tmp)==2:
            print(i)
            exit()

Fixed submission:
#116 B
s =int(input())
lists=[]
lists.append(s)
for i in range(2,1000001):
    if lists[-1]%2==0:
        tmp=int(lists[-1]/2)
        lists.append(tmp)
        if lists.count(tmp)==2:
            print(i)
            exit()
    else:
        tmp=(3*lists[-1])+1
        lists.append(tmp)
        if lists.count(tmp)==2:
            print(i)
            exit()

Buggy python submission (verdict: Runtime Error):
lists=[]
lists.append(s)
for i in range(2,1000000000000000):
    print("A",i)
    if lists[-1]%2==0:
        tmp=int(lists[-1]/2)
        lists.append(tmp)
        if lists.count(tmp)==2:
            print(i)
            exit()
    else:
        tmp=(3*lists[-1])+1
        lists.append(tmp)
        if lists.count(tmp)==2:
            print(i)
            exit()

Fixed submission:
#116 B
s =int(input())
lists=[]
lists.append(s)
for i in range(2,1000001):
    if lists[-1]%2==0:
        tmp=int(lists[-1]/2)
        lists.append(tmp)
        if lists.count(tmp)==2:
            print(i)
            exit()
    else:
        tmp=(3*lists[-1])+1
        lists.append(tmp)
        if lists.count(tmp)==2:
            print(i)
            exit()
Buggy python submission (verdict: Runtime Error):
#106 A

A=int(input())
B=int(input())
print(A*B - (A+B-1))

Fixed submission:
#106 A

A,B= map(int,input().split())

print(A*B - (A+B-1))
Buggy python submission (verdict: Runtime Error):
n = int(input())

cnt =0

for i in range(26):
    for j in range(15):
        if i * 4 + j * 7 == n:
            cnt +=1
if cnt >0:
    print('Yes')
else:
    print('No')

Fixed submission:
#105 A
import math
N,K= map(int,input().split())
print(abs(math.ceil(N/K)- N//K))

Buggy python submission (verdict: Runtime Error):
n = int(input()1
for i in range(26):
    for j in range(15):
        if i * 4 + j * 7 == n:
            cnt +=1
if cnt >0:
    print('Yes')
else:
    print('No')

Fixed submission:
#105 A
import math
N,K= map(int,input().split())
print(abs(math.ceil(N/K)- N//K))
Buggy python submission (verdict: Time Limit Exceeded):
#ABC 103
#最小公倍数
from functools import reduce

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm_base(a, b):
    return a * b // gcd (a, b)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
N=int(input())
A = [int(j) for j in input().split()]

ans = 0
for a in A:
    ans+=(lcm(*A)-1)%a
print(ans)

Fixed submission:
#ABC 103
N=int(input())
A = [int(j) for j in input().split()]
print(sum(A)-len(A))

Buggy python submission (verdict: Runtime Error):
#ABC 103
import math
from functools import reduce

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
N=int(input())
A = [int(j) for j in input().split()]

ans = 0
for a in A:
    ans+=(lcm(*A)-1)%a
print(ans)

Fixed submission:
#ABC 103
N=int(input())
A = [int(j) for j in input().split()]
print(sum(A)-len(A))

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
N=int(input())
A = [int(j) for j in input().split()]

print(lcm(*A)-1)

Fixed submission:
#ABC 103
N=int(input())
A = [int(j) for j in input().split()]
print(sum(A)-len(A))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S =[]
for n in range(N):
    s = input()
    S.append(s[0])
S=sorted(S)
NAME = sorted(["M","A","R","C","H"])
from itertools import combinations
pattern = list(combinations(NAME,3))
LEN = len(S)
cnt=0
for s1 in range(LEN-2):
    for s2 in range(s1+1,LEN-1):
        for s3 in range(s2+1,LEN):
            if (S[s1],S[s2],S[s3]) in pattern:
                cnt+=1
print(cnt)

Fixed submission:
N = int(input())
S =[]
for n in range(N):
    s = input()
    S.append(s[0])
S=sorted(S)
NAME = sorted(["M","A","R","C","H"])
from itertools import combinations
from collections import Counter
pattern = list(combinations(NAME,3))
LEN = len(S)
cnt=0
Counter_S =Counter(S)
cnt = 0
for p in pattern:
    cnt +=(Counter_S[p[0]] * Counter_S[p[1]] * Counter_S[p[2]])
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S =[]
for n in range(N):
    s = input()
    S.append(s[0])
NAME = ["M","A","R","C","H"]
from itertools import permutations
pattern = list(permutations(NAME,3))
LEN = len(S)
cnt=0
for s1 in range(LEN-2):
    for s2 in range(s1+1,LEN-1):
        for s3 in range(s2+1,LEN):
            if (S[s1],S[s2],S[s3]) in pattern:
                cnt+=1
print(cnt)

Fixed submission:
N = int(input())
S =[]
for n in range(N):
    s = input()
    S.append(s[0])
S=sorted(S)
NAME = sorted(["M","A","R","C","H"])
from itertools import combinations
from collections import Counter
pattern = list(combinations(NAME,3))
LEN = len(S)
cnt=0
Counter_S =Counter(S)
cnt = 0
for p in pattern:
    cnt +=(Counter_S[p[0]] * Counter_S[p[1]] * Counter_S[p[2]])
print(cnt)
Buggy python submission (verdict: Runtime Error):
A,B= map(int,input().split())
if (A* B)%2==0:
    ans ='Even'
else:
    ans=='Odd'
print(ans)

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

if (a * b)%2 ==0:
  print("Even")
else:
  print("Odd")
Buggy python submission (verdict: Time Limit Exceeded):
N,Y= map(int,input().split())
ans = 0
for i in reversed(range(Y//10000+1)):
    for j in reversed(range(Y//5000+1)):
        k = N -i-j
        if i * 10000 + j * 5000 + k *1000 == Y and k>-1:
            print(str(i)+" "+str(j)+" "+str(k))
            exit()
print("-1 -1 -1")

Fixed submission:
#085 C

N,Y = map(int, input().split())
A =10000
B =5000
C =1000

for i in range((N)+1):
    for j in range(N+1-i):
        k = N-(i+j)
        if i * A + j * B + k * C == Y and k >= 0:
            print(str(i)+" "+str(j)+" "+str(k))
            exit()
                
print("-1 -1 -1")

Buggy python submission (verdict: Time Limit Exceeded):
#085 C
N,Y =map(int,input().split())
for i in range(N+1):
    for j in range(N+1):
        for k in range(N-(i+j)+1):
            if i * 10000 + j * 5000 + k *1000 ==Y and (i+j+k)==N:
                print(i,j,k)
                exit()
print(-1,-1,-1)

Fixed submission:
#085 C

N,Y = map(int, input().split())
A =10000
B =5000
C =1000

for i in range((N)+1):
    for j in range(N+1-i):
        k = N-(i+j)
        if i * A + j * B + k * C == Y and k >= 0:
            print(str(i)+" "+str(j)+" "+str(k))
            exit()
                
print("-1 -1 -1")
Buggy python submission (verdict: Runtime Error):
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
tmp =gcd_list(A)
for i in range(100):
    if tmp == 2**i:
        print(i)
        break

Fixed submission:
N = [int(i) for i in input()]
A = [int(i) for i in input().split()]

cnt=0
while all(i%2 ==0 for i in A):
  A = [i/2 for i in A]
  cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]

if N < D:
    print('NO')
    exit()

from collections import Counter
 
d_count = Counter(D)
t_count = Counter(T)
for k,v in t_count.items():
    if k not in d_count:
        print('NO')
        exit()
    if d_count[k]< v:
        print('NO')
        exit()
print('YES') 

Fixed submission:
N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]

if N < M:
    print('NO')
    exit()

from collections import Counter
 
d_count = Counter(D)
t_count = Counter(T)
for k,v in t_count.items():
    if k not in d_count:
        print('NO')
        exit()
    if d_count[k]< v:
        print('NO')
        exit()
print('YES')

Buggy python submission (verdict: Runtime Error):
N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]

if N < T:
    print('NO')
    exit()

from collections import Counter
 
d_count = Counter(D)
t_count = Counter(T)
for k,v in t_count.items():
    if k not in d_count:
        print('NO')
        exit()
    if d_count[k]< v:
        print('NO')
        exit()
print('YES') 

Fixed submission:
N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]

if N < M:
    print('NO')
    exit()

from collections import Counter
 
d_count = Counter(D)
t_count = Counter(T)
for k,v in t_count.items():
    if k not in d_count:
        print('NO')
        exit()
    if d_count[k]< v:
        print('NO')
        exit()
print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]
D2 =D

cnt=0
for t in set(T):
    if t in set(D):
        cnt+=1
if cnt !=len(set(T)):
    print('NO')
    exit()
for i in T:
    try:
        D2.remove(i)
    except:
        print('NO')
        exit()
print('YES')

Fixed submission:
N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]

if N < M:
    print('NO')
    exit()

from collections import Counter
 
d_count = Counter(D)
t_count = Counter(T)
for k,v in t_count.items():
    if k not in d_count:
        print('NO')
        exit()
    if d_count[k]< v:
        print('NO')
        exit()
print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]
D2 =D
for i in T:
    try:
        D2.remove(i)
    except:
        print('NO')
        exit()
print('YES')

Fixed submission:
N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]

if N < M:
    print('NO')
    exit()

from collections import Counter
 
d_count = Counter(D)
t_count = Counter(T)
for k,v in t_count.items():
    if k not in d_count:
        print('NO')
        exit()
    if d_count[k]< v:
        print('NO')
        exit()
print('YES')
Buggy python submission (verdict: Runtime Error):
#ABC 072 C
N=int(input())
A=[int(j) for j in input().split()]
cnt=[0]*(10**5)
for a in A:
    cnt[a]+=1
    cnt[a+1]+=1
    cnt[a+2]+=1
print(max(cnt))

Fixed submission:
#ABC 072 C
N=int(input())
A=[int(j) for j in input().split()]
cnt=[0]*(10**6)
for a in A:
    cnt[a]+=1
    cnt[a+1]+=1
    cnt[a+2]+=1
print(max(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
#ABC 072 C
N=int(input())
A=[int(j) for j in input().split()]
cnt=0
for a in A:
    tmp=0
    for i in range(len(A)):
        if -1<= A[i]-a <=1:
            tmp+=1
    cnt=max(tmp,cnt)
print(cnt)

Fixed submission:
#ABC 072 C
N=int(input())
A=[int(j) for j in input().split()]
cnt=[0]*(10**6)
for a in A:
    cnt[a]+=1
    cnt[a+1]+=1
    cnt[a+2]+=1
print(max(cnt))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
N = int(input())
A = [int(i) for i in input().split()]
tmp = list(accumulate(A))[:len(A)-1]
ans = min([abs(sum(A)-2*a) for a in tmp])
print(ans)

Fixed submission:
from itertools import accumulate
N = int(input())
A = [int(i) for i in input().split()]
tmp = list(accumulate(A))[:len(A)-1]
total  = sum(A)

    
ans = min([abs(total-2*a) for a in tmp])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
N = int(input())
A = [int(i) for i in input().split()]

ans = min([abs(sum(A)-2*a) for a in list(accumulate(A))[:len(A)-1]])
print(ans)

Fixed submission:
from itertools import accumulate
N = int(input())
A = [int(i) for i in input().split()]
tmp = list(accumulate(A))[:len(A)-1]
total  = sum(A)

    
ans = min([abs(total-2*a) for a in tmp])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# ABC 066 C
N = int(input())
A = input().split()

tmp = []
for i,a in enumerate(A):
    if i %2!=0:
        tmp.insert(0,a)
    else:
        tmp.append(a)
if N%2!=0:
    tmp.reverse()
print(' '.join(tmp))

Fixed submission:
# ABC 066 C
N = int(input())
A = input().split()
from collections import deque

tmp = deque([])
for i,a in enumerate(A):
    if i %2!=0:
        tmp.appendleft(a)
    else:
        tmp.append(a)
if N%2!=0:
    tmp.reverse()
print(' '.join(tmp))

Buggy python submission (verdict: Time Limit Exceeded):
# ABC 066 C
N = int(input())
A = input().split()

tmp = []
for i,a in enumerate(A):
    if i %2!=0:
        tmp.insert(0,a)
    else:
        tmp.append(a)
if N%2!=0:
    tmp=tmp[::-1]
print(' '.join(tmp))

Fixed submission:
# ABC 066 C
N = int(input())
A = input().split()
from collections import deque

tmp = deque([])
for i,a in enumerate(A):
    if i %2!=0:
        tmp.appendleft(a)
    else:
        tmp.append(a)
if N%2!=0:
    tmp.reverse()
print(' '.join(tmp))

Buggy python submission (verdict: Time Limit Exceeded):
# ABC 066 C
N = int(input())
A = input().split()

tmp = []
for i,a in enumerate(A):
    if i %2!=0:
        A =list(a)
        A.extend(tmp)
        tmp=A
    else:
        tmp.append(a)
if N%2!=0:
    tmp=tmp[::-1]
print(' '.join(tmp))

Fixed submission:
# ABC 066 C
N = int(input())
A = input().split()
from collections import deque

tmp = deque([])
for i,a in enumerate(A):
    if i %2!=0:
        tmp.appendleft(a)
    else:
        tmp.append(a)
if N%2!=0:
    tmp.reverse()
print(' '.join(tmp))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))
not_b10 = sorted([s for s in S if s%10 != 0])
b10 = sorted([s for s in S if s%10 == 0])
    
if sum(S)%10!=0:
    print(sum(S))
elif S ==b10:
    print(0)
else:

    print(sum(S)-not_b10[0])

Fixed submission:
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))
nb10 = ([s for s in S if s%10 != 0])
b10  = ([s for s in S if s%10 == 0])
    
if sum(S)%10!=0:
    print(sum(S))
elif sum(S) ==sum(b10):
    print(0)
else:

    print(sum(S)-sorted(nb10)[0])
Buggy python submission (verdict: Runtime Error):
N,M= map(int,input().split())
AB=[[int(j) for j in input().split()] for i in range(M)]
result=dict()

for i in range(M):
    ind =AB[i][0]
    ind2 =AB[i][1]
    #print(i,ind,ind2)
    if result.get(str(ind)) is None:
        result[str(ind)] =1
    else:
        result[str(ind)] =result[str(ind)]+1
    
    if result.get(str(ind2)) is None:
        result[str(ind2)] =1
    else:
        result[str(ind2)] =result[str(ind2)]+1
    #print(result)
    
for i in range(1,N+1):    
    print(result[str(i)])

Fixed submission:
N,M= map(int,input().split())
f = [0] * (N + 2)
for i in range(M):
    x,y = map(int,input().split())
    f[x]+=1
    f[y]+=1
for i in range(1,N+1):
    print(f[i])
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
AB =[]
for n in range(N):
    a,b = map(int,input().split())
    AB.extend([a]*b)
print(sorted(AB)[K-1])

Fixed submission:
N,K = map(int,input().split())
AB =[]
for n in range(N):
    a,b = map(int,input().split())
    AB.append([a,b])
AB.sort(key=lambda x:x[0])
cnt = 0
for i,a in enumerate(AB):
    if cnt < K:
        cnt +=a[1]
    if cnt >=K:
        print(a[0])
        exit()
Buggy python submission (verdict: Runtime Error):
# ABC 056 C
X =int(input())
for t in range(10**9):
    if t * (t+1)/2 >=X:
        print(t)
        exit()a

Fixed submission:
# ABC 056 C
X =int(input())
for t in range(10**9):
    if t * (t+1)/2 >=X:
        print(t)
        exit()

Buggy python submission (verdict: Time Limit Exceeded):
# ABC 056 C
X =int(input())
L = [int(i) for i in range(X+1)]
from itertools import accumulate
for ind,val in enumerate(list(accumulate(L))):
    if val >=X:
        print(ind)
        exit()

Fixed submission:
# ABC 056 C
X =int(input())
for t in range(10**9):
    if t * (t+1)/2 >=X:
        print(t)
        exit()