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

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
    
def main():
    n,m=map(int,input().split())
    A=[int(input())for _ in range(m)]
    flag=[True]*(n+2)
    for a in A:
        flag[a]=False
    mod=10**9+7
    dp=[0]*(n+1)
    dp[0]=1
    for i in range(n):
        if flag[i+1]:
            dp[i+1]+=dp[i]%mod
        if flag[i+2] and i<n-1:
            dp[i+2]+=dp[i]%mod
    print(dp[n]%mod)

if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()
    
def main():
    n,m=map(int,input().split())
    A=[int(input())for _ in range(m)]
    flag=[True]
    for a in A:
        flag[a]=False
    mod=10**9+7
    dp=[0]*(n+1)
    dp[0]=1
    for i in range(n):
        if flag[i+1]:
            dp[i+1]+=dp[i]%mod
        if flag[i+2] and i<n-1:
            dp[i+2]+=dp[i]%mod
    print(dp[n]%mod)

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

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def f(n,x):#レベルnのx番目
    if n==0:return 0 if x<=0 else 1
    if x<=1+A[n-1]:return f(n-1,x-1)
    return 1+P[n-1]+f(n-1,x-A[n-1]-2)
def main():
    n,x=map(int,input().split())
    global A,P
    A=[1, 5, 13, 29, 61, 125, 253, 509, 1021, 2045, 4093, 8189, 16381, 32765, 65533, 131069, 262141, 524285, 1048573, 2097149, 4194301, 8388605, 16777213, 33554429, 67108861, 134217725, 268435453, 536870909, 1073741821, 2147483645, 4294967293, 8589934589, 17179869181, 34359738365, 68719476733, 137438953469, 274877906941, 549755813885, 1099511627773, 2199023255549, 4398046511101, 8796093022205, 17592186044413, 35184372088829, 70368744177661, 140737488355325, 281474976710653, 562949953421309, 1125899906842621, 2251799813685245, 4503599627370493]
    P=[1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647, 4294967295, 8589934591, 17179869183, 34359738367, 68719476735, 137438953471, 274877906943, 549755813887, 1099511627775, 2199023255551, 4398046511103, 8796093022207, 17592186044415, 35184372088831, 70368744177663, 140737488355327, 281474976710655, 562949953421311, 1125899906842623, 2251799813685247]
    print(f(n,x))

if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()
def f(n,x):#レベルnのx番目
    if n==0:return 0 if x<=0 else 1
    if x<=1+A[n-1]:return f(n-1,x-1)
    if x<=2*A[n-1]+2:return 1+P[n-1]+f(n-1,x-A[n-1]-2)
def main():
    n,x=map(int,input().split())
    global A,P
    A=[1, 5, 13, 29, 61, 125, 253, 509, 1021, 2045, 4093, 8189, 16381, 32765, 65533, 131069, 262141, 524285, 1048573, 2097149, 4194301, 8388605, 16777213, 33554429, 67108861, 134217725, 268435453, 536870909, 1073741821, 2147483645, 4294967293, 8589934589, 17179869181, 34359738365, 68719476733, 137438953469, 274877906941, 549755813885, 1099511627773, 2199023255549, 4398046511101, 8796093022205, 17592186044413, 35184372088829, 70368744177661, 140737488355325, 281474976710653, 562949953421309, 1125899906842621, 2251799813685245, 4503599627370493]
    P=[1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647, 4294967295, 8589934591, 17179869183, 34359738367, 68719476735, 137438953471, 274877906943, 549755813887, 1099511627775, 2199023255551, 4398046511103, 8796093022207, 17592186044415, 35184372088831, 70368744177663, 140737488355327, 281474976710655, 562949953421311, 1125899906842623, 2251799813685247]
    print(f(n,x))

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

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

s1, s2 = 0, sum(w)
ans = sum(w)

for i in range(n):
  s1 += w[i]
  s2 -= w[i]
  ans = min(ans, abs(s1 - s2))
print(ans)

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

s1, s2 = 0, sum(w)
ans = sum(w)

for i in range(n):
  s1 += w[i]
  s2 -= w[i]
  ans = min(ans, abs(s1, - s2))
print(ans)
Problem p02597 (python)

Fixed submission:
"""According to a fortune-teller, a white stone placed to the immediate left of a red stone 
WR leads to nok
"""
n = int(raw_input())
s = list(raw_input())
import collections


def f(s):
	cc = collections.Counter(s)
	if cc['R'] == 0 or cc['W'] == 0:
		return 0
	i = 0
	j = len(s) - 1
	#while(i < len(s) and s[i] == 'R'): i +=1
	#while(j>=0 and s[j] == 'W'): j -=1
	
	c = 0
	while(i < j):
		if s[i] == 'W' and s[j] == 'R':
			s[i],s[j] = s[j],s[i]
			i += 1
			j -= 1
			c += 1
		while(i < j and s[i] == 'R'): i+=1
		while(i < j and s[j] == 'W'): j-=1
	return min(c, cc['R'], cc['W'])

print f(s)

Buggy submission (verdict: Runtime Error):
"""According to a fortune-teller, a white stone placed to the immediate left of a red stone 
WR leads to nok
"""
n = int(raw_input())
s = list(raw_input())
import collections


def f(s):
	cc = collections.Counter(s)
	if cc['R'] == 0 or cc['W'] == 0:
		return 0
	i = 0
	j = len(s) - 1
	while(s[i] == 'R'): i +=1
	while(s[j] == 'W'): j +=1
	
	c = 0
	while(i < j):
		if s[i] == 'W' and s[j] == 'R':
			s[i],s[j] = s[j],s[i]
			i += 1
			j -= 1
			c += 1
		while(i < j and s[i] == 'R'): i+=1
		while(i < j and s[j] == 'W'): j-=1
	return min(c, cc['R'], cc['W'])

print f(s)
Problem p02623 (python)

Fixed submission:
import collections
n,m,k = map(int, raw_input().split(' '))
ais = map(int,raw_input().split(' '))
bis = map(int,raw_input().split(' '))
cumul = 0
pais = [0]
for ai in ais:
	cumul +=ai
	pais.append(cumul)

cumul = 0
pbis = [0]
for ai in bis:
	cumul +=ai
	pbis.append(cumul)
	


q = 0
for j,bi in enumerate(pbis):

	if k >= bi:
		j
		qq = k - bi
		lo,hi = 0, len(pais)-1
		while(lo < hi):
			med = (lo + hi + 1) >> 1
			if pais[med] <= qq:
				lo = med
			else:
				hi = med -1
		
		ans = j + lo
		q = max(ans, q)
print q

Buggy submission (verdict: Runtime Error):
n,m,k = map(int, raw_input().split(' '))
ais = map(int,raw_input().split(' '))
bis = map(int,raw_input().split(' '))

mem = {}
def f(i,j,k,ais,bis):
	if (i,j,k) in mem:
		return mem[(i,j,k)]
	m = 0
	if i < len(ais) and ais[i] <= k:
		m = max(m , 1+ f(i + 1,j, k - ais[i],ais,bis ))
	if j < len(bis) and bis[j] <= k:
		m = max(m , 1+ f(i,j+1, k - bis[i],ais,bis ))
	mem[(i,j,k)] = m
	return m

print f(0,0, k, ais, bis)
Problem p02624 (python)

Fixed submission:


"""
ai             aj
bi             bj


1              2
2              1

1  how many pairs 
2
"""



import collections
n = int(raw_input())
mem = [0] * (n + 1)
mem[1] = 1
primes = [True] * (n + 1)
posprimes = []
d= 2
while( d <= n):
	if primes[d] is True:
		posprimes.append(d)
		k = 2
		while(k * d <= n):
			primes[k * d] = False
			k += 1
	d+=1
def f(k):
	if primes[k] is True:
		mem[k] = 2 if k > 1 else 1
		return mem[k]
	for pos in posprimes:
		if k % pos == 0:
			count = 0
			q = k
			while(q % pos == 0):
				q /= pos
				count += 1

			mem[k] = (count + 1) * mem[q]
			return mem[k]



s = 0
k = 1
while (k<= n):
	s += k * f(k)
	k += 1
print s




#2 4 6 8 10 12 14 16 18
#    6      12       18

Buggy submission (verdict: Runtime Error):
"""
ai             aj
bi             bj


1              2
2              1

1  how many pairs 
2
"""



import collections
n = int(raw_input())
mem = {1: 1}
primes = [True] * (n + 1)
posprimes = []
for d in range(2, n +1):
	if primes[d] is True:
		posprimes.append(d)
		k = 2
		while(k * d <= n):
			primes[k * d] = False
			k += 1

def f(k):
	if primes[k] is True:
		mem[k] = 2 if k > 1 else 1
		return mem[k]
	for pos in posprimes:
		if k % pos == 0:
			count = 0
			q = k
			while(q % pos == 0):
				q /= pos
				count += 1

			mem[k] = (count + 1) * mem[q]
			return mem[k]



s = 0
while (k<= n):
	s += k * f(k)
	k += 1
print s




#2 4 6 8 10 12 14 16 18
#    6      12       18
Problem p02627 (python)

Fixed submission:
a = raw_input()
print 'a' if a.lower() == a else 'A'

Buggy submission (verdict: Runtime Error):

s = raw_input()
print 'a' if a.lower() == a else 'A'
Problem p02659 (python)

Fixed submission:

a,b = raw_input().split(' ')

a = int(a)


b0,b1 = b.split('.') if '.' in b else [int(b), 0]
b0 = int(b0)
b1 = int(b1)

print a*b0 + a*b1/100

Buggy submission (verdict: Runtime Error):
a,b = raw_input().split(' ')

a = int(a)
b = float(b)

b0,b1 = b.split('.') if '.' in b else [int(b), 0]
b0 = int(b0)
b1 = int(b1)

print a*b0 + a*b1/100

Buggy submission (verdict: Runtime Error):

a,b = raw_input().split(' ')

a = int(a)
b = float(b)

b0,b1 = b.split('.') if '.' in b else [int(b), 0]#

print a*b0 + a*b1/100
Problem p02689 (python)

Fixed submission:
import collections

n, m = map(int, raw_input().split(' '))
hs = map(int, raw_input().split(' '))
adj = collections.defaultdict(list)
for _ in range(m):
	a,b = map(int, raw_input().split(' '))
	adj[a].append(b)
	adj[b].append(a)
count = 0
for u in range(1, n + 1):
	if all([hs[v - 1] < hs[u - 1] for v in adj[u]] or [True]):
		count+=1
print count

Buggy submission (verdict: Runtime Error):

import collections # not needed if here
def f(heights,roads):

count, r =0, [True] * len(heights)
for u,v in roads:
		if heights[u-1] <= heights[v-1]: r[u-1] = False
		if heights[u-1] >= heights[v-1]:r[v-1] = False
	for b in r:
		count += 1 if b else 0
	return count

def f_(heights,roads):
	count, adj = 0,collections.defaultdict(list)
	r = [True] * len()
for u,v in roads:

		adj[u].append(v)
		adj[v].append(u)
	for i,h in enumerate(heights):
		u = i + 1
		if h >= max([heights[v - 1] for v in adj[u]] or [-1]): count +=1
	return count

n,m = map(int, raw_input().split(' '))
print f(map(int,raw_input().split(' ')), [map(int, raw_input().split(' ')) for _ in range(m)] )

Buggy submission (verdict: Runtime Error):
import collections
def f(heights,roads):
	adj = collections.defaultdict(list)
	count = 0
	for u,v in roads:
		adj[u].append(v)
		adj[v].append(u)
	for i,h in range(len(heights)):
		u = i + 1
		if h >= max([heights[v-1] for v in adj[u]] or [-1]): count +=1
	return count

n,m = map(int, raw_input().split(' '))
print f(map(int,raw_input().split(' ')), [map(int, raw_input().split(' ')) for _ in range(m)] )
Problem p02711 (python)

Fixed submission:
def f(n):
  return '7' in n
 
print 'Yes' if f(raw_input()) else 'No'

Buggy submission (verdict: Runtime Error):
def f(n):
  return '7' in n
 
print 'Yes' if f(raw_input()) else 'No'

Buggy submission (verdict: Runtime Error):
def f(n):
  return '7' in n

print f(raw_input())
Problem p02753 (python)

Fixed submission:
print "Yes" if len(set(list(raw_input()))) ==2  else "No"

Buggy submission (verdict: Runtime Error):
print "Yes" if len(set(list(raw_input())) ==2  else "No"
Problem p02912 (python)

Fixed submission:
import math
import heapq
n,m = map(int, raw_input().split(' '))

heap = [-e for  e in map(int, raw_input().split(' '))]
heapq.heapify(heap)
while(m and heap):
	u = heapq.heappop(heap)
	u *= -1
	u /=2
	if u:
		heapq.heappush(heap, -u)
	m-=1
	"""

	q = int(math.ceil(math.log(u,2)))
	if 2 ** q <= u: q +=1
	if q <= m:
		m-= q
	else:
		u /= 2
		m -=1
		if u:
			heapq.heappush(heap, -u)

	"""
print -sum(heap or [0])

Buggy submission (verdict: Runtime Error):
import math
import heapq
n,m = map(int, raw_input().split(' '))

heap = [-e for  e in map(int, raw_input().split(' '))]
heapq.heapify(heap)
while(m):
	u = heapq.heappop(heap)
	u *= -1
	u /=2
	if u:
		heapq.heappush(heap, -u)
	m-=1
	"""

	q = int(math.ceil(math.log(u,2)))
	if 2 ** q <= u: q +=1
	if q <= m:
		m-= q
	else:
		u /= 2
		m -=1
		if u:
			heapq.heappush(heap, -u)

	"""
print -sum(heap or [0])
Problem p02948 (python)

Fixed submission:
import collections
import heapq
n,m = map(int,raw_input().split(' '))

elems = [map(int, raw_input().split(' ')) for _ in range(n)]
elems.sort(key = lambda x:x[0])
heap = []

j = 0
cumul = 0
for i in range(1,m+1):

	while(j < len(elems) and elems[j][0] <= i): 
		heapq.heappush(heap,-elems[j][1])
		j+=1
	if heap:
		cumul -= heapq.heappop(heap)

print cumul

Buggy submission (verdict: Runtime Error):

import collections
n,m = map(int,raw_input().split(' '))
h = [0] * (m+1)
for _ in range(n):
	a,b =  map(int, raw_input().split(' '))
		for d in range(m, -1, -1):
			if d - a >=0: h[d] = max(h[d], h[d-a] + b)

print h[m]
Problem p02987 (python)

Fixed submission:
import collections
cc = collections.Counter(raw_input())
print 'Yes' if len(cc) == 2 and cc.values() ==[2,2] else 'No'

Buggy submission (verdict: Runtime Error):
cc = collections.Counter(raw_input())
print 'Yes' if len(cc) == 2 and cc.values() ==[2,2] else 'No'
Problem p03038 (python)

Fixed submission:
import heapq
n,m = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
ais.sort()
heap = []
for _ in range(m):
	u,v = map(int,raw_input().split(' ')) 
	heapq.heappush(heap, (-v,u))
res = 0
for j in range(n):
	
	if heap and -heap[0][0] > ais[j]:
		u,v = heapq.heappop(heap)
		v-=1
		res += -u
		if v >= 1: heapq.heappush(heap, (u,v))
	else:
		res += ais[j]
print res

Buggy submission (verdict: Runtime Error):
n,m = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
ops = [map(int,raw_input().split(' ')) for _ in range(m)]
ops.sort(key = lambda x:x[0])

res = 0
mi = -float('inf')
for j in range(n, -1, -1):
	if ops and ops[-1][0] == j:
		mi = max(mi, ops.pop()[1])
	res += max(ais[j], mi)

print res
Problem p03042 (python)

Fixed submission:
def f(s):
  m,y = int(s[:2]), int(s[2:])
  return 0< m <= 12

def g(s):
  y,m = int(s[:2]), int(s[2:])
  return 0< m <= 12
    
s = raw_input()
p,q = f(s), g(s)

if p and q:
  print 'AMBIGUOUS'
elif p and not(q):
  print 'MMYY'
elif q and not(p):
  print 'YYMM'
else:
  print 'NA'

Buggy submission (verdict: Runtime Error):
print {(0,0):'NA', (0,1): 'YYMM', (1,0): 'MMYY', (1,1):'AMBIGUOUS'}[tuple(map(int,list(tuple([(0<int(s[2*i:2*i+2]) <= 12)	for i in range(2)]))))]

Buggy submission (verdict: Runtime Error):
def f(s):return tuple([0<int(s[2*i:2*i+2]) <= 12	for i in range(0,2,2)])
		
print {(0,0):'NA', (0,1): 'YYMM', (1,0): 'MMYY', (1,1):'AMBIGUOUS'}[tuple(map(int,list(f(raw_input()))))]

Buggy submission (verdict: Runtime Error):
def f(s):
  m,y = int(s[:2]), int(s[2:])
  return (0 < m <= 12,0 < y <= 12 )

p,q = map(int,list(f(raw_input()))
print {(0,0):'NA', (0,1): 'YYMM', (1,0): 'MMYY', (1,1):'AMBIGUOUS'}[(p,q)]

Buggy submission (verdict: Runtime Error):
def f(s):
  m,y = int(s[:2]), int(s[2:])
  return 0< m <= 12:

def g(s):
  y,m = int(s[:2]), int(s[2:])
  return 0< m <= 12:
    
s = raw_input()
p,q = f(s), g(s)

if p and q:
  print 'AMBIGUOUS'
elif p and not(q):
  print 'MMYY'
elif q and not(p):
  print 'YYMM'
else:
  print 'NA'
Problem p03073 (python)

Fixed submission:
import collections

s = map(int,list(raw_input()))

count = 0
for i in range(1,len(s)):
	if s[i] == s[i - 1]:
		s[i] = 1 - s[i]
		count += 1
print count

Buggy submission (verdict: Runtime Error):
import collections

s = list(raw_input())
count = 0
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		s[i] = 1- s[i]
		count +=1
print count

Buggy submission (verdict: Runtime Error):
import collections

s = raw_input()
count = 0
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		s[i] = 1- s[i]
		count +=1
print count
Problem p03107 (python)

Fixed submission:
import collections

s = raw_input()
stack = collections.deque([])
i = 0
j = 0
while(j < len(s)):
	while(j < len(s) and s[i] == s[j]): j += 1	
	stack.append(j-i)
	i = j
n = len(s)
while(len(stack) > 1) :
	v = stack.pop()
	u = stack.pop()
	if v > u: 
		if stack:
			stack[-1] += v-u
		else:
			stack.append(v-u)
	elif v < u: stack.append( u - v)

print n - (stack[-1] if stack else 0)

Buggy submission (verdict: Runtime Error):
import collections

s = raw_input()
stack = collections.deque([])
i = 0
j = 0
while(j < len(s)):
	while(j < len(s) and s[i] == s[j]): j += 1	
	stack.append(j-i)
	i = j
n = len(s)
while(len(stack) > 1) :
	v = stack.pop()
	u = stack.pop()
	if v > u:
		stack[-1] += v-u
	elif v < u:
		stack.append( u - v)

print n - (stack[-1] if stack else 0)

Buggy submission (verdict: Runtime Error):
import collections
i,j = 0,0 
s = raw_input()
q = collections.deque([])
while(j < len(s)):
	while(s[j] == s[i]): j+=1
	q.append(j - i - 1)
	j = i

#5 6 5 1 1 4 2 1 1 1 1 1
ns = len(s)
while(len(q) > 1):
	u,v = q.popleft(), q.popleft()
	if q: q[0] += abs(u-v)
print ns - (q[0] if q else 0)

Buggy submission (verdict: Runtime Error):
import collections
i,j = 0,0 
q = collections.deque([])
while(j < len(s)):
	while(s[j] == s[i]): j+=1
	q.append(j - i - 1)
	j = i

#5 6 5 1 1 4 2 1 1 1 1 1
ns = len(s)
while(len(q) > 1):
	u,v = q.popleft(), q.popleft()
	if q: q[0] += abs(u-v)
print ns - (q[0] if q else 0)

Buggy submission (verdict: Runtime Error):
import collections
i,j = 0,0 
q = collections.deque([])
while(j < len(s)):
  while(s[j] == s[i]): j+=1
  q.append(j - i - 1)
  j = i

5 6 5 1 1 4 2 1 1 1 1 1

while(len(q) > 1):
  u,v = q.popleft(), q.popleft()
  if q: q[0] += abs(u-v)
print q[0] if q else 0
Problem p03207 (python)

Fixed submission:

n = int(raw_input())
prices = [ int(raw_input()) for _ in range(n)] #.split(' '))
prices.sort()
print sum(prices[:-1]) + prices[-1] /2

Buggy submission (verdict: Runtime Error):
3
4980
7980
6980
n = raw_input()
prices = [ int(raw_input()) for _ in range(n)] #.split(' '))
prices.sort()
print sum(prices) - prices[-1] /2
Problem p03208 (python)

Fixed submission:
import collections
n,k = map(int, raw_input().split(' '))
heights = [int(raw_input()) for _ in range(n)]
heights.sort()
q = collections.deque([])
r =  float('inf') 
for h in heights:
	q.append(h)
	if len(q) == k + 1: q.popleft()
	if k and len(q) == k:
		r =min(r, q[-1] - q[0])
print r if k else 0

Buggy submission (verdict: Runtime Error):
import collections
n,k = map(int, raw_input().split(' '))
heigths = [int(raw_input()) for _ in range(n)]
heigths.sort()
q = collections.deque([])
r =  float('inf') 
for h in heights:
	q.append(h)
	if len(q) == k+1: q.popleft()
	if k and len(q) == k:
		r =min(r, q[-1] - q[0])
print r if k else 0

Buggy submission (verdict: Runtime Error):

import collections
n,k = map(int, raw_input().split(' '))
heigths = [int(raw_input()) for _ in range(n)]
heigths.sort()
q = collections.deque([])
r =  float('inf') 
for h in heights:
	q.append(h)
	if len(q) == k+1: q.popleft()
	if len(q) == k:
r =min(r, q[-1] - q[0])
print r
Problem p03250 (python)

Fixed submission:
a,b,c = map(int, raw_input().split(' '))
print max(10*a + b+c, a+10*b + c, a+b + 10*c)

Buggy submission (verdict: Runtime Error):
s = sum(map(int, raw_input().split(' ')))
print sum(s) + 10 *max(s)
Problem p03252 (python)

Fixed submission:
s,t = raw_input(), raw_input()
def f(s,t):
	cc = {}
	cr = {}
	for u,v in zip(s,t):
		if u in cc:
			if cc[u] != v: return False
		if v in cr:
			if cr[v] != u: return False
		
		cc[u] = v
		cr[v] = u
	return True
print 'Yes' if f(s,t) else 'No'

Buggy submission (verdict: Runtime Error):
s,t = raw_input(), raw_input()
def f(s,t):
	cc = {}
	cr = {}
	for u,v in zip(s,t):
		if u in cc:
			if cc[u] != v: return False
		if v in cr:
			if cc[v] != u: return False
		
		cc[u] = v
		cr[v] = u
	return True
print 'Yes' if f(s,t) else 'No'
Problem p03775 (python)

Fixed submission:
n = int(raw_input())
m = len(str(n))
for a in range(2, int(n ** 0.5) + 1):
	if n % a == 0:
		m = min(m, max(len(str(a)), len(str(n/a))))
print m

Buggy submission (verdict: Runtime Error):
n = int(raw_input())
m = len(str(n))
for a in range(2, n ** 0.5 + 1):
	if n % a == 0:
		m = min(m, max(len(str(a)), len(str(n/a))))
print m
Problem p02759 (python)

Fixed submission:
import math
n=int(input())
print(math.ceil(n/2))

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
print(math.ceil(n/2)
Problem p02597 (python)

Fixed submission:
#https://atcoder.jp/contests/agc008/submissions/15248942
import sys
import math

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
c = input()

R = c.count('R')
W = c.count('W')
left = c[:R]

ans = min(R,W)
ans = min(ans,left.count('W'))

print(ans)

Buggy submission (verdict: Runtime Error):
 #https://atcoder.jp/contests/agc008/submissions/15248942
 import sys
 import math
 
 sys.setrecursionlimit(10 ** 8)
 ini = lambda: int(sys.stdin.readline())
 inm = lambda: map(int, sys.stdin.readline().split())
 inl = lambda: list(inm())
 ins = lambda: sys.stdin.readline().rstrip()
 debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))
 
 N = ini()
 c = input()
 
 R = c.count('R')
 left = c[:R]
 ans = left.count('W')
 
 print(ans)
Problem p02549 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 998244353
N, K = map(int, readline().split())
data = []
for _ in range(K):
    L,R = map(int, readline().split())
    data.append((L,R))
    
data = sorted(data)
A = [0]*(N+1)
A[1] = 1
S = [0]*(N+1)
S[1] = 1

for i in range(2,N+1):
    for k in range(K):
        L,R = data[k]
        A[i] += (S[max(0,i-L)]- S[max(0,i-R-1)]) % MOD
        A[i] %= MOD
    S[i] = (S[i-1] + A[i]) % MOD

print(A[N])

Buggy submission (verdict: Runtime Error):
# -*- coding: Shift-JIS -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 998244353

class BIT2:
    """ 区間加算BIT(区間加算・区間合計取得) """
    def __init__(self, N):
        self.N = (N+1)
        self.data0 = [0] * (N+1)
        self.data1 = [0] * (N+1)
        
    def _add(self, data, k, x):
        while k < self.N: #k <= Nと同義
            data[k] += x
            k += k & -k

    def _sum(self, data, k):
        s = 0
        while k:
            s += data[k]
            k -= k & -k
        return s

    def add(self, l, r, x):
        """ 区間[l,r)に値xを追加 """
        self._add(self.data0, l, -x*(l-1))
        self._add(self.data0, r, x*(r-1))
        self._add(self.data1, l, x)
        self._add(self.data1, r, -x)

    def sum(self, l, r):
        """ 区間[l,r)の和を取得 """
        return self._sum(self.data1, r-1) * (r-1) + self._sum(self.data0, r-1) - self._sum(self.data1, l-1) * (l-1) - self._sum(self.data0, l-1)
    
N, K = map(int, readline().split())
bit = BIT2(N)
d = []
for _ in range(K):
    L,R = map(int, readline().split())
    d.append((L,R))
    
d = sorted(d)
bit.add(1,2,1)

for i in range(2,N+1):
    for k in range(K):
        L,R = d[k]
        if i-L > 0:
            tmp = bit.sum(max(1,i-R),i-L+1)%MOD
            bit.add(i,i+1,tmp)
        else:
            break
print(bit.sum(N,N+1))
Problem p02771 (python)

Fixed submission:
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
A,B,C = map(int, readline().split())
if (A == B and B != C) or (B == C and C != A) or (A == C and C != B):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
A,B,C = map(int, readline().split())
if (A == B and B != C) or (B == C and C != A)  (A == C and C != B):
    print('Yes')
else:
    print('No')