Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
txt = list(input())
a = txt.pop(0)
b = a
count = 1
while(len(txt) != 0):
  #print(temp)
  a = txt.pop(0)
  if a == b:
    if len(txt) >= 1:
      a += txt.pop(0)
      b = a
      count += 1
    else:
      b += a
  #print(a)
  else:
    b = a
    count += 1
print(count)

Fixed submission:
txt = list(input())
a = txt[0]
count = 1
i = 1
while(i < len(txt)):
  #print(temp)
  if a != txt[i]:
    a = txt[i]
    i += 1
    count += 1
  else:
    if (len(txt)-i) >= 2:
      a = txt[i:i+1]
      i += 2
      count += 1
    else:
      break
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
txt = list(input())
a = txt.pop(0)
temp = [a]
while(len(txt) != 0):
  #print(temp)
  a = txt.pop(0)
  if a == temp[-1]:
    if len(txt) >= 1:
      a += txt.pop(0)
      temp.append(a)
    else:
      temp[-1] += a
  #print(a)
  else:
    temp.append(a)
print(len(temp))

Fixed submission:
txt = list(input())
a = txt[0]
count = 1
i = 1
while(i < len(txt)):
  #print(temp)
  if a != txt[i]:
    a = txt[i]
    i += 1
    count += 1
  else:
    if (len(txt)-i) >= 2:
      a = txt[i:i+1]
      i += 2
      count += 1
    else:
      break
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = (int)(input())
s = [sorted(list(input())) for i in range(n)]
 
ans = 0
for i in range(n - 1):
  for j in range(i + 1, n):
    if s[i] == s[j]:
      ans += 1
print(ans)

Fixed submission:
n = (int)(input())
s = sorted([sorted(list(input())) for i in range(n)])
 
ans = 0
temp = 1
for i in range(n - 1):
  if s[i] == s[i + 1]:
    temp += 1
  else:
    if temp != 1:
      ans += temp * (temp - 1) // 2
      temp = 1
else:
  if temp != 1:
    ans += temp * (temp - 1) // 2
    temp = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = (int)(input())
s = [sorted(list(input())) for i in range(n)]
 
ans = 0
for i in range(n - 1):
  for j in range(i + 1, n):
    if s[i] == s[j]:
      ans += 1
print(ans)

Fixed submission:
n = (int)(input())
s = sorted([sorted(list(input())) for i in range(n)])
 
ans = 0
temp = 1
for i in range(n - 1):
  if s[i] == s[i + 1]:
    temp += 1
  else:
    if temp != 1:
      ans += temp * (temp - 1) // 2
      temp = 1
else:
  if temp != 1:
    ans += temp * (temp - 1) // 2
    temp = 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = (int)(input())
s = [sorted(list(input())) for i in range(n)]

#print(*count)

ans = 0
for i in range(n - 1):
  for j in range(i + 1, n):
    if count[i] == count[j]:
      ans += 1
print(ans)

Fixed submission:
n = (int)(input())
s = sorted([sorted(list(input())) for i in range(n)])
 
ans = 0
temp = 1
for i in range(n - 1):
  if s[i] == s[i + 1]:
    temp += 1
  else:
    if temp != 1:
      ans += temp * (temp - 1) // 2
      temp = 1
else:
  if temp != 1:
    ans += temp * (temp - 1) // 2
    temp = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = (int)(input())
s = [input() for i in range(n)]
count = [[0 for i in range(26)] for j in range(n)]
for i in range(n):
  for j in range(10):
    count[i][ord(s[i][j]) - 97] += 1
#print(*count)

ans = 0
for i in range(n - 1):
  for j in range(i + 1, n):
    if count[i] == count[j]:
      ans += 1
print(ans)

Fixed submission:
n = (int)(input())
s = sorted([sorted(list(input())) for i in range(n)])
 
ans = 0
temp = 1
for i in range(n - 1):
  if s[i] == s[i + 1]:
    temp += 1
  else:
    if temp != 1:
      ans += temp * (temp - 1) // 2
      temp = 1
else:
  if temp != 1:
    ans += temp * (temp - 1) // 2
    temp = 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int, input().split(" "))
s = input()
lr = [list(map(int, input().split(" "))) for i in range(q)]

for l, r in lr:
  txt = s[l-1:r]
  #print(txt)
  print(txt.count("AC"))
  

Fixed submission:
import bisect
n,q = map(int, input().split(" "))
s = input()
lr = [list(map(int, input().split(" "))) for i in range(q)]
a = []
for i in range(n-1):
  if s[i] +s[i+1]== 'AC':
    a.append(i+1)
for l, r in lr:
  print(bisect.bisect(a, r-1) - bisect.bisect(a, l-0.1))

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

for l, r in lr:
  txt = s[l-1:r]
  #print(txt)
  print(txt.count("AC"))
  

Fixed submission:
import bisect
n,q = map(int, input().split(" "))
s = input()
lr = [list(map(int, input().split(" "))) for i in range(q)]
a = []
for i in range(n-1):
  if s[i] +s[i+1]== 'AC':
    a.append(i+1)
for l, r in lr:
  print(bisect.bisect(a, r-1) - bisect.bisect(a, l-0.1))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split(" "))
max = 1
for i in range((int)(m/n), 1, -1):
  if m % i == 0:
    max = i
    break
print(max)

Fixed submission:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

n, m = map(int, input().split(" "))
max = 1
#print(make_divisors(m))
for i in make_divisors(m):
  if i > m/n:
    break
  else:
    max = i
print(max)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split(" "))
max = 1
for i in range((int)(m/n), 1, -1):
  if m % i == 0:
    max = i
    break
print(max)
  

Fixed submission:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

n, m = map(int, input().split(" "))
max = 1
#print(make_divisors(m))
for i in make_divisors(m):
  if i > m/n:
    break
  else:
    max = i
print(max)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split(" "))
min = 1
for i in range(2, (int)(m/n + 1)):
  if m % i == 0:
    min = i
print(min)

Fixed submission:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

n, m = map(int, input().split(" "))
max = 1
#print(make_divisors(m))
for i in make_divisors(m):
  if i > m/n:
    break
  else:
    max = i
print(max)
Buggy python submission (verdict: Runtime Error):
n=(int)(input())
a=[]
for i in range(2, n):
  temp = i ** 2
  while(temp <= n):
    a.append(temp)
    temp *= i
a = sorted(set(a))
#print(a)
print(list(i for i in a if i <= n)[-1])

Fixed submission:
n=(int)(input())
a=[1]
for i in range(2, n):
  temp = i ** 2
  while(temp <= n):
    a.append(temp)
    temp *= i
a = sorted(set(a))
#print(a)
print(list(i for i in a if i <= n)[-1])
Buggy python submission (verdict: Time Limit Exceeded):
island, fune = map(int, input().split(" "))
route = []
for i in range(fune):
    route.append(list(map(int, input().split(" "))))
pos = False
temp = []
for i in range(fune):
    if route[i][0] == 1:
        temp.append(route[i][1])
for j in range(fune):
    if route[j][1] == island:
        if route[j][0] in temp:
            pos = True
            break
print("POSSIBLE") if pos else print("IMPOSSIBLE")

Fixed submission:
island, fune = map(int, input().split(" "))
route = []
for i in range(fune):
    route.append(list(map(int, input().split(" "))))
temp = []
for i in range(fune):
    if route[i][0] == 1:
        temp.append(route[i][1])
for j in range(fune):
    if route[j][1] == island:
        temp.append(route[j][0])


print("POSSIBLE") if len(temp) != len(list(set(temp))) else print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
island, fune = map(int, input().split(" "))
route = []
for i in range(fune):
    route.append(list(map(int, input().split(" "))))
pos = False
for i in range(fune):
    if route[i][0] == 1:
        for j in range(fune):
            if route[j][1] == island:
                if route[i][1] == route[j][0]:
                    pos = True
                    break
        else:
            continue
        break
print("POSSIBLE") if pos else print("IMPOSSIBLE")

Fixed submission:
island, fune = map(int, input().split(" "))
route = []
for i in range(fune):
    route.append(list(map(int, input().split(" "))))
temp = []
for i in range(fune):
    if route[i][0] == 1:
        temp.append(route[i][1])
for j in range(fune):
    if route[j][1] == island:
        temp.append(route[j][0])


print("POSSIBLE") if len(temp) != len(list(set(temp))) else print("IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
num = (int)(input())
button = []
for i in range(num):
  button.append(list(map(int, input().split(" "))))
count = 0
for i in range(num - 1, -1, -1):
  #print(button)
  tasu = button[i][1] - (button[i][0] % button[i][1]) if button[i][0] % button[i][1] != 0 else 0
  for j in range(i, -1, -1):
    button[j][0] += tasu
  count += tasu
print(count)

Fixed submission:
num = (int)(input())
button = []
for i in range(num):
  button.append(list(map(int, input().split(" "))))
count = 0
for i in range(num - 1, -1, -1):
  button[i][0] += count
  tasu = button[i][1] - (button[i][0] % button[i][1]) if button[i][0] % button[i][1] != 0 else 0
  #print(tasu, count)
  count += tasu
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
num = (int)(input())
button = []
for i in range(num):
  button.append(list(map(int, input().split(" "))))
count = 0
for i in range(num - 1, -1, -1):
  #print(button)
  while(button[i][0] % button[i][1] != 0):
    for j in range(i, -1, -1):
      button[j][0] += 1
    count += 1
print(count)

Fixed submission:
num = (int)(input())
button = []
for i in range(num):
  button.append(list(map(int, input().split(" "))))
count = 0
for i in range(num - 1, -1, -1):
  button[i][0] += count
  tasu = button[i][1] - (button[i][0] % button[i][1]) if button[i][0] % button[i][1] != 0 else 0
  #print(tasu, count)
  count += tasu
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
H, W, M = map(int, input().split())
P = []
X = [0 for i in range(H)]
Y = [0 for j in range(W)]
s = set([])
for i in range(M):
  h, w = map(int, input().split())
  X[h-1] += 1
  Y[w-1] += 1
  s.add((h-1, w-1)) #タプルを使う
I = [i for i in range(H) if X[i] == max(X)]
J = [j for j in range(W) if Y[j] == max(Y)]
flag = 0
for i in I:
  for j in J:
    if (i, j) not in s:
      flag = 1
      print(max(X)+max(Y))
      break
  if flag == 1:
    break
if flag == 0:
  print(max(X)+max(Y)-1)

Fixed submission:
H, W, M = map(int, input().split())
X = [0 for i in range(H)]
Y = [0 for j in range(W)]
s = set([])
for i in range(M):
  h, w = map(int, input().split())
  X[h-1] += 1
  Y[w-1] += 1
  s.add((h-1, w-1)) #タプルを使う
mX = max(X)
mY = max(Y)
I = [i for i in range(H) if X[i] == mX]
J = [j for j in range(W) if Y[j] == mY]
flag = 0
for i in I:
  for j in J:
    if {(i, j)} <= s:
      continue
    flag = 1
    print(mX+mY)
    break
  if flag == 1:
    break
if flag == 0:
  print(mX+mY-1)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
if K % 2 == 0:
  print(-1)
else:
  A = 7 % K
  X = 7 % K
  n = 1
  while A != 0:
    X = (X * 10) % K
    A = (A + X) % K
    n += 1
  print(n)

Fixed submission:
K = int(input())
A = 7 % K
X = 7 % K
n = 1
f = 0
while A != 0:
  X = (X * 10) % K
  A = (A + X) % K
  n += 1
  if n > K:
    print(-1)
    f = 1
    break
if f == 0:
  print(n)
Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]
b = [0]
p = 0
q = 0
for i in range(N):
  if p + A[i] > K:
    break
  a.append(p+A[i])
  p += A[i]
for i in range(M):
  if q + B[i] > K:
    break
  b.append(q+B[i])
  q += B[i]
ans = 0
for n, s in enumerate(a):
  if s > K:
    break
  for m, t in enumerate(b):
    if s + t <= K:
      ans = max(ans, n+m)
    else:
      break
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]
b = [0]
p = 0
for i in range(N):
  p += A[i]
  a.append(p)
q = 0
for j in range(M):
  q += B[j]
  b.append(q)
ans = 0
j = M
for i in range(N+1):
  if a[i] > K:
    break
  while a[i] + b[j] > K:
    j -= 1
  ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]
b = [0]
p = 0
q = 0
for i in range(N):
  a.append(p+A[i])
  p += A[i]
for i in range(M):
  b.append(q+B[i])
  q += B[i]
ans = 0
for n, s in enumerate(a):
  if s > K:
    break
  for m, t in enumerate(b):
    if s + t <= K:
      ans = max(ans, n+m)
    else:
      break
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]
b = [0]
p = 0
for i in range(N):
  p += A[i]
  a.append(p)
q = 0
for j in range(M):
  q += B[j]
  b.append(q)
ans = 0
j = M
for i in range(N+1):
  if a[i] > K:
    break
  while a[i] + b[j] > 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()))
A.sort()
T = [1] * N
for i in range(N):
  if T[i] == 1:
    for j in range(N):
      if i != j:
        if A[i] == A[j]:
          T[i] = 0
        if T[j] == 1 and A[j] % A[i] == 0:
          T[j] = 0
print(sum(T))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
M = max(A)
num = [0] * (M)
T = [0] * (M)
for a in A:
  num[a-1] += 1
  T[a-1] = 1
for i in range(M):
  if num[i] != 0 and T[i] == 1:
    n = 2 * (i + 1)
    while n <= M:
      T[n-1] = 0
      n += (i + 1)
ans = 0
for i in range(M):
  if T[i] == 1 and num[i] == 1:
    ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
T = [1] * (N)
for i in range(N):
  for j in range(N):
    if T[j] == 1 and i != j and A[j] % A[i] == 0:
      T[j] = 0
print(sum(T))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
M = max(A)
num = [0] * (M)
T = [0] * (M)
for a in A:
  num[a-1] += 1
  T[a-1] = 1
for i in range(M):
  if num[i] != 0 and T[i] == 1:
    n = 2 * (i + 1)
    while n <= M:
      T[n-1] = 0
      n += (i + 1)
ans = 0
for i in range(M):
  if T[i] == 1 and num[i] == 1:
    ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
T = [1] * (N)
for i in range(N):
  for j in range(N):
    if i != j and A[j] % A[i] == 0:
      T[j] = 0
print(sum(T))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
M = max(A)
num = [0] * (M)
T = [0] * (M)
for a in A:
  num[a-1] += 1
  T[a-1] = 1
for i in range(M):
  if num[i] != 0 and T[i] == 1:
    n = 2 * (i + 1)
    while n <= M:
      T[n-1] = 0
      n += (i + 1)
ans = 0
for i in range(M):
  if T[i] == 1 and num[i] == 1:
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
L = [[0 for i in range(S+1)] for j in range(N+1)]
L[0][0] = 1
for j, a in enumerate(A):
  for i in range(S+1):
    if i < a:
      L[j+1][i] = (2 * L[j][i]) % mod
    else:
      L[j+1][i] = (2 * L[j][i] + L[j][i-a]) % mod
print(L[N][S])

Fixed submission:
N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
L = [[0 for i in range(S+1)] for j in range(N+1)]
L[0][0] = 1
for j, a in enumerate(A):
  for i in range(S+1):
    if i < a:
      L[j+1][i] = (2 * L[j][i]) % mod
    else:
      L[j+1][i] = (2 * L[j][i] + L[j][i-a]) % mod
print(L[N][S])
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
ans = ""
for s in range(len(S)):
  if S[s] == "?":
    ans += "D"
  else:
    ans += S[s]
print(ans)


Fixed submission:
S = input()
ans = ""
for s in range(len(S)):
  if S[s] == "?":
    print("D", end="")
  else:
    print(S[s], end="")
print("")

Buggy python submission (verdict: Runtime Error):
S = input()
ans = ""
for s in range(len(S)):
  if s == "?":
    ans += "D"
  else:
    ans += s
print(ans)

Fixed submission:
S = input()
ans = ""
for s in range(len(S)):
  if S[s] == "?":
    print("D", end="")
  else:
    print(S[s], end="")
print("")
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [1]
i = 1
n = 0
l = 1
while 1:
  i = A[i]
  if i not in B:
    B.append(i)
    l = l + 1
    if l == K + 1:
      print(i)
      break
  else:
    n = B.index(i)
    print(B[n + (K-n) % (l-n)])
    break

Fixed submission:
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [-1 for i in range(N+1)]
B[1] = 0
n = 1
m = 0
while 1:
  n = A[n]
  m += 1
  if m == K:
    print(n)
    break
  if B[n] == -1:
    B[n] = m
  else:
    a = (K - m) % (m - B[n])
    for i in range(a):
      n = A[n]
    print(n)
    break
Buggy python submission (verdict: Time Limit Exceeded):
S = list(map(int, input()))
L = len(S)
mod = 2019
T = []
t = 0
p = 1
for i in range(L-1, -1, -1):
  t = (t + S[i] * p) % mod
  T.append(t)
  p = (p * 10) % mod
R = [T.count(t) for t in set(T)]
print(T.count(0) + sum([r * (r-1) // 2 for r in R]))

Fixed submission:
S = list(map(int, input()))
L = len(S)
mod = 2019
T = []
A = [0 for i in range(mod)]
t = 0
p = 1
for i in range(L-1, -1, -1):
  t = (t + S[i] * p) % mod
  A[t] += 1
  p = (p * 10) % mod
print(A[0] + sum([a * (a-1) // 2 for a in A]))

Buggy python submission (verdict: Time Limit Exceeded):
S = list(map(int, input()))
L = len(S)
mod = 2019
ans = 0
for i in range(L):
  a = 0
  j = i
  while j < L:
    a = (10 * a + S[j]) % mod
    if a == 0:
      ans += 1
    j += 1
print(ans)

Fixed submission:
S = list(map(int, input()))
L = len(S)
mod = 2019
T = []
A = [0 for i in range(mod)]
t = 0
p = 1
for i in range(L-1, -1, -1):
  t = (t + S[i] * p) % mod
  A[t] += 1
  p = (p * 10) % mod
print(A[0] + sum([a * (a-1) // 2 for a in A]))
Buggy python submission (verdict: Runtime Error):
import math
R = int(input())
print(R * 2 * math.PI)

Fixed submission:
import math
R = int(input())
print(R * 2 * math.pi)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
for i in range(1, N+1):
  print(A.count(i))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = [0 for i in range(N)]
for a in A:
  ans[a-1] += 1
for i in range(N):
  print(ans[i])
Buggy python submission (verdict: Runtime Error):
s = input()
if s[2] == s[3] and s[4] == s[5]:
  print("Yes")
else:
  print("No)

Fixed submission:
s = input()
if s[2] == s[3] and s[4] == s[5]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N, M, K = map(int, input().split())
A = [set() for i in range(N)]
B = [set() for i in range(N)]
for i in range(M):
  a, b = map(lambda x:int(x)-1, input().split())
  A[a].add(b)
  A[b].add(a)
for i in range(K):
  a, b = map(lambda x:int(x)-1, input().split())
  B[a].add(b)
  B[b].add(a)
P = [-1 for i in range(N)]
Q = []
k = -1
for i in range(N):
  if P[i] == -1:
    q = {i}
    k += 1
    P[i] = k
    d = deque([i])
    while len(d):
      s = d.pop()
      for t in A[s]:
        if P[t] == -1:
          P[t] = k
          q.add(t)
          d.append(t)
    Q.append(q)
for i in range(N):
  print(len(Q[P[i]] - A[i] - B[i]) - 1)

Fixed submission:
from collections import deque
N, M, K = map(int, input().split())
A = [[] for i in range(N)]
B = [[] for i in range(N)]
for i in range(M):
  a, b = map(lambda x:int(x)-1, input().split())
  A[a].append(b)
  A[b].append(a)
for i in range(K):
  a, b = map(lambda x:int(x)-1, input().split())
  B[a].append(b)
  B[b].append(a)
P = [-1 for i in range(N)]
Q = []
k = -1
for i in range(N):
  if P[i] == -1:
    q = 1
    k += 1
    P[i] = k
    d = deque([i])
    while len(d):
      s = d.pop()
      for t in A[s]:
        if P[t] == -1:
          P[t] = k
          q += 1
          d.append(t)
    Q.append(q)
for i in range(N):
  ans = Q[P[i]] - len(A[i]) - 1
  for j in B[i]:
    if P[i] == P[j]:
      ans -= 1
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N, M, K = map(int, input().split())
A = [[] for i in range(N)]
B = [[] for i in range(N)]
for i in range(M):
  a, b = map(lambda x:int(x)-1, input().split())
  A[a].append(b)
  A[b].append(a)
for i in range(K):
  a, b = map(lambda x:int(x)-1, input().split())
  B[a].append(b)
  B[b].append(a)
P = [-1 for i in range(N)]
k = 0
for i in range(N):
  if P[i] == -1:
    k += 1
    P[i] = k
    d = deque([i])
    while len(d):
      s = d.pop()
      for t in A[s]:
        if P[t] == -1:
          P[t] = k
          d.append(t)
for i in range(N):
  ans = 0
  for j in range(N):
    if P[i] == P[j] and i != j and j not in A[i] and j not in B[i]:
      ans += 1
  print(ans)

Fixed submission:
from collections import deque
N, M, K = map(int, input().split())
A = [[] for i in range(N)]
B = [[] for i in range(N)]
for i in range(M):
  a, b = map(lambda x:int(x)-1, input().split())
  A[a].append(b)
  A[b].append(a)
for i in range(K):
  a, b = map(lambda x:int(x)-1, input().split())
  B[a].append(b)
  B[b].append(a)
P = [-1 for i in range(N)]
Q = []
k = -1
for i in range(N):
  if P[i] == -1:
    q = 1
    k += 1
    P[i] = k
    d = deque([i])
    while len(d):
      s = d.pop()
      for t in A[s]:
        if P[t] == -1:
          P[t] = k
          q += 1
          d.append(t)
    Q.append(q)
for i in range(N):
  ans = Q[P[i]] - len(A[i]) - 1
  for j in B[i]:
    if P[i] == P[j]:
      ans -= 1
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A = []
for i in range(N):
  A.append(input())
a = collections.Counter(A)
ret = [letter for letter,count in a.most_common() if count == a.most_common()[0][1]]
ret.sort()
for r in ret:
  print(r)

Fixed submission:
N = int(input())
d = {}
for i in range(N):
  s = input()
  if s in d.keys():
    d[s] += 1
  else:
    d[s] = 1
mx = 0
for i in d.values():
  mx = max(mx, i)
for i in sorted(d.items()):
  if i[1] == mx:
    print(i[0])

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A = []
for i in range(N):
  A.append(input())
a = collections.Counter(A)
n = a.most_common()[0][1]
l = []
for i in range(len(a)):
  if a.most_common()[i][1] != n:
    break
  l.append(a.most_common()[i][0])
l.sort()
for o in l:
  print(o)

Fixed submission:
N = int(input())
d = {}
for i in range(N):
  s = input()
  if s in d.keys():
    d[s] += 1
  else:
    d[s] = 1
mx = 0
for i in d.values():
  mx = max(mx, i)
for i in sorted(d.items()):
  if i[1] == mx:
    print(i[0])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = [[input(), 1]]
for i in range(N-1):
  p = input()
  f = 0
  for n in range(len(a)):
    if a[n][0] == p:
      a[n][1] = a[n][1] + 1
      f = 1
      break
  if f == 0:
    a.append([p, 1])
MAX = 0
MAX_n = []
for n in range(len(a)):
  if a[n][1] == MAX:
    MAX_n.append(a[n][0])
  elif a[n][1] > MAX:
    MAX = a[n][1]
    MAX_n = [a[n][0]]
MAX_n.sort()
for i in MAX_n:
  print(i)

Fixed submission:
N = int(input())
d = {}
for i in range(N):
  s = input()
  if s in d.keys():
    d[s] += 1
  else:
    d[s] = 1
mx = 0
for i in d.values():
  mx = max(mx, i)
for i in sorted(d.items()):
  if i[1] == mx:
    print(i[0])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
l = []
f = 0
for a in A:
  if a in l:
    f = 1
    print("NO")
    break
  else:
    l.append(a)
if f == 0:
  print("YES")

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
B = list(set(A))
if len(A) == len(B):
  print("YES")
else:
  print("NO")