Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
H,W,M=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(M)]
Tr=[0 for _ in range(H+1)]
Tc=[0 for _ in range(W+1)]
for i in range(M):
    Tr[s[i][0]]+=1
    Tc[s[i][1]]+=1
mr=max(Tr)
mc=max(Tc)
Mr=[i for i,x in enumerate(Tr) if x==mr]
Mc=[i for i,x in enumerate(Tc) if x==mc]

ans=0
for i in range(len(Mr)):
    for j in range(len(Mc)):
        if not ([Mr[i],Mc[j]] in s):
            ans=mr+mc
            break
    else:
        continue
    break
if ans==0:
    ans=mr+mc-1
print(ans)

Fixed submission:
H,W,M=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(M)]
Tr=[0 for _ in range(H+1)]
Tc=[0 for _ in range(W+1)]
for i in range(M):
    Tr[s[i][0]]+=1
    Tc[s[i][1]]+=1
mr=max(Tr)
mc=max(Tc)
Mr=[0 for _ in range(H+1)]
Mc=[0 for _ in range(W+1)]
Nmr=0
Nmc=0
for i in range(len(Tr)):
    if Tr[i]==mr:
        Mr[i]=1
        Nmr+=1
for i in range(len(Tc)):
    if Tc[i]==mc:
        Mc[i]=1
        Nmc+=1
cnt=0
for i in range(M):
    if Mr[s[i][0]]==1 and Mc[s[i][1]]==1:
        cnt+=1
if cnt<Nmr*Nmc:
    print(mr+mc)
else:
    print(mr+mc-1)
Buggy python submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
cnt=0

for i in range(int(len(a)/2)+1):
    if a[2*i]%2==1:
        cnt+=1

print(cnt)


Fixed submission:
N=int(input())
a=list(map(int,input().split()))
cnt=0

for i in range(0,len(a),2):
    if a[i]%2==1:
        cnt+=1

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)

cnt=0
ans=[]
ans.append(A[0])
ans.append(A[1])
cnt+=ans[0]
for i in range(2,N):
    k=ans.index(A[int((i-1)/2)])
    if k==len(ans)-1:
        kb=k-1
        kn=0
    else:
        kb=k-1
        kn=k+1

    if ans[kb]>=ans[kn]:
        cnt+=min(ans[k],ans[kb])
        ans.insert(kb,A[i])
    elif ans[kb]<ans[kn]:
        cnt+=min(ans[k],ans[kn])
        ans.insert(kn,A[i])

print(cnt)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
A.sort()
A.insert(0,0)

ans=0
for i in range(1,N):
    ans+=A[N-int(i/2)]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
div=7+10**9
ans=1
t=0
i,j=0,N-1

if A[-1]<0 and K%2==1:
    for i1 in range(N-K,N):
        ans*=A[i1]
else:
    while t<K-1:
        if A[i]*A[i+1]>A[j]*A[j-1]:
            ans*=A[i]*A[i+1]
            i+=2
            t+=2
        else:
            ans*=A[j]
            j+=-1
            t+=1
    if t==K-1:
        ans*=A[j]

print(ans%div)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
div=7+10**9
ans=1
t=0
i,j=0,N-1

if A[-1]<0 and K%2==1:
    for i1 in range(N-K,N):
        ans*=A[i1]
        ans%=div
else:
    while t<K-1:
        if A[i]*A[i+1]>A[j]*A[j-1]:
            ans*=A[i]*A[i+1]
            ans%=div
            i+=2
            t+=2
        else:
            ans*=A[j]
            ans%=div
            j+=-1
            t+=1
    if t==K-1:
        ans*=A[j]
        ans%=div

print(ans)

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

B=[]
onlyminus=True
for i in range(N):
    if A[i]>=0:
        B.append([A[i],1])
        onlyminus=False
    else:
        B.append([abs(A[i]),-1])

C=[]
ans=1
div=7+10**9

if onlyminus:
    A.sort(reverse=True)
    for i in range(K):
        ans*=A[i]
else:
    B.sort(reverse=True)
    cnt=0
    for i in range(K):
        C.append(B[i])
        if B[i][1]==-1:
            cnt+=1

    if cnt%2==1:
        Ck=copy.deepcopy(C[-1])
        del C[-1]
        i=K
        if Ck[1]==1:
            while B[i][1]==1:
                i+=1
        else:
            while B[i][1]==-1:
                i+=1
        C.append(B[i])

    for i in range(K):
        ans*=C[i][0]

print(ans%div)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
div=7+10**9
ans=1
t=0
i,j=0,N-1

if A[-1]<0 and K%2==1:
    for i1 in range(N-K,N):
        ans*=A[i1]
        ans%=div
else:
    while t<K-1:
        if A[i]*A[i+1]>A[j]*A[j-1]:
            ans*=A[i]*A[i+1]
            ans%=div
            i+=2
            t+=2
        else:
            ans*=A[j]
            ans%=div
            j+=-1
            t+=1
    if t==K-1:
        ans*=A[j]
        ans%=div

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

H,W=map(int,input().split())
field=[]
dist=[[-1]*W for _ in range(H)]
que=deque()

for i in range(H):
    tmp=list(input())
    for j in range(W):
        if tmp[j]=="#":
            dist[i][j]=0
            que.append([i,j])
    field.append(tmp)

DX=[1,0,-1,0]
DY=[0,1,0,-1]
ans=0
while que:
    y,x=map(int,que.popleft())
    ans=dist[y][x]
    for dx,dy in zip(DX,DY):
        nx=x+dx
        ny=y+dy
        if nx<0 or nx>=W or ny<0 or ny>=H: continue
        if dist[ny][nx]==-1:
            dist[ny][nx]=dist[y][x]+1
            que.append([ny,nx])

print(ans)


Fixed submission:
from collections import deque

H,W=map(int,input().split())
field=[]
dist=[[-1]*W for _ in range(H)]
que=deque()

for i in range(H):
    tmp=list(input())
    for j in range(W):
        if tmp[j]=="#":
            dist[i][j]=0
            que.append([i,j])
    field.append(tmp)

DX=[1,0,-1,0]
DY=[0,1,0,-1]
ans=0
while que:
    y,x=map(int,que.popleft())
    ans=dist[y][x]
    for dx,dy in zip(DX,DY):
        nx=x+dx
        ny=y+dy
        if nx<0 or nx>=W or ny<0 or ny>=H: continue
        if dist[ny][nx]==-1:
            dist[ny][nx]=dist[y][x]+1
            que.append([ny,nx])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)
from collections import deque

H,W=map(int,input().split())
field=[]
dist=[[-1]*W for _ in range(H)]
que=deque()

for i in range(H):
    tmp=list(input())
    for j in range(W):
        if tmp[j]=="#":
            dist[i][j]=0
            que.append([i,j])
    field.append(tmp)

DX=[1,0,-1,0]
DY=[0,1,0,-1]
while que:
    y,x=map(int,que.popleft())
    for dx,dy in zip(DX,DY):
        nx=x+dx
        ny=y+dy
        if nx<0 or nx>=W or ny<0 or ny>=H: continue
        if dist[ny][nx]==-1:
            dist[ny][nx]=dist[y][x]+1
            que.append([ny,nx])

ans=0
for i in range(H):
    ans=max(ans,max(dist[i]))

print(ans)

Fixed submission:
from collections import deque

H,W=map(int,input().split())
field=[]
dist=[[-1]*W for _ in range(H)]
que=deque()

for i in range(H):
    tmp=list(input())
    for j in range(W):
        if tmp[j]=="#":
            dist[i][j]=0
            que.append([i,j])
    field.append(tmp)

DX=[1,0,-1,0]
DY=[0,1,0,-1]
ans=0
while que:
    y,x=map(int,que.popleft())
    ans=dist[y][x]
    for dx,dy in zip(DX,DY):
        nx=x+dx
        ny=y+dy
        if nx<0 or nx>=W or ny<0 or ny>=H: continue
        if dist[ny][nx]==-1:
            dist[ny][nx]=dist[y][x]+1
            que.append([ny,nx])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
ans=0
for i in range(N):
    tmp=S[:i].count("E")+S[i+1:].count("W")
    if tmp>ans:
        ans=tmp
ans=N-1-ans
print(ans)


Fixed submission:
N=int(input())
S=input()
S="N"+S+"N"
ans=0
E=0
W=S.count("W")
for i in range(1,N+1):
    if S[i-1]=="E":
        E+=1
    if S[i]=="W":
        W-=1
    tmp=E+W
    if tmp>ans:
        ans=tmp
ans=N-1-ans
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
graph=[[] for _ in range(N)]
table=[[0]*N for _ in range(N)]

for _ in range(M):
    a,b=map(int,input().split())
    a-=1
    b-=1
    graph[a].append(b)
    graph[b].append(a)
    table[a][b]=1
    table[b][a]=1

def steps(a,b,cnt=0):
    global flag
    global ans
    if cnt==3:
        if a!=b and not table[a][b]: 
            graph[a].append(b)
            graph[b].append(a)
            table[a][b]=1
            table[b][a]=1
            flag=True
            ans=ans+1
        return

    for nb in graph[b]:
        steps(a,nb,cnt+1)

flag=True
ans=0
while flag:
    flag=False
    for i in range(N):
        steps(i,i)
print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
N,M=map(int,input().split())
graph=[[] for _ in range(N)]
color=[-1]*N
for _ in range(M):
    a,b=map(int,input().split())
    a-=1
    b-=1
    graph[a].append(b)
    graph[b].append(a)

def steps(v,col=0):
    color[v]=col
    for nv in graph[v]:
        if color[nv]!=-1:
            if color[nv]==col: return False
            continue
        if not steps(nv,1-col): return False
    return True

flag=True
for v in range(N):
    if color[v]!=-1: continue
    if not steps(v): flag=False

if flag:
    tmp=color.count(0)
    print(tmp*(N-tmp)-M)
else:
    print(N*(N-1)//2-M)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(x) for x in input().split(' ')]
for n in range(N):
    print(A.index(n + 1) + 1, end=' ')

    

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = [0] * N
for i in range(N):
    ans[A[i] - 1]  = i + 1
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
s = set()
for i in range(k):
    l,r = list(map(int, input().split()))
    L = [i for i in range(l,r+1)]
    s = set(L+list(s))
dp=[0]*(n+1)
dp[1] = 1
p = 998244353

for i in range(1, n):
    for j in s:
        if i+j > n:
            continue
        dp[i+j] += (dp[i])
        dp[i+j] %= p

print(dp[n] % p)

Fixed submission:
n, k = map(int, input().split())
dp=[0]*(n+1)
dp[1] = 1

rui=[0]*(n+1)
rui[1] = 1
p = 998244353
lr=[]
for i in range(k):
    lr.append(list(map(int, input().split())))

for i in range(2,n+1):
    for l, r in lr:
        dp[i] += rui[max(i-l, 0)] - rui[max(i-r-1, 0)]
        dp[i] %= p
    rui[i] = rui[i-1] + dp[i]
    rui[i] %= p
print(dp[n])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = 10**9 + 7
dp=[[[0]*(2) for i in range(2)] for i in range(n+1)]
dp[0][0][0]=1

for i in range(n):
  dp[i+1][1][1] += (dp[i][1][1] * 10 + dp[i][0][1]+ dp[i][1][0])
  dp[i+1][1][1] %= p
  dp[i+1][1][0] += (dp[i][1][0] * 9 + dp[i][0][0])
  dp[i+1][1][0] %= p
  dp[i+1][0][1] += (dp[i][0][1] * 9 + dp[i][0][0])
  dp[i+1][0][1] %= p
  dp[i+1][0][0] += (dp[i][0][0] * 8)
  dp[i+1][0][0] %= p
print(dp[n][1][1])

Fixed submission:
n = int(input())
p = 10**9 + 7
dp=[[0]*(2) for i in range(2)]
dp[0][0]=1

for i in range(n):
  nextDP = [[0]*(2) for i in range(2)]
  nextDP[1][1] += (dp[0][1] + dp[1][0] + dp[1][1] * 10) % p
  nextDP[1][0] += (dp[1][0] * 9 + dp[0][0]) % p
  nextDP[0][1] += (dp[0][1] * 9 + dp[0][0]) % p
  nextDP[0][0] += (dp[0][0] * 8) % p
  dp = nextDP
print(dp[1][1] % p)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
sys.setrecursionlimit(10**9)

n = int(input())
a = list(map(int, input().split()))
ma = max(a)
p = [0]*(ma + 1)

for i in a:
  p[i] += 1

pairwise = True
for i in range(2, ma+1):
  cnt = 0
  for j in range(i, ma+1, i):
    cnt += p[j]
  if cnt > 1:
    pairwise = False
    
if pairwise:
  print("pairwise coprime")
else:
  temp = a[0]
  for i in a:
    temp = math.gcd(temp, i)
  if temp == 1:
    print("setwise coprime")
  else:
    print("not coprime")

Fixed submission:
import sys
import math
sys.setrecursionlimit(10**9)

n = int(input())
a = list(map(int, input().split()))
ma = max(a)
p = [0]*(ma + 1)

for i in a:
  p[i] += 1

pairwise = True
for i in range(2, ma+1):
  cnt = 0
  for j in range(i, ma+1, i):
    cnt += p[j]
  if cnt > 1:
    pairwise = False
    break
    
if pairwise:
  print("pairwise coprime")
else:
  temp = a[0]
  for i in a:
    temp = math.gcd(temp, i)
  if temp == 1:
    print("setwise coprime")
  else:
    print("not coprime")
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
temp = 7
juu = 7
for i in range(1, 10**7):
  temp = temp % k
  if temp == 0:
    print(i)
    break
  juu = juu * 10 % k
  temp += juu % k
else:
  print(-1)


Fixed submission:
k = int(input())
temp = 7
juu = 7
for i in range(1, 10**6):
  temp = temp % k
  if temp == 0:
    print(i)
    break
  juu = (juu * 10) % k
  temp += juu % k
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
a = list(map(int, input().split()))
t=1
for i in a[:k]:
  t *= i
temp = [t]

for index, i in enumerate(a[k:]):
  temp.append(temp[-1] * i // a[index])
  
for i,j in zip(temp, temp[1:]):
  if i < j:
    print("Yes")
  else:
    print("No")

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

for i in range(k, n):
  if a[i] > a[i-k]:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n,m,k = map(int,input().split())

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

dp=[0]*(k+1)

sa=0
cnta=0
for i in a:
  sa=sa+i
  cnta+=1
  if sa > k:
    break
  dp[sa]+=cnta

  sb=0
  cntb=0
  for j in b:
    sb=sb+j
    cntb+=1
    if sa+sb > k:
      break
    dp[sa+sb] = dp[sa] + cntb

print(max(dp))

Fixed submission:
n,m,k = map(int,input().split())

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

A=[0]
B=[0]
for i in a:
  A.append(i+A[-1])
for i in b:
  B.append(i+B[-1])
  
ans,j = 0,m
for i in range(n+1):
  if A[i] > k:
    break
  while B[j] + A[i] > k:
    j -= 1
  ans=max(ans,i+j)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

dp = [1]*(max(a)+1)

for i in sorted(a):
  if 2 == dp[i]:
    continue
  if 3 == dp[i]:
    dp[i] = 2
    continue
  dp[i] = 3
  for j in range(2, max(a)//i + 1):
    dp[j * i] = 2

ans=0
for i in a:
  if dp[i] != 2:
    ans += 1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ma = max(a)
dp = [0]*(ma+1)

for i in sorted(a):
  if 1 <= dp[i]:
    dp[i] += 1
    continue

  for j in range(1, ma//i + 1):
    dp[j * i] += 1

ans=0
for i in a:
  if dp[i] == 1:
    ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

dp = [1]*(max(a)+1)

for i in sorted(a):
  if 2 == dp[i]:
    continue
  if 3 == dp[i]:
    dp[i] = 2
    continue
  dp[i] = 3
  for j in range(2, max(a)//i + 1):
    dp[j * i] = 2

ans=0
for i in a:
  if dp[i] != 2:
    ans += 1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ma = max(a)
dp = [0]*(ma+1)

for i in sorted(a):
  if 1 <= dp[i]:
    dp[i] += 1
    continue

  for j in range(1, ma//i + 1):
    dp[j * i] += 1

ans=0
for i in a:
  if dp[i] == 1:
    ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

ans = [0]*(n)

for i in range(n):
  for j in range(n):
    if i == j:
      continue
    if ans[i] == 1 or ans[j] == 1:
      continue
    if a[i] % a[j] == 0:
      ans[i] = 1
    if a[j] % a[i] == 0:
      ans[j] = 1
print(n - sum(ans))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ma = max(a)
dp = [0]*(ma+1)

for i in sorted(a):
  if 1 <= dp[i]:
    dp[i] += 1
    continue

  for j in range(1, ma//i + 1):
    dp[j * i] += 1

ans=0
for i in a:
  if dp[i] == 1:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m,q = map(int,input().split())
t=[]
def dfs(s):
  if len(s) == 0:
    t="1"
  else:
    t=s[-1]
  res=[]
  if len(s) == n:
    return [s]
  for i in range(int(t),m+1):
    res+=dfs(s+str(i))
  return res

for i in range(q):
  t.append(list(map(int, input().split())))

ans=0
for i in dfs(""):
  temp=0
  for a,b,c,d in t:
    if int(i[b-1])-int(i[a-1]) == c:
      temp+=d
  ans=max(ans,temp)
print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n,m,q = map(int,input().split())
t=[]
def dfs(l):
  if len(l) == n:
    return [l]

  if len(l) == 0:
    t=1
  else:
    t=l[-1]
  res=[]
  for i in range(t, m+1):
    temp=l+[i]
    for j in dfs(temp):
      res.append(j)
  return res

for i in range(q):
  t.append(list(map(int, input().split())))

ans=0
l=dfs([])
for i in l:
  temp=0
  for a,b,c,d in t:
    if i[b-1]-i[a-1] == c:
      temp+=d
  ans=max(ans,temp)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
ls=len(s)
m=[0]*(2019)
m[0]+=1

cnt = 0
b=0
for i in range(ls):
  a = (b + int(s[ls - i -1])*10**cnt) % 2019
  m[a] += 1
  b = a
  cnt += 1

ans = 0
for i in m:
  if i <= 1:
    continue
  ans += i*(i-1)//2

print(ans)


Fixed submission:
s=input()
ls=len(s)
m=[0]*(2019)
m[0]+=1

cnt = 0
b = 0
for i in range(ls):
  a = (b + pow(10,cnt,2019)*int(s[ls - i -1])) % 2019
  m[a] += 1
  b = a
  cnt += 1

ans = 0
for i in m:
  if i <= 1:
    continue
  ans += i*(i-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
m=[0]*(2019)
m[0]+=1

cnt = 0
b=0
for i in s[::-1]:
  a = (b + int(i)*10**cnt) % 2019
  m[a] += 1
  b = a
  cnt += 1


ans = 0
for i in m:
  if i <= 1:
    continue
  ans += i*(i-1)//2

print(ans)


Fixed submission:
s=input()
ls=len(s)
m=[0]*(2019)
m[0]+=1

cnt = 0
b = 0
for i in range(ls):
  a = (b + pow(10,cnt,2019)*int(s[ls - i -1])) % 2019
  m[a] += 1
  b = a
  cnt += 1

ans = 0
for i in m:
  if i <= 1:
    continue
  ans += i*(i-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
m=[0]*(2019)
m[0]+=1

cnt = 0
b=0
for i in s[::-1]:
  a = (b + int(i)*10**cnt) % 2019
  m[a] += 1
  b = a
  cnt += 1


ans = 0
for i in m:
  if i <= 1:
    continue
  ans += i*(i-1)//2

print(ans)


Fixed submission:
s=input()
ls=len(s)
m=[0]*(2019)
m[0]+=1

cnt = 0
b = 0
for i in range(ls):
  a = (b + pow(10,cnt,2019)*int(s[ls - i -1])) % 2019
  m[a] += 1
  b = a
  cnt += 1

ans = 0
for i in m:
  if i <= 1:
    continue
  ans += i*(i-1)//2

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
from collections import deque,Counter
n,x,y = map(int,input().split())
route=[[10**10]*(n+1) for i in range(n+1)]
for i in range(1,n+1):
  q=deque([i])
  j=i
  route[i][j]=0
  while q:
    j=q.pop()
    if j == y:
      if route[i][j]+1 < route[i][x]:
        route[i][x]=route[i][j]+1
        q.append(x)
    if j == x:
      if route[i][j]+1 < route[i][y]:
        route[i][y]=route[i][j]+1
        q.append(y)
    if 1 < j:#-1
      if route[i][j]+1 < route[i][j-1]:
        route[i][j-1]=route[i][j]+1
        q.append(j-1)
    if j < n:#+1
      if route[i][j]+1 < route[i][j+1]:
        route[i][j+1]=route[i][j]+1
        q.append(j+1)

ans=Counter(list(itertools.chain.from_iterable(route)))
for i in range(1,n):
  print(ans[i]//2)


Fixed submission:
import itertools
from collections import deque,Counter
n,x,y = map(int,input().split())
route=[[10**10]*(n+1) for i in range(n+1)]
for i in range(1,n+1):
  q=deque([i])
  j=i
  route[i][j]=0
  while q:
    j=q.pop()
    if j == y:
      if route[i][j]+1 < route[i][x]:
        route[i][x]=route[i][j]+1
        q.append(x)
    if j == x:
      if route[i][j]+1 < route[i][y]:
        route[i][y]=route[i][j]+1
        q.append(y)
    if 1 < j:#-1
      if route[i][j]+1 < route[i][j-1]:
        route[i][j-1]=route[i][j]+1
        q.append(j-1)
    if j < n:#+1
      if route[i][j]+1 < route[i][j+1]:
        route[i][j+1]=route[i][j]+1
        q.append(j+1)

ans=Counter(list(itertools.chain.from_iterable(route)))
for i in range(1,n):
  print(ans[i]//2)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n,x,y = map(int,input().split())
route=[[10**10]*(n+1) for i in range(n+1)]
for i in range(1,n+1):
  q=deque([i])
  j=i
  route[i][j]=0
  while q:
    j=q.pop()
    if j == y:
      if route[i][j]+1 < route[i][x]:
        route[i][x]=route[i][j]+1
        q.append(x)
    if j == x:
      if route[i][j]+1 < route[i][y]:
        route[i][y]=route[i][j]+1
        q.append(y)
    if 1 < j:#-1
      if route[i][j]+1 < route[i][j-1]:
        route[i][j-1]=route[i][j]+1
        q.append(j-1)
    if j < n:#+1
      if route[i][j]+1 < route[i][j+1]:
        route[i][j+1]=route[i][j]+1
        q.append(j+1)
ans=[0]*(n+1)
for i in range(1,n+1):
  for j in range(i+1,n+1):
    ans[route[i][j]]+=1
for i in range(1,n):
  print(ans[i])


Fixed submission:
import itertools
from collections import deque,Counter
n,x,y = map(int,input().split())
route=[[10**10]*(n+1) for i in range(n+1)]
for i in range(1,n+1):
  q=deque([i])
  j=i
  route[i][j]=0
  while q:
    j=q.pop()
    if j == y:
      if route[i][j]+1 < route[i][x]:
        route[i][x]=route[i][j]+1
        q.append(x)
    if j == x:
      if route[i][j]+1 < route[i][y]:
        route[i][y]=route[i][j]+1
        q.append(y)
    if 1 < j:#-1
      if route[i][j]+1 < route[i][j-1]:
        route[i][j-1]=route[i][j]+1
        q.append(j-1)
    if j < n:#+1
      if route[i][j]+1 < route[i][j+1]:
        route[i][j+1]=route[i][j]+1
        q.append(j+1)

ans=Counter(list(itertools.chain.from_iterable(route)))
for i in range(1,n):
  print(ans[i]//2)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
a = list(map(int, input().split()))

c = collections.Counter(a)

nc=[-1]*(n+1)
def nConb(n):
  if nc[n] != -1:
    return nc[n]
  nc[n]=n*(n-1)//2
  return nc[n]
  
for i in range(n):
  temp=0
  for k,v in c.items():
    if k == a[i]:
      temp+=nConb(v-1)
    else:
      temp+=nConb(v)
  print(temp)

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

c = collections.Counter(a)

nc=[-1]*(n+1)
def nConb(n):
  if nc[n] != -1:
    return nc[n]
  nc[n]=n*(n-1)//2
  return nc[n]

temp=0
for k,v in c.items():
  temp+=nConb(v)

for i in range(n):
  if c[a[i]] == 1:
    print(temp)
  else:
    print(temp-(c[a[i]]-1))
Buggy python submission (verdict: Runtime Error):
s=input()
q=int(input())
dir=True
ans=s
query=[]
for i in range(q):
  temp=input()
  if temp[0] == "1":
    dir = dir ^ True
  if temp[0] == "2":
    t,f,c = temp.split()

    if (f == "1" and dir) or (f=="2" and not dir):
      ans=c+ans
    else:
      ans=ans+c
def reverse(s):
  t=""
  for i in range(len(s)-1,-1,-1):
    t+=s[i]
  return t

if dir:
  print(ans)
else:
  print(reverse(ans))


Fixed submission:
s = input()

if s.count("A") == 3 or s.count("B") == 3:
  print("No")
else:
  print("Yes")