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

Fixed submission:
import math
from collections import defaultdict

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

def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

pr = prime_factors(m)
di = {}
di = defaultdict(int)
for i in pr:
    while m % i == 0:
        m = m // i
        di[i] += 1

"""def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))"""
mod = 10 ** 9 + 7
MAX_N = 10 ** 5 + 100
factorial = [1] * MAX_N
def calc_factorial():
    for i in range(1, MAX_N):
        factorial[i] = i * factorial[i - 1] % mod

def comb(n, k):
    a = factorial[n] % mod
    b = (factorial[k] * factorial[n - k]) % mod
    b_ = pow(b, mod - 2, mod)
    return (a * b_) % mod


# 階乗を用意
calc_factorial()

ans = 1

for i in di:
    ans = ans * comb(di[i] + n - 1, di[i]) % mod
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import sympy
n, m = map(int, input().split())
di = sympy.factorint(m)
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
ans = 1
mod = 10 ** 9 + 7
for i in di:
    ans = ans * comb(di[i] + n - 1, di[i]) % mod
print(ans)
Problem p03426 (python)

Fixed submission:
h,w,d = map(int, input().split())
a = []

for i in range(h):#h:高さ
    a.append([int(m) for m in input().split()])

q = int(input())
lr = []
for i in range(q):#h:高さ
    lr.append([int(m) for m in input().split()])

rea = []
for i in range(h * w):
    rea.append([])


for i in range(h):
    for j in range(w):
        rea[w*i+j].append(a[i][j])
        rea[w*i+j].append(i)
        rea[w*i+j].append(j)

rea.sort()

pre = []
for i in range(h*w):
    pre.append([])
p = 0
for i in range(h):
    if p == 1:
        break
    for j in range(w):
        if w * i + j + 1 <= d:
            lmn = 0
            pre[w * i + j].append(lmn)

            for k in range(0,h*w,d):
                if w*i+j + d + k < h*w:
                    lmn += abs(rea[w*i+j + k][1] - rea[w*i+j+d + k][1]) + abs(rea[w*i+j + k][2]- rea[w*i+j+d + k][2])
                    pre[w*i+j].append(lmn)
                else:
                    break
        else:
            p = 1
            break

for i in range(q):
    print(pre[(lr[i][0] - 1) % d][(lr[i][1] - 1)//d] - pre[(lr[i][0] - 1) % d][(lr[i][0] - 1)//d])

Buggy submission (verdict: Runtime Error):
h,w,d = map(int, input().split())
a = []

PY = [list(map(int, input().split())) + [i] for i in range(h)]
for i in range(h):#h:高さ
    a.append([int(m) for m in input().split()])

q = int(input())
lr = []
for i in range(q):#h:高さ
    lr.append([int(m) for m in input().split()])

rea = []
for i in range(h * w):
    rea.append([])
for i in range(h):
    for j in range(w):
        rea[i].append([])


for i in range(h):
    for j in range(w):
        rea[w*i+j].append(a[i][j])
        rea[w*i+j].append(i)
        rea[w*i+j].append(j)

rea.sort()

pre = []
for i in range(h*w):
    pre.append([])

for i in range(h):
    for j in range(w):
        lmn = 0
        pre[w * i + j].append(lmn)
        for k in range(i, h*w,d):
            lmn += abs(rea[w*i+j + k][1] - rea[w*i+j+d + k][1]) + abs(rea[w*i+j + k][2]- rea[w*i+j+d + k][2])
            pre[w*i+j].append(lmn)

for i in range(q):
    print(pre[lr[i][0] - 1][(lr[i][1]-lr[i][0])//d - 1])
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())
print(6 - a - b)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = ont(input())
print(6 - a - b)

Buggy submission (verdict: Runtime Error):
a = int(input().split())
b = ont(input().split())
print(6 - a - b)
Problem p02831 (python)

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

print(a*b//fractions.gcd(a, b))

Buggy submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
print(a*b//math.gcd(a, b))
Problem p02832 (python)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
if not 1 in l:
  print(-1)
  exit()
cnt = 1
ans = 0
for item in l:
  if item == cnt:
    ans += 1
    cnt += 1
print(n - ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))
if not 1 in l:
  print(-1)
  exit()
cnt = 1
ans = 0
for item in l:
  if item = cnt:
    ans += 1
    cnt += 1
print(n - ans)
Problem p02833 (python)

Fixed submission:
n = int(input())
if n % 2 == 1:
  print(0)
elif n == 0:
  print(0)
else:
  m = n // 2
  l = 1
  ans = 0
  while 5**l <= m:
    ans += m//(5**l)
    l += 1
  print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n % 2 == 1:
  print(0)
elif n == 0:
  print(1)
else:
  m = n // 2
  l = 1
  ans = 0
  while 5**l <= m:
    ans += m//(5**l)
    l += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n % 2 == 1:
  print(0)
else:
  m = n // 2
  l = 1
  ans = 0
  while 5**l <= m:
    ans += m//(5**l)
    l += 1
print(ans)
Problem p02834 (python)

Fixed submission:
import sys
input = sys.stdin.readline
 
# 再帰上限を引き上げる
sys.setrecursionlimit(10**6)

n, u, v = map(int, input().split())
u, v = u-1, v-1
l = [[] for i in range(n)]
for i in range(n-1):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  l[a].append(b)
  l[b].append(a)

def dfs(G, cr, seen, dist):
  seen[cr] = 1
  for i in G[cr]:
    if seen[i] == 0:
      dist[i] = dist[cr] + 1
      dfs(G, i, seen, dist)
  return dist

seen_u = [0]*n
seen_v = [0]*n
dist_u = [0]*n
dist_v = [0]*n

T1 = dfs(l, u, seen_u, dist_u)
T2 = dfs(l, v, seen_v, dist_v)

for i in range(n):
  if dist_u[i] >= dist_v[i]:
    dist_v[i] = -1
    
print(max(dist_v)-1)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
 
# 再帰上限を引き上げる
sys.setrecursionlimit(10**6)

n, u, v = map(int, input().split())
u, v = u-1, v-1
l = [None]*n
for i in range(n-1):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  l[a].append(b)
  l[b].append(a)

def dfs(G, cr, seen, dist):
  seen[cr] = 1
  for i in range(G[cr]):
    if seen[i] == 0:
      dist[i] = dist[cr] + 1
      dfs(G, i, seen, dist)
  return dist

seen_u = [0]*n
seen_v = [0]*n
dist_u = [0]*n
dist_v = [0]*n

T1 = dfs(l, u, seen_u, dist_u)
T2 = dfs(l, v, seen_v, dist_v)

for i in range(n):
  if dist_u[i] >= dist_v[i]:
    dist_v[i] = -1
    
print(max(dist_v)-1)
Problem p02836 (python)

Fixed submission:
s = input()
kk = len(s)
k = kk//2
ans = 0
for i in range(k):
  if s[i] != s[kk - i - 1]:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
kk = len(s)
k = k//2
ans = 0
for i in range(k):
  if s[i] != s[kk - i - 1]:
    ans += 1
print(ans)
Problem p02891 (python)

Fixed submission:
s = input()
s = s + "1"
k = int(input())
ans = 0
lis = []
tem = 1
for i in range(len(s)-1):
  if s[i] == s[i+1]:
    tem += 1
  else:
    lis.append(tem)
    tem = 1
if s[0] == s[-2]:
  t = lis[0]+lis[-1]
  for i in range(1,len(lis)-1):
    if lis[i] % 2 == 0:
      ans += lis[i]//2
    else:
      ans += (lis[i]-1)//2
  ans*= k
  if t%2 == 0:
    ans += (k-1)*t//2
  else:
    ans += (k-1)*(t-1)//2
  if lis[0]%2 == 0:
    ans += lis[0]//2
  else:
    ans += (lis[0]-1)//2
  if lis[-1]%2 == 0:
    ans += lis[-1]//2
  else:
    ans += (lis[-1]-1)//2
else:
  for item in lis:
    if item % 2 == 0:
      ans += item//2
    else:
      ans += (item-1)//2
  ans *= k
if len(lis) == 1:
  anse = (len(s)-1)*k
  if anse%2 == 0:
    ans = anse//2
  else:
    ans =(anse-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
s = s + "1"
k = int(input())
ans = 0
lis = []
tem = 1
for i in range(len(s)-1):
  if s[i] == s[i+1]:
    tem += 1
  else:
    lis.append(tem)
    tem = 1
if s[0] == s[-2]:
  t = lis[0]+lis[-1]
  for i in range(1,len(lis)-1):
    if item % 2 == 0:
      ans += item//2
    else:
      ans += (item-1)//2
  ans*= k
  if t%2 == 0:
    ans += (k-1)*t//2
  else:
    ans += (k-1)*(t-1)//2
  if lis[0]%2 == 0:
    ans += (k-1)*lis[0]//2
  else:
    ans += (k-1)*(lis[0]-1)//2
  if lis[-1]%2 == 0:
    ans += (k-1)*lis[-1]//2
  else:
    ans += (k-1)*(lis[-1]-1)//2
else:
  for item in lis:
    if item % 2 == 0:
      ans += item//2
    else:
      ans += (item-1)//2
  ans *= k
  
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
s = s + "1"
k = int(input())
ans = 0
lis = []
tem = 1
for i in range(len(s)):
  if s[i] == s[i+1]:
    tem += 1
  else:
    lis.append(tem)
    tem = 1
if s[0] == s[-2]:
  t = lis[0]+lis[-1]
  for i in range(1,lis(lis)-1):
    if item % 2 == 0:
      ans += item//2
    else:
      ans += (item-1)//2
  ans*= k
  if t%2 == 0:
    ans += (k-1)*t//2
  else:
    ans += (k-1)*(t-1)//2
  if lis[0]%2 == 0:
    ans += (k-1)*lis[0]//2
  else:
    ans += (k-1)*(lis[0]-1)//2
  if lis[-1]%2 == 0:
    ans += (k-1)*lis[-1]//2
  else:
    ans += (k-1)*(lis[-1]-1)//2
else:
  for item in lis:
    if item % 2 == 0:
      ans += item//2
    else:
      ans += (item-1)//2
  ans *= k
  
print(ans)
Problem p03104 (python)

Fixed submission:
def calc0toN(a):
  if a % 2 == 0:
    if a % 4 == 0:
      return a
    else:
      return 1 ^ a
  else:
    if (a + 1) % 4 == 0:
      return 0
    else:
      return 1
A, B = map(int, input().split())
print(calc0toN(A - 1) ^ calc0toN(B))

Buggy submission (verdict: Runtime Error):
def calc0toN(a):
  bina = int(bin(a)[2:]) 
  if a % 2 == 0:
    if a % 4 == 0:
      return bina
    else:
      return 1 ^ bina
  else:
    if (a + 1) % 4 == 0:
      return 0
    else:
      return 1
A, B = map(int, input().split())
print(int("0b" + str(calc0toN(A - 1) ^ calc0toN(B)), 2))

Buggy submission (verdict: Runtime Error):
def calc0toN(a):
  bina = int(bin(a)[2:]) 
  if a % 2 == 0:
    if a % 4 == 0:
      return bina
    else:
      return 1 | bina
  else:
    if (a + 1) % 4 == 0:
      return 0
    else:
      return 1
A, B = map(int, input().split())
print(int("0b" + str(calc0toN(A - 1) | calc0toN(B)), 2))
Problem p03137 (python)

Fixed submission:
N, M = map(int, input().split())
lis = [int(x) for x in input().split()]
lis.sort()
if N >= M:
  print(0)
else:
  lis2 = []
  for i in range(M - 1):
    lis2.append(lis[i + 1] - lis[i])
  lis2.sort(reverse = True)
  k = 0
  for i in range(N - 1, M - 1):
    k += lis2[i]
  print(k)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
lis = [int(x) for x in input().split()]
lis.sort()
if N >= M:
  print(0)
else:
  lis2 = []
  for i in range(M - 1):
    lis2.append(lis[i + 1] - lis[i])
  lis2.sort(reverse = True)
  k = 0
  for i in range(N - 1, M - 1)
Problem p02753 (python)

Fixed submission:
S = input()
if S=="AAA" or S=="BBB":
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
S = input()
if S=="AAA" or S="BBB":
  print("No")
else:
  print("Yes")
Problem p02959 (python)

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

kill = 0

if A[0] >= B[0]:
  kill += B[0]
  B[0] = 0
else:
  kill += A[0]
  B[0] -= A[0]

for i in range(N-1):
  if A[i+1] <= B[i]:
    kill += A[i+1]
  else:
    A[i+1] -= B[i]
    kill += B[i]
    if A[i+1] >= B[i+1]:
      kill += B[i+1]
      B[i+1] = 0
    else:
      kill += A[i+1]
      B[i+1] -= A[i+1]

if A[N] <= B[N-1]:
  kill += A[N]
else:
  kill += B[N-1]

print(kill)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

kill = 0

if A[0] >= B[0]:
  kill += B[0]
  B[0] = 0
else:
  kill += A[0]
  B[0] -= A[0]

for i in range(N):
  if A[i+1] <= B[i]:
    kill += A[i+1]
  else:
    A[i+1] -= B[i]
    kill += B[i]
    if A[i+1] >= B[i+1]:
      kill += B[i+1]
      B[i+1] = 0
    else:
      kill += A[i+1]
      B[i+1] -= A[i+1]

print(kill)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

kill = 0

if A[0] >= B[0]:
  kill += B[0]
  B[0] = 0
else:
  kill += A[0]
  B[0] -= A[0]

for i in range(N):
  if A[i+1] <= B[i]:
    kill += A[i+1]
  else:
    A[i+1] -= B[i]
    kill += B[i]
    if A[i+1] >= B[i+1]:
      kill += B[i+1]
      B[i+1] = 0
    else:
      kill += A[i+1]
      B[i+1] -= A[i+1]
Problem p03012 (python)

Fixed submission:
N = int(input())
W = list(map(int, input().split()))
m = 100000
for i in range(len(W)):
  m = min(m, abs(sum(W[:i])-sum(W[i:])))
print(m)

Buggy submission (verdict: Runtime Error):
N = int(input())
W = list(map(int, input().split()))
W = sorted(W)
m = 100000
for i in range(len(W)):
  m = min(m, abs(W[:i]-W[i:]))
print(m)
Problem p03036 (python)

Fixed submission:
r, D, x2000 = map(int, input().split())
x = x2000
for i in range(10):
  x = r*x - D
  print(x)

Buggy submission (verdict: Runtime Error):
r, D, x2000 = map(int, input().split())
for i in range(10):
  x = r*x - D
  print(x)
Problem p03631 (python)

Fixed submission:
N = input()
f = True
L = len(N)
for i in range(L):
  if N[i] != N[L-1-i]:
    f = False
    break
if f:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = input()
f = True
L = len(N)
for i in range(N):
  if N[i] != N[L-1-i]:
    f = False
    break
if f:
  print("Yes")
else:
  print("No")
Problem p03803 (python)

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

if A == 1:
  A = 14
if B == 1:
  B = 14

if A == B:
  print("Draw")
elif A > B:
  print("Alice")
else:
  print("Bob")

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())

if A == 1:
  A = 14
if B == 1:
  B = 14

if A == B:
  print("Draw")
elif A > B:
  print("Alice")
else:
  print("Bob")
Problem p02835 (python)

Fixed submission:
as_ = map(int, input().split())
 
if sum(as_) <= 21:
  print("win")
else:
  print("bust")

Buggy submission (verdict: Runtime Error):
as = map(int, input().split())
 
if sum(as) <= 21:
  print("win")
else:
  print("bust")

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

if as.sum() <= 21:
  print("win")
else:
  print("bust")
Problem p02970 (python)

Fixed submission:
n,d = map(int,input().split())
for i in range(1,n+1):
    if (d*2+1)*i >= n:
        a = i
        break
print(a)

Buggy submission (verdict: Runtime Error):
n,d = map(int,input().split())
for i in range(n):
    if (d*2+1)*i >= n:
        a = i
        break
print(a)
Problem p03042 (python)

Fixed submission:
S = input()
ff = int(S[:2])
ll = int(S[2:])
if 0<ff<=12 and 0<ll<=12:
    print("AMBIGUOUS")
elif (ff == 0 or ff>12) and 0<ll<=12:
    print("YYMM")
elif 0<ff<=12 and (ll>12 or ll== 0):
    print("MMYY")
else:
    print("NA")

Buggy submission (verdict: Runtime Error):
s = input()
f = int(s[0]+s[1])
l = int(s[2]+s[3])
if 1<= f <= 12:
    if 1<= l <= 12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"
if (f == 0) or (f>13):
    if 1<= l <= 12:
        ans = "YYMM"
    else:
        ans = "NA"
print(ans)
Problem p02707 (python)

Fixed submission:
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N    
  for i in range(N-1):
      B[A[N-i-2]-1] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = []
  for i in range(N):
    B.append(0)
    
  for i in range(N):
    e = int(A[N-i-1])
    B[e] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N
  for i in range(N):
    e = int(A[N-i-1])
    B[e] = B[e] + 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N
  B = int(B)
  for i in range(N):
    e = int(A[N-i-1])
    B[e] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N
  for i in range(N):
    e = A[N-i-1]
    B[e] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N
  for i in range(N):
    B[A[N-i-1]] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
def main():
  N = input()
  A = [int(x) for x in input().split()]
  
  B = [0] * N
  for i in range(N):
    B[A[N-i-1]] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()
Problem p02707 (python)

Fixed submission:
import math
import sys
from collections import defaultdict
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
    
n = inp()
A = invr()

map = defaultdict(int)
for i, boss in enumerate(A, 2):
	map[boss] += 1 
	
for i in range(n):
	print map[i+1]

Buggy submission (verdict: Runtime Error):
import math
import sys
from collections import defaultdict
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
    
n = inp()
A = invr()

map = defaultdict(int)
for i, boss in enumerate(A, 2):
	map[boss] += 1 
	
for i in range(n):
	print map[i+1]
Problem p02707 (python)

Fixed submission:
num = int(input())
h_numbers = list(map(int, input().split()))
s = [0] * num
for i in h_numbers:
    s[i-1] += 1
[print(i) for i in s]

Buggy submission (verdict: Runtime Error):
import numpy as np

n = input()
a = np.array([int(i) for i in input().split()])
for i in range(int(n)):
    print(a.count(i+1))

Buggy submission (verdict: Runtime Error):
n = input()
a = np.array([int(i) for i in input().split()])

for i in range(int(n)):
    print(a.count(i+1))

Buggy submission (verdict: Runtime Error):
n = input()
#a = list(map(int, input().split()))
a = np.array([int(i) for i in input().split()])
for i in range(int(n)):
    print(a.count(i+1))

Buggy submission (verdict: Runtime Error):
n = input()
a = list(int, input().split()))

print(0)
for i in range(len(a)):
    print(a.count(i))
Problem p02880 (python)

Fixed submission:
a = int(input())
for i in range(1,10,1):
  if a % i == 0 and a/i < 10:
    print('Yes')
    exit(0)
print('No')

Buggy submission (verdict: Runtime Error):
a = map(int,input().split())
for i in range(2,10,1):
  if a % i == 0 and a/i < 10:
    print('Yes')
	return 0
print('No)
Problem p03017 (python)

Fixed submission:
n, a, b, c, d = (map(int, input().split()))
S = input()
if '##' in S[a-1:c] or '##' in S[b-1:d] :
	print('No')
elif d < c and not '...' in S[b-2:d+1]:
        print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
n, a, b, c, d = (map(int, input().split()))
S = input()
if '##' in S:
	print('No')
elif d<c:
	if not '...' in S:
    	print ('No')
	if d <= n and S[d]=='#' and d-2 >= 0 and S[d-2]=='#':
		print('No')
else:
	print('Yes')

Buggy submission (verdict: Runtime Error):
n, a, b, c, d = (map(int, input().split()))
S = input()
if '##' in S:
	print('No')
elif d<c:
	if not '...' in S:
    	print ('No')
	if d <= n and S[d]=='#' and d-2 >= 0 and s[d-2]=='#':
		print('No')
else:
	print('Yes')

Buggy submission (verdict: Runtime Error):
n, a, b, c, d = (map(int, input().split()))
S = input()
import re
if '##' in S:
  return 'No'
elif d>c and not '...' in S:
  return 'No'
elif c==d:
  return 'No'
else:
  return 'Yes'
Problem p03295 (python)

Fixed submission:
from operator import itemgetter
n, m = map(int, input().split())
bridge = 0
ab = []
for _ in range(m):
  a, b = map(int, input().split())
  ab.append((a,b))
ab = sorted(ab, key=itemgetter(1))
count = 0
for a, b in ab:
  if not a <= bridge <= b:
    count += 1
    bridge = b-1
print(count)

Buggy submission (verdict: Runtime Error):
from operator import itemgetter
n, m = map(int, input().split())
bridge = 0
ab = []
for _ in range(m):
  a, b = map(int, input().split())
  ab.append((a,b))
ab = sorted(ab, key=itemgetter(1))
count = 0
for a, b in ab:
  if not a <= bridge <= b:
    counr += 1
    bridge = b
print(count)
Problem p03041 (python)

Fixed submission:
num_str = input().split(" ")
S = input()

N = int(num_str[0])
K = int(num_str[1])
s = list(S)

if s[K-1] == "A":
  s[K-1] = "a"
elif s[K-1] == "B":
  s[K-1] = "b"
elif s[K-1] == "C":
  s[K-1] = "c"

S = "".join(s)
print(S)

Buggy submission (verdict: Runtime Error):
num_str = input().split(" ")
S = input()

N = int(num_str[0])
K = int(num_str[1])

if S[K-1] == "A":
  S[K-1] = "a"
elif S[K-1] == "B":
  S[K-1] = "b"
elif S[K-1] == "C":
  S[K-1] = "c"
  
print(S)

Buggy submission (verdict: Runtime Error):
num_str = input()
num_str = num_str.split("")

Buggy submission (verdict: Runtime Error):
num_str = input()
num_str = num_str.split("")
N = int(num_str[0])
K = int(num_str[2])

S = input()

if S[K-1] == "A":
  S[K-1] = "a"
elif S[K-1] == "B":
  S[K-1] = "b"
elif S[K-1] == "C":
  S[K-1] = "c"
  
print(S)

Buggy submission (verdict: Runtime Error):
N = int(input())
K = int(input())
S = input()

if S[K] == "A":
  S[K] = "a"
elif S[K] == "B":
  S[K] = "b"
elif S[K] == "C":
  S[K] = "c"
Problem p03127 (python)

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

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

if n==1:
    print(x[0])
else:
    element = gcd(x[0], x[1])
    if n==2:print(element)
    else:
        for i in range(2,n):
            element=gcd(element,x[i])
        print(element)

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

n = int(input())
a = list(map(int, input().split()))

gcd = functools.reduce(math.gcd, a)
print(gcd)
Problem p03011 (python)

Fixed submission:
l = [int(_) for _ in raw_input().split(" ")]
l.sort()
print l[0] + l[1]

Buggy submission (verdict: Runtime Error):
AB, BC, AC = [int(_) for _ in raw_input().split(" ")]

M = [[0, AB, AC],
     [AB, 0, BC],
     [AC, BC, 0]]

def A(l):
    t = [0] * l
    def Sub(targetList, n):
        if 1:
            if len(targetList) == 1:
                t[n] = targetList[0]
                yield t
                t[n] = 0
            for i in range(len(targetList)):
                p = targetList[:i] + targetList[i+1:]
                t[n] = targetList[i]
                for j in Sub(p, n+1):
                    yield j
        else:
            pass
    
    for i in (Sub(tuple(range(l)), 0)):
        yield i

_min = 10**100
for i in A(3):
    _sum = 0
    for j in range(1, len(i)):
        _from = i[j-1]
        _to = i[j]        
        _sum += M[_from][_to]
    #print (_sum)
    if _min > _sum:
        _min = _sum
print (_sum)
Problem p02897 (python)

Fixed submission:
n=int(input())
a=(n+1)//2
print(a/n)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=(n-1)//2
print a/n
Problem p02753 (python)

Fixed submission:
s = input()
if 'A' in s and 'B' in s:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s = input().split()
if s in 'A' and s in 'B':
  print('Yes')
else:
  print('No')
Problem p03073 (python)

Fixed submission:
#coding:utf-8

S = input()
N = len(S)
ans = 0
SR = []
if S[0] == '0':
	for i in range(N):
		SR.append('0')
		SR.append('1')
else:
	for i in range(N):
		SR.append('1')
		SR.append('0')

for i in range(N):
	if S[i] != SR[i]:
		ans += 1
		
print(ans)

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

S = input()

N = len(S)
ans = 0
SR = []
if S[0] == '0':
	for i in range(int(N/2)):
		SR.append('0')
		SR.append('1')
else:
	for i in range(int(N/2)):
		SR.append('1')
		SR.append('0')

for i in range(N):
	if S[i] != SR[i]:
		ans += 1
		
print(ans)
Problem p02753 (python)

Fixed submission:
M = input()
print('No' if M[0] == M[1] == M[2] else "Yes")

Buggy submission (verdict: Runtime Error):
a,b,c = map(input().split())
print("No" if a == b == c else "Yes")