Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math

mod_base = (10 ** 9) + 7
n, k = map(int, input().split(" "))
a = map(int, input().split(" "))
sa = sorted(a, reverse=True)

fact = list()
fact.append(1)

for i in range(1, n + 1):
    fact.append(fact[i - 1] * i)


def comb(a, b):
    return int(fact[a] / (fact[b] * fact[a - b]))

sum_max = 0
sum_min = 0
for i in range(0, n):
    sai = sa[i]

    if (n - i - 1) >= (k - 1):
        # print("max: sai:%d comb:%d" % (sai, comb(n - i - 1, k - 1)))
        sum_max = (sum_max + sai * comb(n - i - 1, k - 1)) % mod_base

    if i >= (k - 1):
        sum_min = (sum_min + sai * comb(i, k - 1)) % mod_base
        # print("min: sai:%d comb:%d" % (sai, comb(i, k - 1)))

# print("%d %d" % (sum_max, sum_min))
print((sum_max - sum_min) % mod_base)


Fixed submission:
mod_base = (10 ** 9) + 7
n, k = map(int, input().split(" "))
a = map(int, input().split(" "))
sa = sorted(a, reverse=True)

fac = fac_inv = inv = list()


def comb_init(n_in, mod):
    global fac, fac_inv, inv
    fac = [1 for x in range(0, n_in + 1)]
    fac_inv = [1 for x in range(0, n_in + 1)]
    inv = [1 for x in range(0, n_in + 1)]
    # fac[0] = fac[1] = 1
    # fac_inv[0] = fac_inv[1] = 1
    # inv[0] = inv[1] = 1

    for i in range(2, n_in + 1):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        fac_inv[i] = fac_inv[i - 1] * inv[i] % mod


def comb(n_in, r, mod):
    if n_in < r:
        return 0
    elif n_in < 0 or r < 0:
        return 0
    else:
        return fac[n_in] * (fac_inv[r] * fac_inv[n_in - r] % mod) % mod


comb_init(n, mod_base)

sum_max = 0
sum_min = 0
for i in range(0, n):
    sai = sa[i]

    if (n - i - 1) >= (k - 1):
        # print("max: sai:%d comb:%d" % (sai, comb(n - i - 1, k - 1)))
        sum_max = (sum_max + sai * comb(n - i - 1, k - 1, mod_base)) % mod_base

    if i >= (k - 1):
        sum_min = (sum_min + sai * comb(i, k - 1, mod_base)) % mod_base
        # print("min: sai:%d comb:%d" % (sai, comb(i, k - 1)))

# print("%d %d" % (sum_max, sum_min))
print((sum_max - sum_min) % mod_base)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, raw_input().split(" "))
s = raw_input()

new_s = s[:k] + chr(ord(s[k]) + 32) + s[k+1:]
print(new_s)


Fixed submission:
n, k = map(int, raw_input().split(" "))
s = raw_input()

new_s = s[:k - 1] + chr(ord(s[k - 1]) + 32) + s[k:]
print(new_s)
Buggy python submission (verdict: Runtime Error):
import sys

s = input()

if s[0] != "A":
    print("WA")
    sys.exit(0)

if s[1] < "a" or s[1] > "z":
    print("WA")
    sys.exit(1)


sub = s[2:-1]
has = False
for c in sub:
    if not has and c == "C":
        has = True

    elif "a" <= c <= "z":
        continue

    else:
        has = False
        break

if not has:
    print("wA")
    sys.exit(0)

if "a" <= s[len(s) - 1] <= "z":
    print("AC")
else:
    print("WA")


Fixed submission:
import sys

s = input()

if s[0] != "A":
    print("WA")
    sys.exit(0)

if s[1] < "a" or s[1] > "z":
    print("WA")
    sys.exit(0)


sub = s[2:-1]
has = False
for c in sub:
    if not has and c == "C":
        has = True

    elif "a" <= c <= "z":
        continue

    else:
        has = False
        break

if not has:
    print("WA")
    sys.exit(0)

if "a" <= s[-1] <= "z":
    print("AC")
else:
    print("WA")
Buggy python submission (verdict: Runtime Error):
import itertools
import math

d, g = map(int, input().split(" "))

all = set()
for x in range(0, d):
    all.add(x)

pl = list()
for i in range(0, d):
    p, c = map(int, input().split(" "))
    pl.append((i, p, c))

ans = 100000000
for n in range(0, d + 1):
    for select in itertools.combinations(pl, n):
        full_sum = 0
        full_count = 0
        full_list = set()

        for fp, fn, fc in select:
            full_sum += (fp + 1) * 100 * fn + fc
            full_count += fn
            full_list.add(fp)
        
        if full_sum > g:
            ans = min(ans, full_count)
            # print("full: %s rest: None score: %d ans: %d" % (str(full_list), full_sum, ans))

        else:
            rest = max(all - full_list)
            rest_n, rest_p, rest_c = pl[rest]

            if g - full_sum <= (rest_n + 1) * 100 * (rest_p - 1):
                ans = min(ans, full_count + math.ceil((g - full_sum) / ((rest_n + 1) * 100)))
                # print("full: %s rest: %d score: %d ans: %d" % (str(full_list), rest_n, full_sum + rest_n * (rest_p - 1), ans))
        

print(ans)



Fixed submission:
import itertools
import math

d, g = map(int, input().split(" "))

all = set()
for x in range(0, d):
    all.add(x)

pl = list()
for i in range(0, d):
    p, c = map(int, input().split(" "))
    pl.append((i, p, c))

ans = 100000000
for n in range(0, d + 1):
    for select in itertools.combinations(pl, n):
        full_sum = 0
        full_count = 0
        full_list = set()

        for fp, fn, fc in select:
            full_sum += (fp + 1) * 100 * fn + fc
            full_count += fn
            full_list.add(fp)
        
        if full_sum >= g:
            ans = min(ans, full_count)
            # print("full: %s rest: None score: %d ans: %d" % (str(full_list), full_sum, ans))

        elif len(all - full_list) > 0:
            rest = max(all - full_list)
            rest_n, rest_p, rest_c = pl[rest]

            if g - full_sum <= (rest_n + 1) * 100 * (rest_p - 1):
                ans = min(ans, full_count + math.ceil((g - full_sum) / ((rest_n + 1) * 100)))
                # print("full: %s rest: %d score: %d ans: %d" % (str(full_list), rest_n, full_sum + rest_n * (rest_p - 1), ans))
        

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()

dp_prev = [1, 0, 0, 0]

for c in s:
    dp_new = [dp_prev[i] for i in range(0, 4)]
    for i in range(0, 4):
        if c == "A":
            dp_new[1] = dp_prev[0] + dp_prev[1]

        elif c == "B":
            dp_new[2] = dp_prev[1] + dp_prev[2]

        elif c == "C":
            dp_new[3] = dp_prev[2] + dp_prev[3]

        else:
            dp_new[0] = dp_prev[0] * 3
            dp_new[1] = dp_prev[0] + dp_prev[1] * 3
            dp_new[2] = dp_prev[1] + dp_prev[2] * 3
            dp_new[3] = dp_prev[2] + dp_prev[3] * 3

    dp_prev = dp_new

ans = dp_prev[3] % 1000000007
print(ans)


Fixed submission:
s = input()

dp_prev = [1, 0, 0, 0]

MODE_BASE = 1000000007

for c in s:
    dp_new = [dp_prev[i] for i in range(0, 4)]
    for i in range(0, 4):
        if c == "A":
            dp_new[1] = (dp_prev[0] + dp_prev[1]) % MODE_BASE

        elif c == "B":
            dp_new[2] = (dp_prev[1] + dp_prev[2]) % MODE_BASE

        elif c == "C":
            dp_new[3] = (dp_prev[2] + dp_prev[3]) % MODE_BASE

        else:
            dp_new[0] = (dp_prev[0] * 3) % MODE_BASE
            dp_new[1] = (dp_prev[0] + dp_prev[1] * 3) % MODE_BASE
            dp_new[2] = (dp_prev[1] + dp_prev[2] * 3) % MODE_BASE
            dp_new[3] = (dp_prev[2] + dp_prev[3] * 3) % MODE_BASE

    dp_prev = dp_new

ans = dp_prev[3]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

p = list(map(int, input().split(' ')))

ans = 0
for i in range(n):
    flag = True

    if i > 0:

        if min(p[:i+1]) != p[i]:
            flag = False

    if flag:
        ans += 1

print(ans)


Fixed submission:
n = int(input())

p = list(map(int, input().split(' ')))


ans = 1
min_num = p[0]

for i in range(n-1):
    if p[i+1] < min_num:
        ans += 1
        min_num = p[i+1]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

p = list(map(int, input().split(' ')))

ans = 0
for i in range(n):
    flag = True
    for j in range(i+1):
        if p[i] > p[j]:
            flag = False

    if flag:
        ans += 1

print(ans)


Fixed submission:
n = int(input())

p = list(map(int, input().split(' ')))


ans = 1
min_num = p[0]

for i in range(n-1):
    if p[i+1] < min_num:
        ans += 1
        min_num = p[i+1]

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

S=[''.join(sorted(input())) for _ in range(n)]

ans=0

for i in range(n-1):
    for j in range(i+1,n):
        if S[i]==S[j]:
            ans+=1
print(ans)        

Fixed submission:
import collections
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


n=int(input())

S=[''.join(sorted(input())) for _ in range(n)]

c=collections.Counter(S)
ans=0
for i in c.values():
    if i==2:
        ans+=1
    elif i>2:
        ans+=cmb(i,2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

S=[input() for _ in range(n)]

ans=0

for i in range(n-1):
    for j in range(i+1,n):
        if sorted(S[i])==sorted(S[j]):
            ans+=1
print(ans)

Fixed submission:
import collections
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


n=int(input())

S=[''.join(sorted(input())) for _ in range(n)]

c=collections.Counter(S)
ans=0
for i in c.values():
    if i==2:
        ans+=1
    elif i>2:
        ans+=cmb(i,2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
ans=[]
for i in range(q):
    l,r=map(int,input().split())
    ans.append(s[l-1:r].count('AC'))
for i in range(len(ans)):
    print(ans[i])

Fixed submission:
N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1:i+1]=="AC":count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])
Buggy python submission (verdict: Runtime Error):
s=input()

if s[0]=='A':
    if s[2:-1].count('C')==1:
        index=s[2:-1].index('C')
        if tmp==tmp.lower():
            print('AC')
        else:
            print('WA')
    else:
        print('WA')
else:
    print('WA')



Fixed submission:
s=input()
print('AC' if 'C' in s[2:-1] and 'A' in s and s[1:].replace('C','',1).islower() else 'WA')
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=sorted(map(int,input()))
print(a[-1]-a[0])

Fixed submission:
n=int(input())
a=sorted(map(int,input().split()))
print(a[-1]-a[0])

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=sorted(map(int,input()))
print(a[:-1]-a[0])

Fixed submission:
n=int(input())
a=sorted(map(int,input().split()))
print(a[-1]-a[0])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

a.insert(0,0)
a.append(0)

for i in range(1,n+1):
    ans=0
    tmp=a.copy()
    tmp.pop(i)
    for j in range(1,n+1):
        ans+=abs(tmp[j]-tmp[j-1])
    print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))+[0]
A.insert(0,0)
cost=0
for i in range(N+1):
    cost+=abs(A[i+1]-A[i])
for i in range(1,N+1):
    print(cost-abs(A[i+1]-A[i])-abs(A[i]-A[i-1])+abs(A[i+1]-A[i-1]))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print(a if [a,b,c].count(a)==1 else b if [a,b,c].count@(b)==1 else c)

Fixed submission:
a,b,c=map(int,input().split())
print(a if [a,b,c].count(a)==1 else b if [a,b,c].count(b)==1 else c)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

ans=[]

for i in range(n):
    a=int(input())
    if a in ans:
        ans.remove(a)
    else:
        ans.append(a)


print(len(ans))

Fixed submission:
n=int(input())

s=set()

for i in range(n):
    s^={input()}
print(len(s))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())

sa=set()
sb=set()

for i in range(m):
    a,b=map(int,input().split())
    if a==1:sb.add(b)
    if b==N:sa.add(a)

print('IMPOSSIBLE' if len(sa&sb)=0 else 'POSSIBLE')

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

sa=set()
sb=set()

for i in range(m):
    a,b=map(int,input().split())
    if a==1:sb.add(b)
    if b==n:sa.add(a)

print('IMPOSSIBLE' if len(sa&sb)==0 else 'POSSIBLE')
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
print(*A[::-2],*A[N%2::2])

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
print(' '.join(map(str,A[::-2]+A[N%2::2])))

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
print(*A[::-2],*A[N%2::2])

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
print(' '.join(map(str,A[::-2]+A[N%2::2])))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())


b=[]
k=N%2
for a in list(map(int,input().split())):
    if k==a%2:
        b.insert(0,a)
    else:
        b.append(a)
print(' '.join(map(str,b)))

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
print(' '.join(map(str,A[::-2]+A[N%2::2])))

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

b=[]
k=N%2
for a in A:
    if k==a%2:
        b.insert(0,a)
    else:
        b.append(a)
print(' '.join(map(str,b)))

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
print(' '.join(map(str,A[::-2]+A[N%2::2])))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=list(int(input()) for _ in range(n))

push=[0 for _ in range(n)]
index=0
cnt=1
flag=True

while flag:
    push[index]+=1
    if s[index]==2:
        print(cnt)
        flag=False
    else:
        if push.count(2)!=0:
            print(-1)
            flag=False
        else: 
            index=s[index]-1
            cnt+=1


Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]

c,s=1,a[0]

while s!=2 and c<n:
    c,s=c+1,a[s-1]

print(c if c<n else -1)
Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())

print(len([i for i in range(k+1)  for j in range(k+1)  for l in range(k+1) if i+j+l==s] ))

Fixed submission:
k,s=map(int,input().split())

print(len([1 for z in range(k+1) for y in range(k+1) if 0<=s-y-z<=k]))
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()

N = int(a)
S = b

alpha_dict = {chr(c): i+1 for i, c in enumerate(range(ord('A'), ord('Z')+1))}

st =""

for c in S:
    n = alpha_dict[c]
    n = n + N
    if (n > 26):
        n = n - 26
    keys = [k for k, v in alpha_dict.items() if v == n]
    st += str(keys[0])
    
print(st)

Fixed submission:
string = input()
#days = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

if string =="SUN":
  print(str(7))
elif string == "MON":
  print(str(6))
elif string == "TUE":
  print(str(5))
elif string == "WED":
  print(str(4))
elif string == "THU":
  print(str(3))
elif string == "FRI":
  print(str(2))
elif string == "SAT":
  print(str(1))

Buggy python submission (verdict: Runtime Error):
str = input()
#days = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

if str =="SUN":
  print(str(7))
else if str = "MON":
  print(str(6))
else if str = "TUE":
  print(str(5))
else if str = "WED":
  print(str(4))
else if str = "THU":
  print(3)
else if str = "FRI":
  print(2)
else if str = "SAT":
  print(1)
 

Fixed submission:
string = input()
#days = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

if string =="SUN":
  print(str(7))
elif string == "MON":
  print(str(6))
elif string == "TUE":
  print(str(5))
elif string == "WED":
  print(str(4))
elif string == "THU":
  print(str(3))
elif string == "FRI":
  print(str(2))
elif string == "SAT":
  print(str(1))

Buggy python submission (verdict: Runtime Error):
str = input()
#days = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

if str =="SUN":
  print(7)
else if str = "MON":
  print(6)
else if str = "TUE":
  print(5)
else if str = "WED":
  print(3)
else if str = "THU":
  print(3)
else if str = "FRI":
  print(2)
else if str = "SAT":
  print(1)
 

Fixed submission:
string = input()
#days = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

if string =="SUN":
  print(str(7))
elif string == "MON":
  print(str(6))
elif string == "TUE":
  print(str(5))
elif string == "WED":
  print(str(4))
elif string == "THU":
  print(str(3))
elif string == "FRI":
  print(str(2))
elif string == "SAT":
  print(str(1))
Buggy python submission (verdict: Runtime Error):
a = input().splitlines()

N = int(a[0])
S = a[1]

alpha_dict = {chr(c): i+1 for i, c in enumerate(range(ord('A'), ord('Z')+1))}

st =""

for c in S:
    n = alpha_dict[c]
    n = n + N
    if (n > 26):
        n = n - 26
    keys = [k for k, v in alpha_dict.items() if v == n]
    st += str(keys[0])
    
print(st)

Fixed submission:
a = input()
b = input()

N = int(a)
S = b

alpha_dict = {chr(c): i+1 for i, c in enumerate(range(ord('A'), ord('Z')+1))}

st =""

for c in S:
    n = alpha_dict[c]
    n = n + N
    if (n > 26):
        n = n - 26
    keys = [k for k, v in alpha_dict.items() if v == n]
    st += str(keys[0])
    
print(st)

Buggy python submission (verdict: Runtime Error):
a = input().split()

N = int(a[0])
S = a[1]

alpha_dict = {chr(c): i+1 for i, c in enumerate(range(ord('A'), ord('Z')+1))}

st =""
o = []
for c in S:
    # print(c)
    n = alpha_dict[c]
    n = n + N
    if (n > 26):
        n = n - 26
    # print(n)
    keys = [k for k, v in alpha_dict.items() if v == n]
    st += str(keys[0])
    #o.append(keys)
    # print(alpha_dict[n])


print(st)

Fixed submission:
a = input()
b = input()

N = int(a)
S = b

alpha_dict = {chr(c): i+1 for i, c in enumerate(range(ord('A'), ord('Z')+1))}

st =""

for c in S:
    n = alpha_dict[c]
    n = n + N
    if (n > 26):
        n = n - 26
    keys = [k for k, v in alpha_dict.items() if v == n]
    st += str(keys[0])
    
print(st)

Buggy python submission (verdict: Runtime Error):
a = input().split()

N = int(a[0])
S = a[1]

alpha_dict = {chr(c): i+1 for i, c in enumerate(range(ord('A'), ord('Z')+1))}

st =""
o = []
for c in S:
    # print(c)
    n = alpha_dict[c]
    n = n + 2
    if (n > 26):
        n = n - 26
    # print(n)
    keys = [k for k, v in alpha_dict.items() if v == n]
    st += str(keys[0])
    #o.append(keys)
    # print(alpha_dict[n])


print(st)

Fixed submission:
a = input()
b = input()

N = int(a)
S = b

alpha_dict = {chr(c): i+1 for i, c in enumerate(range(ord('A'), ord('Z')+1))}

st =""

for c in S:
    n = alpha_dict[c]
    n = n + N
    if (n > 26):
        n = n - 26
    keys = [k for k, v in alpha_dict.items() if v == n]
    st += str(keys[0])
    
print(st)
Buggy python submission (verdict: Runtime Error):
abcd=int(input().split())
a=abcd[0]
b=abcd[1]
c=abcd[2]
d=abcd[3]
if a+b==c+d:
  print('Balanced')
else:
    if a+b>c+d:
      print('Left')
    else:
        print('Right')
        

Fixed submission:
abcd=input().split()
a=int(abcd[0])
b=int(abcd[1])
c=int(abcd[2])
d=int(abcd[3])
if a+b==c+d:
  print('Balanced')
else:
    if a+b>c+d:
      print('Left')
    else:
        print('Right')

Buggy python submission (verdict: Runtime Error):
abcd=int(input().split())
a=abcd[0]
b=abcd[1]
c=abcd[2]
d=abcd[3]
if a+b==c+d:
  print('Balanced')
  else:
    if a+b>c+d:
      print('Left')
      else:
        print('Right')
        

Fixed submission:
abcd=input().split()
a=int(abcd[0])
b=int(abcd[1])
c=int(abcd[2])
d=int(abcd[3])
if a+b==c+d:
  print('Balanced')
else:
    if a+b>c+d:
      print('Left')
    else:
        print('Right')

Buggy python submission (verdict: Runtime Error):
abcd=int(input().split())
a=abcd[0]
b=abcd[1]
c=abcd[2]
d=abcd[3]
if a+b=c+d:
  print('Balanced')
  else:
    if a+b>c+d:
      print('Left')
      else:
        print('Right')
        

Fixed submission:
abcd=input().split()
a=int(abcd[0])
b=int(abcd[1])
c=int(abcd[2])
d=int(abcd[3])
if a+b==c+d:
  print('Balanced')
else:
    if a+b>c+d:
      print('Left')
    else:
        print('Right')

Buggy python submission (verdict: Runtime Error):
abcd=int(input().split())
a=abcd[0]
b=abcd[1]
c=abcd[2]
d=abcd[3]
if a+b=c+d:
  print('balanced')
  else:
    if a+b>c+d:
      print('Left')
      else:
        print('Right')
        

Fixed submission:
abcd=input().split()
a=int(abcd[0])
b=int(abcd[1])
c=int(abcd[2])
d=int(abcd[3])
if a+b==c+d:
  print('Balanced')
else:
    if a+b>c+d:
      print('Left')
    else:
        print('Right')
Buggy python submission (verdict: Time Limit Exceeded):
a,b=(int(x) for x in input().split())
for i in range (b):
  a=a-1
  if a==0:
    break
print(a)

Fixed submission:
a,b=(int(x) for x in input().split())
c=0
if a>b :
  c=a-b
else:
  c=0
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

n_in = input()
result = input().split()
total = 0
n_in = int(n_in)

for k0 in range(n_in):
    count = 0
    for l0 in range(k0):
        if int(result[k0]) <= int(result[l0]):
            count += 1
    if count == k0:
        total += 1

print(total)


Fixed submission:
import sys

n_in = input()
result = input().split()
total = 0
n_in = int(n_in)
p_min = int(result[0])
for k0 in range(n_in):
    count = 0
    if int(result[k0]) <= p_min:
        total += 1
        p_min = int(result[k0])

print(total)
Buggy python submission (verdict: Runtime Error):
raw_input = input()
input_list = inp.split()   

coding_contest_rank = int(input_list[0])
robot_rank = int(input_list[1])

if coding_contest_rank == 3 or robot_rank == 3:
  coding_money = 100000
  robot_money = 100000
elif coding_contest_rank == 2 or robot_rank == 2:
  coding_money = 200000
  robot_moeny = 200000
elif coding_contest_rank == 1 or robot_rank == 1:
  coding_money = 300000
  robot_moeny = 300000
elif coding_contest_rank == 1 and robot_rank == 1:
  print(1000000)
  break

print(coding_money + robot_money)
  

  

Fixed submission:
raw_input = input()
input_list = raw_input.split()   
 
coding_contest_rank = int(input_list[0])
robot_rank = int(input_list[1])


if coding_contest_rank == 3:
    coding_money = 100000
if robot_rank == 3:
    robot_money = 100000
if coding_contest_rank == 2:
    coding_money = 200000
if robot_rank == 2:    
    robot_money = 200000
if coding_contest_rank == 1:
    coding_money = 300000
if robot_rank == 1:    
    robot_money = 300000
if coding_contest_rank > 3:
    coding_money = 0
if robot_rank > 3:
    robot_money = 0

if coding_contest_rank == 1 and robot_rank == 1: 
    print(coding_money + robot_money + 400000)
else:
    print(coding_money + robot_money)
Buggy python submission (verdict: Runtime Error):
N = int(input())
B =  [int(i) for i in input().split()]

A = [0] * N
sub= [0] * N
ans = 0

A[0] = B[0]
A[-1] = B[-1] 

for i in range(1, N-2):
    A[i]   = B[i]
    A[i+1] = B[i]
    if B[i] >= B[i+1]:
        A[i] = B[i-1]

if B[N-2] > B[N-1]:
    A[N-2] = B[N-3]
        
for i in range(N):
    ans = ans + A[i]

print(ans)

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

A = [0] * N
sub= [0] * N
ans = 0

A[0] = B[0]
A[-1] = B[-1] 

# A[N-3]まで
for i in range(1, N-2):
    A[i] = min(B[i], B[i-1])

A[0] = B[0]
A[-1] = B[-1] 
A[N-2] = min(B[N-2], B[N-3])

for i in range(N):
    ans = ans + A[i]

print(ans)

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

A = [0] * N
sub= [0] * N
ans = 0

A[0] = B[0]
A[-1] = B[-1] 

if N > 2:
    for i in range(1, N-1):
        A[i]   = B[i]
        A[i+1] = B[i]
        if B[i] > B[i+1]:
            A[i] = B[i-1]

    for i in range(N):
        ans = ans + A[i]

print(ans)

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

A = [0] * N
sub= [0] * N
ans = 0

A[0] = B[0]
A[-1] = B[-1] 

# A[N-3]まで
for i in range(1, N-2):
    A[i] = min(B[i], B[i-1])

A[0] = B[0]
A[-1] = B[-1] 
A[N-2] = min(B[N-2], B[N-3])

for i in range(N):
    ans = ans + A[i]

print(ans)

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

A = [0] * N
sub= [0] * N
ans = 0

A[0] = B[0]
A[-1] = B[-1] 

for i in range(1, N-1):
    A[i]   = B[i]
    A[i+1] = B[i]
    if B[i] > B[i+1]:
        A[i] = B[i-1]
    
for i in range(N):
    ans = ans + A[i]

print(ans)

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

A = [0] * N
sub= [0] * N
ans = 0

A[0] = B[0]
A[-1] = B[-1] 

# A[N-3]まで
for i in range(1, N-2):
    A[i] = min(B[i], B[i-1])

A[0] = B[0]
A[-1] = B[-1] 
A[N-2] = min(B[N-2], B[N-3])

for i in range(N):
    ans = ans + A[i]

print(ans)