Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
N = int(input())
A = [int(a) for a in input().split()]
Q = int(input())
process = []
proc_append = process.append
for i in range(Q):
	proc_append(tuple(input().split()))
	process[i] = tuple(map(int,process[i]))

A.sort()

for b,c in process:
	if b in set(A):
		for i in range(N):
			if b==A[i]:
				begin = i
				break
		for i in range(begin,N):
			if b!=A[i]:
				end = i-1
				break
			if i==N-1:
				end = i
		for i in range(begin,end+1):
			A[i] = c
	print(sum(A))

Fixed submission:
c = input()
oc = ord(c)

if 65<=oc<=90:
  print('A')
else:
  print('a')

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def conv(a): #convert the num to character
  a += 97
  return chr(a)

# 整数の入力
n = int(input())
name = ''

while n>0:
  n -= 1
  name += conv(n%26)
  n //= 26

# 出力
print(name[::-1])

Fixed submission:
c = input()
oc = ord(c)

if 65<=oc<=90:
  print('A')
else:
  print('a')

Buggy python submission (verdict: Runtime Error):
c = input()
ord_c = ord(c)
if ord_c >= 65 and ord_c <= 90:　#大文字
  print('A')
else:
  print('a')

Fixed submission:
c = input()
oc = ord(c)

if 65<=oc<=90:
  print('A')
else:
  print('a')
Buggy python submission (verdict: Runtime Error):
X,Y = input().split()
v = Y-(2*X)
if v<0 or v%2==1:
  print('No')
else:
  print('Yes')

Fixed submission:
X,Y = map(int,input().split())
v = Y-(2*X)
if v<0 or v%2==1:
  print('No')
elif 4*X < Y:
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
X,N = map(int,input().split())

if N==0:
  print(X)
else:
  P = list(map(int,input().split()))
  hash_p = [0]*101
  for i in P:
    hash_p[i] += 1
  for i in range(N):
    if hash_p[X-i]==0:
      print(X-i)
      break
    if hash_p[X+i]==0:
      print(X+i)
      break

Fixed submission:
X,N = map(int,input().split())

if N==0:
  print(X)
else:
  P = list(map(int,input().split()))
  hash_p = [0]*102
  for i in P:
    hash_p[i] += 1
  for i in range(N+1):
    if hash_p[X-i]==0:
      print(X-i)
      break
    if hash_p[X+i]==0:
      print(X+i)
      break
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

if 0 in A:
  print(0)
else:
  prod = 1
  for i in A:
    prod *= i
    if prod>10**18:
      print(-1)
      break
  print(prod)

Fixed submission:
a,b = input().split()
a = int(a)
b = int(b[:-3]+b[-2:])
print(int(a*b//100))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [0]
A.extend(list(map(int,input().split())))
pair = 0

for i in range(1,n+1):
  for j in range(i+1,n+1):
    num = abs(i-j)
    if A[i]+A[j] == num:
      pair += 1
      
print(pair)

Fixed submission:
n = int(input())
A = [0]
A.extend(list(map(int,input().split())))
B = {}
pair = 0

for i in range(1,n+1):
  if i+A[i] in B:
    B[i+A[i]] += 1
  else:
    B[i+A[i]] = 1
  
for j in range(2,n+1):
  if j-A[j] in B:
    pair += B[j-A[j]]

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

ans = 0
for i in range(1<<q):
  score = 0
  A = [0]*(n+1)
  for j in range(q):
    if (i>>j)&1 == 1:
      A[abcd[j][1]] = A[abcd[j][0]] + abcd[j][2]
      if A[abcd[j][1]] > m:
        break
  for j in range(q):
    if A[abcd[j][1]] - A[abcd[j][0]] == abcd[j][2]:
      score += abcd[j][3]
  if score > ans:
    ans = score
print(ans)

Fixed submission:
n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]
a,b,c,d = [],[],[],[]
for i in range(q):
  a.append(abcd[i][0])
  b.append(abcd[i][1])
  c.append(abcd[i][2])
  d.append(abcd[i][3])

def score(A):
  tmp = 0
  for ai, bi, ci, di in zip(a, b, c, d):
      if A[bi] - A[ai] == ci:
          tmp += di
  return tmp

def dfs(A):
  if len(A)==n+1:
    return score(A)
  ans = 0
  for i in range(A[-1],m):
    A.append(i)
    ans = max(ans,dfs(A))
    A.pop()
  return ans

print(dfs([0]))

Buggy python submission (verdict: Time Limit Exceeded):
n,m,q = map(int, input().split())
a,b,c,d = [],[],[],[]
for i in range(q):
  ai,bi,ci,di = map(int, input().split())
  a.append(ai)
  b.append(bi)
  c.append(ci)
  d.append(di)

ans = 0
for i in range(1<<q):
  score = 0
  A = [0]*(n+1)
  for j in range(q):
    if (i>>j)&1 == 1:
      A[b[j]] = A[a[j]] + c[j]
  for j in range(q):
    if A[b[j]] - A[a[j]] == c[j]:
      score += d[j]
  if score > ans:
    ans = score
print(ans)

Fixed submission:
n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]
a,b,c,d = [],[],[],[]
for i in range(q):
  a.append(abcd[i][0])
  b.append(abcd[i][1])
  c.append(abcd[i][2])
  d.append(abcd[i][3])

def score(A):
  tmp = 0
  for ai, bi, ci, di in zip(a, b, c, d):
      if A[bi] - A[ai] == ci:
          tmp += di
  return tmp

def dfs(A):
  if len(A)==n+1:
    return score(A)
  ans = 0
  for i in range(A[-1],m):
    A.append(i)
    ans = max(ans,dfs(A))
    A.pop()
  return ans

print(dfs([0]))
Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int, input().split())
ans = 0

yuka = lambda a,b: (a-(a%b))//b

for x in range(b):
  if x>n:
    break
  score = yuka(a*(x%b),b)
  ans = max(ans,score)

print(ans)

Fixed submission:
a,b,n = map(int, input().split())
yuka = lambda a,b: (a-(a%b))//b

x = min(n,b-1)
score = yuka(a*(x%b),b)
ans = score

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int, input().split())
ans = 0
N = [x for x in range(1,n+1) if (a*x)%b < a*(x%b)]

yuka = lambda a,b: (a-(a%b))/b

for x in N:
  score = yuka(a*x,b) - a*yuka(x,b)
  ans = max(ans,score)

print(int(ans))

Fixed submission:
a,b,n = map(int, input().split())
yuka = lambda a,b: (a-(a%b))//b

x = min(n,b-1)
score = yuka(a*(x%b),b)
ans = score

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math

a,b,n = map(int, input().split())
ans = 0
N = [x for x in range(1,n+1) if a*(x/b - int(x/b))>1]

for x in N:
  k = x/b
  f = math.floor(a*k) - math.floor(k)*a
  if ans<f:
    ans = f

print(ans)

Fixed submission:
a,b,n = map(int, input().split())
yuka = lambda a,b: (a-(a%b))//b

x = min(n,b-1)
score = yuka(a*(x%b),b)
ans = score

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math

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

x = 1
k = 1/b
f = math.floor(a*k) - math.floor(k)*a
ans = 0
while x<=n:
  if ans<f:
    ans = f
  x += 1
  k = x/b
  f = math.floor(a*k) - math.floor(k)*a
  
print(ans)

Fixed submission:
a,b,n = map(int, input().split())
yuka = lambda a,b: (a-(a%b))//b

x = min(n,b-1)
score = yuka(a*(x%b),b)
ans = score

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
goods = []

for _ in range(n):
  s = input()
  if s not in goods:
    goods.append(s)
    
print(len(goods))

Fixed submission:
n = int(input())
goods = set(input() for _ in range(n))
print(len(goods))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
mul = set(str(2019*i) for i in range(1,100))
ans = 0

for i in range(len(s)-3):
  p = 4
  while i+p<=len(s):
    if s[i:i+p] in mul:
      ans += 1
    p += 1

print(ans)

Fixed submission:
S = input()[::-1]
ans = 0
mods = [0] * 2019
mods[0] = 1
current = 0
x = 1
for s in S:
  current = (current + x * int(s)) % 2019
  ans += mods[current % 2019]
  mods[current % 2019] += 1
  x = x * 10 % 2019
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0

for i in range(len(s)):
  p = 4
  while i+p<=len(s):
    if int(s[i:i+p])%2019==0:
      ans += 1
    p += 1
print(ans)

Fixed submission:
S = input()[::-1]
ans = 0
mods = [0] * 2019
mods[0] = 1
current = 0
x = 1
for s in S:
  current = (current + x * int(s)) % 2019
  ans += mods[current % 2019]
  mods[current % 2019] += 1
  x = x * 10 % 2019
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(n for n in range(N+1))
ans = 0
for i in range(K,N+2):
  L = sum(A[:i])
  R = sum(A[N-i+1:N+1])
  ans += (R-L+1)
print(ans%((10**9)+7))

Fixed submission:
N, K = map(int, input().split())
A = list(n for n in range(N+1))
ans = 0
for i in range(K,N+2):
  L = i*(i-1)//2
  R = i*(2*N+1-i)//2
  ans += (R-L+1)
print(ans%((10**9)+7))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(n for n in range(N+1))
comb = set()
for i in range(1<<N+1):
  goukei = 0
  cnt = 0
  for j in range(N+1):
    if (i>>j)&1 == 1:
      goukei += A[j]
      cnt += 1
  comb.add((cnt,goukei))
ans = 0
for c in comb:
  if c[0]>=K:
    ans += 1
print(ans%((10**9)+7))

Fixed submission:
N, K = map(int, input().split())
A = list(n for n in range(N+1))
ans = 0
for i in range(K,N+2):
  L = i*(i-1)//2
  R = i*(2*N+1-i)//2
  ans += (R-L+1)
print(ans%((10**9)+7))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

r = S.count('R')
g = S.count('G')
b = S.count('B')
ans = r*g*b

for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if k>2*j-i:
        break
      if S[i]!=S[j]!=S[k]!=S[i]:
        if j-i==k-j:
          ans -= 1

print(ans)

Fixed submission:
N = int(input())
S = input()

r = S.count('R')
g = S.count('G')
b = S.count('B')
ans = r*g*b

for i in range(N):
  for j in range(i+1,N):
    k=2*j-i
    if k<N and S[i]!=S[j]!=S[k]!=S[i]:
      ans -= 1

print(ans)

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

r = S.count('R')
g = S.count('G')
b = S.count('B')
ans = r*g*b

for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if S[i]!=S[j]!=S[k]!=S[i]:
        if j-i==k-j:
          ans -= 1

print(ans)

Fixed submission:
N = int(input())
S = input()

r = S.count('R')
g = S.count('G')
b = S.count('B')
ans = r*g*b

for i in range(N):
  for j in range(i+1,N):
    k=2*j-i
    if k<N and S[i]!=S[j]!=S[k]!=S[i]:
      ans -= 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
ans = 0

for i in range(N):
  if S[i]=='R':
    for j in range(i+1,N):
      if S[j]=='G':
        ans += S[j+1:].count('B')
        if 2*j-i<=N-1 and S[2*j-i]=='B':
          ans -= 1
      if S[j]=='B':
        ans += S[j+1:].count('G')
        if 2*j-i<=N-1 and S[2*j-i]=='G':
          ans -= 1
  if S[i]=='G':
    for j in range(i+1,N):
      if S[j]=='R':
        ans += S[j+1:].count('B')
        if 2*j-i<=N-1 and S[2*j-i]=='B':
          ans -= 1
      if S[j]=='B':
        ans += S[j+1:].count('R')
        if 2*j-i<=N-1 and S[2*j-i]=='R':
          ans -= 1
  if S[i]=='B':
    for j in range(i+1,N):
      if S[j]=='G':
        ans += S[j+1:].count('R')
        if 2*j-i<=N-1 and S[2*j-i]=='R':
          ans -= 1
      if S[j]=='R':
        ans += S[j+1:].count('G')
        if 2*j-i<=N-1 and S[2*j-i]=='G':
          ans -= 1
print(ans)

Fixed submission:
N = int(input())
S = input()

r = S.count('R')
g = S.count('G')
b = S.count('B')
ans = r*g*b

for i in range(N):
  for j in range(i+1,N):
    k=2*j-i
    if k<N and S[i]!=S[j]!=S[k]!=S[i]:
      ans -= 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
mi = n
loop = True

if n%k==0:
  mi = 0
  loop = False

while loop:
  loop = False
  if mi > abs(n-k):
    loop = True
    n = abs(n-k)
    mi = n

print(mi)

Fixed submission:
n,k = map(int, input().split())
mi = n%k
if mi > abs(mi-k):
  print(abs(mi-k))
else:
  print(mi)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))        
D,d = [0]*(n+1),[0]*(n+1)
C = lambda x: x*(x-1)//2
s = 0
for i in set(A):
  D[i] = A.count(i)
  s += C(D[i])
for i in set(A):
  d[i] = s-D[i]+1
for i in A:
  print(d[i])

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))        
C = lambda x: x*(x-1)//2
s = 0
D = Counter(A)
for i,j in D.items():
  s += C(j)
for i in A:
  print(s-D[i]+1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))        
D,d = {},{}
C = lambda x: x*(x-1)//2

for i in set(A):
  D[i] = A.count(i)
  
for i in set(A):
  res = 0
  for j,k in D.items():
    if i==j:
      res += C(k-1)
      continue
    res += C(k)  
  d[i] = res

for i in A:
  print(d[i])

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))        
C = lambda x: x*(x-1)//2
s = 0
D = Counter(A)
for i,j in D.items():
  s += C(j)
for i in A:
  print(s-D[i]+1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))        
D = {}
C = lambda x: x*(x-1)//2

for i in set(A):
  D[i] = A.count(i)
  
for i in A:
  res = 0
  for j,k in D.items():
    if i==j:
      res += C(k-1)
      continue
    res += C(k)
  print(res)

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))        
C = lambda x: x*(x-1)//2
s = 0
D = Counter(A)
for i,j in D.items():
  s += C(j)
for i in A:
  print(s-D[i]+1)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
r = False
for _ in range(q):
  d = list(input().split())
  if len(d)==1:
    r = ~r
  else:
    if (d[1]=='1' and ~r) or (d[1]=='2' and r):
      s = d[2] + s
    else:
      s += d[2]
if r:
  s = s[::-1]
print(s)

Fixed submission:
from collections import deque
s = input()
q = int(input())
r = False
S = deque(s)
for _ in range(q):
  d = list(input().split())
  if len(d)==1:
    r = ~r
  else:
    if (d[1]=='1' and ~r) or (d[1]=='2' and r):
      S.appendleft(d[2])
    else:
      S.append(d[2])
s = ''.join(S)
if r:
  s = s[::-1]
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
for _ in range(q):
  d = list(input().split())
  if len(d)==1:
    s = s[::-1]
  else:
    if d[1]=='1':
      s = d[2] + s
    else:
      s += d[2]
print(s)

Fixed submission:
from collections import deque
s = input()
q = int(input())
r = False
S = deque(s)
for _ in range(q):
  d = list(input().split())
  if len(d)==1:
    r = ~r
  else:
    if (d[1]=='1' and ~r) or (d[1]=='2' and r):
      S.appendleft(d[2])
    else:
      S.append(d[2])
s = ''.join(S)
if r:
  s = s[::-1]
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
d = list(input() for _ in range(n))
D = Counter(d)
m = D.most_common()[0][1]
for i in range(len(D)):
  k = D.most_common()[i][1]
  if m != k:
    break
  p = i
D = D.most_common()[:p+1]
D = sorted(D)
for i in D:
  print(i[0])

Fixed submission:
from collections import Counter
n = int(input())
d = list(input() for _ in range(n))
D = Counter(d)
m = max(D.values())
l = []
for i,j in D.most_common():
  if m != j:
    break
  l.append(i)
l.sort()
for i in l:
  print(i)
Buggy python submission (verdict: Time Limit Exceeded):
h,n = map(int, input().split())
ab = []
amax = 10**5
for _ in range(n):
  ab.append(tuple(map(int,input().split())))
  amax = max(amax,ab[-1][1])
p = [10**10]*(h+amax+1)
q = [(i,j) for i,j in ab]
while q:
  a,b = q.pop()
  if b<p[a]: p[a]=b
  else: b=p[a]
  if a>=h: continue
  for i,j in ab:
    if b+j<p[a+i]:
      p[a+i]=b+j
      q.append((a+i,b+j))
print(min(p[h:]))

Fixed submission:
h,n = map(int, input().split())
ab = []
amax = 10**5
for _ in range(n):
  ab.append(tuple(map(int,input().split())))
amax = max(a for a,b in ab)
p = [0]*(h+amax+1)
for i in range(1,h+amax):
  p[i] = min(p[i-a]+b for a,b in ab)
print(p[h])

Buggy python submission (verdict: Time Limit Exceeded):
h,n = map(int, input().split())
ab = []
amax = 10**5
for _ in range(n):
  ab.append(tuple(map(int,input().split())))
  amax = max(amax,ab[-1][1])
p = [10**10]*(h+amax+1)
q = [(i,j) for i,j in ab]
while q:
  a,b = q.pop()
  if b<p[a]: p[a]=b
  else: b=p[a]
  if a>=h: continue
  for i,j in ab:
    if b+j<p[a+i]:
      p[a+i]=b+j
      q.append((a+i,b+j))
print(min(p[h:]))

Fixed submission:
h,n = map(int, input().split())
ab = []
amax = 10**5
for _ in range(n):
  ab.append(tuple(map(int,input().split())))
amax = max(a for a,b in ab)
p = [0]*(h+amax+1)
for i in range(1,h+amax):
  p[i] = min(p[i-a]+b for a,b in ab)
print(p[h])

Buggy python submission (verdict: Runtime Error):
from collections import deque
h,n = map(int, input().split())
p = [10**10]*(2*h)
ab = []
for _ in range(n):
  ab.append(tuple(map(int,input().split())))
q = deque()
for i in ab:
  q.append(i)
while q:
  a,b = q.popleft()
  if b<p[a]: p[a]=b
  else: b=p[a]
  if a>=h: continue
  for i,j in ab:
    if b+j<p[a+i]:
      p[a+i]=b+j
      q.append((a+i,b+j))
print(min(p[h:-1]))

Fixed submission:
h,n = map(int, input().split())
ab = []
amax = 10**5
for _ in range(n):
  ab.append(tuple(map(int,input().split())))
amax = max(a for a,b in ab)
p = [0]*(h+amax+1)
for i in range(1,h+amax):
  p[i] = min(p[i-a]+b for a,b in ab)
print(p[h])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7

res = 0
for i in range(len(a)):
    for j in range(i+1, len(a)):
        res = (res+((a[i]*a[j])%mod))%mod

print(res)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7

res = 0
s = 0
for i in range(1, len(a)):
    s = (s+a[i-1])%mod
    res = (res+(s*a[i])%mod)%mod

print(res)
Buggy python submission (verdict: Runtime Error):
a, b, c, k = map(int, input().split())
a, b, c, k = map(int, input().split())
j = k-(a+b)
j = 0 if j < 0 else j
print(a-j if k > a else k)

Fixed submission:
a, b, c, k = map(int, input().split())
j = k-(a+b)
j = 0 if j < 0 else j
print(a-j if k > a else k)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
A = list(map(int, input().split()))
 
next_city = 1
visited = []
x = [-1]*n
while x[next_city-1] == -1:
    visited.append(next_city)
    next_city = A[next_city-1]
idx = visited.index(next_city)
visited2 = visited[idx:]
mod = len(visited2)
x = (k%mod-idx)%mod
print(visited2[x])

Fixed submission:
n, k = map(int, input().split())
A = list(map(int, input().split()))
visited = [0]*n
n_city = 1
while visited[n_city-1] == 0:
    visited[n_city-1] = 1
    n_city = A[n_city-1]
cnt = 1
root = n_city
n_city = A[n_city-1]
while n_city != root:
    n_city = A[n_city-1]
    cnt += 1
to_root = 0
n_city = 1
while n_city != root:
    n_city = A[n_city-1]
    to_root += 1
loop_num = k if k < to_root else (k-to_root)%cnt + to_root
cnt = 0
n_city = 1
while cnt < loop_num:
    n_city = A[n_city-1]
    cnt += 1
print(n_city)
Buggy python submission (verdict: Runtime Error):
1 2 3

Fixed submission:
a = list(map(int, input().split()))
print(str(a[2])+' '+str(a[0])+' '+str(a[1]))
Buggy python submission (verdict: Time Limit Exceeded):
nkc = list(map(int, input().split()))
s = input()
num = [0 for i in range(nkc[0])]
ok = [i for i in range(nkc[0]) if s[i]=='o']

def next_day(f_day, ol, c):
    nk = []
    for x in ol:
        if x-f_day >= c+1:
            nk.append(x)
    return nk

avail_dict = dict()
for i in range(len(ok)):
    avail_dict[ok[i]] = next_day(ok[i], ok[i:], nkc[2])

def workday_search(nk_list, avail_dict, depth, k):
    if len(nk_list) == 0:
        return False
    elif depth+1 == k:
        return nk_list
    else:
        days = []
        for x in nk_list:
            tmp = workday_search(avail_dict.get(x), avail_dict, depth+1, k)
            if tmp:
                for data in tmp:
                    if type(data) == int:
                        days.append([x, data])
                    else:
                        y = [x]
                        y.extend(data)
                        days.append(y)
        return days

last_day = ok[-1:][0]
workdays = workday_search([x for x in ok if (last_day-x+1) >= (nkc[1]+nkc[2]*(nkc[1]-1))], avail_dict, 0, nkc[1])

for res in workdays:
    if type(res) == int:
        num[res] += 1
    else:
        for i in res:
            num[i] += 1

for i in range(nkc[0]):
    if num[i] == len(workdays):
        print(i+1)

Fixed submission:
nkc = list(map(int, input().split()))
s = input()
ok = [i for i in range(nkc[0]) if s[i]=='o']

L = []
today = -1000000
for x in ok:
    if x-today >= nkc[2]+1:
        today = x
        L.append(x)
    if len(L) == nkc[1]:
        break

R = []
today = 1000000
ok.reverse()
for x in ok:
    if today-x >= nkc[2]+1:
        today = x
        R.append(x)
    if len(R) == nkc[1]:
        break

R.reverse()
for i in range(nkc[1]):
    if L[i] == R[i]:
        print(L[i]+1)
Buggy python submission (verdict: Time Limit Exceeded):
tmp = list(map(int, input().split()))
x, y, a, b, c = tmp
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

def choice(li, n):
    d = []
    for i in range(n):
        m = max(li)
        d.append(m)
        li[li.index(m)] = -1
    return d

deli = []
red = choice(p, x)
green = choice(q, y)
deli.extend(red)
deli.extend(green)
while True:
    m = max(r)
    if m <= 0:
        break
    min_deli = min(deli)
    if m > min_deli:
        deli[deli.index(min_deli)] = m
        r[r.index(m)] = -1
    else:
        break

print(sum(deli))

Fixed submission:
tmp = list(map(int, input().split()))
x, y, a, b, c = tmp
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort()
q.sort()
p = p[a-x:]
q = q[b-y:]

p.extend(q)
p.extend(r)
p.sort()
print(sum(p[len(p)-x-y:]))
Buggy python submission (verdict: Runtime Error):
import math
import collections

n = int(input())
a = list(map(int, input().split()))
num_list = []
ans_total = 0

c = collections.Counter(a)

for d in c:
    ans_total += int(math.factorial(c[d])/(2*math.factorial(c[d]-2)))

for i in range(n):
    print(ans_total-c[a[i]]+1)

Fixed submission:
import math
import collections

n = int(input())
a = list(map(int, input().split()))
num_list = []
ans_total = 0

c = collections.Counter(a)

for d in c:
    if not c[d] == 1:
        ans_total += int(math.factorial(c[d])/(2*math.factorial(c[d]-2)))

for i in range(n):
    print(ans_total-c[a[i]]+1)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

for i in range(q):
    query = input()
    if query == '1':
        s = s[::-1]
    else:
        _, f, c = query.split()
        if f == '1':
            s = c+s
        else:
            s = s+c

print(s)

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

add_s = ['', ''] #pre, post
rev_flag = 0

for i in range(q):
    query = input()
    if query == '1':
        rev_flag = (rev_flag+1)%2
    else:
        _, f, c = query.split()
        if f == '1':
            add_s[rev_flag] += c
        else:
            add_s[(rev_flag+1)%2] += c

if rev_flag == 1:
    s = s[::-1]

print(add_s[rev_flag][::-1]+s+add_s[(rev_flag+1)%2])
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = "No"
for i in range(9):
    if n%(9-i)==0:
        if n/(9-i)<10:
            s="Yes"
print(s)

Fixed submission:
n = int(input())
ans = "No"
for i in range(9):
    if n%(9-i)==0:
        if n/(9-i)<10:
            ans="Yes"
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ans=n+1
i=1
while i*i<=n:
    if n%i==0 and ans > n%i+n/i:
        ans = n%i + n/i
print(ans-2)

Fixed submission:
import math
n=int(input())
ans=n+1
i=1
while i<=math.sqrt(n):
    if n%i==0 and ans > i +n/i:
        ans = i + n/i
    i+=1
ans = int(ans)
print(ans-2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if (int)n/100==n%10:
    print("Yes")
else:
    print("No")

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