Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()
def check(a,b):
  for c in a:
    if a.count(c) > 1:
      m = [i for i, x in enumerate(a) if x == c]
      w = b[m[0]]
      for i in range(1,len(m)):
        if b[m[i]] != w:
          return "No" 
  return "Yes"
ans = check(s,t)
if ans == "Yes" : ans = check(t,s)
print(ans)

Fixed submission:
s = input()
t = input()
def check(a,b):
  l = []
  for c in a:
    if c in l:
      continue
    l.append(c)
    if a.count(c) > 1:
      m = [i for i, x in enumerate(a) if x == c]
      for i in range(1,len(m)):
        if b[m[i]] != b[m[0]]:
          return "No" 
  return "Yes"
ans = check(s,t)
if ans == "Yes" : ans = check(t,s)
print(ans)
Buggy python submission (verdict: Runtime Error):
k = (int(input())
print(( k // 2 ) * ( k - k // 2 ))

Fixed submission:
k = int(input())
print(( k // 2 ) * ( k - k // 2 ))
Buggy python submission (verdict: Runtime Error):
x1,y1,x2,y2 = map(int,int(input().split())
h = max(abs(x2-x1),abs(y2-y1))
v = min(abs(x2-x1),abs(y2-y1))
if x1 > x2:
  if y1 > y2: print(x2+h,y2-v,x1+h,y1-v)
  else:print(x2-v,y2-h,x1-v,y1-h)
else:
  if y1 > y2: print(x2+v,y2+h,x1+v,y1+h)
  else:print(x2-h,y2+v,x1-h,y1+v)

Fixed submission:
x1,y1,x2,y2 = map(int,input().split())
h = abs(x2-x1)
v = abs(y2-y1)
if x1 > x2:
  if y1 > y2: print(x2+v,y2-h,x1+v,y1-h)
  else:         print(x2-v,y2-h,x1-v,y1-h)
else:
  if y2 > y1: print(x2-v,y2+h,x1-v,y1+h)
  else:         print(x2+v,y2+h,x1+v,y1+h)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
S = 4*(((A-1)/2) *((B-1)/2))
print(int(S))

Fixed submission:
l = input().split()
S = 4*(((int(l[0])-1)/2) *((int(l[1])-1)/2))
print(int(S))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
ans = 100
for i in range(0,len(s)):
    tmp = 0
    for j in range(0,len(s)):
        if j<i and s[j]=='W':
            tmp += 1
        elif j>i and s[j]=='E':
            tmp += 1
    ans = min(ans,tmp)
print(ans)

Fixed submission:
n = int(input())
s = list(input())
ans = s.count('E')
r = 10**6
if s[0]=='E':
    ans -= 1

r = min(ans,r)

for i in range(1,n):
    if s[i-1]=='W' and s[i]=='W':
        ans += 1
    elif s[i-1]=='E' and s[i]=='E':
        ans -= 1
    r = min(ans,r)
print(r)
Buggy python submission (verdict: Runtime Error):
import sys
h, w = (int(i) for i in input().split())
s =[list(input()) for i in range(h)]
flags = []
for i in range(0,h):
    flags.append([0 for i in range(w)])

for i in range(0,h):
    for j in range(0,w-1):
        if s[i][j]=='#' and s[i][j+1]=='#':
            flags[i][j]=1
            flags[i][j+1]=1

for i in range(0,w):
    for j in range(0,h-1):
        if s[j][i]=='#' and s[j+1][i]=='#':
            flags[j][i]=1
            flags[j+1][i]=1

for i in range(0,w):
    for j in range(0,h):
        if s[i][j]=="#":
            if flags[i][j]==0:
                print("No")
                sys.exit()
            else:
                continue

print("Yes")


Fixed submission:
import sys
h, w = (int(i) for i in input().split())
s =[list(input()) for i in range(h)]
flags = []
for i in range(0,h):
    flags.append([0 for i in range(w)])

for i in range(0,h):
    for j in range(0,w-1):
        if s[i][j]=='#' and s[i][j+1]=='#':
            flags[i][j]=1
            flags[i][j+1]=1

for i in range(0,w):
    for j in range(0,h-1):
        if s[j][i]=='#' and s[j+1][i]=='#':
            flags[j][i]=1
            flags[j+1][i]=1

for i in range(0,h):
    for j in range(0,w):
        if s[i][j]=="#":
            if flags[i][j]==0:
                print("No")
                sys.exit()
            else:
                continue

print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ai = []
bi = []
ci = []
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

for i in range(0,n):
    cnt = 0
    for j in range(0,n):
        if a[i] >= b[j]:
            break
        cnt += 1
    ai.append(cnt)

for i in range(0,n):
    cnt = 0
    for j in range(0,n):
        if b[i] >= c[j]:
            break
        cnt += 1
    bi.append(cnt)

ans = 0
for i in range(0,n):
    if ai[i] > 0:
        for j in range(0,ai[i]):
            ans += bi[j]

print(ans)



Fixed submission:
n = int(input())
a = sorted(list(map(int,input().split())))
b = sorted(list(map(int,input().split())))
c = sorted(list(map(int,input().split())))

bmul = [0]*(n+1)
ci = 0

for bi in range(n):
    while ci != n and c[ci] <= b[bi]:
        ci += 1
    bmul[bi] = n-ci
for i in range(n):
    bmul[n-i-1] += bmul[n-i]
bi = 0
ai = 0
ret = 0
for ai in range(n):
    while bi != n and b[bi] <= a[ai]:
        bi += 1
    ret += bmul[bi]
print(ret)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
b = []
for key,val in Counter(a).items():
    if val >= 2:
        b.append(key)
        if val >= 4:
            b.append(key)

b.sort()

if len(b)>=2:
    x = b.pop()
    y = b.pop()
    ans = x*y
else:
    ans = 0

print(ans)


Fixed submission:
x, a, b = (int(i) for i in input().split())
aa = abs(a-x)
bb = abs(b-x)
if aa > bb:
    print("B")
else:
    print("A")
Buggy python submission (verdict: Runtime Error):
import sys

st = list(input())
ls = list(set(st))
ls.sort()
abc = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(0,len(abc)):
    if abc[i] != ls[i]:
        print(abc[i])
        sys.exit()
print("None")


Fixed submission:
st = list(input())
ls = list(set(st))
abc = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
set_ab = set(abc) - set(ls)
ans = list(set_ab)
ans.sort()
if ans:
    print(ans[0])
else:
    print("None")
Buggy python submission (verdict: Time Limit Exceeded):
import sys

n,m = (int(i) for i in input().split())
abstart=[]
abgoal=[]
for i in range(0,m):
    inp=[int(i) for i in input().split()]
    if inp[0]==1:
        abstart.append(inp[1])
    elif inp[1]==n:
        abgoal.append(inp[0])

for st in abstart:
    for go in abgoal:
        if st == go:
            print('POSSIBLE')
            sys.exit()
print('IMPOSSIBLE')


Fixed submission:
n,m = (int(i) for i in input().split())
abstart=[]
abgoal=[]
for i in range(0,m):
    inp=[int(i) for i in input().split()]
    if inp[0]==1:
        abstart.append(inp[1])
    elif inp[1]==n:
        abgoal.append(inp[0])

start = set(abstart)
goal = set(abgoal)
matched = list(start & goal)

if len(matched)>0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
def p(b):
    for i in range(0,len(b)):
        if i==len(b)-1:
            print(b[i])
        else:
            print(b[i],' ',end="")
n=int(input())
e=[int(i) for i in input().split()]
b=[]
for i in range(0,n):
    b.append(e.pop(0))
    b.reverse()
p(b)


Fixed submission:
def p(b):
    for i in range(0,len(b)):
        if i==len(b)-1:
            print(b[i])
        else:
            print(b[i],' ',end="")

n=int(input())
a=[int(i) for i in input().split()]
b=[None]*n
if n%2==1:
    m=int(n/2)
    b[m]=a[0]
    s=1
    t=1
    while s+m<n:
        b[m+s]=a[t]
        t+=1
        b[m-s]=a[t]
        t+=1
        s+=1
    p(b)
else:
    m=int(n/2)
    b[m]=a[0]
    s=1
    t=1
    while s+m<=n:
        b[m-s]=a[t]
        t+=1
        if m-s==0:
            break
        b[m+s]=a[t]
        t+=1
        s+=1
    p(b)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n=int(input())
s=[int(i) for i in input().split()]
div=int(10**9+7)
c = Counter(s)
j=-1
for i in range(1, n + 1):
    if c[i] == 2:
        j = i
        break
a, b = [i for i in range(n + 1) if s[i] == j]

f=[1]
t=1
for i in range(1,n+2):
    t=t*i
    f.append(t)


for i in range(1,n+2):
    x=round(f[n+1]/(f[i]*f[n+1-i]))
    y=round(f[a+n-b]/(f[i-1]*f[a+n-b-i+1]))
    ans=(x-y)%div
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
occur = [0 for i in range(n + 1)]
MOD = 1000000007
for i in range(n + 1):
    if occur[a[i]] > 0: val = n - 1 - i + occur[a[i]]
    else: occur[a[i]] = i + 1
inv = [0 if i > 2 else 1 for i in range(n + 2)]
pinv = [0 if i > 2 else 1 for i in range(n + 2)]
perm = [0 if i > 2 else 1 for i in range(n + 2)]
for i in range(2, n + 2):
    inv[i] = -int(MOD / i) * inv[MOD % i] + MOD
    pinv[i] = pinv[i - 1] * inv[i] % MOD
    perm[i] = perm[i - 1] * i % MOD
def C(n, m):
    return (perm[m] * pinv[n] % MOD) * pinv[m - n] % MOD if n <= m else 0
for i in range(1, n + 2):
    temp = C(i, n + 1) - C(i - 1, val)
    if temp < 0: temp += MOD
    print(temp)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]

count = 1
state = 'none'
b = [a[0]]

for i in range(1,n):
    if state=='none':
        before=b.pop()
        now = a[i]
        if before<now:
            b.append(now)
            state='incr'
        elif before>now:
            b.append(now)
            state='decr'
        else:
            b.append(now)
    elif state=='incr':
        before=b.pop()
        now = a[i]
        if before<=now:
            b.append(now)
        else:
            b=[now]
            state='none'
            count+=1
    elif state=='decr':
        before=b.pop()
        now = a[i]
        if before=>now:
            b.append(now)
        else:
            b=[now]
            state='none'
            count+=1
print(count)


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

count = 1
state = 'none'
b = [a[0]]

for i in range(1,n):
    if state=='none':
        before=b.pop()
        now = a[i]
        if before<now:
            b.append(now)
            state='incr'
        elif before>now:
            b.append(now)
            state='decr'
        else:
            b.append(now)
    elif state=='incr':
        before=b.pop()
        now = a[i]
        if before<=now:
            b.append(now)
        else:
            b=[now]
            state='none'
            count+=1
    elif state=='decr':
        before=b.pop()
        now = a[i]
        if before>=now:
            b.append(now)
        else:
            b=[now]
            state='none'
            count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = sorted([int(i) for i in input().split()])
mod = 10e9+7
if n%2==0:
    able = []
    for i in range(1,n,2):
        able.append(i)
        able.append(i)
else:
    able = [0]
    for i in range(2,n,2):
        able.append(i)
        able.append(i)

if a == able:
    r = n//2
    ans = 2**r % mod
    print(int(ans))
else:
    print(0)


Fixed submission:
n = int(input())
a = sorted([int(i) for i in input().split()])
mod = 10**9+7
if n%2==0:
    able = []
    for i in range(1,n,2):
        able.append(i)
        able.append(i)
else:
    able = [0]
    for i in range(2,n,2):
        able.append(i)
        able.append(i)

if a == able:
    r = n//2
    ans = 1
    for i in range(0,r):
        ans = ans * 2 % mod
    print(int(ans))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
total = [int(i) for i in input().split()]
n = total[0]
time_limit = total[1]

ci = []
ti = []
for i in range(n):
    list = [int(j) for j in input().split()]
    ci.append(list[0])
    ti.append(list[1])

min = 1000
for i in range(len(ci)):
    if ci[i] < min and ti[i] < time_limit:
        min = ci[i]

if min != 1000:
    print(min)
else:
    print("TLE")

Fixed submission:
n = int(input())

if n == 1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print("{0}".format(a + b))

Buggy python submission (verdict: Runtime Error):
total = [int(i) for i in input().split()]
n = total[0]
time_limit = total[1]

ci = []
ti = []
for i in range(n):
    list = [int(j) for j in input().split()]
    ci.append(list[0])
    ti.append(list[1])

min = 100
update = 0
for i in range(len(ci)):
    if ci[i] <= min and ti[i] <= time_limit:
        min = ci[i]
        update = 1

if update == 1:
    print(min)
else:
    print("TLE")

Fixed submission:
n = int(input())

if n == 1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print("{0}".format(a + b))
Buggy python submission (verdict: Runtime Error):
p_100 = n // 100
tmp = n % 100
p_10 = tmp // 10
p_1 = tmp % 10
if p_100 == p_10:
    if p_10 == p_1:
        print(str(p_1) * 3)
    elif p_10 <= p_1:
        print(str(p_10+1) * 3)
    elif p_10 >= p_1:
        print(str(p_10) * 3)
elif p_100 <= p_10:
    print(str(p_100+1) * 3)
elif p_100 >= p_10:
    print(str(p_100) * 3)

Fixed submission:
n = int(input()) # 入力を受け付ける
match = 0

if 100 <= n and n <= 111:
    match = 111
elif 112 <= n and n <= 222:
    match = 222
elif 223 <= n and n <= 333:
    match = 333
elif 334 <= n and n <= 444:
    match = 444
elif 445 <= n and n <= 555:
    match = 555
elif 556 <= n and n <= 666:
    match = 666
elif 667 <= n and n <= 777:
    match = 777
elif 778 <= n and n <= 888:
    match = 888
elif 889 <= n and n <= 999:
    match = 999

print(match)
Buggy python submission (verdict: Runtime Error):
def cal(n):
  ans = 0
  while n != 0:
    ans += n % 10
    n /= 10
  return ans

n = int(raw_input())
if n % cal(n) == 0:
  print "Yes"
else:
  print "No"


Fixed submission:
s = raw_input()
n = 0
for c in s:
  if c == '+':
    n += 1
  else:
    n -= 1
print n
Buggy python submission (verdict: Runtime Error):
def cal(n):
  ans = 0
  while n != 0:
    ans += n % 10
    n /= 10
  return n

n = int(raw_input())
if n % cal(n) == 0:
  print "Yes"
else:
  print "No"


Fixed submission:
def cal(n):
  ans = 0
  while n != 0:
    ans += n % 10
    n /= 10
  return ans

n = int(raw_input())
if n % cal(n) == 0:
  print "Yes"
else:
  print "No"
Buggy python submission (verdict: Runtime Error):
if int(raw_iniput()) >= 1000:
  print 'ABD'
else:
  print 'ABC'


Fixed submission:
if int(raw_input()) >= 1000:
  print 'ABD'
else:
  print 'ABC'
Buggy python submission (verdict: Time Limit Exceeded):
s = raw_input()
k = int(raw_input())
l = len(s)
ls = []
for a in range(l):
    for b in range(a+1,l+1):
        if ls.count(s[a:b]) == 0:
            ls.append(s[a:b])
ls.sort()
print ls[k-1]

Fixed submission:
s = raw_input()
k = int(raw_input())
l = len(s)
ls = []
for a in range(l):
    for b in range(a+1,min(a+k+1,l+1)):
        if ls.count(s[a:b]) == 0:
            ls.append(s[a:b])
ls.sort()
print ls[k-1]
Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
a = map(int, raw_input().split())
a.append(0)
for i in range(n):
    c = 0
    p = 0
    for j in range(n+1):
        if j == i:
            continue
        c += abs(a[j] - p)
        p = a[j]
    print c


Fixed submission:
n = int(raw_input())
a = [0] + map(int, raw_input().split()) + [0]
s = 0
for i in range(n+1):
    s += abs(a[i+1] - a[i])
for i in range(1,n+1):
    print s + abs(a[i+1] - a[i-1]) - (abs(a[i+1] - a[i]) + abs(a[i] - a[i-1]))
Buggy python submission (verdict: Runtime Error):
l = [int(raw_input()) for _ in range(3)]
print (l[0] - l[[1]) % l[2]


Fixed submission:
l = [int(raw_input()) for _ in range(3)]
print (l[0] - l[1]) % l[2]
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int, raw_input().split()
if (b-a) % 2 == 0:
  print "Alice"
else:
  print "Borys"


Fixed submission:
n,a,b = map(int, raw_input().split())
if (b-a) % 2 == 0:
  print "Alice"
else:
  print "Borys"
Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
l = [map(int, raw_input().split()) for _ in range(n-1)]
m = []
for i in range(n-1):
    m.append(l[i][1]+l[i][0])
    for j in range(i):
        if m[j] <= l[i][1]:
            m[j] = m[i]
        else:
            k = l[i][1] + l[i][2]
            while m[j] > k:
                k += l[i][2]
            m[j] = k +  l[i][0]
m.append(0)
for i in m:
    print i


Fixed submission:
n = int(raw_input())
l = [map(int, raw_input().split()) for _ in range(n-1)]
m = []
for i in range(n-1):
    m.append(l[i][1]+l[i][0])
    for j in range(i):
        if m[j] <= l[i][1]:
            m[j] = m[i]
        else:
            k = (m[j] + l[i][2] - 1) / l[i][2] * l[i][2]
            m[j] = k +  l[i][0]
m.append(0)
for i in m:
    print i
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n = int(raw_input())
c = Counter(map(int, raw_input().split()))
s = 0
for k,v in c:
    if v < k:
        s += v
    else:
        s += v - k
print s


Fixed submission:
from collections import Counter

n = int(raw_input())
c = Counter(map(int, raw_input().split()))
s = 0
for k,v in c.items():
    if v < k:
        s += v
    else:
        s += v - k
print s
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int, raw_input().split())
print(min(n*a, b))


Fixed submission:
n,a,b = map(int, raw_input().split())
print(min(n*a, b))
Buggy python submission (verdict: Runtime Error):
n = raw_input()
if int(n) % sum(map(int, list(n))) == 0:
  print('YES')
else:
  print('NO')


Fixed submission:
n = raw_input()
if int(n) % sum(map(int, list(n))) == 0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
al = map(int, raw_input().split())
bl = map(int, raw_input().split())
cl = map(int, raw_input().split())
al.sort()
bl.sort()
cl.sort()
l = [(0,0) for _ in range(n)]
p = 0
for i, b in enumerate(bl):
    while cl[p] <= b:
        p += 1
    l[i] = (b, n-p)
p = n-1
s = 0
t = 0
for a in al[::-1]:
    while p >= 0 and l[p][0] > a:
        s += l[p][1]
        p -= 1
    t += s
print t


Fixed submission:
n = int(raw_input())
al = map(int, raw_input().split())
bl = map(int, raw_input().split())
cl = map(int, raw_input().split())
al.sort()
bl.sort()
cl.sort()
l = [(0,0) for _ in range(n)]
p = 0
for i, b in enumerate(bl):
    while p < n and cl[p] <= b:
        p += 1
    l[i] = (b, n-p)
p = n-1
s = 0
t = 0
for a in al[::-1]:
    while p >= 0 and l[p][0] > a:
        s += l[p][1]
        p -= 1
    t += s
print t
Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,f = map(int,raw_input().split())
lim = f
f /= 100
wl = [False for _ in range(f+1)]
sl = [False for _ in range(f*e+1)]
wl[a] = True
wl[b] = True
sl[c] = True
sl[d] = True

for i in range(f):
    if wl[i] and i+a <= f:
        wl[i+a] = True
    if wl[i] and i+b <= f:
        wl[i+b] = True

for i in range(f*e):
    if sl[i] and i+c <= f*e:
        sl[i+c] = True
    if sl[i] and i+d <= f*e:
        sl[i+d] = True

maxd = 0.0
maxw = 0
maxs = 0
for i,w in enumerate(wl):
    for j,s in enumerate(sl):
        if w and s and i*100+j <= lim:
            if i*e >= j and float(j) / float(100*i+j) > maxd:
                maxd = float(j) / float(100*i + j)
                maxw = i*100
                maxs = j
print maxw+maxs,maxs


Fixed submission:
a,b,c,d,e,f = map(int,raw_input().split())
lim = f
f /= 100
wl = [False for _ in range(f+1)]
sl = [False for _ in range(f*e+1)]
if a <= f:
    wl[a] = True
if b <= f:
    wl[b] = True
if c <= f*e:
    sl[c] = True
if d <= f*e:
    sl[d] = True

for i in range(f):
    if wl[i] and i+a <= f:
        wl[i+a] = True
    if wl[i] and i+b <= f:
        wl[i+b] = True

for i in range(f*e):
    if sl[i] and i+c <= f*e:
        sl[i+c] = True
    if sl[i] and i+d <= f*e:
        sl[i+d] = True

maxd = 0.0
maxw = a*100
maxs = 0
for i,w in enumerate(wl):
    for j,s in enumerate(sl):
        if w and s and i*100+j <= lim:
            if i*e >= j and float(j) / float(100*i+j) > maxd:
                maxd = float(j) / float(100*i + j)
                maxw = i*100
                maxs = j
print maxw+maxs,maxs
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
l = map(int, raw_input().split())
ans = 0
i = 0
while i < n:
    if i+1 == l[i]:
        ans += 1
        if i+2 == l[i+1]:
            i += 1
    i += 1
print ans


Fixed submission:
n = int(raw_input())
l = map(int, raw_input().split())
ans = 0
i = 0
while i < n:
    if i+1 == l[i]:
        ans += 1
        if i+1 < n and i+2 == l[i+1]:
            i += 1
    i += 1
print ans
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, raw_input().split())
xls = map(int, raw_input().split())
yls = map(int, raw_input().split())
ans = 0
for x in range(n-1):
    for y in range(m-1):
        ans += (xls[x+1] -xls[x]) * (yls[y+1] - yls[y]) * (x+1) * (n-x-1) * (y+1) * (m-y-1)
        ans %= 10**9 + 7
print ans


Fixed submission:
n,m = map(int, raw_input().split())
xls = map(int, raw_input().split())
yls = map(int, raw_input().split())
xsum = 0
for x in range(n):
    xsum += x * xls[x] - (n-x-1) * xls[x]
ysum = 0
for y in range(m):
    ysum += y * yls[y] - (m-y-1) * yls[y]
print (xsum * ysum) % (10**9 + 7)
Buggy python submission (verdict: Time Limit Exceeded):
s = raw_input()
p = s.find('ST')
while p != -1:
    s = s[:p] + s[p+2:]
    p = s.find('ST')
print len(s)


Fixed submission:
s = raw_input()
p = 0
m = 0
for c in s:
    if c == 'S':
        p -= 1
    elif c == 'T':
        p += 1
    m = max(m,p)
print m*2
Buggy python submission (verdict: Runtime Error):
n,m = map(int, raw_input().split())
rl = [0.0 for _ in range(n)]
wl = [1.0 for _ in range(n)]
rl[0] = 1.0
wl[0] = 0.0
for _ in range(m):
    x,y = map(int, raw_input().split())
    p = rl[x-1] + wl[x-1]
    rl[y-1] += rl[x-1] / p
    wl[y-1] += wl[x-1] / p
    rl[x-1] -= rl[x-1] / p
    wl[x-1] -= wl[x-1] / p
cnt = 0
for p in rl:
    if p != 0:
        cnt += 1
print cnt


Fixed submission:
a,b = map(int, raw_input().split())
if a <= 0 and b >= 0:
    print 'Zero'
elif a < 0 and b < 0 and (b-a) % 2 == 0:
    print 'Negative'
else:
    print 'Positive'
Buggy python submission (verdict: Time Limit Exceeded):
s = 'AKIHABARA'
t = raw_input()
n = len(t)
i = 0
j = 0
while i < n and j < len(s): 
	if t[i] == s[j]:
		i += 1
		j += 1
	elif s[j] == 'A':
		j += 1
	else:
		print 'NO'
		exit()
while j < len(s):
	if s[j] == 'A':
		j += 1
if i == n and j == len(s):
	print 'YES'
else:
	print 'NO'
	



Fixed submission:
s = 'AKIHABARA'
t = raw_input()
n = len(t)
i = 0
j = 0
while i < n and j < len(s): 
	if t[i] == s[j]:
		i += 1
		j += 1
	elif s[j] == 'A':
		j += 1
	else:
		print 'NO'
		exit()
while j < len(s):
	if s[j] == 'A':
		j += 1
	else:
		break
if i == n and j == len(s):
	print 'YES'
else:
	print 'NO'

Buggy python submission (verdict: Runtime Error):
s = 'AKIHABARA'
t = raw_input()
n = len(t)
i = 0
j = 0
while i < n: 
	if t[i] == s[j]:
		i += 1
		j += 1
	elif s[j] == 'A':
		j += 1
	else:
		print 'NO'
		exit()
if i == n:
	print 'YES'
else:
	print 'NO'
	



Fixed submission:
s = 'AKIHABARA'
t = raw_input()
n = len(t)
i = 0
j = 0
while i < n and j < len(s): 
	if t[i] == s[j]:
		i += 1
		j += 1
	elif s[j] == 'A':
		j += 1
	else:
		print 'NO'
		exit()
while j < len(s):
	if s[j] == 'A':
		j += 1
	else:
		break
if i == n and j == len(s):
	print 'YES'
else:
	print 'NO'
Buggy python submission (verdict: Runtime Error):
x, y, z = map(int, raw_input().split())
print (x - z) / (y + z)

Fixed submission:
a, b = raw_input().split()
if a == b:
	print '='
if a < b:
	print '<'
if a > b:
	print '>'
Buggy python submission (verdict: Runtime Error):
a = raw_input()
b = raw_input()
a = list(a)
b = list(b)
n = len(a)
m = len(b)
z = ''
for i in range(n - m + 1):
	flag = True
	for j in range(m):
		if a[i + j] != b[j] and a[i + j] != '?':
			flag = False
	if not flag:
		continue
	c = a
	for j in range(m):
		c[i + j] = b[j]
	for i in range(n):
		if c[i] == '?':
			c[i] = 'a'
	if z == '':
		z = c
	else:
		z = min(z, c)
if z == '':
	print UNRESTORABLE
else:
	print ''.join(z)

Fixed submission:
a = raw_input()
b = raw_input()
a = list(a)
b = list(b)
n = len(a)
m = len(b)
z = ''
for i in range(n - m + 1):
	flag = True
	for j in range(m):
		if a[i + j] != b[j] and a[i + j] != '?':
			flag = False
	if not flag:
		continue
	c = a[::]
	for j in range(m):
		c[i + j] = b[j]
	for i in range(n):
		if c[i] == '?':
			c[i] = 'a'
	if z == '':
		z = c
	else:
		z = min(z, c)
if z == '':
	print 'UNRESTORABLE'
else:
	print ''.join(z)