Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,m,k=map(int,input().split())
mod=10**9+7
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%mod
A=n*m
v=cmb(A-2,k-2)
t=0
y=0
for i in range(1,n):
  t+=i*(n-i)*m*m%mod
for i in range(1,m):
  y+=i*(m-i)*n*n%mod

ans=v*(t+y)
print(ans%mod)


Fixed submission:
n,m,k=map(int,input().split())
mod=10**9+7
A=n*m-2
from math import factorial
def Comb(N, K):
    a = factorial(N) % mod
    b = factorial(K) % mod
    c = factorial(N-K) % mod
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod
v=Comb(A,k-2)
t=0
y=0
for i in range(1,n):
  t+=i*(n-i)*m*m%mod
for i in range(1,m):
  y+=i*(m-i)*n*n%mod

ans=v*(t+y)
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n,m,k=map(int,input().split())
mod=10**9+7
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%mod
A=n*m
v=cmb(A-2,k-2)
t=0
y=0
for i in range(1,n):
  t+=i*(n-i)*m*m%mod
for i in range(1,m):
  y+=i*(m-i)*n*n%mod

ans=v*(t+y)
print(ans%mod)

Fixed submission:
n,m,k=map(int,input().split())
mod=10**9+7
A=n*m-2
from math import factorial
def Comb(N, K):
    a = factorial(N) % mod
    b = factorial(K) % mod
    c = factorial(N-K) % mod
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod
v=Comb(A,k-2)
t=0
y=0
for i in range(1,n):
  t+=i*(n-i)*m*m%mod
for i in range(1,m):
  y+=i*(m-i)*n*n%mod

ans=v*(t+y)
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n,m,k=map(int,input().split())
mod=10**9+7
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
A=n*m
v=cmb(A-2,k-2)
t=0
y=0
for i in range(1,n):
  t+=i*(n-i)*m*m
for i in range(1,m):
  y+=i*(m-i)*n*n

ans=v*(t+y)
print(ans%mod)

Fixed submission:
n,m,k=map(int,input().split())
mod=10**9+7
A=n*m-2
from math import factorial
def Comb(N, K):
    a = factorial(N) % mod
    b = factorial(K) % mod
    c = factorial(N-K) % mod
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod
v=Comb(A,k-2)
t=0
y=0
for i in range(1,n):
  t+=i*(n-i)*m*m%mod
for i in range(1,m):
  y+=i*(m-i)*n*n%mod

ans=v*(t+y)
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd 
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
    ans=max(ans,gcd(a[:i]+a[i+1:]))
print(ans)

Fixed submission:
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
L=[0]
R=[0]
for i in range(n-1):
    L.append(gcd(L[i],a[i]))
    R.append(gcd(R[i],a[-1-i]))
MAX=0
for i in range(n):
    MAX=max(MAX,gcd(L[i],R[-1-i]))
print(MAX)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd 
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
    ans=max(ans,reduce(gcd,a[:i]+a[i+1:]))
print(ans)

Fixed submission:
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
L=[0]
R=[0]
for i in range(n-1):
    L.append(gcd(L[i],a[i]))
    R.append(gcd(R[i],a[-1-i]))
MAX=0
for i in range(n):
    MAX=max(MAX,gcd(L[i],R[-1-i]))
print(MAX)

Buggy python submission (verdict: Runtime Error):
from math import gcd 
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
    ans=max(ans,reduce(gcd,a[:i]+a[i+1:]))
print(ans)

Fixed submission:
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
L=[0]
R=[0]
for i in range(n-1):
    L.append(gcd(L[i],a[i]))
    R.append(gcd(R[i],a[-1-i]))
MAX=0
for i in range(n):
    MAX=max(MAX,gcd(L[i],R[-1-i]))
print(MAX)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=list(input())
cnt=0
ans=0
j=0
for i in range(n):
    if s[i]=="0":
        if i==0 or s[i-1]=="1":
            cnt+=1
    if cnt>k:
        while s[j]=="1":
            j+=1
        while s[j]=="0":
            j+=1
        cnt-=1
    ans=max(ans,i-j+1)

print(ans)

Fixed submission:
a,b=map(int,input().split())
print(max(2*a-1,a+b,2*b-1))
Buggy python submission (verdict: Runtime Error):
a=[int(input()) for _ in range(5)]
b=0
c=[]
for i in range(5):
    if (b+a[i])%10==0:
        b+=a[i]
    else:
        b+=(a[i]//10+1)*10
for i in range(5):
    if a[i]%10!=0:
        c.append(a[i]%10)
print(b+min(c)-10)



Fixed submission:
a=0
c=9
for i in range(5):
    b=int(input())
    a+=((b-1)//10+1)*10
    c=min((b-1)%10,c)
print(a-9+c)

Buggy python submission (verdict: Runtime Error):
a=[int(input()) for _ in range(5)]
b=0
c=[]
for i in range(5):
    if (b+a[i])%10==0:
        b+=a[i]
    else:
        b+=(a[i]//10+1)*10
for i in range(5):
    if a[i]%10!=0:
        c.append(a[i]%10)
print(b+min(c)-10)



Fixed submission:
a=0
c=9
for i in range(5):
    b=int(input())
    a+=((b-1)//10+1)*10
    c=min((b-1)%10,c)
print(a-9+c)
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
A = [list(map(int, input().split())) for _ in range(q)]
for l,r in A:
    print(s[l-1:r].count("AC"))


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


Fixed submission:
s=input();print(min(s.count("0"),s.count("1"))*2)

Buggy python submission (verdict: Runtime Error):
s=int(input())
print(2*min(s.count(0),mins.count(1)))

Fixed submission:
s=input();print(min(s.count("0"),s.count("1"))*2)
Buggy python submission (verdict: Runtime Error):
n,m=map(int, input().split())
List=list(map(int, input().split()))
#d=[0]*n*9+[-1]*n*9
print(d)
for i in range(1, n+1):
    d[i]=max(d[i-int("0255456376"[a])]*10+a for a in List)
print(d[n])


Fixed submission:
n,m=map(int, input().split())
List=list(map(int, input().split()))
d=[0]*n*9+[-1]*n*9
#print(d)
for i in range(1, n+1):
    d[i]=max(d[i-int("0255456376"[a])]*10+a for a in List)
print(d[n])
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
h = [int(input()) for i in range(N)]
h.sort()
ans=10**9
for i in range(n-k+1):
    ans=min(ans,max(h[i:i+k])-min(h[i:i+k]))
print(ans)

Fixed submission:
n,k=map(int,input().split())
h = [int(input()) for i in range(n)]
h.sort()
ans=10**9
for i in range(n-k+1):
    ans=min(ans,h[i+k-1]-h[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
h=[]
for i in range(n):
   h.append(int(input())) 
h.sort()
ans=10**9
a=[]
for i in range(n-k+1):
    ans=min(ans,max(h[i:i+k])-min(h[i:i+k]))
print(ans)

Fixed submission:
n,k=map(int,input().split())
h = [int(input()) for i in range(n)]
h.sort()
ans=10**9
for i in range(n-k+1):
    ans=min(ans,h[i+k-1]-h[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
def dfs(s):
    if int(s)>n:
        return 0 
    if all(s.count(i) for i in '753'):
        ans=1
    else:
        ans=0
    for i in '753':
        ans+=dfs(s+i)
    return ans
print(ans)

Fixed submission:
x=int(input())
if x==3 or x==5 or x==7:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
x=int(input())
y=int(input())
z=int(input())
if x==1:
    print('Hello World')
else:
    print(y+z)


Fixed submission:
if int(input()) == 1:
  print('Hello World')
else:
  print(int(input()) + int(input()))
Buggy python submission (verdict: Runtime Error):
import math
n,X=map(int,input().split())
z=list(map(int,input().split()))
x=[]
for j in range(n):
        x.append(abs(X-z[j]))
g=x[0]
for i in range(1,n):
        g=math.gcd(g,x[i])
print(g)

Fixed submission:
from fractions import gcd
from functools import reduce

N, X = map(int,input().split()) 
nums=list(map(int,input().split()))
nums=list(map(lambda i: abs(i - X),nums))
 
D = reduce(gcd, nums)
print(D)

Buggy python submission (verdict: Runtime Error):
import math
n,X=map(int,input().split())
z=list(map(int,input().split()))
x=[]
for j in range(n):
        x.append(abs(X-z[j]))
g=x[0]
for i in range(1,n):
        g=math.gcd(g,x[i])
print(g)

Fixed submission:
from fractions import gcd
from functools import reduce

N, X = map(int,input().split()) 
nums=list(map(int,input().split()))
nums=list(map(lambda i: abs(i - X),nums))
 
D = reduce(gcd, nums)
print(D)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
print((a-1)*(b-1)

Fixed submission:
a,b=map(int,input().split())
 
print(a*b-(a+b-1))
Buggy python submission (verdict: Runtime Error):
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
print(math.ceil((n-k)/(k-1)+1))


Fixed submission:
k=[]
k=list(map(str,input()))
n=0
for i in range(4):
    if k[i]=='+':
        n+=1
    else:
        n-=1
print(n)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
ans=10**9
for i in range(n):
    b=0
    b+=s[:i].count("W")
    b+=s[i+1:].count("E")
    ans=min(b,ans)
print(ans)

Fixed submission:
n=int(input())
s=input()
e=s.count("E")
w=0
ans=e+w
for si in s:
    if si=="E":
        e-=1
    else:
        w+=1
    ans=min(ans,w+e)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
num = 55555
input_list = [False if i%2 == 0 or i%3 == 0 or i%5==0 else True for i in range(num)]
input_list[0] = input_list[1] = False
input_list[2] = input_list[3] = input_list[5] = True
sqrt = math.sqrt(num)

for serial in range(3, num, 2):
    if serial >= sqrt:
        break
    for s in range(serial ** 2, num, serial):
        input_list[s] = False

ans = []
count = 0
for i in range(11111):
    if input_list[5*i-1]:
        ans.append(5*i-1)
    if len(ans) == N:
        break

ans2 = ""
for i in range(len(ans)):
    ans2 += str(ans[i])
    if i != len(ans)-1:
        ans2 += " "

print(ans2) 

         


Fixed submission:
a,b=map(int,input().split(' '))
if a>b:
    print(a-1)
else:
    print(a)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
n=int(input())
def sosuu(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
ans=0
data=get_sieve_of_eratosthenes(55555)
for k in itertools.permutations(data,n):
    for j in itertools.permutations(k,n):
        if not(sosuu(sum(j))):
            ans+=1
            break
        if ans==n:
            print(*k)
            exit()

Fixed submission:
n=int(input())
import math
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
data=get_sieve_of_eratosthenes(55555)
b=[]
for i in range(len(data)):
    if data[i]%5==1:
        b.append(data[i])
print(*b[:n])
Buggy python submission (verdict: Runtime Error):
n,c=map(int,input().split())
xv = list(list(map(int, input().split())) for i in range(n))
vx=xy[::-1]
sushi1, max1, sushi2, max2 = [0], [0], [0], [0]
import numpy as np

sum1,sum2=0,0
for x,v in xv:
        sum1+=v
        sushi1.append(max(sum1 - x, sushi1[-1]))
        max1.append(max(sum1 - 2*x, max1[-1]))
for x, v in vx:
    sum2 += v
    sushi2.append(max(sum2 - (c-x), sushi2[-1]))
    max2.append(max(sum2 - 2*(c-x), max2[-1]))
ans1 = max(np.array(sushi1) + np.array(max2[::-1]))
ans2 = max(np.array(sushi2) + np.array(max1[::-1]))
print(max(0, ans1, ans2))

Fixed submission:
n,c=map(int,input().split())
xv = list(list(map(int, input().split())) for i in range(n))
vx=xv[::-1]
sushi1, max1, sushi2, max2 = [0], [0], [0], [0]
import numpy as np

sum1,sum2=0,0
for x,v in xv:
        sum1+=v
        sushi1.append(max(sum1 - x, sushi1[-1]))
        max1.append(max(sum1 - 2*x, max1[-1]))
for x, v in vx:
    sum2 += v
    sushi2.append(max(sum2 - (c-x), sushi2[-1]))
    max2.append(max(sum2 - 2*(c-x), max2[-1]))
ans1 = max(np.array(sushi1) + np.array(max2[::-1]))
ans2 = max(np.array(sushi2) + np.array(max1[::-1]))
print(max(0, ans1, ans2))
Buggy python submission (verdict: Time Limit Exceeded):
import copy
n=int(input())
m=0
x=list(map(int,input().split()))
for i in range(n):
    y=copy.deepcopy(x)
    y.pop(i)
    if n%2==0:
        m=n//2
        y.sort()
        print(y[m-1])
    else:
        m=n//2
        y.sort()
        print((y[m]-y[m-1])/2)

Fixed submission:
N = int(input())
arr = []
for x in list(map(int,input().split())):
    arr.append(x)
sort_arr = sorted(arr)
mid1 = sort_arr[N//2-1]
mid2 = sort_arr[N//2]

for x in arr:
    if x <= mid1:
        print(mid2)
    else:
        print(mid1)
Buggy python submission (verdict: Runtime Error):
N=int(input())
a = sorted(map(int, input().split()))
print(abs((sum(a[1::2]) - sum(a[::2])))

Fixed submission:

n = input()
a = sorted(map(int, input().split()))
print(abs(sum(a[1::2]) - sum(a[::2])))
Buggy python submission (verdict: Time Limit Exceeded):
q=int(input())
def sosuu(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
ans=0
A=[list(map(int,input().split())) for _  in range(q) ]
for l , r in A:
    for i in range(l,r+1):
        if i%2!=0 and sosuu(i) and sosuu((i+1)/2):
            ans+=1
    print(ans)
    ans=0

Fixed submission:
N = 100001
A,B = [True]*N,[0]*N
A[0],A[1] = False,False
for i in range(2,N):
    if A[i]:
        for j in range(i*2,N,i):
            A[j] = False
c=0
for i in range(3,N):
    if A[i] and A[(i+1)//2]:
        c += 1
    B[i] = c
Q = int(input())
for i in range(Q):
    l,r = map(int,input().split())
    print(B[r]-B[l-1])
Buggy python submission (verdict: Runtime Error):
s=list(input())
n=len(s)
ans=n
for i in range(n-1):
    if s[i]!=s[i+1]:
        t=max(i+1,n-(i+1))
        ans=min(asn,t)

print(ans)

Fixed submission:
S=list(input())
n=len(S)
ans=n
for _ in range(n-1):
	if S[_]!=S[_+1]:
		tmp=max(_+1,n-(_+1))
		ans=min(ans,tmp)

print(ans)

Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
ans=n
for i in range(n-1):
    if s[i]!=s[i+1]:
        t=max(i+1,n-(i+1))
        ans=min(asn,t)

print(ans)

Fixed submission:
S=list(input())
n=len(S)
ans=n
for _ in range(n-1):
	if S[_]!=S[_+1]:
		tmp=max(_+1,n-(_+1))
		ans=min(ans,tmp)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from scipy.sparse.csgraph import floyd_warshall
n=int(input())
s=[[0]*n for _ in range(n)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    s[a-1][b-1]=c
    s[b-1][a-1]=c
s=floyd_warshall(s)

q,k=map(int,input().split())
for i in range(q):
    ans=0
    x,y=map(int,input().split())
    ans+=s[x-1][k-1]
    ans+=s[k-1][y-1]
    print(int(ans))


Fixed submission:
N=int(input())
edges=[list(map(int,input().split())) for i in range(N-1)]
Q,K=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(Q)]
root=[[] for _ in range(N)]
for a,b,c in edges:
        root[a-1].append((b-1,c))
        root[b-1].append((a-1,c))
d=[-1]*N
s=[K-1]
d[K-1]=0
while s:
        l=s.pop()

        for i,c in root[l]:
                if d[i]==-1:
                        d[i]=d[l]+c
                        s.append(i)
for i in range(Q):
        print(d[xy[i][0]-1]+d[xy[i][1]-1])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    b.append(a[i])
    b=b[::-1]
print(*(b))

Fixed submission:
N=int(input())
s=list(input().split())
b=s[N::-2]+s[N%2::2]
print(*(b))
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
a,b,c=map(int,input().split())
print("NO"if c%gcd(a,b)!=0else"YES")

Fixed submission:
x,y,z=map(str,input().split(' '))

if x[len(x)-1]==y[0] and y[len(y)-1]==z[0]:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
a,b,c=map(int,input().split())
print("NO"if c%gcd(a,b)!=0　else"YES")

Fixed submission:
a,b,c=map(int,input().split())
ans='NO'
for i in range(b):
    if (a*i-c)%b==0:
        ans='YES'
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
x,y,z=map(str,input().split(' '))
if y-x==z-y:
    print('YES')
else:
    print('NO')


Fixed submission:
a,b,c=map(int,input().split())
print("YES"if b-a==c-b else "NO")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
S += S[0:2]

for ans in ['SS','SW','WS','WW']:
    for i in range(1,N+1):
        if (ans[-1] == 'S' and S[i] == 'o') or (ans[-1] == 'W' and S[i] == 'x'):
            ans += ans[-2]
        else:
            ans += ('S' if ans[-2] == 'W' else 'W')
    if ans[:2] == ans[N:]:
        print(ans[:N])
        exit()
print(-1)


Fixed submission:
N = int(input())
S = input()
S += S[0:2]

for ans in ['SS','SW','WS','WW']:
    for i in range(1,N+1):
        if (ans[-1] == 'S' and S[i] == 'o') or (ans[-1] == 'W' and S[i] == 'x'):
            ans += ans[-2]
        else:
            ans += ('S' if ans[-2] == 'W' else 'W')
    if ans[:2] == ans[N:]:
        print(ans[:N])
        exit()
print(-1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
q = len(set(A))
if q % 2 == 0:
    print(q - 1)
else:
    print(q)


Fixed submission:
x=int(input())
if x<1200:
    print('ABC')
else:
    print('ARC')
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
x=[]
for i in range(len(s)):
    for j in range(1,len(s)):
        if s[i]=="A" and s[j]=="Z":
           x.append(int(j-i+1))
print(max(x))

Fixed submission:
s = input()
print(s.rfind('Z') - s.find('A') + 1)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print(min(b+c,a+2*b+1))


Fixed submission:
n=int(input())
A=[]
B=[]
ans=0
for i in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
for i in range(n-1,-1,-1):
    if (A[i]+ans)%B[i]!=0:
        ans+=(B[i]-(A[i]+ans)%B[i])

print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c=input().split(' ')
if b=='+':
    print(int(a)+int(c))
else:
    print(int(a)-int(c))


Fixed submission:
a,b,c=map(str,input().split(','))
print(a,b,c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))
mod = 10**9+7
if n % 2 == 0 and len(set(l)) == n/2:
  print(int(2**(n/2)%mod))
elif not n % 2 == 0 and l.count(0) == 1:
  print(int(2**((n-1)/2)%mod))
else:
  print(0)


Fixed submission:
n = int(input())
l = list(map(int, input().split()))
mod = 10**9+7
if n % 2 == 0 and len(set(l)) == n//2:
  print(2**(n//2)%mod)
elif not n % 2 == 0 and l.count(0) == 1:
  print(2**((n-1)//2)%mod)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
n,t=map(int,input().split())
a=list(map(int,input().split()))
c=[]
d=[0]*(10**5)
if a[0]<a[1]:
    c.append([a[0],0])
else:
    d[0]=a[0]
for i in range(1,n-1):
    if a[i]>a[i+1] and a[i-1]<a[i]:
        d[i]=a[i]
    if a[i]<a[i+1] and a[i-1]>a[i]:
        c.append([a[i],i])
d[n-1]=a[n-1]
e=[0]*(10**5)
for i in c:
    E=max(d[i[1]:])-i[0]
    e[E]+=1
print(max(e))

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

sa=0
ans=1

n=k[a-1]

for i in range(a-2,-1,-1):
    if k[i]>n:
        n=k[i]
    tmp=n-k[i]
    if tmp>sa:
        sa=tmp
        ans=1
    elif tmp==sa:
        ans+=1

    

print(ans)

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

a=list(map(int,input().split()))
c=[]
d=[0]*(10**5)
if a[0]<a[1]:
    c.append([a[0],0])
else:
    d[0]=a[0]
for i in range(1,n-1):
    if a[i]>a[i+1] and a[i-1]<a[i]:
        d[i]=a[i]
    if a[i]<a[i+1] and a[i-1]>a[i]:
        c.append([a[i],i])
d[n-1]=a[n-1]
e=[0]*(10**5)
for i in c:
    E=max(d[i[1]:])-i[0]
    e[E]+=1
print(max(e))

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

sa=0
ans=1

n=k[a-1]

for i in range(a-2,-1,-1):
    if k[i]>n:
        n=k[i]
    tmp=n-k[i]
    if tmp>sa:
        sa=tmp
        ans=1
    elif tmp==sa:
        ans+=1

    

print(ans)

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

a=list(map(int,input().split()))
c=[]
d=[0]*(10**5)
if a[0]<a[1]:
    c.append([a[0],0])
else:
    d[0]=a[0]
for i in range(1,n-1):
    if a[i]>a[i+1] and a[i-1]<a[i]:
        d[i]=a[i]
    if a[i]<a[i+1] and a[i-1]>a[i]:
        c.append([a[i],i])
d[n-1]=a[n-1]
e=[0]*(10**5)
for i in c:
    E=max(d[i[1]:])-i[0]
    e[E]+=1
print(max(e))

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

sa=0
ans=1

n=k[a-1]

for i in range(a-2,-1,-1):
    if k[i]>n:
        n=k[i]
    tmp=n-k[i]
    if tmp>sa:
        sa=tmp
        ans=1
    elif tmp==sa:
        ans+=1

    

print(ans)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
print(K*(K-1)**(N-1)

Fixed submission:
n,k=map(int,input().split())
print(k*(k-1)**(n-1))
Buggy python submission (verdict: Runtime Error):
x,n = map(int,input().split())
lst = list(map(int,input().split()))
ans = lst[0]

for e in lst:
  if abs(e-n) < abs(e-ans):
    ans = e
   
  elif abs(e-n) == abs(e-ans):
    ans = min(e,ans)
    
  else:
    pass
  
print(ans)

Fixed submission:
x,n = map(int,input().split())
lst = sorted(list(map(int,input().split())))

ans = x
if ans in lst:
    pass
else:
    print(ans)
    exit()

left,right = ans-1,ans+1

while True:
    if left in lst and right in lst:
        left -=1
        right += 1

    elif left in lst:
        print(right)
        exit()

    else:
        print(left)
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    if s[i] == s[j]:
      continue
    for k in range(j+1,n):
      if k -j == j -i:
        continue
      if s[i] == s[k] or s[j] == s[k]:
        continue
      else:
        ans += 1
        
print(ans)
        

Fixed submission:
n = int(input())
s = input()
ans = s.count('R')*s.count('B')*s.count('G')
for i in range(n-2):
    for j in range(i+1,n-1):
        k = j + (j - i)
        if k>=n:break
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            ans -= 1
        
print(ans)
Buggy python submission (verdict: Runtime Error):
def print_kaijou(k):
    print(str(int(k*(k+1)/2)))

n = int(input())


    
print_kaijou(n-1):


Fixed submission:
n = int(input())
ans = n*(n-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
num = int(input())
string = input()

if num>=3200:
  print(string):
else:
  print("red")

Fixed submission:
num = int(input())
string = input()

if num>=3200:
  print(string)
else:
  print("red")
Buggy python submission (verdict: Runtime Error):
def return_sorted_string(string):
    lst=list(map(ord,list(string)))
    lst.sort()
    lst=list(map(chr,lst))
    string="".join(lst)
    return string
    



n = int(input())
strings=[input() for i in range(n)]
dic={}
for i in range(n):
    string=return_sorted_string(strings[i])
    if string in dic:
        dic[string]+=1
    else:
        dic[string]=1

count=0        

for i in dic.values():
    count += i*(i-1)/2


print(int(count))

Fixed submission:
a,b=list(map(int,input().split()))
print(max(a+b,a-b,a*b))