Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys

args = sys.argv[1]
args = int(args)
print(args*args)

Fixed submission:
from sys import stdin

a = stdin.readline().rstrip()
a = int(a)
print(a*a)

Buggy python submission (verdict: Runtime Error):
args = sys.argv[1]
print(args*args)

Fixed submission:
from sys import stdin

a = stdin.readline().rstrip()
a = int(a)
print(a*a)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
ans = []
for i in range(n-1):
    for j in range(i+1, n):
        ans.append((a[i]*a[j])%mod)
print(sum(ans)%mod)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
x = sum(a)-a[0]
ans = 0
for i in range(n-1):
    ans += (a[i]*x)%mod
    x -= a[i+1]
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
s = input()
ans = []
cnt = 0
for i in range(len(s)):
    if s[i] == "R":
        cnt += 1
    else: 
        ans.append(cnt)
        cnt = 0
print(max(ans))

Fixed submission:
s = input()
ans = 0
if "RRR" in s:
    ans = 3
elif "RR" in s:
    ans = 2
elif "R" in s:
    ans = 1
print(ans)
Buggy python submission (verdict: Runtime Error):
x = int(input())
if 400 <= x <= 599: ans = 8
elif 600 <= x <= 799: ans = 7
elif 800 <= x <- 999: ans = 6
elif 1000 <= x <= 1199: ans = 5
elif 1200 <= x <= 1399: ans = 4
elif 1400 <= x <= 1599: ans = 3
elif 1600 <= x <= 1799: ans = 2
elif 1800 <= x <= 1999: ans = 1
print(ans)

Fixed submission:
x = int(input())
if 400 <= x <= 599: ans = 8
elif 600 <= x <= 799: ans = 7
elif 800 <= x <= 999: ans = 6
elif 1000 <= x <= 1199: ans = 5
elif 1200 <= x <= 1399: ans = 4
elif 1400 <= x <= 1599: ans = 3
elif 1600 <= x <= 1799: ans = 2
elif 1800 <= x <= 1999: ans = 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
A = list(map(int, input().split()))
a = 1
for i in range(k):
    a *= A[i]
ans = a
for i in range(k,n):
    a = a//A[i-k] * A[i]
    if ans < a: print("Yes")
    else: print("No")
    ans = a

Fixed submission:
n,k = map(int, input().split())
A = list(map(int, input().split()))
a = 0
for i in range(k):
    a += A[i]
ans = a
for i in range(k,n):
    a = a-A[i-k] + A[i]
    if ans < a: print("Yes")
    else: print("No")
    ans = a
Buggy python submission (verdict: Runtime Error):
from collections import Counter 
n = int(input())
x = list(map(int, input().split()))
A = [x[i] for i in range(n) if i!=n-1 and x[i] != x[i+1]]
if A[-1] != x[-1]: A.append(x[-1])
a = Counter(A)
cnt = 0
money = 1000
b = 0
for i in range(len(A)-1):
    a[A[i]] -= 1
    if a[A[i]] == 0: a.pop(A[i])

    if i == len(A)-2 and cnt >0:
        if A[i] < A[i+1]: continue

    if b != 0 and b < A[i]:
        money += cnt * A[i]
        cnt = 0
        b = 0
    else:
        flag = False
        for j in a.keys():
            if A[i] < j:
                flag = True
                break
        if flag:
            cnt += money//A[i]
            money %= A[i]
            b = A[i]
if cnt > 0:
    money += cnt * A[-1]
print(money)

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

cnt = 0
money = 1000
b = 0
for i in range(n-1):
    if cnt == 0 and A[i] < A[i+1]:
        cnt += money//A[i]
        money %= A[i]
        b = A[i]
    else:
        money += cnt * A[i]
        cnt = 0
        if A[i] < A[i+1]:
            cnt += money//A[i]
            money %= A[i]
if cnt > 0:
    money += cnt * max(A[-1], b)
print(money)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())

ans = [0] * n
for v in itertools.product(list(range(1,n+1)), repeat=3):
    x,y,z = v[0], v[1], v[2]
    a = x*x + y*y + z*z + x*y + y*z + z*x
    if a <= n:ans[a-1] += 1
    else: continue
for i in ans: print(i)

Fixed submission:
n = int(input())
ans = [0] * n
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            a = x * x + y * y + z * z + x * y + x * z + y * z
            if a > n: continue
            ans[a-1] += 1
for i in ans: print(i)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
ans = [0] * n
for x,y,z in itertools.combinations_with_replacement(list(range(1,n+1)),3):
    a = x**2 + y**2 + z**2 + x*y + y*z + z*x
    if a > n: continue
    if x==y==z: b = 1
    elif x==y or x==z or y==z: b = 3
    else: b = 6
    ans[a-1] = b
for i in ans: print(i)

Fixed submission:
n = int(input())
ans = [0] * n
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            a = x * x + y * y + z * z + x * y + x * z + y * z
            if a > n: continue
            ans[a-1] += 1
for i in ans: print(i)

Buggy python submission (verdict: Runtime Error):
n = int(input())
N = 1
while N**2 < n:
    N += 1
ans = [0] * n
for x in range(1,N+1):
    for y in range(1,N+1):
        for z in range(1,N+1):
            a = x**2+y**2+z**2 + x*y+y*z+z*x
            if a >= 20: continue
            if x==y==z: b = 1
            elif x==y or y==z or x==z: b = 3
            else: b = 6
            ans[a-1] =b
            break
for i in ans: print(i)

Fixed submission:
n = int(input())
ans = [0] * n
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            a = x * x + y * y + z * z + x * y + x * z + y * z
            if a > n: continue
            ans[a-1] += 1
for i in ans: print(i)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n,m,k = map(int, input().split())
A = deque(map(int, input().split()))
B = deque(map(int, input().split()))
a,b = A.popleft(), B.popleft()
ans = 0
ok = False
while k > 0:
    if ok: break
    if a < b and k-a >= 0:
        k -= a
        ans += 1
        if A: a = A.popleft()
        else: a = float("INF")
    elif a > b and k-b >= 0:
        k -= b
        ans += 1
        if B: b = B.popleft()
        else: b = float("INF")
    elif a == b:
        for i in range(min(len(A), len(B))):
            if A[i] == B[i]:
                if k-A[i] >=0: 
                    k-= A[i]
                    ans += 1
                else: 
                    ok = True
            elif A[i] < B[i] and k-A[i] >= 0:
                k -= A[i]
                ans += 1
                A = deque(list(A)[i+1:])
            elif A[i] > B[i] and k-B[i]>=0:
                k -= B[i]
                ans += 1
                B = deque(list(B)[i+1:])
            else: ok = True
    else: break
print(ans)

Fixed submission:
import numpy
import bisect
n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]+list(numpy.cumsum(A))
b = [0]+list(numpy.cumsum(B))
ans = 0
# print(a,b)
for i in range(len(a)):
    x = k - a[i]
    if x >= 0:
        j = bisect.bisect_right(b,x)-1
        ans = max(ans, i+j)
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import deque
n,m,k = map(int, input().split())
A = deque(map(int, input().split()))
B = deque(map(int, input().split()))

a,b = A.popleft(), B.popleft()
ans = 0
ok = False
while k > 0:
    if ok: break
    if a < b and k-a >= 0:
        k -= a
        ans += 1
        if A: a = A.popleft()
        else: a = float("INF")
    elif a > b and k-b >= 0:
        k -= b
        ans += 1
        if B: b = B.popleft()
        else: b = float("INF")
    elif a == b:
        for i in range(min(len(A), len(B))):
            if A[i] == B[i]:
                if k-A[i] >=0: 
                    k-= A[i]
                    ans += 1
                else: 
                    ok = True
                continue
            if A[i] < B[i] and k-A[i] >= 0:
                k -= A[i]
                ans += 1
                A = A[i+1:]
            elif A[i] > B[i] and k-B[i]>=0:
                k -= B[i]
                ans += 1
                B = B[i+1:]
            else: ok = True
    else: break
print(ans)

Fixed submission:
import numpy
import bisect
n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]+list(numpy.cumsum(A))
b = [0]+list(numpy.cumsum(B))
ans = 0
# print(a,b)
for i in range(len(a)):
    x = k - a[i]
    if x >= 0:
        j = bisect.bisect_right(b,x)-1
        ans = max(ans, i+j)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = [chr(i) for i in range(ord("a"), ord("z"))]
ans = []
while n > 26:
    ans.append(x[n%26-1])
    n //= 26
ans.append(x[n-1])
print("".join(ans[::-1]))

Fixed submission:
n = int(input())
x = [chr(i) for i in range(ord("a"), ord("z")+1)]
ans = []
while n > 26:
    ans.append(x[n%26-1])
    if n%26 == 0:
        n = n//26 -1
    else:n //= 26
ans.append(x[n-1])
print("".join(ans[::-1]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
L = [0]*(N+1)
R = [0]*(N+1)
for i in range(N):
  L[i+1] = L[i]^a[i]
  R[N-i-1] = R[N-i]^a[N-i-1]
  ans = [None]*N
for i in range(N):
  ans[i] = L[i]^R[i+1]
print(*ans)

Fixed submission:
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    a = list(map(int, input().split()))
    L = [0]*(N+1)
    R = [0]*(N+1)
    for i in range(N):
        L[i+1] = L[i]^a[i]
        R[N-i-1] = R[N-i]^a[N-i-1]
    ans = [None]*N
    for i in range(N):
        ans[i] = L[i]^R[i+1]
    print(*ans)
    # print(L,R)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
L = [0]*(N+1)
R = [0]*(N+1)
for i in range(N):
  L[i+1] = L[i]^a[i]
  R[N-i-1] = R[N-i]^a[N-i-1]
  ans = [None]*N
for i in range(N):
  ans[i] = L[i]^R[i+1]
print(*ans)

Fixed submission:
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    a = list(map(int, input().split()))
    L = [0]*(N+1)
    R = [0]*(N+1)
    for i in range(N):
        L[i+1] = L[i]^a[i]
        R[N-i-1] = R[N-i]^a[N-i-1]
    ans = [None]*N
    for i in range(N):
        ans[i] = L[i]^R[i+1]
    print(*ans)
    # print(L,R)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
x,y = map(int, input().split())
for v in itertools.product([2,4], repeat=x):
    if sum(v) == y:
        print("Yes")
        exit()
print("No")

Fixed submission:
x,y = map(int, input().split())
for a in range(x+1):
    b = x-a
    if 2*a+4*b==y or 4*a+2*b==y:
        print("Yes")
        exit()
print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
A.sort()
check = [0]*(max(A)+1)
for a in A:
    i = 1
    while a * i <= max(A):
        check[a*i] += 1
        i += 1
cnt = 0
for a in A:
    if check[a] == 1: cnt += 1
print(cnt)

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

cnt = [0] * (10**6+1)
for a in A:
    if cnt[a] != 0:
        cnt[a] += 1
        continue
    for i in range(10**6+1)[a::a]:
        cnt[i] += 1
ans = 0
for a in A:
    if cnt[a] == 1:
        ans += 1
print(ans)

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

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

check = [0]*(max(A)+1)
for a in A:
    i = 1
    while a * i <= max(A):
        check[a*i] += 1
        i += 1
cnt = 0
for a in A:
    if check[a] == 1: cnt += 1
print(cnt)

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

cnt = [0] * (10**6+1)
for a in A:
    if cnt[a] != 0:
        cnt[a] += 1
        continue
    for i in range(10**6+1)[a::a]:
        cnt[i] += 1
ans = 0
for a in A:
    if cnt[a] == 1:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
a = [0] + list(map(int, input().split()))
r = [1]
k += 1
now = 1
for i in range(n):
   now = a[now]
   if now in r: break
   r.append(now)
   if len(r) == k:
     print(now)
     exit()
I = r.index(now)
if I != 0: 
  k -= I
  r = r[I:]
print(r[-1] if k%len(r)==0 else r[k%len(r)-1])

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

now = 1
check = [-1]*(n+1)

for i in range(k):
  if check[now] == -1:
    check[now] = i
    now = a[now]
  else:
    loop = i - check[now]
    afterloop = (k-(i-loop))%loop
    print(check.index((i-loop) + afterloop))
    exit()
print(now)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
a = [0] + list(map(int, input().split()))
r = [1]
k += 1
now = 1
for i in range(n):
   now = a[now]
   if now in r:break
   r.append(now)
I = r.index(now)

if len(r) > k: print(r[k-1])
else:
  if I != 0: 
    k -= I
    r = r[I:]
  print(r[-1] if k%len(r)==0 else r[k%len(r)-1])

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

now = 1
check = [-1]*(n+1)

for i in range(k):
  if check[now] == -1:
    check[now] = i
    now = a[now]
  else:
    loop = i - check[now]
    afterloop = (k-(i-loop))%loop
    print(check.index((i-loop) + afterloop))
    exit()
print(now)
Buggy python submission (verdict: Time Limit Exceeded):
import math
x = int(input())

if x == 1: print(0, -1)

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

    l = make_divisors(x)
    for i in l:
        for j in range(i+1):
            if j**5 - (-(i-j)) ** 5 == x:
                print(j, -(i-j))
                exit()

Fixed submission:
x = int(input())

for i in range(-120, 120):
    for j in range(-120, 120):
        if x == i ** 5 - j **5:
            print(i, j)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    for j in range(i+2, n):
        if a[i] >= abs(i-j) or a[j] >= abs(i-j):
          if a[i] > abs(i-(n-1)): break
          else: continue 
        if abs(i-j) == a[i]+a[j]: ans += 1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = []
c = {}

ans = 0
for i in range(n):
    b.append(a[i]+i+1)
    x = -a[i]+i+1
    if x in c:
        c[x] += 1
    else:
        c[x] = 1
for i in range(n):
    if b[i] in c:
        ans += c[b[i]]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    for j in range(i+2, n):
        if a[i] >= abs(i-j) or a[j] >= abs(i-j): continue
        if abs(i-j) == a[i]+a[j]: ans += 1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = []
c = {}

ans = 0
for i in range(n):
    b.append(a[i]+i+1)
    x = -a[i]+i+1
    if x in c:
        c[x] += 1
    else:
        c[x] = 1
for i in range(n):
    if b[i] in c:
        ans += c[b[i]]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n,m,q = map(int, input().split())
abc = []
d = []
for _ in range(q):
    A,B,C,D = map(int, input().split())
    abc.append([A,B,C])
    d.append(D)

l = range(1,m+1)
point = 0
for v in itertools.combinations_with_replacement(l,n):
    p = 0
    for i in range(n-1):
        for j in range(i+1, n):
            if [i+1,j+1, abs(v[j]-v[i])] in abc:
                p += d[abc.index([i+1,j+1, abs(v[j]-v[i])])]
    if point < p: point = p
print(point)

Fixed submission:
import itertools
n,m,q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]

l = range(1,m+1)
point = 0
for v in itertools.combinations_with_replacement(l,n):
    p = 0
    for a,b,c,d in abcd:
        if v[b-1] - v[a-1] == c:
            p += d
    if p > point: point = p
print(point)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int, input().split())
print(max([int(a*x/b)-a*int(x/b) for x in range(1,n+1)]))

Fixed submission:
import math
a,b,n = map(int, input().split())
if n >= b-1:
    print(math.floor(a*(b-1)/b) - a*math.floor((b-1)/b))
else:
    print(math.floor(a*n/b) - a*math.floor(n/b))
Buggy python submission (verdict: Runtime Error):
import bisect
N = int(input())
S = list(input())
R_i = []
G_i = []
B_i = []
for i in range(N):
  if S[i] == "R": R_i.append(i)
  elif S[i] == "G": G_i.append(i)
  else: B_i.append(i)

r = len(R_i)
g = len(G_i)
b = len(B_i)

ans = 0
for i in range(N):
  for j in range(1, N-i):
    if S[i] == "R":
      print(i+j in G_i , b - bisect.bisect_right(B_i,i + j) > 0)
      if i+j in G_i and b - bisect.bisect_right(B_i,i + 2 * j) > 0:
        ans += b - bisect.bisect_right(B_i,i + 2 * j)
        if i + j + j in b: ans -= 1
      elif i+ j in B_i and g - bisect.bisect_right(G_i,i + 2 * j) > 0:
        ans += g - bisect.bisect_right(G_i,i + 2 * j)
        if i + j + j in g: ans -= 1
    elif S[i] == "G":
      if i+j in R_i and b - bisect.bisect_right(B_i,i + 2 * j) > 0:
        ans += b - bisect.bisect_right(B_i,i + 2 * j)
        if i + j + j in b: ans -= 1
      elif i+j in B_i and r - bisect.bisect_right(R_i,i + 2 * j) > 0:
        ans += r - bisect.bisect_right(R_i,i + 2 * j)
        if i + j + j in r: ans -= 1
    else:
      if i+j in R_i and g - bisect.bisect_right(G_i,i + 2 * j) > 0:
        ans += g - bisect.bisect_right(G_i,i + 2 * j)
        if i + j + j in g: ans -= 1
      elif i+j in G_i and r - bisect.bisect_right(R_i,i + 2 * j) > 0:
        ans += r - bisect.bisect_right(R_i,i + 2 * j)
        if i + j + j in r: ans -= 1
print(ans)

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

R = S.count("R")
G = S.count("G")
B = S.count("B")

def f(S):
  N = len(S)
  ret = 0
  for i in range(N):
    for j in range(i+1, N):
      k = j + j -i
      if k >= N:
        break
      if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
        ret += 1
  return ret

ans = R * B * G - f(S)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
Q = int(input())

reverse = True
for _ in range(Q):
  q = list(input())
  if q[0] == "1":
    if reverse: reverse = False
    else: reverse = True
  else:
    if reverse:
      if q[2] == "1": S.insert(0, q[4])
      else: S.append(q[4])
    else:
      if q[2] == "1": S.append(q[4])
      else: S.insert(0, q[4])

print("".join(S) if reverse else "".join(S[::-1])) 

Fixed submission:
from collections import deque
S = deque(input())
Q = int(input())
q = [list(input().split()) for _ in range(Q)]

ok = True #Falseで反転させる
for i in range(Q):
    l = q[i]
    if l[0] == "1":
        if ok: ok = False
        else: ok = True
    else:
        if ok:
            if l[1] == "1": S.appendleft(l[2])
            else: S.append(l[2])
        else:
            if l[1] == "1": S.append(l[2])
            else: S.appendleft(l[2])
if not ok:
    S = list(S)[::-1]
print("".join(list(S)))

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

for _ in range(Q):
  q = list(input())
  if q[0] == "1":
    S = S[::-1]
  else:
    if q[2] == "1": S.insert(0, q[4])
    else: S.append(q[4])

print("".join(S)) 

Fixed submission:
from collections import deque
S = deque(input())
Q = int(input())
q = [list(input().split()) for _ in range(Q)]

ok = True #Falseで反転させる
for i in range(Q):
    l = q[i]
    if l[0] == "1":
        if ok: ok = False
        else: ok = True
    else:
        if ok:
            if l[1] == "1": S.appendleft(l[2])
            else: S.append(l[2])
        else:
            if l[1] == "1": S.append(l[2])
            else: S.appendleft(l[2])
if not ok:
    S = list(S)[::-1]
print("".join(list(S)))
Buggy python submission (verdict: Runtime Error):
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
b = [int(input()) for _ in range(N)]

for i in range(N):
  if b[i] in A1:
    if len(list(set(A1))) == 1:
      A1 = [0] * 3
    else:
      A1[A1.index(b[i])] = 0
  elif b[i] in A2:
    if len(list(set(A2))) == 1:
      A2 = [0] * 3
    else:
      A2[A2.index(b[i])] = 0
  elif b[i] in A3:
    if len(list(set(A3))) == 1:
      A3 = [0] * 3
    else:
      A3[A3.index(b[i])] = 0


if A1[0] == 0 and A1[0] == A2[0] == A3[0]:
  ans = "Yes"
elif A1[1] == 0 and A1[1] == A2[1] == A3[1]:
  ans = "Yes"
elif A1[2] == 0 and A1[2] == A2[2] == A3[2]:
  ans = "Yes"
elif A1[0] == 0 and A1[0] == A2[1] == A3[2]:
  ans = "Yes"
elif A1[2] == 0 and A1[2] == A2[1] == A3[0]:
  ans = "Yes"
elif A[0] == [0] * 3 or A[1] == [0] * 3 or A[2] == [0] * 3:
  ans = "Yes"
else:
  ans = "No"

print(ans)

Fixed submission:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
b = [int(input()) for _ in range(N)]

for i in range(N):
  if b[i] in A1:
    if len(list(set(A1))) == 1:
      A1 = [0] * 3
    else:
      A1[A1.index(b[i])] = 0
  elif b[i] in A2:
    if len(list(set(A2))) == 1:
      A2 = [0] * 3
    else:
      A2[A2.index(b[i])] = 0
  elif b[i] in A3:
    if len(list(set(A3))) == 1:
      A3 = [0] * 3
    else:
      A3[A3.index(b[i])] = 0


if A1[0] == 0 and A1[0] == A2[0] == A3[0]:
  ans = "Yes"
elif A1[1] == 0 and A1[1] == A2[1] == A3[1]:
  ans = "Yes"
elif A1[2] == 0 and A1[2] == A2[2] == A3[2]:
  ans = "Yes"
elif A1[0] == 0 and A1[0] == A2[1] == A3[2]:
  ans = "Yes"
elif A1[2] == 0 and A1[2] == A2[1] == A3[0]:
  ans = "Yes"
elif A1 == [0] * 3 or A2 == [0] * 3 or A3 == [0] * 3:
  ans = "Yes"
else:
  ans = "No"

print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

ok = False
n = [-1] * M
for s, c in sc:
  if n[s-1] != -1:
    if n[s-1] == c: continue
    ans = -1
    ok = True
    break
  n[s-1] = c

if n[0] == 0:
  ans = -1
  ok = True
if not ok:
  ans = ""
  for i in range(M):
    if i == 0 and n[i] == -1:
      ans += "1"
    elif n[i] == -1:
      ans += "0"
    else:
      ans += str(n[i])
print(ans)

Fixed submission:
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

ans = ["0"] * N
if N > 1: ans[0] = "1"
rep = {}

ok = True
for s, c in sc:
  ans[s - 1] = str(c)
  if s in rep and rep[s] != str(c):
    ok = False
  else:
    rep[s] = str(c)

if ok:
  if ans[0] == "0" and N > 1:
    ok = False

print("".join(ans) if ok else -1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input() for _ in range(N))

a = sorted(list(set(S)))
b = [0] * len(a)
for i in range(N):
  b[a.index(S[i])] += 1
  
for j in range(len(a)):
  if b[j] == max(b):
    print(a[j])

Fixed submission:
N = int(input())
S = list(input() for _ in range(N))

import collections
a = collections.Counter(S).most_common()
ans = []
for i in range(len(a)):
  if i == 0:
    ans.append(a[i][0])
  elif a[i - 1][1] == a[i][1]:
    ans.append(a[i][0])
  else:
    break
ans.sort()

for j in ans:
  print(j)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input() for _ in range(N))

a = list(set(S))

b = []
n = 0
for i in range(len(a)):
  if n == S.count(a[i]):
    b.append(a[i])
  elif n < S.count(a[i]):
    b = [a[i]]
    n = S.count(a[i])

b.sort()
for j in b:
  print(j)

Fixed submission:
N = int(input())
S = list(input() for _ in range(N))

import collections
a = collections.Counter(S).most_common()
ans = []
for i in range(len(a)):
  if i == 0:
    ans.append(a[i][0])
  elif a[i - 1][1] == a[i][1]:
    ans.append(a[i][0])
  else:
    break
ans.sort()

for j in ans:
  print(j)
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
H = sorted(list(map(int, input().split())))
if k >= n: ans = 0
elif k == 0: ans = sum(H)
else: ans = sum(H[-k])
print(ans)

Fixed submission:
N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
for i in range(K):
  if len(H) <= 0:
    break
  H.pop(-1)
print(sum(H) if len(H) > 0 else 0)