Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
L,R = map(int,input().split())

ans = 2018
for i in range(L,R):
    for j in range(i+1,R+1):
        tmp = i*j%2019
        if(tmp < ans):
            ans = tmp

print(ans)

Fixed submission:
L,R = map(int,input().split())

if(R-L>=2018):
    print(0)
else:
    ans = 2018
    for i in range(L,R):
        for j in range(i+1,R+1):
            tmp = i*j%2019
            if(tmp < ans):
                ans = tmp
    
    print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())

MOD = 10**9 +7

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


def cmb(n,k):
    return (fact[n]//(fact[k]*fact[n-k]))%MOD

def f(x,y):
    if(x<0):return 0
    if(y<0):return 0
    if(x<y):return 0
    return cmb(x-1,y-1)


for i in range(1,K+1):

    print ((f(K,i))*(f(N-K,i-1)+2*f(N-K,i)+f(N-K,i+1))%MOD)

Fixed submission:
word = input()

while True:
    if(word[0]==word[1]):
        if((word[2]==word[3])and(word[0]!=word[2])):
            print("Yes")
            break
    if(word[0]==word[2]):
        if(word[1]==word[3])and(word[0]!=word[1]):
            print("Yes")
            break    
    if(word[0]==word[3]):
        if((word[1]==word[2])and(word[0]!=word[1])):
            print("Yes")
            break
    if((word[1]==word[2])and(word[0]==word[1])):
        print("No")
        break
    if((word[1]==word[3])and(word[0]==word[1])):
        print("No")
        break
    if((word[1]==word[3])and(word[2]==word[1])):
        print("No")
        break
    else:      
        print("No")
        break

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

count = 0
for i in range(N-2):
    if((num[i]<num[i+1]<num[i+2])or(num[i]>num[i+1]>num[i+2])):
        count +=1
print(count)

Fixed submission:
word = input()

while True:
    if(word[0]==word[1]):
        if((word[2]==word[3])and(word[0]!=word[2])):
            print("Yes")
            break
    if(word[0]==word[2]):
        if(word[1]==word[3])and(word[0]!=word[1]):
            print("Yes")
            break    
    if(word[0]==word[3]):
        if((word[1]==word[2])and(word[0]!=word[1])):
            print("Yes")
            break
    if((word[1]==word[2])and(word[0]==word[1])):
        print("No")
        break
    if((word[1]==word[3])and(word[0]==word[1])):
        print("No")
        break
    if((word[1]==word[3])and(word[2]==word[1])):
        print("No")
        break
    else:      
        print("No")
        break
Buggy python submission (verdict: Runtime Error):
A,B,C,D = map(int,input().split())

def gcd(x,y):

    if(y>x):
        x,y = y,x
    if(x%y==0):
        return y
    else:return gcd(y,x%y)


def lcm(x,y):
    return x*y//gcd(x,y)


Bika = B - B//C -B//D + B//lcm(C,D)
Aika = A-1 - (A-1)//C -(A-1)//D + (A-1)//lcm(C,D)

print(Bika-Aika)


Fixed submission:
pw = input()

if(pw[0]==pw[1] or pw[1]==pw[2] or pw[2] ==pw[3]):
    print("Bad")
    
else:
    print("Good")
Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,D = map(int,input().split())

count = 0
for i in range(A,B+1):
    if((i%C !=0) and (i%D !=0)):
        count+=1

print(count)

Fixed submission:
A,B,C,D = map(int,input().split())

def gcd(x,y):

    if(y>x):
        x,y = y,x
    if(x%y==0):
        return y
    else:return gcd(y,x%y)


def lcm(x,y):
    return x*y//gcd(x,y)

Bika = B - B//C -B//D + B//lcm(C,D)
Aika = A-1 - (A-1)//C -(A-1)//D + (A-1)//lcm(C,D)

print(Bika-Aika)
Buggy python submission (verdict: Runtime Error):
MOD = 1000000007

N,M = map(int,input().split())
A=[int(input()) for i in range(M)]



def binet_mod(n):
    if(n==0):
        return 0
    return((int(1/5**(1/2)*((((1+5**(1/2))/2)**n)-((1-5**(1/2))/2)**n)))%MOD)
    

l = 0
ans = 1

for i in range(M):
    ans = ans * binet_mod(A[i] - l)
    l = A[i] + 1
    

ans = (ans * binet_mod(N-l+1))%MOD
print(ans)

Fixed submission:
MOD = 1000000007

N,M = map(int,input().split())
A=[int(input()) for i in range(M)]

T = [-1]*(N+1)

T[0] = 1
T[1] = 1

for i in (A):
    T[i] = 0

    


for i in range(2,N+1):
    if(T[i] == -1):
        T[i] = (T[i-1] + T[i-2])%MOD
        
print(T[N])
Buggy python submission (verdict: Runtime Error):
import math
n, w = map(int, input().split())
m = list()
for i in range(n):
  m.append(int(input()))

w -= sum(m)
print(len(m) + math.floor(w/min(m)))

Fixed submission:
s = input()
t = 700 + (100 * s.count("o"))
print(t)
Buggy python submission (verdict: Runtime Error):
n = int(input())

a = []
maximum = 0
second_maximum = 0
for i in range(n):
    input_num = int(input())
    a.append(input_num)
    if input_num > maximum:
        second_maximum = maximum
        maximum = input_num
    elif input_num > second_maximum:
        second_maximum = input_num
        
for a_num in a:
    if a_num == maximum:
        print(second_maximum)
    else:
        print(maximum)

Fixed submission:
n = int(input())

print(3 * (n ** 2))
Buggy python submission (verdict: Runtime Error):
from math import factorial

def count_pattern(n, r):
    if r == 0:
        return 1
    else:
        a = factorial(n) // factorial(r) // factorial(n - r)
    return int(a)

n, k = map(int, input().split())

for i in range(k):
    pick_count = i + 1

    blue_pattern =  count_pattern(k - 1, pick_count - 1)
    red_pattern = count_pattern(n - k + 1 , pick_count)
    total_pattern = blue_pattern * red_pattern
    print (int(total_pattern % (10 ** 9 + 7)))


Fixed submission:
import collections

inputstr = input()
input = sorted(inputstr)
a = collections.Counter(input)
if len(a) == 2 and a.most_common()[0][1] == 2:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
import sys
import collections

input = sorted(sys.argv[1])
a = collections.Counter(input)
if len(a) == 2 and a.most_common()[0][1] == 2:
    print('Yes')
else:
    print('No')

Fixed submission:
import collections

inputstr = input()
input = sorted(inputstr)
a = collections.Counter(input)
if len(a) == 2 and a.most_common()[0][1] == 2:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
from math import factorial

def count_pattern(n, r):
    if r == 0:
        return 1
    else:
        a = factorial(n) // factorial(r) // factorial(n - r)
    return int(a)

n, k = map(int, input().split())

for i in range(k):
    pick_count = i + 1

    blue_pattern =  count_pattern(k - 1, pick_count - 1)
    red_pattern = count_pattern(n - k + 1 , pick_count)
    total_pattern = blue_pattern * red_pattern
    print (int(total_pattern % (10 ** 9 + 7)))


Fixed submission:
from math import factorial

def count_pattern(n, r):
    if r == 0:
        return 1
    elif n < r:
        return 0
    else:
        a = factorial(n) // factorial(r) // factorial(n - r)
    return int(a)

n, k = map(int, input().split())

for i in range(k):
    pick_count = i + 1

    blue_pattern =  count_pattern(k - 1, pick_count - 1)
    red_pattern = count_pattern(n - k + 1 , pick_count)
    total_pattern = blue_pattern * red_pattern
    print (int(total_pattern % (10 ** 9 + 7)))

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

def count_pattern(n, r):
    if r == 0:
        return 1
    else:
        a = factorial(k) / factorial(r) / factorial(n - r)

n, k = map(int, input().split())

for i in range(k):
    blue_pattern =  count_pattern(n, i - 1)
    red_pattern = count_pattern(k, i)
    total_pattern = blue_pattern * red_pattern
    print (total_pattern % (10 ** 9 + 7))


Fixed submission:
from math import factorial

def count_pattern(n, r):
    if r == 0:
        return 1
    elif n < r:
        return 0
    else:
        a = factorial(n) // factorial(r) // factorial(n - r)
    return int(a)

n, k = map(int, input().split())

for i in range(k):
    pick_count = i + 1

    blue_pattern =  count_pattern(k - 1, pick_count - 1)
    red_pattern = count_pattern(n - k + 1 , pick_count)
    total_pattern = blue_pattern * red_pattern
    print (int(total_pattern % (10 ** 9 + 7)))
Buggy python submission (verdict: Runtime Error):
ソースコード
[0]
1
N = int(input())
2
n_list = list(map(int,input().split()))
3
​
4
n_list.sort()
5
​
6
new_list = []
7
ctr = 0
8
​
9
while len(n_list) > 1:
10
  n_list[ctr] = (n_list[ctr] + n_list[ctr+1])/2
11
  n_list.pop(ctr + 1)
12
  n_list.sort
13
  
14
print(n_list[0

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

n_list.sort()

new_list = []
ctr = 0

while len(n_list) > 1:
  n_list[ctr] = (n_list[ctr] + n_list[ctr+1])/2
  n_list.pop(ctr + 1)
  n_list.sort
  
print(n_list[0])
Buggy python submission (verdict: Runtime Error):
A, B, C = input().split()
 
answer = (B + C) % A
 
print(answer)

Fixed submission:
A, B, C = map(int,input().split())
print(C - min(A-B,C))

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())

answer = (b + c) % a

print(answer)

Fixed submission:
A, B, C = map(int,input().split())
print(C - min(A-B,C))
Buggy python submission (verdict: Time Limit Exceeded):
A, B = map(int,input().split())

for i in range(1,10**9):
  if (abs(A-i) == abs(B-i)):
      print(i)
      exit()

print("IMPOSSIBLE")

Fixed submission:
A, B = map(int,input().split())
 
if (A % 2 != B % 2):
  print("IMPOSSIBLE")
else:
  print(int((A + B) / 2))
Buggy python submission (verdict: Runtime Error):
N = int(input())
X = list(map(int,input().split())
ctr = 0
         
for i in range(1,N):
  if X[i] != i:
    ctr += 1

if ctr > 2:
  print("NO")
else:
  print("YES")

Fixed submission:
N = int(input())
X = list(map(int,input().split()))
ctr = 0
         
for i in range(1,N):
  if X[i-1] != i:
    ctr += 1
 
if ctr > 2:
  print("NO")
else:
  print("YES")
Buggy python submission (verdict: Runtime Error):
N = input()
A = list((map(int,input().split()))
B = list(map(int,input().split()))

ans = 0
         
for i in range(0,N):
    left = A[i] - B[i]
	ans += min(A[i],B[i])
         
    if left < 0:
		right = A[i+1] - abs(left)
    	ans += min( A[i+1],abs(left))
		A[i+1] = right

print(ans)


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

ans = 0
         
for i in range(0,N):
      left = A[i] - B[i]
      ans += min(A[i],B[i])
         
      if left < 0:
          right = A[i+1] - abs(left)
          if right < 0: right = 0
          ans += A[i+1] - right
          A[i+1] = right

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())

input_list = []
tmplist = []

for i in range(N):
  input_list.append(int(input()))

for i in input_list:
  tmplist = input_list[:]
  tmplist.remove(i)
  print(max(tmplist))

Fixed submission:
r = int(input())
print(3*r**2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
 
input_list = []
tmplist = []
 
for i in range(N):
  input_list.append(int(input()))
 
for i in input_list:
  tmplist = input_list[:]
  tmplist.remove(i)
  print(max(tmplist))

Fixed submission:
N = int(input())
 
input_list = []
tmplist = []
 
for i in range(N):
  input_list.append(int(input()))

sorted_list = sorted(input_list)

first_val = sorted_list[-1]
second_val = sorted_list[-2]

for i in input_list:
  if i == first_val:
    print(second_val)
  else:
    print(first_val)

Buggy python submission (verdict: Time Limit Exceeded):
import copy

N = int(input())

input_list = []
tmplist = []

for i in range(N):
  input_list.append(int(input()))

for i in input_list:
  tmplist = copy.copy(input_list)
  tmplist.remove(i)
  print(max(tmplist))

Fixed submission:
N = int(input())
 
input_list = []
tmplist = []
 
for i in range(N):
  input_list.append(int(input()))

sorted_list = sorted(input_list)

first_val = sorted_list[-1]
second_val = sorted_list[-2]

for i in input_list:
  if i == first_val:
    print(second_val)
  else:
    print(first_val)
Buggy python submission (verdict: Runtime Error):
N = int(input())
Plist = list(map(int,input().split()))
ctr = 0
 
for i in range(1,N-2):
  if (Plist[i] > Plist[i-1]) or (Plist[i] > Plist[i+1]):
    ctr += 1
 
print(ctr)

Fixed submission:
N = input()

for i in N:
  if N.count(i) != 2:
    print("No")
    exit()

print("Yes")
Buggy python submission (verdict: Runtime Error):
A,B,C,D = map(int,input().split())
 
def gcd( x, y ):
    while y != 0:
        x, y = y, x%y

ctr = 0

tmp1 = A // C
tmp2 = A // D
tmp3 = B // (C * D / gcd(C,D))
tmp4 = B // C
tmp5 = B // D

print(tmp4 + tmp5 - tmp3 - tmp1 -tmp2)



Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

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

b_num = B//C + B//D - B//lcm(C, D)
a_num = (A-1)//C + (A-1)//D - (A-1)//lcm(C, D)

print((B-A+1) -(b_num - a_num))
Buggy python submission (verdict: Runtime Error):
r,D,x = map(int,input().split())

tmp = r * x - D
print(tmp)

for i in range(1 to 10):
  tmp = tmp * x - D
  print(temp)

Fixed submission:
r,D,x = map(int,input().split())
 
tmp = r * x - D
print(tmp)
 
for i in range(1 , 10):
  tmp = tmp * r - D
  print(tmp)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
list = []
 
for i in range(M):
  L,R = map(int,input().split())
  list.extend(range(L,R + 1))
 
unq = set(list)

counter = 0
 
for i in unq:
  if list.count(i) == M:
    counter +=1
    
print(counter)

Fixed submission:
N,M = map(int,input().split())
L_list = []
R_list = []

for i in range(M):
  L,R = map(int,input().split())
  L_list.append(L)
  R_list.append(R)
  
if min(R_list) >= max(L_list):
  print(min(R_list)  - max(L_list)+1)
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
str = "Christmas"
 
if N != 25:
	while N < 25:
		str += " Eve"
		N -= 1
        
print(str)

Fixed submission:
N = int(input())
str = "Christmas"
 
if N != 25:
	while N < 25:
		str += " Eve"
		N += 1
        
print(str)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
str = "Christmas"
 
if N != 25:
	while N >= 22:
		str += " Eve"
		N += 1
        
print(str)

Fixed submission:
N = int(input())
str = "Christmas"
 
if N != 25:
	while N < 25:
		str += " Eve"
		N += 1
        
print(str)

Buggy python submission (verdict: Runtime Error):
N = int(input())
str = "Christmas"
 
if N != 25:
	while N >= 22:
		str += " Eve"
        N -= 1
        
print(str)

Fixed submission:
N = int(input())
str = "Christmas"
 
if N != 25:
	while N < 25:
		str += " Eve"
		N += 1
        
print(str)

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

if N != 25:
	while N >= 22:
		str += " Eve"
        
print(str)
  

Fixed submission:
N = int(input())
str = "Christmas"
 
if N != 25:
	while N < 25:
		str += " Eve"
		N += 1
        
print(str)
Buggy python submission (verdict: Runtime Error):
N = int(input())

input_list = []

for i in range(N):
  input_list.append(int(input)) 
  
input_list.sort()

input_list[-1] = int(input_list[-1] / 2)

ans = 0
for i in input_list:
  ans += i
  
print(ans)

Fixed submission:
N = int(input())
 
input_list = []
 
for i in range(N):
  input_list.append(int(input())) 
  
input_list.sort()
 
input_list[-1] = int(input_list[-1] / 2)
 
ans = 0
for i in input_list:
  ans += i
  
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N >= 1000:
  print("ABD"+str((N-1000).zfill(3)))
else:
  print("ABC"+str((N).zfill(3)))

Fixed submission:
N = int(input())
 
if N >= 1000:
  print("ABD")
else:
  print("ABC")
Buggy python submission (verdict: Runtime Error):
BlueN = int(input())
BlueList = []
for i in range(1,BlueN):
  BlueList.append(input())

RedN = int(input())
RedList = []
for i in range(1,RedN):
  RedList.append(input())

stocker = 0

for i in set(BlueList):
  if BlueList.count(i) * 1 + RedList.count(i) * -1 >= stocker:
    stocker = BlueList.count(i)

print(stocker)

Fixed submission:
BlueN = int(input())
BlueList = []
for i in range(0,BlueN):
  BlueList.append(input())

RedN = int(input())
RedList = []
for i in range(0,RedN):
  RedList.append(input())

stocker = 0

for i in set(BlueList):
  if BlueList.count(i) * 1 + RedList.count(i) * -1 >= stocker:
    stocker = BlueList.count(i) * 1 + RedList.count(i) * -1

print(stocker)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split()

if a * b % 2 == 0:
  print("Even")
else:
  print("Odd")

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

if a * b % 2 == 0:
  print("Even")
else:
  print("Odd")
Buggy python submission (verdict: Runtime Error):
N = input()
ctr = 0
for i in range(0,len(N)-1):
	if N[i] = "1":ctr+=1
print(ctr)

Fixed submission:
N = input()
ctr = 0
for i in N:
	if i == "1":ctr+=1
print(ctr)
Buggy python submission (verdict: Runtime Error):
n, a, b = map( int, input() )
print( min( n*a, b ) )

Fixed submission:
n, a, b = map( int, input().split() )
print( min( n*a, b ) )
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; ++i )
typedef long long ll ;


int main() {
  string n_str = 0;
  cin >> n_str ;
  if ( n_str[0] == n_str[2] ) puts( "Yes" ) ;
  else                        puts( "No" ) ;

  return 0 ;
}



Fixed submission:
a, b, c = input()
print( "Yes" if a==c else "No" )
Buggy python submission (verdict: Runtime Error):
o = input()
e = input() + [""]

for x,y in zip( o, e ) : print( x+y, sep="" )

Fixed submission:
o = list(input())
e = list(input()) + [""]

for x,y in zip( o, e ) : print( x+y, end="" )
Buggy python submission (verdict: Runtime Error):
input_N_L = input()
#print( input_N_L )
N, L = map( int, input_N_L.split() )

#print( N )
#print( L )

str_set = []
for i in range( L ):
  str_set.append( input() )
#print( array )

sorted_str = ""
for s in sorted( str_set ):
  sorted_str += s
print( sorted_str )

Fixed submission:
n, l = map( int, input().split( ' ' ) )
strs = sorted( [ input() for i in range(n) ] )
print( ''.join( strs ) )

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

str_set = set()
for i in range( L ):
  str_set.add( input() )

sorted_str = ""
for s in sorted( str_set ):
  sorted_str += s
print( sorted_str )

Fixed submission:
n, l = map( int, input().split( ' ' ) )
strs = sorted( [ input() for i in range(n) ] )
print( ''.join( strs ) )

Buggy python submission (verdict: Runtime Error):
input_N_L = input()
#print( input_N_L )
N, L = map( int, input_N_L.split() )

#print( N )
#print( L )

str_set = set()
for i in range( L ):
  str_set.add( input() )
#print( array )

sorted_str = ""
for s in sorted( str_set ):
  sorted_str += s
print( sorted_str )

Fixed submission:
n, l = map( int, input().split( ' ' ) )
strs = sorted( [ input() for i in range(n) ] )
print( ''.join( strs ) )

Buggy python submission (verdict: Runtime Error):
array_temp = input.split()
N = array[0]
L = array[1]
strs = array[2:]
strs.sort()
print(strs)

Fixed submission:
n, l = map( int, input().split( ' ' ) )
strs = sorted( [ input() for i in range(n) ] )
print( ''.join( strs ) )
Buggy python submission (verdict: Runtime Error):
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

h, w, a, b = map( int, input().split() )

ans = 0
mod_parent = 10**9 + 7
for i in range( 1, w-b ) :
  ans += ( cmb( h-a-1+i, i ) %  mod_parent ) + ( cmb( a+w-i-2, a-1 ) %  mod_parent )
print( ans )

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

SIZE = h+w+2
MOD = 10**9 + 7
MOD_Farmer = 10**9+5

fact = [0] * SIZE
inv = [0] * SIZE
fact_inv = [0] * SIZE

# prepare --------------------------------
inv[0] = 0
inv[1] = 1
fact[0] = fact[1] = 1
fact_inv[0] = fact_inv[1] = 1
for i in range( 2, SIZE ):
  inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
  fact[i] = fact[i-1] * i % MOD
  fact_inv[i] = fact_inv[i-1] * inv[i] % MOD
#  fact_inv[i] = fact[i] **( 10**4 ) \
#              * fact[i] **( 10**5 ) \
#              * fact[i] ** 5 % MOD % MOD
# ----------------------------------------
def comb( n, r ):
  if r >= 0 and n >= 0:
    return fact[n] * fact_inv[n-r]%MOD * fact_inv[r]%MOD
  else :
    return 0.0
# ----------------------------------------

#print( fact_inv )

ans = 0
for i in range( h-a ):
    ans += comb(i+b-1, b-1) * comb(h-i-1+w-b-1,w-b-1)
    ans %= MOD
print( ans )

Buggy python submission (verdict: Runtime Error):
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

h, w, a, b = map( int, input().split() )

ans = 0
mod_parent = 10**9 + 7
for i in range( a+1 ) :
  ans += ( cmb( b+h-a, i ) %  mod_parent ) + ( cmb( h+w-b, h-i ) %  mod_parent )
print( ans )

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

SIZE = h+w+2
MOD = 10**9 + 7
MOD_Farmer = 10**9+5

fact = [0] * SIZE
inv = [0] * SIZE
fact_inv = [0] * SIZE

# prepare --------------------------------
inv[0] = 0
inv[1] = 1
fact[0] = fact[1] = 1
fact_inv[0] = fact_inv[1] = 1
for i in range( 2, SIZE ):
  inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
  fact[i] = fact[i-1] * i % MOD
  fact_inv[i] = fact_inv[i-1] * inv[i] % MOD
#  fact_inv[i] = fact[i] **( 10**4 ) \
#              * fact[i] **( 10**5 ) \
#              * fact[i] ** 5 % MOD % MOD
# ----------------------------------------
def comb( n, r ):
  if r >= 0 and n >= 0:
    return fact[n] * fact_inv[n-r]%MOD * fact_inv[r]%MOD
  else :
    return 0.0
# ----------------------------------------

#print( fact_inv )

ans = 0
for i in range( h-a ):
    ans += comb(i+b-1, b-1) * comb(h-i-1+w-b-1,w-b-1)
    ans %= MOD
print( ans )
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int, input().split()))
can_n = [0]*n
for i in range(n):
    can = 0
    for j in range(n-i-1):
        left = i+j
        right = left+1
        if h[left] >= h[right]:
            can += 1
        else:
            break
    can_n[i] = can
print(max(can_n))

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
can = 0
max_h = h[0]
max_c = 0
for i in range(n-1):
    l = h[i]
    r = h[i+1]
    if l >= r:
        can += 1
    else:
        can = 0
        max_h = r
    if can > max_c:
        max_c = can
print(max_c)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
sum_w = s.count("W")
ans = n
for i in range(n):
    left_w = s[:i].count("W")
    right_e = (n-i-1)-(sum_w-left_w)
    if s[i] == "W":
        right_e += 1
    sum = left_w+right_e
    if sum < ans:
        ans = sum
print(ans)


Fixed submission:
n = int(input())
s = input()
sum_w = s.count("W")
ans = n
lw = [0]*n
count = 0
for i in range(n):
    lw[i] = count
    if s[i] == "W":
        count += 1
for i in range(n):
    left_w = lw[i]
    right_w = sum_w-left_w
    if s[i] == "W":
        right_w -= 1
    right_e = (n-i-1)-right_w
    sum = left_w+right_e
    if sum < ans:
        ans = sum
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = n
for i in range(n):
    left_w = s[:i].count("W")
    right_e = s[i+1:].count("E")
    sum = left_w+right_e
    if sum < ans:
        ans = sum
print(ans)

Fixed submission:
n = int(input())
s = input()
sum_w = s.count("W")
ans = n
lw = [0]*n
count = 0
for i in range(n):
    lw[i] = count
    if s[i] == "W":
        count += 1
for i in range(n):
    left_w = lw[i]
    right_w = sum_w-left_w
    if s[i] == "W":
        right_w -= 1
    right_e = (n-i-1)-right_w
    sum = left_w+right_e
    if sum < ans:
        ans = sum
print(ans)