Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
for i in range(q):
	l, r = map(int, input().split())
	x = s[l-1:r]
	ans = x.count("AC")
	print (ans)

Fixed submission:
n, q = map(int, input().split())
s = input()
a = [list(map(int, input().split())) for _ in range(q)]

b = [0] * n
cnt = 0
for i in range(n-1):
	if s[i:i+2] == "AC":
		b[i+1] = b[i] + 1
	else:
		b[i+1] = b[i]
for i in a:
	print (b[i[1]-1] - b[i[0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
a = [list(map(int, input().split())) for _ in range(q)]

b = []
for i in range(n-1):
	if s[i:i+2] == "AC":
		b.append((i,i+1))
for i in a:
	cnt = 0
	for j in b:
		if (i[0]-1) <= j[0] and j[1] <= (i[1]-1):
			cnt += 1
	print (cnt)


Fixed submission:
n, q = map(int, input().split())
s = input()
a = [list(map(int, input().split())) for _ in range(q)]

b = [0] * n
cnt = 0
for i in range(n-1):
	if s[i:i+2] == "AC":
		b[i+1] = b[i] + 1
	else:
		b[i+1] = b[i]
for i in a:
	print (b[i[1]-1] - b[i[0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
a = [list(map(int, input().split())) for _ in range(q)]

for i in a:
	ss = s[i[0]-1:i[1]]
	t = ss.replace("AC","")
	print (int((len(ss) - len(t))/2))

Fixed submission:
n, q = map(int, input().split())
s = input()
a = [list(map(int, input().split())) for _ in range(q)]

b = [0] * n
cnt = 0
for i in range(n-1):
	if s[i:i+2] == "AC":
		b[i+1] = b[i] + 1
	else:
		b[i+1] = b[i]
for i in a:
	print (b[i[1]-1] - b[i[0]-1])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ss = s
leng = 1
while leng != 0:
	ollen = len(s)
	s = s.replace('01','')
	s = s.replace('10','')
	nwlen = len(s)
	if ollen != nwlen:
		leng = abs(ollen - nwlen)
	else:
		leng = 0

print (len(ss)-len(s))


Fixed submission:
s = input()
cnt0 = 0
cnt1 = 0
cnt0 = s.count("0")
cnt1 = s.count("1")
print (min(cnt0,cnt1)*2)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [10**9+7] * n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
	for j in range(k):
		j += 1
		dp[i] = min(dp[i],dp[i-j]+abs(h[i] - h[i-j]))
print (dp[n-1])

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [10**9+7] * n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
	for j in range(k):
		j += 1
		dp[i] = min(dp[i],dp[i-j]+abs(h[i] - h[i-j]))
print (dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, w = map(int, input().split())
dp = [[0 for i in range(w+1)] for j in range(n+1)]
#print (dp)
we = []
v = []
for i in range(n):
	ww,vv = map(int,input().split())
	we.append(ww)
	v.append(vv)
for i in range(n):
	for j in range(w+1):
		if we[i] <= j:
			dp[i+1][j] = max(dp[i][j-we[i]] + v[i], dp[i][j])
		else:
			dp[i+1][j] = dp[i][j]
print (dp[n][w])


Fixed submission:
n, w = map(int, input().split())
dp = [[0 for i in range(w+1)] for j in range(n+1)]
#print (dp)
we = []
v = []
for i in range(n):
	ww,vv = map(int,input().split())
	we.append(ww)
	v.append(vv)
for i in range(n):
	for j in range(w+1):
		if we[i] <= j:
			dp[i+1][j] = max(dp[i][j-we[i]] + v[i], dp[i][j])
		else:
			dp[i+1][j] = dp[i][j]
print (dp[n][w])
Buggy python submission (verdict: Runtime Error):
import collections
n = int(input())
v = list(map(int, input().split()))
if len(set(v)) == 1:
	print (n//2)
	exit()
a = v[1::2]
b = v[0::2]
if len(set(a)) == 1 and len(set(b)) == 1:
	print (0)
	exit()

aa = collections.Counter(a)
bb = collections.Counter(b)

yousoa = aa.most_common()[0][0]
maa = aa.most_common()[0][1]
yousob = bb.most_common()[0][0]
mbb = bb.most_common()[0][1]
if yousoa == yousob
	if len(a) == 1:
		ans = (len(a) - maa) + (len(b) - bb.most_common()[1][1])
	elif len(b) == 1:
		ans = (len(a) - aa.most_common()[1][1]) + (len(b)-mbb)
	else:
		ans = (len(a) - maa) + (len(b) - bb.most_common()[1][1])
else:
	ans = len(a)-maa + len(b)-mbb
print (ans)

Fixed submission:
import collections
n = int(input())
v = list(map(int, input().split()))
if len(set(v)) == 1:
	print (n//2)
	exit()
a = v[1::2]
b = v[0::2]
if len(set(a)) == 1 and len(set(b)) == 1:
	print (0)
	exit()
ans = 0

aa = collections.Counter(a)
bb = collections.Counter(b)

yousoa = aa.most_common()[0][0]
maa = aa.most_common()[0][1]
yousob = bb.most_common()[0][0]
mbb = bb.most_common()[0][1]
if len(set(a)) == 1:
	ans += len(b) - mbb
	print (ans)
	exit()
if len(set(b)) == 1:
	ans += len(a) - maa
	print (ans)
	exit()
maa2 = aa.most_common()[1][1]
mbb2 = bb.most_common()[1][1]
if yousoa == yousob:
	ans = min(n//2-maa + n//2-mbb2,n//2-maa2 + n//2-mbb)
	print (ans)
else:
	print (n-maa-mbb)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n%2 == 0:
	print (n):
else:
	print (n*2)

Fixed submission:
n = int(input())
if n%2 == 0:
	print (n)
else:
	print (n*2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
c = n
s = a[0]
d = 0
for i in range(n):
	s = a[i]
	j = i
	d = 0
	while j < n-1:
		xs = s ^ a[j+1]
		s += a[j+1]
		if s == xs:
			d += 1
		else:
			break
		j += 1
	c += d
print (c)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
c = 0
s = 0
d = 0
j = 0
for i in range(n):
	d = 0
	while j < n and s & a[j] == 0:
		s += a[j]
		j += 1
	s -= a[i]
	c += j-i
print (c)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
c = n
i = 0
s = a[0]
xor = []
d = 0
for i in range(n):
	s = a[i]
	j = i
	d = 0
	while j < n-1:
		xs = s ^ a[j+1]
		s += a[j+1]
		if s == xs:
			d += 1
		else:
			break
		j += 1
	c += d
for i in xor:
	c += i*(i-1)//2
print (c)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
c = 0
s = 0
d = 0
j = 0
for i in range(n):
	d = 0
	while j < n and s & a[j] == 0:
		s += a[j]
		j += 1
	s -= a[i]
	c += j-i
print (c)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
c = [1]
for i in range(1,x):
	for j in range(2,x):
		if i**j <= x:
			c.append(i**j)
print (max(c))

Fixed submission:
x = int(input())
c = [1]
for i in range(1,x):
	for j in range(2,x):
		if i**j <= x:
			c.append(i**j)
		else:
			break
print (max(c))
Buggy python submission (verdict: Time Limit Exceeded):
#ABC097  C
s = input()
k = int(input())

c = []
for i in range(len(s)+1):
	for j in range(i+1,len(s)+1):
		if s[i:j] not in c:
			c.append(s[i:j])
c.sort()
#print (c)
print (c[k-1])

Fixed submission:
s = input()
k = int(input())

c = []
for i in range(1,6):
	for j in range(len(s)):
		if s[j:j+i] not in c:
			c.append(s[j:j+i])
c.sort()
print (c[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
	cnt = 0
	c = []
	c = copy.copy(a)
	c.pop(i)
	iti = 0
	for j in range(len(c)):
		cnt += abs(c[j] - iti)
		iti = c[j]
	cnt += abs(c[-1])
	print (cnt)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.append(0)
a.insert(0,0)
cnt = 0
for i in range(n+1):
	cnt += abs(a[i+1] - a[i])

for i in range(n):
	print (cnt + abs(a[i] - a[i+2]) - abs(a[i] -a[i+1]) - abs(a[i+1] - a[i+2]))
Buggy python submission (verdict: Time Limit Exceeded):
h, w, d = map(int, input().split())
a = []
dict = {}
for i in range(h):
	b = list(map(int, input().split()))
	for j in range(w):
		dict[b[j]] = [i,j]

dist = [0 for i in range(h*w)]
for i in range(1,h*w-d+1):
	dist[i-1] = abs(dict[i+d][1]-dict[i][1]) + abs(dict[i+d][0]-dict[i][0])
q = int(input())
for i in range(q):
	l, r = map(int, input().split())
	cnt = 0
	if l==r:
		print (cnt)
		continue
	for j in range(l,r+1,d):
		cnt += dist[j-1]
	cnt -= dist[r-1]
	print (cnt)


Fixed submission:
h, w, d = map(int, input().split())
a = []
dict = {}
for i in range(h):
	b = list(map(int, input().split()))
	for j in range(w):
		dict[b[j]] = [i,j]

dist = [0 for i in range(h*w)]
for i in range(1,h*w-d+1):
	dist[i-1] = abs(dict[i+d][1]-dict[i][1]) + abs(dict[i+d][0]-dict[i][0])

for i in range(h*w-d-1,-1,-1):
	dist[i] += dist[i+d]

q = int(input())
for i in range(q):
	l, r = map(int, input().split())
	ans = dist[l-1] - dist[r-1]
	print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
h, w, d = map(int, input().split())
a = []
dict = {}
for i in range(h):
	b = list(map(int, input().split()))
	for j in range(w):
		dict[b[j]] = [i,j]

q = int(input())
for i in range(q):
	l, r = map(int, input().split())
	cnt = 0
	v =[]
	for j in range(l,r+1,d):
		v.append(dict[j])
	for j in range(len(v)-1):
		cnt += abs(v[j+1][1]-v[j][1]) + abs(v[j+1][0]-v[j][0])
	print (cnt)


Fixed submission:
h, w, d = map(int, input().split())
a = []
dict = {}
for i in range(h):
	b = list(map(int, input().split()))
	for j in range(w):
		dict[b[j]] = [i,j]

dist = [0 for i in range(h*w)]
for i in range(1,h*w-d+1):
	dist[i-1] = abs(dict[i+d][1]-dict[i][1]) + abs(dict[i+d][0]-dict[i][0])

for i in range(h*w-d-1,-1,-1):
	dist[i] += dist[i+d]

q = int(input())
for i in range(q):
	l, r = map(int, input().split())
	ans = dist[l-1] - dist[r-1]
	print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
q = int(input())
import math
def is_prime(n):
	if n == 1:
		return False
	
	for k in range(2, int(math.sqrt(n)) + 1):
		if n%k == 0:
			return False
	return True

a = [0 for i in range(10**5+1)]
for i in range(1,10**5+1,2):
	if is_prime(i) and is_prime((i+1)//2):
		a[i] = 1

for i in range(q):
	l, r = map(int, input().split())
	print (sum(a[l:r+1]))

Fixed submission:
q = int(input())
import math
def is_prime(n):
	if n == 1:
		return False
	
	for k in range(2, int(math.sqrt(n)) + 1):
		if n%k == 0:
			return False
	return True

a = [0 for i in range(10**5+1)]
for i in range(1,10**5+1,2):
	if is_prime(i) and is_prime((i+1)//2):
		a[i] = a[i-1] + 1
		a[i+1] = a[i-1] + 1
	else:
		a[i] = a[i-1]
		a[i+1] = a[i-1]
for i in range(q):
	l, r = map(int, input().split())
	print (a[r]-a[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
q = int(input())
import math
def is_prime(n):
	if n == 1:
		return False
	
	for k in range(2, int(math.sqrt(n)) + 1):
		if n%k == 0:
			return False
	return True
#判定済み
a = []
#素数
b = []
for i in range(q):
	l, r = map(int, input().split())
	cnt = 0
	for j in range(l, r+1):
		if j%2 == 1:
			if j in a:
				if j in b:
					cnt += 1
				continue
			a.append(j)
			if is_prime(j) and is_prime((j+1)//2):
				b.append(j)
				cnt += 1
	print (cnt)

Fixed submission:
q = int(input())
import math
def is_prime(n):
	if n == 1:
		return False
	
	for k in range(2, int(math.sqrt(n)) + 1):
		if n%k == 0:
			return False
	return True

a = [0 for i in range(10**5+1)]
for i in range(1,10**5+1,2):
	if is_prime(i) and is_prime((i+1)//2):
		a[i] = a[i-1] + 1
		a[i+1] = a[i-1] + 1
	else:
		a[i] = a[i-1]
		a[i+1] = a[i-1]
for i in range(q):
	l, r = map(int, input().split())
	print (a[r]-a[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = list(set(a))
ans = 0
for i in range(len(b)):
	cnt = a.count(b[i])
	if (cnt > b[i]):
		ans += cnt - b[i]
	elif (cnt < b[i]):
		ans += cnt
print (ans)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = Counter(a)
ans = 0
for i in c.keys():
	if c[i] >= i:
		ans += c[i] - i
	else:
		ans += c[i]
print (ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

b = 0
by = 0
flg = 0
for i,j in enumerate(a):
	if abs(i) > abs(b):
		b = j
		by = i+1
		if j > 0:
			flg = 1
		else:
			flg = 0
ans = []
if flg == 1:
	x = min(a)
	if x < 0:
		for i in range(n):
			if a[i] != b:
				a[i] += b
				ans.append([by,i+1])
	for i in range(1,n):
		a[i] += a[i-1]
		ans.append([i,i+1])
else:
	x = max(a)
	if x > 0:
		for i in range(n,-1,-1):
			if a[i] != b:
				a[i] += b
				ans.append([by,i+1])
	for i in range(n-2,-1,-1):
		a[i] += a[i+1]
		ans.append([i+2,i+1])
print (len(ans))
for i in ans:
	print (*i)


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

b = 0
by = 0
flg = 0
for i,j in enumerate(a):
	if abs(j) > abs(b):
		b = j
		by = i+1
		if j > 0:
			flg = 1
		else:
			flg = 0
ans = []
if flg == 1:
	x = min(a)
	if x < 0:
		for i in range(n):
			if a[i] != b:
				a[i] += b
				ans.append([by,i+1])
	for i in range(1,n):
		a[i] += a[i-1]
		ans.append([i,i+1])
else:
	x = max(a)
	if x > 0:
		for i in range(n-1,-1,-1):
			if a[i] != b:
				a[i] += b
				ans.append([by,i+1])
	for i in range(n-2,-1,-1):
		a[i] += a[i+1]
		ans.append([i+2,i+1])
print (len(ans))
for i in ans:
	print (*i)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = collections.Counter(a)
cnt = 0
c = b.most_common()[::-1]
while len(c) > k:
	cnt += c[0][1]
	c.pop(0)
print (cnt)

Fixed submission:
import collections
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = collections.Counter(a)
cnt = 0
c = b.most_common()
s = 0
for i in range(len(c)):
	cnt += 1
	if cnt > k:
		for j in range(i,len(c)):
			s += c[j][1]
		break
print (s)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n, m, R = map(int, input().split())
r = list(map(int, input().split()))

d = [[10**7 for j in range(n)] for i in range(n)]
for i in range(m):
  a, b, c = map(int, input().split())
  a -= 1
  b -= 1
  d[a][b] = c
  d[b][a] = c

for i in range(n):
  d[i][i] = 0

for k in range(n):
  for i in range(n):
    for j in range(n):
      d[i][j] = min(d[i][k]+d[k][j],d[i][j])

# print (d)
ans = 10**8
for i in itertools.permutations(r):
  x = i
  k = 0
  for j in range(R-1):
    a,b = x[j+1],x[j]
    a -= 1
    b -= 1
    k += d[b][a]
  ans = min(ans,k)
print (ans)

Fixed submission:
import itertools
n, m, R = map(int, input().split())
r = list(map(int, input().split()))

d = [[10**10 for j in range(n)] for i in range(n)]
for i in range(m):
  a, b, c = map(int, input().split())
  a -= 1
  b -= 1
  d[a][b] = c
  d[b][a] = c

for i in range(n):
  d[i][i] = 0

for k in range(n):
  for i in range(n):
    for j in range(n):
      d[i][j] = min(d[i][k]+d[k][j],d[i][j])

# print (d)
ans = 10**10
for i in itertools.permutations(r):
  x = i
  k = 0
  for j in range(R-1):
    a,b = x[j+1],x[j]
    a -= 1
    b -= 1
    k += d[b][a]
  ans = min(ans,k)
print (ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
dict = {}
b = []
c = []
for i in a:
	if i in dict:
		dict[i] += 1
	else:
		dict[i] = 1
	if dict[i] == 2:
		b.append(i)
	if dict[i] == 4:
		c.append(i)
b.sort(reverse=True)
c.sort(reverse=True)
if len(b) < 2:
	print (0)
else:
	print (max(b[0] * b[1],c[0]**2))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
dict = {}
b = [0,0]
c = [0,0]
for i in a:
	if i in dict:
		dict[i] += 1
	else:
		dict[i] = 1
	if dict[i] == 2:
		b.append(i)
	if dict[i] == 4:
		c.append(i)
b.sort(reverse=True)
c.sort(reverse=True)
print (max(b[0] * b[1],c[0]**2))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
c = [False for i in range(199999)]
d = [False for i in range(199999)]
for i in range(m):
	a, b = map(int, input().split())
	if a == 1:
		c[b] = True
	if b == n:
		d[a] = True
for i in range(199999):
	if c[i] and d[i]:
		print ("POSSIBLE")
		exit()
print ("IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())
#2次元配列
#a=[list(map(int,input().split())) for i in range(m)]

aa = []
bb = []
for i in range (m):
	a, b = map(int, input().split())
	if(a == 1):
		aa.append(b)
	if(b == n):
		bb.append(a)

if( len(set(aa) & set(bb)) == 0):
	print ("IMPOSSIBLE")
else:
	print ("POSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ab = []
c = []
for i in range(m):
	a, b = map(int, input().split())
	if b == n:
		c.append(a)
	ab.append([a,b])
ab.sort(key=lambda x: x[0])
for i in range(m):
	if ab[i][0] == 1:
		d = ab[i][1]
		if d in c:
			print ("POSSIBLE")
			exit()
print ("IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())
#2次元配列
#a=[list(map(int,input().split())) for i in range(m)]

aa = []
bb = []
for i in range (m):
	a, b = map(int, input().split())
	if(a == 1):
		aa.append(b)
	if(b == n):
		bb.append(a)

if( len(set(aa) & set(bb)) == 0):
	print ("IMPOSSIBLE")
else:
	print ("POSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ab = []
for i in range(m):
	a, b = map(int, input().split())
	ab.append([a,b])
ab.sort()
for i in range(m):
	if ab[i][0] == 1:
		d = ab[i][1]
		for j in ab[i+1:]:
			if j[0] == d and j[1] == n:
				print ("POSSIBLE")
				exit()
print ("IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())
#2次元配列
#a=[list(map(int,input().split())) for i in range(m)]

aa = []
bb = []
for i in range (m):
	a, b = map(int, input().split())
	if(a == 1):
		aa.append(b)
	if(b == n):
		bb.append(a)

if( len(set(aa) & set(bb)) == 0):
	print ("IMPOSSIBLE")
else:
	print ("POSSIBLE")
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
lef2 = s.rindex(")")
rit2 = s.index("(")

ans = s
ans += ")"*(n-(lef2+1))
ans = "("*rit2 + ans
lef = ans.count("(")
rit = ans.count(")")
if lef > rit:
	ans += ")"*(lef-rit)
	print (ans)
elif lef == rit:
	print (ans)
else:
	ans = "("*(rit-lef) + ans
	print (ans)

Fixed submission:
n = int(input())
s = input()
ans = s

let = 0
let2 = ""
for i in range(n):
	if s[i] == "(":
		let += 1
	else:
		if let > 0:
			let -= 1
		else:
			let2 += "("
print (let2 + s + ")"*let)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
x = int(input())
xx = x//2
a = []
s = 0
for i in range(xx):
	s += i+1
	a.append(s)
	#print (s)

r = bisect.bisect_left(a, x)
print (r+1)


Fixed submission:
import bisect
x = int(input())
xx = x//2
a = []
s = 0
for i in range(x+1):
	if (i * (i+1))/2 >= x:
		print(i)
		exit()

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
x = int(input())
xx = x//2
a = []
s = 0
for i in range(x):
	s += i+1
	a.append(s)
	#print (s)

r = bisect.bisect_left(a, x)
print (r+1)


Fixed submission:
import bisect
x = int(input())
xx = x//2
a = []
s = 0
for i in range(x+1):
	if (i * (i+1))/2 >= x:
		print(i)
		exit()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
c = 0
ans = 1
for i in range(n):
	c += 1
	ans *= c
print (ans%(10**9+7))

Fixed submission:
n = int(input())

num = 1
for i in range (n):
	num = (num*(i+1)) % (10**9 + 7)
print (num % 1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

num = 1
for i in range (n):
	num *= i+1
print (num % 1000000007)

Fixed submission:
n = int(input())

num = 1
for i in range (n):
	num = (num*(i+1)) % (10**9 + 7)
print (num % 1000000007)
Buggy python submission (verdict: Runtime Error):
import copy
n = int(input())
t = list(map(int, input().split()))
m = int(input())
c = []
for i in range(m):
	p, x = map(int, input().split())
	c = []
	c = copy.copy(t)
	c[p-1] = x
	print (sum(c))

Fixed submission:
a, op, b = map(str, input().split())
if op == "+":
	print (int(a) + int(b))
else:
	print (int(a) - int(b))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ss = "".join(list(reversed(s)))
a = ["maerd","esare","resare","remaerd"]
flg = 0
while flg == 0:
	if ss[:5] ==a[0] or ss[:5] == a[1]:
		ss = ss[5:]
	elif ss[:6] == a[2]:
		ss = ss[6:]
	elif ss[:7] == a[3]:
		ss = ss[:7]
	else:
		flg = 1
	if len(ss) == 0:
		print ("YES")
		exit()
print ("NO")

Fixed submission:
s = input()
a = ["eraser", "erase", "dreamer", "dream"]

for i in a:
	s = s.replace(i, "")
if s == "":
	print ("YES")
else:
	print ("NO")
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a + b > 24:
	print (a+b - 24)
else:
	print (a+b)

Fixed submission:
a = list(map(str, input().split()))
print ("A" + a[1][0] + "C")
Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
a = [input() for _ in range(n)]
a.sort()
print ("".join(a))

Fixed submission:
a = list(map(int, input().split()))
a.sort()
if a[0] == 5 and a[1] == 5 and a[2] == 7:
	print ("YES")
else:
	print ("NO")
Buggy python submission (verdict: Runtime Error):
X,N = map(int, input().split())
p = list(map(int, input().split()))
dif = 1

if(X not in p):
    print(X)
else:
    while True:
        if(X-dif not in p):
            dif = dif*(-1)
            break
        elif(X+dif not in p):
            break
        else:
            dif=dif+1
      print(X+dif)

Fixed submission:
X,N = map(int, input().split())
p = list(map(int, input().split()))
dif = 1

if(X not in p):
    print(X)
else:
    while True:
        if(X-dif not in p):
            dif = dif*(-1)
            break
        elif(X+dif not in p):
            break
        else:
            dif=dif+1
    print(X+dif)
Buggy python submission (verdict: Runtime Error):
S = list(input())
T = list(input())


for i in range(0, len(S)-1):
    if (S[i] != T[i]):
        print('No')
    else :
		if(len(S)+1 == len(T)):
    		print('Yes')
		elif(len(S)>=len(T)):
    		print('No')
		elif(len(S)+1 < len(T)):
    		print('No')

Fixed submission:
S = list(input())
T = list(input())
ans = 0

for i in range(0, len(S)):
    if (S[i] != T[i]):
        ans = 0
        break    
    else :
      if(len(S)+1 == len(T)):
        ans = 1
      elif(len(S)>=len(T)):
        ans = 2
      elif(len(S)+1 < len(T)):
        ans = 3

if(ans == 1):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())

n = int(A/D)
m = int(C/B)

if n<=m:
    print('No')
elif n>m:
    print('Yes')

Fixed submission:
S, W = map(int, input().split())

if S>W:
    print('safe')
else:
    print('unsafe')

Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())

n = int(A/D)
m = int(C/B)

if n>m:
    x = n
else :
    x = m
    
for i in range(1, x+1):
    a = C - B
    t = A - D
    if a <= 0:
        print('Yes')
        break
    elif t <= 0:
        print('No')
        break

Fixed submission:
S, W = map(int, input().split())

if S>W:
    print('safe')
else:
    print('unsafe')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

for i in range(0, N):
    print(A.count(i+1))

Fixed submission:
import math
math.pi

N = int(input())

print(2*N*math.pi)

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

for i in range(0, N):
    print(A.count(i+1))

Fixed submission:
import math
math.pi

N = int(input())

print(2*N*math.pi)
Buggy python submission (verdict: Runtime Error):
a = list(map(int,input().split()))
N = a[0]
blue = a[1]
red = a[2]
ans = 0
A = blue + red
X = N // A
Y = N % A
if Y <= blue:
    ans = blue * X + Y
else:
    ans = blue * X + blue
print(ans)

Fixed submission:
S = list(input())
ans = 0

for i in range(0,2):
    if(S[i] != S[i+1]):
        ans = 1
        break
    else :
        ans = 0

if(ans == 1):
    print('Yes')
elif(ans == 0):
    print('No')

Buggy python submission (verdict: Runtime Error):
N,A,B = map(int, input().split())
ans = 0
S = A+B
T = N//S
U = N%S


if(A == 0):
    ans = 0
else :
    if(0< U < A):
        ans = A*T+U
    elif(U == 0):
        ans = A*T
    elif(U >= A):
        ans = A*T+A
    
print(ans)


Fixed submission:
S = list(input())
ans = 0

for i in range(0,2):
    if(S[i] != S[i+1]):
        ans = 1
        break
    else :
        ans = 0

if(ans == 1):
    print('Yes')
elif(ans == 0):
    print('No')
Buggy python submission (verdict: Runtime Error):
S = list(input())
ans = []

for i in range(len(S)):
    if(S[i] != 'B'):
        ans.append(S[i])
    elif(S[i] == 'B' and len(ans) != 0):
        ans.remove(ans[i-1])

        
print(''.join(ans))

Fixed submission:
S = list(input())
ans = []

for i in range(len(S)):
    if(S[i] != 'B'):
        ans.append(S[i])
    elif(S[i] == 'B' and len(ans) != 0):
        ans.pop()

        
print(''.join(ans))