Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
A = map(int,raw_input().split())
S = 0
inv = [1,-1]*(n//2) + [1]
for q in range(n):
  S += A[q]*inv1[q]
ans = [0]*n
for q in range(n):
  ans[q] = S
  S = 2*A[q]-S
print ' '.join(map(str, ans))


Fixed submission:
n = int(raw_input())
A = map(int,raw_input().split())
S = 0
inv = [1,-1]*(n//2) + [1]
for q in range(n):
  S += A[q]*inv[q]
ans = [0]*n
for q in range(n):
  ans[q] = S
  S = 2*A[q]-S
print ' '.join(map(str, ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
A = map(int,raw_input().split())

import numpy

mat = []
for q in range(n-1):
  mat.append( [0]*q + [0.5,0.5] + [0]*(n-q-2) )
mat.append([0.5] + [0]*(n-2) + [0.5])

X = numpy.matrix(mat)

mat2 = []
for q in A:
  mat2.append([q])
Y = numpy.matrix(mat2)
ans = numpy.linalg.solve(X,Y)
ans = map(int,ans)
print ' '.join(map(str, ans))  

Fixed submission:
n = int(raw_input())
A = map(int,raw_input().split())
S = 0
inv = [1,-1]*(n//2) + [1]
for q in range(n):
  S += A[q]*inv[q]
ans = [0]*n
for q in range(n):
  ans[q] = S
  S = 2*A[q]-S
print ' '.join(map(str, ans))
Buggy python submission (verdict: Runtime Error):
n,m = map(int,raw_input().split())
a = []
buf = -111
for q in range(m):
  a.append(int( raw_input() ))
  buf = a[q]
  if buf - a[q] == 1:
    print 0
    exit(0)

now = [0]*100001

if m == 0:
  now[0] = 1
  now[1] = 1
  for q in range(2,n+1):
    now[q] = (now[q-1] + now[q-2]) % 1000000007
  print now[q] % 1000000007
  exit(0)
    
now[0] = 1
if a[0] == 1: now[1] = 0
else: now[1] = 1

for q in range(2,n+1):
  if q in a: continue
  now[q] = (now[q-1] + now[q-2]) % 1000000007
  
print now[q] % 1000000007

Fixed submission:
n,m = map(int,raw_input().split())
a = []
buf = -111
for q in range(m):
  a.append(int( raw_input() ))
  buf = a[q]
  if buf - a[q] == 1:
    print 0
    exit(0)

if n==1:
  print 1
  exit(0)
if n==2:
  if m==1:
    print 1
    exit(0)
  if m==0:
    print 2
    exit(0)

now = [-1]*100001

if m == 0:
  now[0] = 1
  now[1] = 1
  for q in range(2,n+1):
    now[q] = (now[q-1] + now[q-2]) % 1000000007
  print now[q] % 1000000007
  exit(0)
    
now[0] = 1
if a[0] == 1: now[1] = 0
else: now[1] = 1

for q in a:
  now[q] = 0

for q in range(2,n+1):
  if now[q] != -1: continue
  now[q] = (now[q-1] + now[q-2]) % 1000000007
  
print now[q] % 1000000007

Buggy python submission (verdict: Runtime Error):
n,m = map(int,raw_input().split())
a = []
buf = -111
for q in range(m):
  a.append(int( raw_input() ))
  if buf - a[q] == 1:
    print 0
    exit(0)

now = [0]*100001
now[0] = 1
if a[0] == 1: now[1] = 0
else: now[1] = 1

for q in range(2,n+1):
  if q in a: continue
  now[q] = now[q-1] + now[q-2]
  
print now[q] % 1000000007

Fixed submission:
n,m = map(int,raw_input().split())
a = []
buf = -111
for q in range(m):
  a.append(int( raw_input() ))
  buf = a[q]
  if buf - a[q] == 1:
    print 0
    exit(0)

if n==1:
  print 1
  exit(0)
if n==2:
  if m==1:
    print 1
    exit(0)
  if m==0:
    print 2
    exit(0)

now = [-1]*100001

if m == 0:
  now[0] = 1
  now[1] = 1
  for q in range(2,n+1):
    now[q] = (now[q-1] + now[q-2]) % 1000000007
  print now[q] % 1000000007
  exit(0)
    
now[0] = 1
if a[0] == 1: now[1] = 0
else: now[1] = 1

for q in a:
  now[q] = 0

for q in range(2,n+1):
  if now[q] != -1: continue
  now[q] = (now[q-1] + now[q-2]) % 1000000007
  
print now[q] % 1000000007
Buggy python submission (verdict: Time Limit Exceeded):
import copy
import math

N,X = map(int,raw_input().split())
S = map(int,raw_input().split())
MOD = 10**9 + 7

S.sort()

dp = [[0 for i in range(X+1)] for j in range(N+1)]

for i in range(X+1):
  dp[1][i] = i % S[0]

for n in range(2,N+1):
  for x in range(X+1):
    #print n,x
    dp[n][x] =  dp[n-1][x] * (n-1) 
    dp[n][x] += dp[n-1][x%S[n-1]]
    dp[n][x] %= MOD

print dp[N][X]


Fixed submission:
import copy
import math

N,X = map(int,raw_input().split())
S = map(int,raw_input().split())
MOD = 10**9 + 7

S.sort()

dp = [[0 for i in range(X+1)] for j in range(N+1)]

for i in range(X+1):
  dp[1][i] = i % S[0]

for n in range(2,N+1):
  for x in range(X+1):
    #print n,x
    dp[n][x] =  dp[n-1][x] * (n-1) 
    dp[n][x] += dp[n-1][x%S[n-1]]
    dp[n][x] %= MOD

print dp[N][X]

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

n,x = map(int,raw_input().split())
s = map(int,raw_input().split())

s.sort(reverse=True)
ans = 0

def dfs(xx,ss):
  ans = 0
  if len(ss)==1:
    return xx % ss[0]

  for q in ss:
    x2 = xx % q
    s2 = copy.deepcopy(ss)
    s2.remove(q)
    if x2 < min(s2):
      ans += math.factorial( len(s2) ) * x2
    else:
       ans += dfs(x2,s2)
  return ans

print dfs(x,s) % (10**9 + 7)


Fixed submission:
import copy
import math

N,X = map(int,raw_input().split())
S = map(int,raw_input().split())
MOD = 10**9 + 7

S.sort()

dp = [[0 for i in range(X+1)] for j in range(N+1)]

for i in range(X+1):
  dp[1][i] = i % S[0]

for n in range(2,N+1):
  for x in range(X+1):
    #print n,x
    dp[n][x] =  dp[n-1][x] * (n-1) 
    dp[n][x] += dp[n-1][x%S[n-1]]
    dp[n][x] %= MOD

print dp[N][X]

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

n,x = map(int,raw_input().split())
s = map(int,raw_input().split())

s.sort(reverse=True)
ans = 0

def dfs(xx,ss):
  ans = 0
  if len(ss)==1:
    return xx % ss[0]

  for q in ss:
    x2 = xx % q
    s2 = copy.deepcopy(ss)
    s2.remove(q)
    if x2 < min(s2):
      ans += math.factorial( len(s2) ) * x2
    else:
       ans += dfs(x2,s2)
  return ans

print dfs(x,s) % (10**9 + 7)


Fixed submission:
import copy
import math

N,X = map(int,raw_input().split())
S = map(int,raw_input().split())
MOD = 10**9 + 7

S.sort()

dp = [[0 for i in range(X+1)] for j in range(N+1)]

for i in range(X+1):
  dp[1][i] = i % S[0]

for n in range(2,N+1):
  for x in range(X+1):
    #print n,x
    dp[n][x] =  dp[n-1][x] * (n-1) 
    dp[n][x] += dp[n-1][x%S[n-1]]
    dp[n][x] %= MOD

print dp[N][X]
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

from operator import mul
from functools import reduce

def comb(r,n):
  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 = 10**9 + 7

n = int(raw_input())
s = raw_input()

ans = 0

q = []

for a in "abcdefghijklmnopqrstuvwxyz":
  q.append( s.count(a) )

for a in range(1,min(26+1,n+1)):
  #print a
  for x in itertools.combinations(q,a):
    ans += reduce(mul,x)
    ans %= mod

print ans % mod


Fixed submission:
mod = 10**9 + 7

n = int(raw_input())
s = raw_input()

q = []

for a in "abcdefghijklmnopqrstuvwxyz":
  q.append( s.count(a) )

ans = 1

for a in q:
  ans *= (a+1)
  ans %= mod

print ans-1

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

mod = 10**9 + 7

n = int(raw_input())
s = raw_input()

def comb(r,n):
  if r == 0: return 1
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans = 0

q = []

for a in "abcdefghijklmnopqrstuvwxyz":
  q.append( s.count(a) )

#print q

for a in range(1,min(26+1,n+1)):
  ans += comb(a,n)

  for b in range(len(q)):
    if q[b] > 1 and a > 1:
      #print a,q[b]
      #print comb(2,q[b]) * comb(a-2,n-q[b])
      ans -= comb(2,q[b]) * comb(a-2,n-q[b])
      for c in range(b+1,len(q)):
        if q[c] > 1 and a > 3:
          ans += comb(2,q[b]) * comb(2,q[c]) * comb(a-2-2,n-q[b]-q[c])

print ans % mod


Fixed submission:
mod = 10**9 + 7

n = int(raw_input())
s = raw_input()

q = []

for a in "abcdefghijklmnopqrstuvwxyz":
  q.append( s.count(a) )

ans = 1

for a in q:
  ans *= (a+1)
  ans %= mod

print ans-1
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())

ans = 100000

d = []

for a in range(1,7):d.append( 6**a )
for a in range(1,6):d.append( 9**a )
d.append(1)
d.sort()
#print d

dp = [1000000000] * 100000
dp[0] = 0
for x in range(0,n+1):
  for y in d:
    if x-y >= 0:
      dp[x] = min( dp[x-y] + 1, dp[x] )

print dp[n]


Fixed submission:
n = int(raw_input())

ans = 100000

d = []

for a in range(1,7):d.append( 6**a )
for a in range(1,6):d.append( 9**a )
d.append(1)
d.sort()
#print d

dp = [1000000000] * 100001
dp[0] = 0
for x in range(0,n+1):
  for y in d:
    if x-y >= 0:
      dp[x] = min( dp[x-y] + 1, dp[x] )

print dp[n]

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())

ans = 100000

d = []

for a in range(1,7):d.append( 6**a )
for a in range(1,6):d.append( 9**a )
d.append(1)
d.sort()
print d

dp = [1000000000] * 100000
dp[0] = 0
for x in range(0,n+1):
  for y in d:
    if x-y >= 0:
      dp[x] = min( dp[x-y] + 1, dp[x] )

print dp[n]


Fixed submission:
n = int(raw_input())

ans = 100000

d = []

for a in range(1,7):d.append( 6**a )
for a in range(1,6):d.append( 9**a )
d.append(1)
d.sort()
#print d

dp = [1000000000] * 100001
dp[0] = 0
for x in range(0,n+1):
  for y in d:
    if x-y >= 0:
      dp[x] = min( dp[x-y] + 1, dp[x] )

print dp[n]
Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
a = map(int,raw_input().split())

lp = [0]
lx = [0]

nowlp = 0
nowlx = 0

for x in range( len(a) ):
  nowlp += a[x]
  nowlx ^= a[x]

  lp.append(nowlp)
  lx.append(nowlx)
#print lp
#print lx

ans = 0

for l in range(1,len(a)+1 ):
  for r in range(l,len(a)+1 ):
    if lp[r] - lp[l-1] == lx[r] ^ lx[l-1]:
      #print l,r,lp[r],lp[l], lx[r] ,lx[l]
      ans += 1
    if len(bin(lp[r] - lp[l-1])) - len(bin(lp[r] ^ lp[l-1])) > 2:
      break

print ans


Fixed submission:
n = int(raw_input())
a = map(int,raw_input().split())

lp = [0]
nowlp = 0

for x in range( len(a) ):
  nowlp += a[x]
  lp.append(nowlp)

ans = 0
prev = [ [0,0] ]

for l in range(0,n-1):
  r = prev[l][1] + 1
  ans += prev[l][1]-l
  now = lp[r] - lp[l]

  while r <= n-1 and now^a[r] == now+a[r]:
    ans += 1
    now += a[r]
    r += 1
  prev.append( [l,r-1] )

ans += n
print ans

Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
a = map(int,raw_input().split())

lp = [0]
lx = [0]

nowlp = 0
nowlx = 0

for x in range( len(a) ):
  nowlp += a[x]
  nowlx ^= a[x]

  lp.append(nowlp)
  lx.append(nowlx)
#print lp
#print lx

ans = 0

for l in range(1,len(a)+1 ):
  for r in range(l,len(a)+1 ):
    if lp[r] - lp[l-1] == lx[r] ^ lx[l-1]:
      #print l,r,lp[r],lp[l], lx[r] ,lx[l]
      ans += 1

print ans


Fixed submission:
n = int(raw_input())
a = map(int,raw_input().split())

lp = [0]
nowlp = 0

for x in range( len(a) ):
  nowlp += a[x]
  lp.append(nowlp)

ans = 0
prev = [ [0,0] ]

for l in range(0,n-1):
  r = prev[l][1] + 1
  ans += prev[l][1]-l
  now = lp[r] - lp[l]

  while r <= n-1 and now^a[r] == now+a[r]:
    ans += 1
    now += a[r]
    r += 1
  prev.append( [l,r-1] )

ans += n
print ans
Buggy python submission (verdict: Runtime Error):

  q = x[0]*x[1]
  buf = math.sqrt(q)
  buf = int(buf)
  if buf*buf == x[0]*x[1]:
    buf -= 1

  ans = buf * 2 - 2
  if buf*(buf+1) < x[0]*x[1]:
    ans += 1

  print ans


Fixed submission:
import math

n = int(raw_input())

for a in range(n):
  x = map(int,raw_input().split())
  x.sort()

  if x[0] == x[1]:
    print 2*x[0] - 2
    continue

  if x[0]+1 == x[1]:
    print 2*x[0] - 2
    continue

  q = x[0]*x[1]
  q = int(math.sqrt(q))

  if q*q == x[0]*x[1]:
    q -= 1

  if q*(q+1) >= x[0]*x[1]:
    print 2*q - 2
    continue

  print 2*q - 1
Buggy python submission (verdict: Runtime Error):
a = int(raw_input())
b = int(raw_input())
ans = 0
for x in range(a,b+1):
  q = str(x)
  if q[0:2] == q[3:5]:
    ans += 1
print ans


Fixed submission:
a,b = map(int,raw_input().split(" "))
ans = 0
for x in range(a,b+1):
  q = str(x)
  if q[0:2] == q[3:5][::-1]:
    ans += 1
print ans
Buggy python submission (verdict: Time Limit Exceeded):
h,w,d = map(int,raw_input().split(" "))

mp = []

for a in range(h):
  mp += map(int,raw_input().split(" "))

data = [-1] * (h*w + 1)

for a in range(d+1,h*w+1):
  l = mp.index(a-d)
  r = mp.index(a)
  x = abs((r/w) - (l/w))
  y = abs((r%w) - (l%w))
  data[a] = x+y

data2 = [-1] * (h*w + 1)

for a in range(d+1,h*w+1):
  if a - d <= 0:
    continue
  data2[a] = data2[a-d] + data[a]

q = int(raw_input())

for a in range(q):
  l,r = map(int,raw_input().split(" "))
  print data2[r] - data2[l]


Fixed submission:
h,w,d = map(int,raw_input().split(" "))

mp = {}
now = 0

for a in range(h):
  z = map(int,raw_input().split(" "))
  for zz in z:
    mp[zz] = now
    now += 1

data = [-1] * (h*w + 1)
data2 = [-1] * (h*w + 1)

for a in range(d+1,h*w+1):
  l = mp[a-d]
  r = mp[a]
  x = abs((r/w) - (l/w))
  y = abs((r%w) - (l%w))
  data[a] = x+y
  if a - d <= 0:
    continue
  data2[a] = data2[a-d] + data[a]

q = int(raw_input())

for a in range(q):
  l,r = map(int,raw_input().split(" "))
  print data2[r] - data2[l]

Buggy python submission (verdict: Time Limit Exceeded):
h,w,d = map(int,raw_input().split(" "))

mp = []

for a in range(h):
  mp += map(int,raw_input().split(" "))

data = [-1] * (h*w + 1)

for a in range(d+1,h*w+1):
  l = mp.index(a-d)
  r = mp.index(a)
  x = abs((r/w) - (l/w))
  y = abs((r%w) - (l%w))
  data[a] = x+y

q = int(raw_input())

for a in range(q):
  l,r = map(int,raw_input().split(" "))
  ans = 0
  for b in range(l+d,r+1,d):
    ans += data[b]
  print ans


Fixed submission:
h,w,d = map(int,raw_input().split(" "))

mp = {}
now = 0

for a in range(h):
  z = map(int,raw_input().split(" "))
  for zz in z:
    mp[zz] = now
    now += 1

data = [-1] * (h*w + 1)
data2 = [-1] * (h*w + 1)

for a in range(d+1,h*w+1):
  l = mp[a-d]
  r = mp[a]
  x = abs((r/w) - (l/w))
  y = abs((r%w) - (l%w))
  data[a] = x+y
  if a - d <= 0:
    continue
  data2[a] = data2[a-d] + data[a]

q = int(raw_input())

for a in range(q):
  l,r = map(int,raw_input().split(" "))
  print data2[r] - data2[l]
Buggy python submission (verdict: Runtime Error):
n,m = map(int,raw_input().split(" "))

pos = []
for a in range(100001):
  pos.append([a,0])

def check(i):
  k,x = pos[i]
  if k != i:
    k2,x2 = check(k)
    pos[i] = [k2,x+x2]
  return pos[i]

for a in range(m):
  l,r,d = map(int,raw_input().split(" "))

  lk,lx = check(l)
  rk,rx = check(r)

  if lk != rk:
    t = d+lx-rx
    if t >= 0:
      pos[rk] = (lk,t)
    else:
      pos[lk] = (rk,-t)
  else:
    if rx - lx != d:
      print "No"
      exit(0)
print "Yes"



  if l > r:
    data.append([r,l,-d])
  else:
    data.append([l,r,d])
data.sort()



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

pos = []
for a in range(100001):
  pos.append([a,0])

def check(i):
  k,x = pos[i]
  if k != i:
    k2,x2 = check(k)
    pos[i] = [k2,x+x2]
  return pos[i]

for a in range(m):
  l,r,d = map(int,raw_input().split(" "))

  lk,lx = check(l)
  rk,rx = check(r)

  if lk != rk:
    t = d+lx-rx
    if t >= 0:
      pos[rk] = (lk,t)
    else:
      pos[lk] = (rk,-t)
  else:
    if rx - lx != d:
      print "No"
      exit(0)
print "Yes"
Buggy python submission (verdict: Time Limit Exceeded):
k = int(raw_input())
a = map(int,raw_input().split(" "))

if a[-1] != 2:
  print "-1"
  exit(0)

r = [2,3]
ainv = a[::-1]

for now in ainv[1:]:
  lower = (r[0]/now)*now
  if lower < r[0]:
    lower += now
  q = [lower,lower + now - 1]

  upper = lower + now - 1
  while (upper / now) * now <= r[1]:
    upper += 1
  upper -= 1

  if q[0] > r[1]:
    print "-1"
    exit(0)
  q = [lower,upper]
  #print r,q
  r = q

print "%d %d" % (r[0],r[1])


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

if a[-1] != 2:
  print "-1"
  exit(0)

r = [2,3]
ainv = a[::-1]

for now in ainv[1:]:
  lower = (r[0]/now)*now
  if lower < r[0]:
    lower += now
  upper = (r[1]/now)*now

  q = [lower,upper]

  if q[0] > r[1]:
    print "-1"
    exit(0)
  #print r,q
  q[1] = q[1] + now - 1
  r = q

print "%d %d" % (r[0],r[1])
Buggy python submission (verdict: Time Limit Exceeded):
prime = [True]*(10**5+1)
prime[0] = False
prime[1] = False

for a in range(2,318): # >>> gmpy2.isqrt(10**5+1) -> mpz(316)
  if prime[a] == False:
    continue
  else:
    for b in range(a*2,10**5+1,a): 
      prime[b] = False
"""
print prime
import gmpy2

for a in range(0,10**5+1):
  if prime[a] != gmpy2.is_prime(a):
    print "NO"
    print a
"""
ans = [False]*(10**5+1)
for a in range(3,10**5+1,2):
  if prime[a] == True and prime[(a+1)/2] == True:
    ans[a] = True

q = int(raw_input())
for a in range(q):
  l,r = map(int,raw_input().split(" "))
  print ans[l:r+1].count(True)


Fixed submission:
prime = [True]*(10**5+1)
prime[0] = False
prime[1] = False

for a in range(2,318): # >>> gmpy2.isqrt(10**5+1) -> mpz(316)
  if prime[a] == False:
    continue
  else:
    for b in range(a*2,10**5+1,a): 
      prime[b] = False
"""
print prime
import gmpy2

for a in range(0,10**5+1):
  if prime[a] != gmpy2.is_prime(a):
    print "NO"
    print a
"""
ans = [0]*(10**5+1)
now = 0
for a in range(3,10**5+1,2):
  if prime[a] == True and prime[(a+1)/2] == True:
    now = now + 1
  ans[a] = now

q = int(raw_input())
for a in range(q):
  l,r = map(int,raw_input().split(" "))
  x = ans[r] - ans[l]
  if prime[l] == True and prime[(l+1)/2] == True:
    x = x + 1
  print x
Buggy python submission (verdict: Runtime Error):
YAKINIKUFESTIVAL

Fixed submission:
print raw_input()[:-8]
Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
d = map(int,raw_input().split(" "))
m = int(raw_input())
t = map(int,raw_input().split(" "))

dic = {}

for a in t:
  if a not in dic:
    dic[a]=1
  else:
    dic[a] += 1

for a in dic:
  if dic[a] > d.count(a):
    print "NO"
    exit(0)

print "YES"


Fixed submission:
n = int(raw_input())
d = sorted(map(int,raw_input().split(" ")))
m = int(raw_input())
t = sorted(map(int,raw_input().split(" ")))

dic = {}
dic2 = {}

for a in t:
  if a not in dic:
    dic[a]=1
  else:
    dic[a] += 1

for a in d:
  if a not in dic2:
    dic2[a]=1
  else:
    dic2[a] += 1

for a in dic:
  if a not in dic2:
    print "NO"
    exit(0)
  if dic[a] > dic2[a]:
    print "NO"
    exit(0)

print "YES"
Buggy python submission (verdict: Runtime Error):
data = raw_input()

n,m = map(int,data.split(" "))

data = []

for x in range(n):
  data.append(raw_input())

temp = []

for x in range(m):
  temp.append(raw_input())

for x in range(n):
  for y in range(n):
    if temp[0] == data[x][y:y+m]:
      flag = 1
      pos = y
      for xx in range(x+1,x+m):
        if temp[xx - x] != data[xx][pos:pos+m]:
          flag = 0
          break
      if flag == 1:
        print "Yes"
        exit(0)

print "No"

Fixed submission:
data = raw_input()

n,m = map(int,data.split(" "))

data = []

for x in range(n):
  data.append(raw_input())

temp = []

for x in range(m):
  temp.append(raw_input())

for x in range(n-m+1):
  for y in range(n-m+1):
    if temp[0] == data[x][y:y+m]:
      flag = 1
      pos = y
      for xx in range(x+1,x+m):
        if temp[xx - x] != data[xx][pos:pos+m]:
          flag = 0
          break
      if flag == 1:
        print "Yes"
        exit(0)

print "No"
Buggy python submission (verdict: Runtime Error):
dat = raw_input()
(N,T) = dat.split(" ")

N = int(N)
T = int(T)

dat = raw_input()
A = map(int,dat.split(" "))

diffno = 0

mind = A[0]
maxd = 0

for x in range(1,len(A)):
  if maxd < (A[x] - mind):
    maxd = A[x] - mind
    diffno = 1
  elif maxd == (A[x] - mind):
    diffno += 1

  if mind > A[x]:
    mind = A[x]

print diffno


Fixed submission:
dat = raw_input()
(A,B,C) = dat.split(" ")
A = int(A)
B = int(B)
C = int(C)

if A == (B+C) or (A+B) == C or (A+C) == B:
  print "Yes"
else:
  print "No"
Buggy python submission (verdict: Time Limit Exceeded):
dat = raw_input()
(N,T) = dat.split(" ")

N = int(N)
T = int(T)

dat = raw_input()
A = map(int,dat.split(" "))

diffmax = 0
diffno = 0

for x in range(0,len(A)-1):
  d = max(A[x+1:]) - A[x]
  if d > diffmax:
    diffmax = d
    diffno = 1
  elif d == diffmax:
    diffno += 1

print diffno


Fixed submission:
dat = raw_input()
(N,T) = dat.split(" ")

N = int(N)
T = int(T)

dat = raw_input()
A = map(int,dat.split(" "))

diffno = 0

mind = A[0]
maxd = 0

for x in range(1,len(A)):
  if maxd < (A[x] - mind):
    maxd = A[x] - mind
    diffno = 1
  elif maxd == (A[x] - mind):
    diffno += 1

  if mind > A[x]:
    mind = A[x]

print diffno
Buggy python submission (verdict: Runtime Error):
s = input()
if s = "ABC":
    print("ARC")
else:
    print("ABC")

Fixed submission:
s = input()
if s == "ABC":
    print("ARC")
else:
    print("ABC")
Buggy python submission (verdict: Time Limit Exceeded):
n,m = list(map(int,input().split()))
h = list(map(int,input().split()))
a=[]
b=[]
for i in range(m):
    hoge = list(map(int,input().split()))
    a.append(hoge[0])
    b.append(hoge[1])
tenbo = list(range(1,n+1))
for i in range(m):
    if h[a[i]-1] > h[b[i]-1] and b[i] in tenbo:
        tenbo.remove(b[i])
    elif h[a[i]-1] < h[b[i]-1] and a[i] in tenbo:
        tenbo.remove(a[i])
    elif h[a[i]-1] == h[b[i]-1]:
        if a[i] in tenbo:
            tenbo.remove(a[i])
        if b[i] in tenbo:
            tenbo.remove(b[i])
print(len(tenbo))

Fixed submission:
from collections import Counter
n,m = list(map(int,input().split()))
h = list(map(int,input().split()))
a=[]
b=[]
for i in range(m):
    hoge = list(map(int,input().split()))
    a.append(hoge[0])
    b.append(hoge[1])

tenbo = []
for i in range(m):
    if h[a[i]-1] > h[b[i]-1]:
        tenbo.append(b[i])
    elif h[a[i]-1] < h[b[i]-1]:
        tenbo.append(a[i])
    elif h[a[i]-1] == h[b[i]-1]:
        tenbo.append(a[i])
        tenbo.append(b[i])

print(n - len(Counter(tenbo)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(n):
    gift = input()
    if not(gift in s):
        s.append(gift)
print(len(s))


Fixed submission:
from collections import Counter
n = int(input())
s = []
for i in range(n):
    s.append(input())
print(len(Counter(s)))
Buggy python submission (verdict: Runtime Error):
a = int(input())
s = int(input())
if a >= 3200:
        print(s)
else:
        print("red")

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
        print(s)
else:
        print("red")
Buggy python submission (verdict: Runtime Error):
n,l = list(map(int,input().split()))
apple = []
for i in range(n):        apple.append(l+i)
if 0 in apple:
        print(sum(apple))
elif apple[n] < 0:
        print(sum(apple)-apple[len(apple)-1])
else:
        print(sum(apple[1:len(apple)+1]))

Fixed submission:
n,l = list(map(int,input().split()))
apple = []
for i in range(n):        apple.append(l+i)
if 0 in apple:
        print(sum(apple))
elif apple[n-1] < 0:
        print(sum(apple)-apple[len(apple)-1])
else:
        print(sum(apple[1:len(apple)+1]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())
K = int(input())
print(key)
for i in range(N):
    if S[i] != key:
        S[i] = "*"
print("".join(S))

Fixed submission:
N = int(input())
S = list(input())
K = int(input())
key = S[K-1]
for i in range(N):
    if S[i] != key:
        S[i] = "*"
print("".join(S))
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = input().split()

mizuyari = 0
for i in range(int(sorted(h)[n-1])):
    maenohana = False
    mizuyari += thismizuyari
    thismizuyari = 0
    for j in range(n):
        if not maenohana and i+1<=int(h[j]):
            thismizuyari += 1
        maenohana = i+1<=int(h[j])
print(mizuyari)

Fixed submission:
n = int(input())
h = list(map(int,input().split()))
 
mizuyari = 0
for i in range(sorted(h)[n-1]):
    maenohana = False
    for j in range(n):
        if not maenohana and i+1<=h[j]:
            mizuyari += 1
        maenohana = i+1<=h[j]
print(mizuyari)
Buggy python submission (verdict: Runtime Error):
data = input().split()
data = data.sort()
print(data[2]+data[1])

Fixed submission:
data = input().split()
print(int(sorted(data)[2] + sorted(data)[1]) + int(sorted(data)[0]))

Buggy python submission (verdict: Runtime Error):
data = input().split()
print(data.sort()[2]+data.sort()[1])

Fixed submission:
data = input().split()
print(int(sorted(data)[2] + sorted(data)[1]) + int(sorted(data)[0]))