Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))

L.sort()

count = 0
for i in range(0, N - 2):
    for p in range(i + 1, N - 1):
        left = p + 1
        right = N - 1
        tmp = (left + right) // 2
        if left == right:
            if L[i] + L[p] > L[left]:
                count += (left - p)
                break
        while 'true':
            if L[i] + L[p] > L[tmp]:
                left = tmp
                tmp = (left + right) // 2
            else:
                right = tmp
                tmp = (left + right) // 2
            if abs(right - left) <= 1:
                if L[i] + L[p] > L[right]:
                    count += (right - p)
                    break
                elif L[i] + L[p] > L[left]:
                    count += (left - p)
                    break
                else:
                    break
print(count)

Fixed submission:
import bisect

N = int(input())
L = list(map(int, input().split()))

L.sort()

count = 0
for i in range(0, N - 2):
    for p in range(i + 1, N - 1):
        count += bisect.bisect_left(L, L[i] + L[p]) - p - 1
print(count)

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

L.sort()

count = 0
for i in range(0, N - 2):
    for p in range(i + 1, N - 1):
        left = p + 1
        right = N - 1
        tmp = (left + right) // 2
        while 'true':
            if L[i] + L[p] > L[tmp]:
                left = tmp
                tmp = (left + right) // 2
            else:
                right = tmp
                tmp = (left + right) // 2
            if abs(right - left) <= 1:
                if L[i] + L[p] > L[right]:
                    count += (right - p)
                    break
                elif L[i] + L[p] > L[left]:
                    count += (left - p)
                    break
                else:
                    break
print(count)

Fixed submission:
import bisect

N = int(input())
L = list(map(int, input().split()))

L.sort()

count = 0
for i in range(0, N - 2):
    for p in range(i + 1, N - 1):
        count += bisect.bisect_left(L, L[i] + L[p]) - p - 1
print(count)

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

L.sort()

count = 0
for i in range(0, N - 2):
    for p in range(i + 1, N - 1):
        for q in range(p + 1, N):
            if L[i] + L[p] > L[q]:
                count += 1
            else:
                break
print(count)

Fixed submission:
import bisect

N = int(input())
L = list(map(int, input().split()))

L.sort()

count = 0
for i in range(0, N - 2):
    for p in range(i + 1, N - 1):
        count += bisect.bisect_left(L, L[i] + L[p]) - p - 1
print(count)
Buggy python submission (verdict: Runtime Error):
if input() > 1200:
  print("ABC")
else:
  print("ARC")

Fixed submission:
if int(input()) < 1200:
  print("ABC")
else:
  print("ARC")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
M = A[0]
ans = 0
for i in range(1,N):
  if M > A[i]:
    ans += M-A[i]
  else:
    M = A[i]
print(ans)v

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
M = A[0]
ans = 0
for i in range(1,N):
  if M > A[i]:
    ans += M-A[i]
  else:
    M = A[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
if S == "RRR":
  print(0)
elif S == "SSS":
  print(3)
elif S == "SSR" or S = "RSS":
  print(2)
else:
  print(1)

Fixed submission:
S = input()
if S == "RRR":
  print(3)
elif S == "SSS":
  print(0)
elif S == "SRR" or S == "RRS":
  print(2)
else:
  print(1)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
s = 1
for j in range(K-1):
  s *= A[j]
for i in range(K, N):
  if A[i] > A[i-K]:
    print("Yes")
  else:
    print("No")
  s *= A[i]
  s //= A[i-K]

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 = int(input())
A = list(map(int, input().split()))
kabu = 0
money = 1000
for i in range(N):
  money += kabu*A[i]
  kabu = 0
  if i!=N-1:
    if A[i]<A[i+1]:
      kabu += money//A[i]
      money %= 0
    else:
      continue
print(money)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
kabu = 0
money = 1000
for i in range(N):
  money += kabu*A[i]
  kabu = 0
  if i!=N-1:
    if A[i]<=A[i+1]:
      kabu += money//A[i]
      money %= A[i]
    else:
      pass
print(money)
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()))

a = [0 for _ in range(N)]
b = [0 for _ in range(M)]

a[0] = A[0]
for i in range(1,N):
  a[i] = a[i-1] + A[i]
  
b[0] = B[0]
for j in range(1,M):
  b[j] = b[j-1] + B[j]
  
num = M-1
ans = 0
for k in range(N):
  if a[k] > K:
    break
  while b[num] > K - a[k]:
    num -= 1
  ans = max(ans, k+num+2)
  
print(ans)

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

a = [0 for _ in range(N+1)]
b = [0 for _ in range(M+1)]

for i in range(1,N+1):
  a[i] = a[i-1] + A[i-1]
  
for j in range(1,M+1):
  b[j] = b[j-1] + B[j-1]
  
num = M
ans = 0
for k in range(N+1):
  if a[k] > K:
    break
  while b[num] > K - a[k]:
    num -= 1
  ans = max(ans, k+num)
  
print(ans)

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()))

numA = 0
numB = 0
count = 0
time = 0
for i in range(N+M):
  if numA < N and numB < M:
    if A[numA] > B[numB] and time + B[numB] <= K:
      count += 1
      time += B[numB]
      numB += 1
    elif A[numA] < B[numB] and time + A[numA] <= K:
      count += 1
      time += A[numA]
      numA += 1
    elif A[numA] == B[numB]:
      if numA == N-1 and time + B[numB] <= K:
        count += 1
        time += B[numB]
        numB += 1
      elif numB == M-1 and time + A[numA] <= K:
        count += 1
        time += A[numA]
        numA += 1
      elif A[numA + 1] > B[numB + 1] and time + B[numB] <= K:
        count += 1
        time += B[numB]
        numB += 1        
      elif A[numA + 1] <= B[numB + 1] and time + A[numA] <= K:    
        count += 1
        time += A[numA]
        numA += 1    
      else:
        break
    else:
      break
  else:
    if numA >= N and numB < M and time + B[numB] <= K:
      count += 1
      time += B[numB]
      numB += 1
    elif numB >= M and numA < N and time + A[numA] <= K:
      count += 1
      time += A[numA]
      numA += 1
    else:
      break
print(count)

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

a = [0 for _ in range(N+1)]
b = [0 for _ in range(M+1)]

for i in range(1,N+1):
  a[i] = a[i-1] + A[i-1]
  
for j in range(1,M+1):
  b[j] = b[j-1] + B[j-1]
  
num = M
ans = 0
for k in range(N+1):
  if a[k] > K:
    break
  while b[num] > K - a[k]:
    num -= 1
  ans = max(ans, k+num)
  
print(ans)
Buggy python submission (verdict: Runtime Error):
T = list(input())
if len(T) == 1:
  if T[0] == "?":
    print("D")
  else:
    print("".join(T))
else:
  for i in range(len(T)):
    if i > 0 and T[i] == "?" and T[i-1] == "P":
      T[i] = "D"
    elif i <= len(T) -1 and T[i] == "?" and (T[i+1] == "D" or T[i+1] == "?"):
      T[i] = "P"
    elif T[i] == "?":
      T[i] = "D"
  print("".join(T))

Fixed submission:
T = list(input())
if len(T) == 1:
  if T[0] == "?":
    print("D")
  else:
    print("".join(T))
else:
  for i in range(len(T)):
    if i > 0 and T[i] == "?" and T[i-1] == "P":
      T[i] = "D"
    elif i < len(T) -1 and T[i] == "?" and (T[i+1] == "D" or T[i+1] == "?"):
      T[i] = "P"
    elif T[i] == "?":
      T[i] = "D"
  print("".join(T))

Buggy python submission (verdict: Runtime Error):
T = list(input())
for i in range(len(T)):
  if i > 0 and T[i] == "?" and T[i-1] == "P":
    T[i] = "D"
  elif i <= len(T) -1 and T[i] == "?" and (T[i+1] == "D" or T[i+1] == "?"):
    T[i] = "P"
  elif T[i] == "?":
    T[i] = "D"
print("".join(T))

Fixed submission:
T = list(input())
if len(T) == 1:
  if T[0] == "?":
    print("D")
  else:
    print("".join(T))
else:
  for i in range(len(T)):
    if i > 0 and T[i] == "?" and T[i-1] == "P":
      T[i] = "D"
    elif i < len(T) -1 and T[i] == "?" and (T[i+1] == "D" or T[i+1] == "?"):
      T[i] = "P"
    elif T[i] == "?":
      T[i] = "D"
  print("".join(T))

Buggy python submission (verdict: Runtime Error):
T = list(input())
for i in range(1, len(T)):
  if T[i] == "?" and T[i-1] == "P":
    T[i] = "D"
  elif T[i] == "?" and (T[i+1] == "D" or T[i+1] == "?"):
    T[i] = "P"
  elif T[i] == "?":
    T[i] = "D"
print("".join(T))

Fixed submission:
T = list(input())
if len(T) == 1:
  if T[0] == "?":
    print("D")
  else:
    print("".join(T))
else:
  for i in range(len(T)):
    if i > 0 and T[i] == "?" and T[i-1] == "P":
      T[i] = "D"
    elif i < len(T) -1 and T[i] == "?" and (T[i+1] == "D" or T[i+1] == "?"):
      T[i] = "P"
    elif T[i] == "?":
      T[i] = "D"
  print("".join(T))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

X = 0
town = 1
counted = [0 for _ in range(N)]
for k in range(N):
  X += 1
  counted[k] = town
  town = A[town-1]
  if town in counted:
    ini = counted.index(town)
    Q = X - ini
    break
if K >= ini:    
  num = (K-ini) % Q
  print(counted[ini+num])
else:
  print(counted[K])


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

X = 0
town = 1
counted = [0 for _ in range(N)]
List = [0 for _ in range(N)]
for k in range(N):
  X += 1
  counted[k] = town
  town = A[town-1]
  if List[town-1] == 1:
    ini = counted.index(town)
    Q = X - ini
    break
  else:
    List[town-1] = 1
if K >= ini:    
  num = (K-ini) % Q
  print(counted[ini+num])
else:
  print(counted[K])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

X = 0
town = 1
counted = [0 for _ in range(N)]
for k in range(N):
  X += 1
  counted[k] = town
  town = A[town-1]
  if town in counted:
    roop = counted[counted.index(town):counted.index(0)]
    Q = len(roop)
    I = counted[:counted.index(town)]
    ini = X - Q
    break
if K >= ini:    
  num = (K-ini) % Q
  print(roop[num])
else:
  print(I[K])


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

X = 0
town = 1
counted = [0 for _ in range(N)]
List = [0 for _ in range(N)]
for k in range(N):
  X += 1
  counted[k] = town
  town = A[town-1]
  if List[town-1] == 1:
    ini = counted.index(town)
    Q = X - ini
    break
  else:
    List[town-1] = 1
if K >= ini:    
  num = (K-ini) % Q
  print(counted[ini+num])
else:
  print(counted[K])

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

X = 0
town = 1
counted = []
for k in range(N):
  X += 1
  counted.append(town)
  town = A[town-1]
  if town in counted:
    Q = len(counted[counted.index(town):])
    roop = counted[counted.index(town):]
    I = counted[:counted.index(town)]
    ini = X - Q
    break
print(I)
print(roop)
ans = 1
if K > ini:    
  num = (K-ini) % Q
  print(roop[num])
else:
  print(I[K])
  

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

X = 0
town = 1
counted = [0 for _ in range(N)]
List = [0 for _ in range(N)]
for k in range(N):
  X += 1
  counted[k] = town
  town = A[town-1]
  if List[town-1] == 1:
    ini = counted.index(town)
    Q = X - ini
    break
  else:
    List[town-1] = 1
if K >= ini:    
  num = (K-ini) % Q
  print(counted[ini+num])
else:
  print(counted[K])
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
H = list(map(int,input().split()))
Road = [list(map(int, input().split())) for _ in range(M)]
num = 0
for i in range(N):
  for j in range(M):
    if Road[j][1] == i+1 and H[Road[j][0]-1] >= H[i]:
      break
    elif Road[j][0] == i+1 and H[Road[j][1]-1] >= H[i]:
      break
  else:
    num += 1
print(num)

Fixed submission:
N, M = map(int, input().split())
H = list(map(int,input().split()))
Road = [sorted(list(map(int, input().split()))) for _ in range(M)]
num = N
Mem = [0 for _ in range(N)]
for j in range(M):
  if H[Road[j][0]-1] > H[Road[j][1]-1] and Mem[Road[j][1]-1] != 1:
    num -= 1
    Mem[Road[j][1]-1] = 1
  elif H[Road[j][1]-1] > H[Road[j][0]-1] and Mem[Road[j][0]-1] != 1:
    num -= 1
    Mem[Road[j][0]-1] = 1
  elif H[Road[j][1]-1] == H[Road[j][0]-1]:
    if Mem[Road[j][0]-1] != 1 and Mem[Road[j][1]-1] != 1:
      num -= 2
      Mem[Road[j][0]-1] = 1
      Mem[Road[j][1]-1] = 1
    elif Mem[Road[j][0]-1] == 1 and Mem[Road[j][1]-1] == 1:
      continue
    else:
      num -= 1
      Mem[Road[j][0]-1] = 1
      Mem[Road[j][1]-1] = 1
print(num)
Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(Q)]
List = sorted(X)  
ans = 0
for i in range(2**Q):
  sum = 0
  A = [0 for _ in range(N)]
  for j in range(Q):
    if ((i >> j) & 1) and A[List[j][0]-1] != 0 and A[List[j][1]-1] != 0: #値入ってる
      if A[List[j][1]-1] - A[List[j][0]-1] == List[j][2]:
        sum += List[j][3]
      else:
        break
    elif ((i >> j) & 1) and A[List[j][0]-1] != 0 and A[List[j][1]-1] == 0: #aだけ値入ってる
      A[List[j][1]-1] = A[List[j][0]-1] + List[j][2] #値決める
      if A[List[j][1]-1] > M:
        break
      else:
        sum += List[j][3]
    elif ((i >> j) & 1) and A[List[j][0]-1] == 0 and A[List[j][1]-1] == 0: #値入ってない
      A[List[j][0]-1] = 1
      A[List[j][1]-1] = 1 + List[j][2] #値決める
      sum += List[j][3]
  else:
    if ans < sum:
      ans = sum
print(ans)

Fixed submission:
N, M, Q =  map(int, input().split())
List = [list(map(int, input().split())) for _ in range(Q)]
A = [1 for _ in range(N)]
ans = 0

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

def new_A(A):
  for i in range(N):
    if A[N-i-1] < M:
      A[N-i-1] += 1
      break
    elif A[N-i-1] == M and A[N-i-2] < M:
      A[N-i-2] += 1
      for x in range(N-i-1, N):
        A[x] = A[N-i-2]
      break
  return A

for j in range(cmb(N+M-1, N)):
  sum = 0
  for k in range(Q):
    if A[List[k][1]-1] - A[List[k][0]-1] == List[k][2]:
      sum += List[k][3]
  if ans < sum:
    ans = sum
  A = new_A(A)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = ["" for _ in range(N)]
num = 0
for i in range(N):
  X = input()
  if not X in S:
    S[i] = X
    num += 1
print(num)

Fixed submission:
N = int(input())
S = ["" for _ in range(N)]
num = 1
for i in range(N):
  S[i] = input()
List = sorted(S)
for j in range(N-1):
  if List[j] != List[j+1]:
    num += 1
print(num)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
K = int(input())
sum = 0
for a in range(1, K+1):
  for b in range(a+1, K+1):
    for c in range(b+1, K+1):
      sum += gcd(gcd(a, b), c)
sum *= 6
for j in range(1, K+1):
  for k in range(j+1, K+1):
    sum += gcd(j, k)*6
for l in range(1, K+1):
  sum += l 
print(sum)

Fixed submission:
from math import gcd
K = int(input())
sum = 0
for a in range(1, K+1):
  for b in range(a+1, K+1):
    for c in range(b+1, K+1):
      sum += gcd(gcd(a, b), c)
sum *= 6
for j in range(1, K+1):
  for k in range(j+1, K+1):
    sum += gcd(j, k)*6
for l in range(1, K+1):
  sum += l 
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
K = int(input())
sum = 0
for a in range(1, K+1):
  for b in range(a+1, K+1):
    for c in range(b+1, K+1):
      sum += gcd(gcd(a, b), c)
sum *= 6
for j in range(1, K+1):
  for k in range(j+1, K+1):
    sum += gcd(j, k)*6
for l in range(1, K+1):
  sum += l 
print(sum)

Fixed submission:
from math import gcd
K = int(input())
sum = 0
for a in range(1, K+1):
  for b in range(a+1, K+1):
    for c in range(b+1, K+1):
      sum += gcd(gcd(a, b), c)
sum *= 6
for j in range(1, K+1):
  for k in range(j+1, K+1):
    sum += gcd(j, k)*6
for l in range(1, K+1):
  sum += l 
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
S = input()
sum = 0
for i in range(K-2):
  for j in range(i+1, K-1):
    if S[i] == S[j]:
      pass
    else:
      for k in range(j+1, K):
        if S[j] != S[k] and S[k] != S[i] and j - i != k - j:
          sum += 1
print(sum)

Fixed submission:
N = int(input())
S = input()
sum = 0
for i in range(N):
  if S[i] == "R":
    sum += S[i+1:].count("G")*S[i+1:].count("B")
  elif S[i] == "G":
    sum += S[i+1:].count("R")*S[i+1:].count("B")
  elif S[i] == "B":
    sum += S[i+1:].count("G")*S[i+1:].count("R")
for a in range(N):
  for b in range(a+1, N):
    if S[a] == S[b] or 2*b-a >= N:
      pass
    elif S[b] != S[2*b-a] and S[2*b-a] != S[a]:
      sum -= 1
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
S = input()
sum = 0
for i in range(K-2):
  for j in range(i+1, K-1):
    for k in range(j+1, K):
      if S[i] != S[j] and S[j] != S[k] and S[k] != S[i] and j - i != k - j:
        sum += 1
print(sum)

Fixed submission:
N = int(input())
S = input()
sum = 0
for i in range(N):
  if S[i] == "R":
    sum += S[i+1:].count("G")*S[i+1:].count("B")
  elif S[i] == "G":
    sum += S[i+1:].count("R")*S[i+1:].count("B")
  elif S[i] == "B":
    sum += S[i+1:].count("G")*S[i+1:].count("R")
for a in range(N):
  for b in range(a+1, N):
    if S[a] == S[b] or 2*b-a >= N:
      pass
    elif S[b] != S[2*b-a] and S[2*b-a] != S[a]:
      sum -= 1
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
for p in range(K):
  if (N - p) % K == 0 or (N + p) % K == 0:
    print(p)
    break
  elif (N - (K - p)) % K == 0 or (N + (K - p)) % K == 0:
    print(K - p)
    break

Fixed submission:
N, K = map(int, input().split())
print(min(N%K, K-N%K))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
for p in range(K):
  if (N - p) % K == 0 or (N + p) % K == 0:
    print(p)
    break

Fixed submission:
N, K = map(int, input().split())
print(min(N%K, K-N%K))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
for p in range(K):
  if (N - p) % K == 0 or (N + p) % K == 0:
    print(p)
    break

Fixed submission:
N, K = map(int, input().split())
print(min(N%K, K-N%K))
Buggy python submission (verdict: Time Limit Exceeded):
N, X, Y = map(int, input().split())
List = []
for i in range(1,N):
  for j in range(i+1, N+1):
    List.append(min(j-i, abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X)))
for k in range(1, N):
  print(List.count(k))

Fixed submission:
N, X, Y = map(int, input().split())
List = [0 for _ in range(N-1)]
for i in range(1,N):
  for j in range(i+1, N+1):
    num = min(j-i, abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X))
    List[num-1] += 1
for k in range(N-1):
  print(List[k])
Buggy python submission (verdict: Runtime Error):
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
for i in range(N):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if A[j][k] == b:
        A[j][k] = "x"
if A[0] == ["x","x","x"]:
  print("Yes")
elif A[1] == ["x","x","x"]:
  print("Yes")
elif A[2] == ["x","x","x"]:
  print("Yes")
elif A[0][0] == "x" and A[1][0] == "x" and A[2][0] == "x":
  peint("Yes")
elif A[0][1] == "x" and A[1][1] == "x" and A[2][1] == "x":
  print("Yes")
elif A[0][2] == "x" and A[1][2] == "x" and A[2][2] == "x":
  print("Yes")
elif A[0][0] == "x" and A[1][1] == "x" and A[2][2] == "x":
  print("Yes")
elif A[0][2] == "x" and A[1][1] == "x" and A[2][0] == "x":
  print("Yes")
else:
  print("No")

Fixed submission:
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
for i in range(N):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if A[j][k] == b:
        A[j][k] = "x"
      else:
        pass
if A[0] == ["x","x","x"]:
  print("Yes")
elif A[1] == ["x","x","x"]:
  print("Yes")
elif A[2] == ["x","x","x"]:
  print("Yes")
elif A[0][0] == "x" and A[1][0] == "x" and A[2][0] == "x":
  print("Yes")
elif A[0][1] == "x" and A[1][1] == "x" and A[2][1] == "x":
  print("Yes")
elif A[0][2] == "x" and A[1][2] == "x" and A[2][2] == "x":
  print("Yes")
elif A[0][0] == "x" and A[1][1] == "x" and A[2][2] == "x":
  print("Yes")
elif A[0][2] == "x" and A[1][1] == "x" and A[2][0] == "x":
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Counted = []
num = []
 
for i in range(N):
  S = input()
  if S in Counted:
    num[Counted.index(S)] += 1
  else:
    Counted.append(S)
    num.append(1)

Dict = list(zip(Counted, num))
Dict_sorted = sorted(Dict,key=lambda x: x[1], reverse = True)
 
VVV = []
 
for i in range(len(Dict_sorted)):
  if Dict_sorted[i][1] == Dict_sorted[0][1]:
    VVV.append(Dict_sorted[i][0])
  else:
    break

SSS = sorted(VVV)
 
for _ in range(len(SSS)):
  print(SSS[_])

Fixed submission:
N = int(input())
dic = {}
Max = 1

for _ in range(N):
  S = input()
  if not S in dic:
    dic[S] = 1
  else:
    dic[S] += 1
    Max = max([Max, dic[S]])

ans = []
    
for x in dic:
  if dic[x] == Max:
    ans.append(x)

ans_sorted = sorted(ans)
for y in range(len(ans)):
  print(ans_sorted[y])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Counted = []
num = [0 for _ in range(N)]
 
for i in range(N):
  S = input()
  if S in Counted:
    num[Counted.index(S)] += 1
  else:
    Counted.append(S)
    num[Counted.index(S)] += 1

Dict = list(zip(Counted, num))
Dict_sorted = sorted(Dict,key=lambda x: x[1], reverse = True)
 
VVV = []
 
for i in range(len(Dict_sorted)):
  if Dict_sorted[i][1] == Dict_sorted[0][1]:
    VVV.append(Dict_sorted[i][0])
  else:
    break

SSS = sorted(VVV)
 
for _ in range(len(SSS)):
  print(SSS[_])

Fixed submission:
N = int(input())
dic = {}
Max = 1

for _ in range(N):
  S = input()
  if not S in dic:
    dic[S] = 1
  else:
    dic[S] += 1
    Max = max([Max, dic[S]])

ans = []
    
for x in dic:
  if dic[x] == Max:
    ans.append(x)

ans_sorted = sorted(ans)
for y in range(len(ans)):
  print(ans_sorted[y])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Counted = []
num = [0 for _ in range(N)]

for i in range(N):
  S = input()
  if S in Counted:
    num[Counted.index(S)] += 1
  else:
    Counted.append(S)
    num[Counted.index(S)] += 1

Dict = list(zip(Counted, num))
Dict_sorted = sorted(Dict,key=lambda x: x[1], reverse = True)

VVV = []

for i in range(len(Dict_sorted)):
  if Dict_sorted[i][1] == Dict_sorted[0][1]:
    VVV.append(Dict_sorted[i][0])
  else:
    break

SSS = sorted(VVV)

for _ in range(len(SSS)):
  print(SSS[_])

Fixed submission:
N = int(input())
dic = {}
Max = 1

for _ in range(N):
  S = input()
  if not S in dic:
    dic[S] = 1
  else:
    dic[S] += 1
    Max = max([Max, dic[S]])

ans = []
    
for x in dic:
  if dic[x] == Max:
    ans.append(x)

ans_sorted = sorted(ans)
for y in range(len(ans)):
  print(ans_sorted[y])