Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03361 (python)

Fixed submission:
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    h, w = map(int, input().split())
    
    ss = ['.' * (w + 2)] + ['.' + input() + '.' for _ in range(h)] + ['.' * (w + 2)]

    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if ss[i][j] == '#':
                if ss[i + 1][j] == '.' and ss[i - 1][j] == '.' and ss[i][j + 1] == '.' and ss[i][j - 1] == '.':
                    print("No")
                    break
        else:
            continue
        break
    else:
        print("Yes")



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    h, w = map(int, input().split())
    
    ss = ['.' * w] + ['.' + input() + '.' for _ in range(h)] + ['.' * w]

    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if ss[i][j] == '#':
                if ss[i + 1][j] == '.' and ss[i - 1][j] == '.' and ss[i][j + 1] == '.' and ss[i][j - 1] == '.':
                    print("No")
                    break
        else:
            continue
        break
    else:
        print("Yes")



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    h, w = map(int, input().split())
    
    ss = [['.'] * w] + ['.' + input() + '.' for _ in range(h)] + [['.'] * w]

    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if ss[i][j] == '#':
                if ss[i + 1][j] == '.' and ss[i - 1][j] == '.' and ss[i][j + 1] == '.' and ss[i][j - 1] == '.':
                    print("No")
                    break
        else:
            continue
        break
    else:
        print("Yes")



if __name__ == '__main__':
    main()
Problem p03777 (python)

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

if a == b:
    print("H")
else:
    print("D")

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

if a == b:
    print("H")
else:
    print("D")
Problem p03828 (python)

Fixed submission:
import collections
import functools
DIVISOR = 10 ** 9 + 7
n = int(input())

if n == 1:
    print(1)
else:
    prime_factor = collections.defaultdict(int)
    for i in range(1, n + 1):
        tmp = i
        for j in range(2, int(n ** 0.5) + 1):
            while tmp % j == 0:
                prime_factor[j] += 1
                tmp //= j

        if tmp > 1:
            prime_factor[tmp] += 1

    # print(prime_factor)
    prime_factor_num = [prime_factor[key] + 1 for key in prime_factor]

    print((functools.reduce(lambda x, y: (x % DIVISOR) * y, prime_factor_num)) % DIVISOR)

Buggy submission (verdict: Runtime Error):
import collections
import functools
DIVISOR = 10 ** 9 + 7
n = int(input())

prime_factor = collections.defaultdict(int)

for i in range(1, n + 1):
    tmp = i
    for j in range(2, int(n ** 0.5) + 1):
        while tmp % j == 0:
            prime_factor[j] += 1
            tmp //= j

    if tmp > 1:
        prime_factor[tmp] += 1

# print(prime_factor)
prime_factor_num = [prime_factor[key] + 1 for key in prime_factor]

print((functools.reduce(lambda x, y: (x % DIVISOR) * y, prime_factor_num)) % DIVISOR)
Problem p03854 (python)

Fixed submission:
s = input()
i = len(s)
while i > 0:
    if s[i - 5:i] in ('dream', 'erase'):
        i -= 5
    elif s[i - 6:i] == 'eraser':
        i -= 6
    elif s[i - 7:i] == 'dreamer':
        i -= 7
    else:
        print("NO")
        break
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
def erase_check(i, s):
    if s[i:i + 5] == 'erase':
        i_next = erase_check(i + 5, s)
        if i_next == i + 5 and s[i_next] == 'r':
            return s_check(i_next + 1, s)
        else:
            return s_check(i_next, s)
    else:
        return i


def s_check(i, s):
    if s[i:i + 5] == 'dream':
        i_next = erase_check(i + 5, s)
        if i_next == i + 5 and s[i_next:i_next + 2] == 'er':
            return s_check(i_next + 2, s)
        else:
            return s_check(i_next, s)
    else:
        return erase_check(i, s)


s = input()

if s_check(0, s) == len(s):
    print("YES")
else:
    print("NO")
Problem p02936 (python)

Fixed submission:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from collections import defaultdict,deque


## input
N,Q = map(int, input().split())
cnt = [0 for _ in range(N)]
route = defaultdict(lambda:set([]))
for _ in range(N-1):
  a,b = map(int, input().split())
  route[a-1].add(b-1)
  route[b-1].add(a-1)
for _ in range(Q):
  p,x = map(int, input().split())
  cnt[p-1] += x

## solve
stk = deque([0])
cost = [-1 for _ in range(N)]
cost[0] = cnt[0]
while len(stk) > 0:
  p = stk.pop()
  for q in route[p]:
    if cost[q] >= 0:
      continue
    cost[q] = cost[p] + cnt[q]
    stk.append(q)

print(*cost)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from collections import defaultdict


## input
N,Q = map(int, input().split())
cnt = [0 for _ in range(N)]
route = defaultdict(lambda:set([]))
for _ in range(N-1):
  a,b = map(int, input().split())
  route[a-1].add(b-1)
  route[b-1].add(a-1)
for _ in range(Q):
  p,x = map(int, input().split())
  cnt[p-1] += x

## solve
def dfs(p,q):
  for r in route[q]:
    if p != r:
      cnt[r] += cnt[q]
      dfs(q,r)

dfs(-1,0)
print(" ".join([str(c) for c in cnt]))
Problem p03043 (python)

Fixed submission:
# /usr/bin/python
# -*- coding: utf-8 -*-
import math



N,K = map(int, input().split())

ans = 0
for i in range(1,N+1):
  if i < K:
    cnt = math.ceil(math.log2(K/i))
  else:
    cnt = 0
  ans += (1/2)**cnt

print(ans/N)

Buggy submission (verdict: Runtime Error):
# /usr/bin/python
# -*- coding: utf-8 -*-
import math



N,K = map(int, input().split())

ans = 0
for i in range(1,N+1):
  if i < K:
    cnt = math.ceil(math.log2(K/i))
  else:
    cnt = 0
  ans += (1/2)**cnt

print(ans/N)
Problem p03044 (python)

Fixed submission:
# /usr/bin/python
# -*- coding: utf-8 -*-
from collections import deque,defaultdict


N = int(input())

colors = [-1 for _ in range(N)]
tree = [{} for _ in range(N)]
for _ in range(N-1):
  u,v,w = map(int, input().split())
  tree[u-1][v-1] = w % 2
  tree[v-1][u-1] = w % 2

visiting = deque([0])
colors[0] = 0
while len(visiting) > 0:
  p = visiting.popleft()
  for q in tree[p]:
    if colors[q] < 0:
      colors[q] = (tree[p][q]+colors[p]) % 2
      visiting.append(q)

for c in colors:
  print(c)

Buggy submission (verdict: Runtime Error):
# /usr/bin/python
# -*- coding: utf-8 -*-
import math
from collections import defaultdict


N = int(input())
cn = [-1 for i in range(N)]
cn[0] = 0
route = defaultdict(list)
wn = [[0 for j in range(N+1)] for i in range(N+1)]

for _ in range(N-1):
  u,v,w = map(int, input().split())
  wn[u][v] = w
  wn[v][u] = w
  route[u].append(v)
  route[v].append(u)

nxt = set([1])
vnum = 0
while vnum<N and len(nxt)>0:
  p = nxt.pop()
  for q in route[p]:
    if cn[q-1] > 0:
      continue
    else:
      vnum += 1
      nxt.add(q)
      cn[q-1] = (cn[p]+wn[p][q]) % 2

for c in cn:
  print(c)
Problem p03061 (python)

Fixed submission:
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math


def gcd_ab(a,b):
  a,b = sorted([a,b])
  if a == 0:
    return b
  return gcd_ab(b%a, a)

if __name__ == "__main__": 
  N = int(input())
  An = list(map(int, sys.stdin.readline().rstrip().split()))
  cum = [[0,0] for i in range(N+2)]

  for i in range(N):
    cum[i+1][0] = gcd_ab(cum[i][0], An[i])
    cum[N-i][1] = gcd_ab(cum[N-i+1][1], An[N-i-1])

  ans = [0 for i in range(N)]
  for i in range(1,N+1):
    ans[i-1] = gcd_ab(cum[i-1][0], cum[i+1][1])
  print(max(ans))

Buggy submission (verdict: Runtime Error):
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math


def gcd_ab(a,b):
  while a != b:
    if a > b:
      a,b = [b,a]
    if a == 0:
      return b
    b = b-a
  return a


if __name__ == "__main__": 
  N = int(input())
  An = list(map(int, sys.stdin.readline().rstrip().split()))
  cum = [[0,0] for i in range(N+2)]

  for i in range(N):
    cum[i+1][0] = math.gcd(cum[i][0], An[i])
    cum[N-i][1] = math.gcd(cum[N-i+1][1], An[N-i-1])

  ans = [0 for i in range(N)]
  for i in range(1,N+1):
    ans[i-1] = math.gcd(cum[i-1][0], cum[i+1][1])
  print(max(ans))

Buggy submission (verdict: Runtime Error):
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math



def gcd_ab(a,b):
  while a != b:
    a,b = sorted([a,b])
    if a == 0:
      return b
    b = b-a
  return a


if __name__ == "__main__": 
  N = int(input())
  An = list(map(int, sys.stdin.readline().rstrip().split()))
  cuml = An.copy()
  cumr = An.copy()

  for i in range(1, N):
    cuml[i] = gcd_ab(cuml[i-1], An[i])
    cumr[N-i-1] = gcd_ab(cumr[N-i], An[N-i-1])

  cuml = [0] + cuml + [0]
  cumr = [0] + cumr + [0]

  ans = 0
  for i in range(1,N+1):
    ans = max(ans, gcd_ab(cuml[i-1], cumr[i+1]))
  print(ans)

Buggy submission (verdict: Runtime Error):
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math



def gcd(a,b):
  while a != b:
    a,b = sorted([a,b])
    if a == 0:
      return b
    b = b-a
  return a


if __name__ == "__main__": 
  N = int(input())
  An = list(map(int, sys.stdin.readline().rstrip().split()))
  cuml = An.copy()
  cumr = An.copy()

  for i in range(1, N):
    cuml[i] = gcd(cuml[i-1], An[i])
    cumr[N-i-1] = gcd(cumr[N-i], An[N-i-1])

  cuml = [0] + cuml + [0]
  cumr = [0] + cumr + [0]

  ans = 0
  for i in range(1,N+1):
    ans = max(ans, gcd(cuml[i-1], cumr[i+1]))
  print(ans)
Problem p03162 (python)

Fixed submission:
import math
import sys
from operator import itemgetter

# N, K = map(int, input().split())
# h = list(map(int, input().split()))
# S = [input() for _ in range(H)]
# X = [[0 for j in range(100)] for i in range(200)]


### input
N = int(input())
a = [0]*100001
b = [0]*100001
c = [0]*100001

for i in range(N):
	a[i], b[i], c[i] = map(int, input().split())


### solve
hpns = [[0 for j in range(100001)] for i in range(3)]

for i in range(1, N+1):
	hpns[0][i] = max(hpns[1][i-1], hpns[2][i-1]) + a[i-1]
	hpns[1][i] = max(hpns[2][i-1], hpns[0][i-1]) + b[i-1]
	hpns[2][i] = max(hpns[0][i-1], hpns[1][i-1]) + c[i-1]
	
print(max(hpns[0][N], hpns[1][N], hpns[2][N]))

Buggy submission (verdict: Runtime Error):
import math
import sys
from operator import itemgetter

# N, K = map(int, input().split())
# h = list(map(int, input().split()))
# S = [input() for _ in range(H)]
# X = [[0 for j in range(100)] for i in range(200)]


### input
N = int(input())
a = [0]*100001
b = [0]*100001
c = [0]*100001

for i in range(N):
	a[i], b[i], c[i] = map(int, input().split())


### solve
hpns = [[0 for j in range(101)] for i in range(3)]

for i in range(1, N+1):
	hpns[0][i] = max(hpns[1][i-1], hpns[2][i-1]) + a[i-1]
	hpns[1][i] = max(hpns[2][i-1], hpns[0][i-1]) + b[i-1]
	hpns[2][i] = max(hpns[0][i-1], hpns[1][i-1]) + c[i-1]
	
print(max(hpns[0][N], hpns[1][N], hpns[2][N]))
Problem p03219 (python)

Fixed submission:
x, y = map(int, input().split())
print(x + y // 2)

Buggy submission (verdict: Runtime Error):
input = sys.stdin.readline

a, b = map(int, input().rstrip().split())
print(a + b // 2)# -*- coding: utf-8 -*-

import math
import sys
from operator import itemgetter
input = sys.stdin.readline

# a = int(input().rstrip())
# a, b = map(int, input().rstrip().split())
# D = list(map(int, input().rstrip().split()))
# H = [int(input().rstrip()) for _ in range(L)]
# DD = [[0 for j in range(100)] for i in range(200)]
# dict = {} ## dictionary

# a = sorted(a, key=lambda x: x[1]))
# if __name__ == '__main__':

a, b = map(int, input().rstrip().split())
print(a + b // 2)

Buggy submission (verdict: Runtime Error):
input = sys.stdin.readline

a, b = map(int, input().rstrip().split())
print(a + b // 2)
Problem p03241 (python)

Fixed submission:
# -*- coding: utf-8 -*-

import math
import sys
import heapq
from operator import itemgetter
import itertools
input = sys.stdin.readline

# a = int(input().rstrip())
# a, b = map(int, input().rstrip().split())
# D = list(map(int, input().rstrip().split()))
# H = [int(input().rstrip()) for _ in range(L)]
# DD = [[0 for j in range(100)] for i in range(200)]
# dict = {} ## dictionary

# a = sorted(a, key=lambda x: x[1]))
# if __name__ == '__main__':


def divisors(n, m):
	for i in range(m//n, 0, -1):
		if m % i == 0:
			return(i)


N, M = map(int, input().rstrip().split())
print(divisors(N, M))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import math
import sys
import heapq
from operator import itemgetter
import itertools
input = sys.stdin.readline

# a = int(input().rstrip())
# a, b = map(int, input().rstrip().split())
# D = list(map(int, input().rstrip().split()))
# H = [int(input().rstrip()) for _ in range(L)]
# DD = [[0 for j in range(100)] for i in range(200)]
# dict = {} ## dictionary

# a = sorted(a, key=lambda x: x[1]))
# if __name__ == '__main__':


def divisors(p, q):
	ans = []
	if q == 1:
		ans = [1]
	else:
		for i in range(2, q // p + 1):
			if q % i == 0:
				ans.append(i)
	return(ans)

N, M = map(int, input().rstrip().split())
print(divisors(N, M)[-1])
Problem p03318 (python)

Fixed submission:
t = i = 1
k = int(input()) 
while k:
  if t < i / sum(map(int, list(str(i)))):
    i += 9 * t
    t *= 10
  else:
    print(i)
    i += t
    k -= 1

Buggy submission (verdict: Runtime Error):
# /user/bin/python
# -*- coding: utf-8 -*-
from matplotlib import pyplot


def solve(k):
  step = 1
  ret = 0
  mx = 9
  while k > 0:
    ret += step
    k -= 1
    if ret >= mx:
      step *= 10
      mx = mx*10 + 9
    print(ret)

k = int(input())
solve(k)
Problem p03504 (python)

Fixed submission:
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math


## input
N,C = map(int, input().split())
Cn = [[0 for j in range(10**5+1)] for i in range(C)]
An = [0 for j in range(10**5+1)]
for i in range(N):
  s,t,c = map(int, input().split())
  if Cn[c-1][s] == -1:
    An[s] += 1
  else:
    An[s-1] += 1
  if Cn[c-1][t] == 1:
    An[t-1] -= 1
  else:
    An[t] -= 1    

  Cn[c-1][s] += 1
  Cn[c-1][t] -= 1

for i in range(1,10**5+1):
  An[i] += An[i-1]

print(max(An))

Buggy submission (verdict: Runtime Error):
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math


## input
N,C = map(int, input().split())
Cn = [[0 for j in range(10**5+1)] for i in range(C)]
An = [0 for j in range(10**5*2+1)]
for i in range(N):
  s,t,c = map(int, input().split())
  if Cn[c-1][s*2] == -1:
    An[s*2] += 1
  else:
    An[s*2-1] += 1
  An[t*2] -= 1

  Cn[c-1][s] += 1
  Cn[c-1][t] -= 1

for i in range(1,10**5*2+1):
  An[i] += An[i-1]

print(max(An))
Problem p03607 (python)

Fixed submission:
# /usr/bin/python
# -*- coding: utf-8 -*-
import math
from collections import defaultdict


An = defaultdict()
for _ in range(int(input())):
  i = int(input())
  if i not in An:
    An[i] = 1
  else:
    An[i] += 1

ans = 0
for i in An:
  ans += An[i]%2
print(ans)

Buggy submission (verdict: Runtime Error):
# /usr/bin/python
# -*- coding: utf-8 -*-
import math



An = [0 for _ in range(100001)]
for _ in range(int(input())):
  i = int(input())
  An[i] = (An[i]+1)%2

print(sum(An))
Problem p03659 (python)

Fixed submission:
# /usr/bin/python
# -*- coding: utf-8 -*-
import math


N = int(input())
An = list(map(int, input().split()))
sm = [0, sum(An)]

ans = abs(An[0] - sum(An[1:]))
for i in range(N-1):
  sm[0] += An[i]
  sm[1] -= An[i]
  ans = min(ans, abs(sm[0]-sm[1]))
print(ans)

Buggy submission (verdict: Runtime Error):
# /usr/bin/python
# -*- coding: utf-8 -*-
import math
import numpy as np


N = int(input())
An = list(map(int, input().split()))
sm = [0, sum(An)]

ans = abs(An[0] - sum(An[1:]))
for i in range(N-1):
  sm[0] += An[i]
  sm[1] -= An[i]
  ans = min(ans, abs(sm[0]-sm[1]))
print(ans)

Buggy submission (verdict: Runtime Error):
# /usr/bin/python
# -*- coding: utf-8 -*-
import math
import numpy as np


N = int(input())
An = np.asarray(list(map(int, input().split())))
cumsum = np.cumsum(An)
sm = np.sum(An)

ans = 10**14+1
for i in range(N-1):
  ans = min(ans, abs(sm-2*cumsum[i]))
print(ans)
Problem p02882 (python)

Fixed submission:
import sys, math

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

A, B, X = MAP()
V = A* A * B - X

if V < X:
    # Y = 2 * vacant / A / A
    if V > 0:
        ans = 90 - math.degrees(math.atan(A**3 / (2*V)))
    else:
        ans = 0
else:
    # Y = 2 * X / A / B
    ans = 90 - math.degrees(math.atan(2 * X / (A*B*B)))
print(ans)

Buggy submission (verdict: Runtime Error):
import sys, math

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

A, B, X = MAP()
V = A* A * B - X
if V < X:
    # Y = 2 * vacant / A / A
    ans = 90 - math.degrees(math.atan(A**3 / (2*V)))
else:
    # Y = 2 * X / A / B
    ans = 90 - math.degrees(math.atan(2 * X / (A*B*B)))
print(ans)
Problem p02924 (python)

Fixed submission:
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    count = 0
    for nn in range(1, N):
        count += nn
    print(count)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    print(sum(list(range(1, N))))

if __name__ == '__main__':
    main()
Problem p03006 (python)

Fixed submission:
import sys
import collections

def input():
    return sys.stdin.readline()[:-1]

def main():
    n = int(input())
    x = [list(map(int, input().split())) for _ in range(n)]

    if n == 1:
        print(1)
    else:
        dist = [(x[j][0] - x[i][0], x[j][1] - x[i][1]) for j in range(n) for i in range(n)]
        c = collections.Counter(dist)
        ans = c.most_common()
        print(n - ans[1][1])

if __name__ == '__main__':
    main()

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

def input():
    return sys.stdin.readline()[:-1]

def main():
    n = int(input())
    x = [list(map(int, input().split())) for _ in range(n)]

    dist = [(x[j][0] - x[i][0], x[j][1] - x[i][1]) for j in range(n) for i in range(n)]
    c = collections.Counter(dist)
    ans = c.most_common()
    print(n - ans[1][1])

if __name__ == '__main__':
    main()
Problem p03049 (python)

Fixed submission:
def main():
    n = int(input())
    s = [input() for i in range(n)]

    AB = 0
    B_ = 0
    _A = 0
    B_A = 0
    for ss in s:
        for i in range(len(ss)-1):
            if ss[i:i+2] == 'AB':
                AB += 1
        if ss[0] == 'B':
            if ss[-1] == 'A':
                B_A += 1
            else:
                B_ += 1
        elif ss[-1] == 'A':
            _A += 1
    if B_A > 0:
        if _A > 0 and B_ > 0:
            print(AB + (B_A - 1) + 2 + min(_A - 1, B_ - 1))
        elif _A == 0 and B_ == 0:
            print(AB + (B_A - 1))
        else:
            print(AB + (B_A - 1) + 1)
    else:
        print(AB + min(_A, B_))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    s = [input() for i in range(n)]

    AB = 0
    B_ = 0
    _A = 0
    B_A = 0
    for ss in s:
        for i in range(len(ss)-1):
            if ss[i:i+2] == 'AB':
                AB += 1
        if ss[0] == 'B':
            if ss[-1] == 'A':
                B_A += 1
            else:
                B_ += 1
        elif ss[-1] == 'A':
            _A += 1
    if _A == B_ && _A > 1:
        print(AB + max((B_A - 1), 0) + max(min(B_ + int(B_A > 0), _A), min(B_, _A + int(B_A > 0))) + 1)
    else:
        print(AB + max((B_A - 1), 0) + max(min(B_ + int(B_A > 0), _A), min(B_, _A + int(B_A > 0))))
    # print(AB, B_, _A, B_A)

if __name__ == '__main__':
    main()
Problem p03067 (python)

Fixed submission:
import sys

def main():
    argv = input().split()
    A = int(argv[0])
    B = int(argv[1])
    C = int(argv[2])
    print(judge(A, B, C))

def judge(A, B, C):
    if (A < C and C < B) or (C < A and B < C):
        return 'Yes'
    else:
        return 'No'

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

def main(argv):
    A = int(argv[0])
    B = int(argv[1])
    C = int(argv[2])
    print(judge(A, B, C))

def judge(A, B, C):
    if (A < C and A < B) or (C < A and B < A):
        return 'Yes'
    else:
        return 'No'

if __name__ == '__main__':
    main(sys.argv[1:])
Problem p02995 (python)

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

a,b,c,d=map(int,input().split())
cn1=0
cn2=0
cn3=0
an1=0
an2=0
an3=0
cnt=0
ans=0
lm=(c*d)//gcd(c,d)

#bまで
cn1=b//c
cn2=b//d
cn3=b//lm
#aまで
an1=(a-1)//c
an2=(a-1)//d
an3=(a-1)//lm
#aからbまで
cn1=cn1-an1
cn2=cn2-an2
cn3=cn3-an3

cnt=cn1+cn2-cn3
ans=b-a-cnt+1

print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
def lcm(x,y):
    return (x*y)//math.gcd(x,y)
lm=lcm(c,d)
print(lm)
Problem p02898 (python)

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))
from bisect import bisect_left
print(n - bisect_left(sorted(h),k))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = list(map(int, input().split()))
from bisect import bisect_left
rint(n - bisect_left(sorted(h),k))
Problem p02934 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0
for _a in a:
    ans +=1/_a
print(1/ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input()))
ans = 0
for _a in a:
    ans +=1/_a
print(1/ans)
Problem p02947 (python)

Fixed submission:
from collections import Counter 
n = int(input())
anagram =[]
ans = 0
for _ in range(n):
    s = ''.join(sorted(input()))
    anagram.append(s)
count_ana = Counter(anagram)
for v in count_ana.values():
    ans += v * (v - 1) // 2
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
anagram =[]
ans = 0
for _ in range(n):
    s = ''.join(input())
    anagram.append(s)
count_ana = Counter(anagram)
for v in count_ana.values():
    ans += v * (v + 1) // 2
print(ans)