Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
K = int(input())

import gcd from math

def g(a,b,c):
  retunr gcd(gcd(a,b),c)

a = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      a += g(i,j,k)

print(a)

Fixed submission:
K = int(input())

from math import gcd

def g(a,b,c):
  return gcd(gcd(a,b),c)

a = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      a += g(i,j,k)

print(a)
Buggy python submission (verdict: Time Limit Exceeded):
N,X,Y = map(int,input().split())

def f(i,j):
  if j <= X:
    return j-i
  elif Y <= i:
    return j-i
  elif X <= i and j <= Y:
    return min(j-i,(i-X)+1+(Y-j))
  elif i <= X and Y <= j:
    return (X-i)+1+(j-Y)
  elif i <= X and X <= j and j <= Y:
    return (X-i)+min(j-X,1+(Y-j))
  else:
    return (j-Y)+min(Y-i,(i-X)+1)

A = []

for k in range(1,N,1):
  for l in range(k+1,N+1,1):
    A.append(f(k,l))

for k in range(1,N,1):
  print(A.count(k))

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

def f(i,j):
  if j <= X:
    return j-i
  elif Y <= i:
    return j-i
  elif X <= i and j <= Y:
    return min(j-i,(i-X)+1+(Y-j))
  elif i <= X and Y <= j:
    return (X-i)+1+(j-Y)
  elif i <= X and X <= j and j <= Y:
    return (X-i)+min(j-X,1+(Y-j))
  else:
    return (j-Y)+min(Y-i,(i-X)+1)

A = [0]*(N-1)

for k in range(1,N,1):
  for l in range(k+1,N+1,1):
    A[f(k,l)-1] += 1

for k in range(1,N,1):
  print(A[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

B = []
for i in range(0,N-1,1):
  a = 0
  for j in range(i+1,N,1):
    if A[i] == A[j]:
      a += 1
  B.append(a)

C = []
for i in range(N):
  b = 0
  for j in range(N):
    if A[i] == A[j]:
      b += 1
  C.append(b-1)
  
for i in range(N):
  print(sum(B)-C[i])
      
    

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

B = [0]*N
for i in range(N):
  B[A[i]-1] += 1

s = 0
for i in range(N):
  s += B[i]*(B[i]-1)//2

for i in range(N):
  print(s-B[A[i]-1]+1)
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
A = list(map(int,input()))
B = []
M = math.ceil(math.log(N,2)) 

for i in range(N):
  a = 0
  for j in range(1,M+1,1):
    a += math.floor((N-1)/(2**j))-math.floor((i)/(2**j))-math.floor((N-1-i)/(2**j))
  if a == 0:
    B.append(1)
  else:
    B.append(0)
    
b = 0
for i in range(N):
  b += B[i]*A[i]
if b % 2 == 1:
  print(1)
else:
  for i in range(N):
    if A[i] == 2:
      print(0)
      break
  else:
    for i in range(N):
      A[i] = (A[1]-1)//2
    for i in range(N):
      a = 0
      C = []
      for j in range(1,M+1,1):
        a += math.floor((N-1)/(2**j))-math.floor((i)/(2**j))-math.floor((N-1-i)/(2**j))
      if a == 0:
        C.append(1)
      else:
        C.append(0)
    
    for i in range(N):
      b += C[i]*A[i]
    if b % 2 == 1:
      print(2)
    else:
      print(0)

Fixed submission:
import math

N = int(input())
A = list(map(int,input()))
B = []

for i in range(N):
  if N-1 == (i|N-1-i):
    B.append(1)
  else:
    B.append(0)
    
b = 0
for i in range(N):
  b += B[i]*A[i]
if b % 2 == 1:
  print(1)
else:
  for i in range(N):
    if A[i] == 2:
      print(0)
      break
  else:
    c = 0
    for i in range(N):
      A[i] = (A[i]-1)//2
      c += B[i]*A[i]
    if c % 2 == 1:
      print(2)
    else:
      print(0)

Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
A = list(map(int,input()))

if N == 2:
  print(abs(A[0]-A[1]))

elif (N+sum(A)) % 2 == 1:
  print(1)
else:
  for i in range(N):
    if A[i] == 2:
      print(0)
      break
    else:
      B = []
      C = []
      M = math.ceil(math.log(N,A)) 
      for i in range(N-1):
        B.append(abs(A[i]-A[i+1]))
        a = 0
        for j in range(1,M+1,1):
          a += math.floor((N-2)/(2**j))-math.floor((i)/(2**j))-math.floor((N-2-i)/(2**j))
        if a == 0:
          C.append(1)
        else:
          C.append(0)
      b = 0
      for i in range(N-1):
        b += B[i]*C[i]
      if b % 4 == 0:
        print(0)
      else:
        print(2)

Fixed submission:
import math

N = int(input())
A = list(map(int,input()))
B = []

for i in range(N):
  if N-1 == (i|N-1-i):
    B.append(1)
  else:
    B.append(0)
    
b = 0
for i in range(N):
  b += B[i]*A[i]
if b % 2 == 1:
  print(1)
else:
  for i in range(N):
    if A[i] == 2:
      print(0)
      break
  else:
    c = 0
    for i in range(N):
      A[i] = (A[i]-1)//2
      c += B[i]*A[i]
    if c % 2 == 1:
      print(2)
    else:
      print(0)
Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
Q = N//(A + B)
if N - Q * (A + B) > A:
  print(Q * A + A)
else:
  print(Q * A + N - Q * (A + B))

Fixed submission:
S = input()
if S[0] == S[1] and S[1] == S[2]:
  print('No')
else:
  print('Yes')

Buggy python submission (verdict: Runtime Error):
S = input()
if S[0] == S[1] and S[1] == S[2]:
  print('NO")
else:
        print('Yes')

Fixed submission:
S = input()
if S[0] == S[1] and S[1] == S[2]:
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
Q = int(input())
Query = [list(input().split()) for i in range(Q)]

from collections import deque

q = deque(S)

r = 0  #反転の有無

for i in range(Q):
    if Query[i][0] == '1':
        r = 1-r
    else:
        if (r + int(Query[i][1])) % 2 == 1:
            q.appendleft(Query[i][2])
        else:
            q.append(Query[i][2])

A = list(q)

if r % 2 == 1:
    A.reverse()

ans = ''
for i in range(len(A)):
    ans += A[i]

print(ans)

Fixed submission:
S = list(input())
Q = int(input())
Query = [list(input().split()) for i in range(Q)]

from collections import deque

q = deque(S)

r = 0  #反転の有無

for i in range(Q):
    if Query[i][0] == '1':
        r = 1-r
    else:
        if (r + int(Query[i][1])) % 2 == 1:
            q.appendleft(Query[i][2])
        else:
            q.append(Query[i][2])

A = list(q)

if r % 2 == 1:
    A.reverse()

ans = ''
for i in range(len(A)):
    ans += A[i]

print(ans)
Buggy python submission (verdict: Runtime Error):
N = input()
if N % 2 == 0:
  print(N/2)
else:
  print((N+1)/2)


Fixed submission:
N = int(input())
if N % 2 == 0:
  print(int(N/2))
else:
  print(int((N+1)/2))

Buggy python submission (verdict: Runtime Error):
N == input()
if N % 2 == 0:
  print(N/2)
else:
  print((N+1)/2)

Fixed submission:
N = int(input())
if N % 2 == 0:
  print(int(N/2))
else:
  print(int((N+1)/2))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
data = [list(map(int,input().split())) for i in range(M)]

A = [[] for i in range(3)]

for i in range(M):
    if data[i][0] == 1 and data[i][1] == 0:
        print(-1)
        exit()
    else:
        A[data[i][0]-1].append(data[i][1])

for i in range(N):
    A[i] = set(A[i])
    if len(A[i]) > 1:
        print(-1)
        exit()

B = []
for i in range(N):
    if len(A[i]) == 1:
        for s in A[i]:
            B.append(s)
    else:
        B.append(0)

ans = str(B[0])
for i in range(1,3):
    ans += str(B[i])

print(ans)

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

A = [[] for i in range(3)]

for i in range(M):
    if data[i][0] == 1 and data[i][1] == 0 and N != 1:
        print(-1)
        exit()
    else:
        A[data[i][0]-1].append(data[i][1])

for i in range(N):
    A[i] = set(A[i])
    if len(A[i]) > 1:
        print(-1)
        exit()

B = []
for i in range(N):
    if len(A[i]) == 1:
        for s in A[i]:
            if i == 0 and s == 0 and N != 1:
                B.append(1)
            else:
                B.append(s)
    else:
        if i == 0 and N != 1:
            B.append(1)
        else:
            B.append(0)

ans = str(B[0])
for i in range(1,N):
    ans += str(B[i])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
H,N = map(int,input().split())
C = [list(map(int,input().split())) for i in range(N)]

A = []
B = []
for i in range(N):
    A.append(C[i][0])
    B.append(C[i][1])

M = max(A)
m = min(A)

dp = {} #dp[h]は体力をh減らすのに必要な魔力の最小値

for i in range(-M+1,1):
    dp[i] = 0

for i in range(1,H+m):
    dp[i] = min(dp[i-A[j]] + B[j] for j in range(N))

print(min(dp[i] for i in range(H,H+m)))

Fixed submission:
H,N = map(int,input().split())
C = [list(map(int,input().split())) for i in range(N)]

A = []
B = []
for i in range(N):
    A.append(C[i][0])
    B.append(C[i][1])

M = max(A)
m = min(A)

dp = {} #dp[h]は体力をh減らすのに必要な魔力の最小値

for i in range(-M+1,1):
    dp[i] = 0

for i in range(1,H+m):
    dp[i] = min(dp[i-A[j]] + B[j] for j in range(N))

print(min(dp[i] for i in range(H,H+m)))
Buggy python submission (verdict: Runtime Error):
from collections import deque

H,W = map(int,input().split())
S = [list(input().split()) for _ in range(H)]
a = 0

for h in range(H):
  for w in range(W): #スタートが(h,w)
    if S[h][w] == '#':
      continue
    d = [[-1]*W for i in range(H)]
    d[h][w] = 0
    
    q = deque([[h,w]])
    
    while q:
      nh,nw = q.pop()
      
      if nw+1<W and S[nh][nw+1]=='.' and d[nh][nw+1]==-1:
        d[nh][nw+1] = d[nh][nw]+1
        q.append([nh,nw+1])
      if 0<=nw-1 and S[nh][nw-1]=='.' and d[nh][nw-1]==-1:
        d[nh][nw-1] = d[nh][nw]+1
        q.append([nh,nw-1])
      if nh+1<H and S[nh+1][nw]=='.' and d[nh+1][nw]==-1:
        d[nh+1][nw] = d[nh][nw]+1
        q.append([nh+1,nw])
      if 0<=nh-1 and S[nh-1][nw]=='.' and d[nh-1][nw]==-1:
        d[nh-1][nw] = d[nh][nw]+1
        q.append([nh-1,nw])
    a = max(a,max([max(i) for i in d]))
    
print(a)

Fixed submission:
from collections import deque

H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]
directions = [[0,1],[1,0],[0,-1],[-1,0]]

def f(h,w): #スタートが(h,w)
  if S[h][w] == '#':
    return 0
  else:
    d = [[-1]*W for i in range(H)]
    d[h][w] = 0
    
    q = deque([[h,w]])
    
    while q:
      nh,nw = q.pop()
      
      for dh,dw in directions:
        if not (0<=nh+dh<H and 0<=nw+dw<W):
          continue
        if S[nh+dh][nw+dw] == '#':
          continue
        if d[nh+dh][nw+dw] != -1:
          continue
        d[nh+dh][nw+dw] = d[nh][nw]+1
        q.appendleft([nh+dh,nw+dw])
     
    return max([max(i) for i in d])

a = 0
for h in range(H):
  for w in range(W):
    a = max(a,f(h,w))
    
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)

mod = 10**9+7


def p(m,n):
    a = 1
    for i in range(n):
        a = a*(m-i)
    return a

def p_mod(m,n,mod):
    a = 1
    for i in range(n):
        a = a*(m-i) % mod
    return a

def c(m,n):
    return p(m,n) // p(n,n)

def c_mod(m,n,mod):
    return (p_mod(m,n,mod)*pow(p_mod(n,n,mod),mod-2,mod)) % mod

C = [0]*(N-K+1)  #C[i] = (N-i-1)C_(K-1),予め二項係数を計算しておく
for i in range(N-K+1):
    if i == 0:
        C[i] = c_mod(N-1,K-1,mod)
    else:
        C[i] = C[i-1]*(N-K-i+1)*pow(N-i,mod-2,mod)

#各Aの元が何回max,minに採用されるかを考える

ans = 0
for i in range(N-K+1):
    ans -= (A[i]*C[i]) % mod

A.reverse()
for i in range(N-K+1):
    ans += (A[i]*C[i]) % mod

print(ans % mod)

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

mod = 10**9+7


def p(m,n):
    a = 1
    for i in range(n):
        a = a*(m-i)
    return a

def p_mod(m,n,mod):
    a = 1
    for i in range(n):
        a = a*(m-i) % mod
    return a

def c(m,n):
    return p(m,n) // p(n,n)

def c_mod(m,n,mod):
    return (p_mod(m,n,mod)*pow(p_mod(n,n,mod),mod-2,mod)) % mod

C = [0]*(N-K+1)  #C[i] = (N-i-1)C_(K-1),予め二項係数を計算しておく
for i in range(N-K+1):
    if i == 0:
        C[i] = c_mod(N-1,K-1,mod)
    else:
        C[i] = (C[i-1]*(N-K-i+1)*pow(N-i,mod-2,mod)) % mod

#各Aの元が何回max,minに採用されるかを考える

ans = 0
for i in range(N-K+1):
    ans -= (A[i]*C[i]) % mod

A.reverse()
for i in range(N-K+1):
    ans += (A[i]*C[i]) % mod

print(ans % mod)

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

mod = 10**9+7

def p(m,n):
    a = 1
    for i in range(n):
        a = a*(m-i)
    return a

def p_mod(m,n,mod):
    a = 1
    for i in range(n):
        a = a*(m-i) % mod
    return a

def c(m,n):
    return p(m,n) // p(n,n)

def c_mod(m,n,mod):
    return (p_mod(m,n,mod)*pow(p_mod(n,n,mod),mod-2,mod)) % mod

#各Aの元が何回max,minに採用されるかを考える

ans = 0
for i in range(N-K+1):
    ans -= (A[i]*c_mod(N-i-1,K-1,mod)) % mod

A.reverse()
for i in range(N-K+1):
    ans += (A[i]*c_mod(N-i-1,K-1,mod)) % mod

print(ans % mod)

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

mod = 10**9+7


def p(m,n):
    a = 1
    for i in range(n):
        a = a*(m-i)
    return a

def p_mod(m,n,mod):
    a = 1
    for i in range(n):
        a = a*(m-i) % mod
    return a

def c(m,n):
    return p(m,n) // p(n,n)

def c_mod(m,n,mod):
    return (p_mod(m,n,mod)*pow(p_mod(n,n,mod),mod-2,mod)) % mod

C = [0]*(N-K+1)  #C[i] = (N-i-1)C_(K-1),予め二項係数を計算しておく
for i in range(N-K+1):
    if i == 0:
        C[i] = c_mod(N-1,K-1,mod)
    else:
        C[i] = (C[i-1]*(N-K-i+1)*pow(N-i,mod-2,mod)) % mod

#各Aの元が何回max,minに採用されるかを考える

ans = 0
for i in range(N-K+1):
    ans -= (A[i]*C[i]) % mod

A.reverse()
for i in range(N-K+1):
    ans += (A[i]*C[i]) % mod

print(ans % mod)
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    import sys

    def LI():
        return list(map(int, sys.stdin.readline().rstrip().split()))  # 空白あり

    def S():
        return sys.stdin.readline().rstrip()

    N, M = map(int, S().split())
    A = LI()
    A.sort()

    from bisect import bisect_left

    low = 2
    high = 2 * A[-1] + 1

    while low + 1 < high:
        mid = (low + high) // 2
        if sum(N - bisect_left([A[i] + A[j] for j in range(N)], mid) for i in range(N)) >= M:
            low = mid
        else:
            high = mid

    a = low  # a以上のA[i]+A[j]がM個以上となる最大のa

    from itertools import accumulate

    B = [0] + list(accumulate(A))

    r = 0
    ans = 0
    for i in range(N):  # a+1以上のA[i]+A[j]を足し合わせていく
        b = bisect_left([A[i] + A[j] for j in range(N)], a + 1)
        r += N - b
        ans += B[N] - B[b]
        ans += A[i] * (N - b)

    ans += (M - r) * a  # A[i]+A[j] == a となるものを足し合わせる

    print(ans)

if __name__ == '__main__':
    resolve()

Fixed submission:
def resolve():
    import sys

    def LI():
        return list(map(int, sys.stdin.readline().rstrip().split()))  # 空白あり

    def S():
        return sys.stdin.readline().rstrip()

    N, M = map(int, S().split())
    A = LI()
    A.sort()

    def f(n,x):  # A[n]+A[i]>=x となる i の最小値
        left = -1
        right = N
        while left + 1 < right:
            mid = (left + right) // 2
            if A[n] + A[mid] < x:
                left = mid
            else:
                right = mid
        return right

    low = 2 * A[0]
    high = 2 * A[-1] + 1

    while low + 1 < high:
        mid = (low + high) // 2
        if sum(N - f(i,mid) for i in range(N)) >= M:
            low = mid
        else:
            high = mid

    a = low  # a以上のA[i]+A[j]がM個以上となる最大のa

    from itertools import accumulate

    B = [0] + list(accumulate(A))

    r = 0
    ans = 0
    for i in range(N):  # a+1以上のA[i]+A[j]を足し合わせていく
        b = f(i,a+1)
        r += N - b
        ans += B[N] - B[b]
        ans += A[i] * (N - b)

    ans += (M - r) * a  # A[i]+A[j] == a となるものを足し合わせる

    print(ans)

if __name__ == '__main__':
    resolve()
Buggy python submission (verdict: Runtime Error):
S = list(input())
s = len(S)
K = int(input())
A = []
j = 1

for i in range(0,s-1,1):
  if S[i] == S[i+1]:
    j += 1
  else:
    A.append(j)
    j = 1
A.append(j)

a = len(A)

b = 0
for i in range(a):
  b += i//2
  
x = b*K

if S[s-1] == S[0] and A[a-1] % 2 == 1 and A[1] % 2 == 1:
  x += K-1
  
print(x)

Fixed submission:
N,A,B = map(int,input().split())
if (B-A) % 2 == 0:
  print((B-A)//2)
elif A-1 <= N-B:
  print((A+B-1)//2)
else:
  print(N+1-(B+A+1)//2)
Buggy python submission (verdict: Runtime Error):
A = map(int,input().split())

if A[0]+A[1]+A[2] <= 21:
  print('win')
else:
  print('bust')

Fixed submission:
A,B,C = map(int,input().split())

if A+B+C <= 21:
  print('win')
else:
  print('bust')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

M = max(A)
m = M
a = 1
while m // 2 != 0:
  m = m//2
  a += 1
#aはMの桁数

b = 0
for i in range(a):
  c = 0
  for j in range(N):
    c += (A[j] & 2**i)//(2**i)  #A[j]の2**iの位の値をcに加えている
  b = (b + c*(N-c)*pow(2,i,10**9+7)) % (10**9+7)
  
print(b)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

M = max(A)
m = M
a = 1
while m // 2 != 0:
  m = m//2
  a += 1
#aはMの桁数

b = 0
for i in range(a):
  c = 0
  for j in range(N):
    c += (A[j] & 2**i)//(2**i)  #A[j]の2**iの位の値をcに加えている
  b = (b + c*(N-c)*pow(2,i,10**9+7)) % (10**9+7)
  
print(b)
Buggy python submission (verdict: Runtime Error):
S = list(input())
s = len(S)
K = int(input())
A = []
j = 1

for i in range(0,s-1,1):
  if S[i] == S[i+1]:
    j += 1
  else:
    A.append(j)
    j = 1
A.append(j)

a = len(A)

b = 0
for i in range(0,a,1):
  b += A[i]//2
  
x = b*K

if S[s-1] == S[0] and A[a-1] % 2 == 1 and A[1] % 2 == 1:
  x += K-1

print(x)

Fixed submission:
S = list(input())
s = len(S)
K = int(input())
A = []
j = 1

for i in range(0,s-1,1):
  if S[i] == S[i+1]:
    j += 1
  else:
    A.append(j)
    j = 1
A.append(j)

a = len(A)

b = 0
for i in range(0,a,1):
  b += A[i]//2
  
x = b*K

if a == 1:
  x = (s*K)//2
elif S[s-1] == S[0] and A[a-1] % 2 == 1 and A[0] % 2 == 1:
  x += K-1

print(x)

Buggy python submission (verdict: Runtime Error):
S = list(input())
s = len(S)
K = int(input())
A = []
j = 1

for i in range(0,s-1,1):
  if S[i] == S[i+1]:
    j += 1
  else:
    A.append(j)
    j = 1
A.append(j)

a = len(A)

b = 0
for i in range(0,a,1):
  b += A[i]//2
  
x = b*K

if S[s-1] == S[0] and A[a-1] % 2 == 1 and A[1] % 2 == 1:
  x += K-1

print(b)
print(x)

Fixed submission:
S = list(input())
s = len(S)
K = int(input())
A = []
j = 1

for i in range(0,s-1,1):
  if S[i] == S[i+1]:
    j += 1
  else:
    A.append(j)
    j = 1
A.append(j)

a = len(A)

b = 0
for i in range(0,a,1):
  b += A[i]//2
  
x = b*K

if a == 1:
  x = (s*K)//2
elif S[s-1] == S[0] and A[a-1] % 2 == 1 and A[0] % 2 == 1:
  x += K-1

print(x)

Buggy python submission (verdict: Runtime Error):
S = list(input())
s = len(S)
K = int(input())
A = []
j = 1

for i in range(0,s-1,1):
  if S[i] == S[i+1]:
    j += 1
  else:
    A.append(j)
    j = 1
A.append(j)

a = len(A)

b = 0
for i in range(a):
  b += i//2
  
x = b*K

if S[s-1] == S[0] and A[a-1] % 2 == 1 and A[1] % 2 == 1:
  x += K-1
  
print(x)


Fixed submission:
S = list(input())
s = len(S)
K = int(input())
A = []
j = 1

for i in range(0,s-1,1):
  if S[i] == S[i+1]:
    j += 1
  else:
    A.append(j)
    j = 1
A.append(j)

a = len(A)

b = 0
for i in range(0,a,1):
  b += A[i]//2
  
x = b*K

if a == 1:
  x = (s*K)//2
elif S[s-1] == S[0] and A[a-1] % 2 == 1 and A[0] % 2 == 1:
  x += K-1

print(x)
Buggy python submission (verdict: Runtime Error):
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,K,Q = MI()

X = [0]*(N+1)  # 各参加者の正解数
for _ in range(Q):
    a = I()
    X[a] += 1

for i in range(1,N+1):
    x = X[i]
    print('Yes' if K-(Q-x) > 0 else 'No')


Fixed submission:
import sys
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


S = LS2()
N = len(S)
S1 = S[::2]
S2 = S[1::2]

r = sum(s in ['R','U','D'] for s in S1) + sum(s in ['L','U','D'] for s in S2)
print('Yes' if r == N else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()

N = I()
s = [sorted(S()) 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:
import sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()

N = I()
s = [''.join(sorted(S())) for i in range(N)]

from collections import Counter

c = Counter(s)
ans = 0
for i in c.keys():
    ans += c[i]*(c[i]-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()

N = I()
s = [sorted(S()) 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:
import sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()

N = I()
s = [''.join(sorted(S())) for i in range(N)]

from collections import Counter

c = Counter(s)
ans = 0
for i in c.keys():
    ans += c[i]*(c[i]-1)//2

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

A = []

for i in range(N):
    A.append((data[i][1],data[i][0]))

A = sorted(A)

a = 0  #i番目にやった仕事の終了時間
for i in range(N):
    a += A[i][1]
    if a > A[i][0]:
        print('No')
        break
    else:
        continue
else:
    print('Yes')

Fixed submission:
S = list(input())

for i in range(len(S)-1):
  if S[i] == S[i+1]:
    print('Bad')
    break
else:
  print('Good')
Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
data = [list(input()) for i in range(H)]

A = [[0]*(W) for i in range(H)]
B = [[0]*(W) for i in range(H)]

for i in range(H):
    a = 0
    f = 0
    t = 0
    for j in range(W):
        if data[i][j] == '.' and j < W-1:
            a += 1
            t += 1
        elif data[i][j] == '#':
            for k in range(f,t):
                A[i][k] = a
            t = j+1
            f = j+1
            a = 0
        else:
            for k in range(f,t+1):
                A[i][k] = a+1
for j in range(W):
    b = 0
    f = 0
    t = 0
    for i in range(H):
        if data[i][j] == '.' and i < H-1:
            b += 1
            t += 1
        elif data[i][j] == '#':
            for k in range(f,t):
                B[k][j] = b
            t = i+1
            f = i+1
            b = 0
        else:
            for k in range(f,t+1):
                B[k][j] = b+1
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans,A[i][j]+B[i][j])
print(ans-1)

Fixed submission:
H,W = map(int,input().split())
data = [list(input()) for i in range(H)]

A = [[0]*(W) for i in range(H)]
B = [[0]*(W) for i in range(H)]

for i in range(H):
    a = 0
    f = 0
    t = 0
    for j in range(W):
        if data[i][j] == '.' and j < W-1:
            a += 1
            t += 1
        elif data[i][j] == '#':
            for k in range(f,t):
                A[i][k] = a
            t = j+1
            f = j+1
            a = 0
        else:
            for k in range(f,t+1):
                A[i][k] = a+1
for j in range(W):
    b = 0
    f = 0
    t = 0
    for i in range(H):
        if data[i][j] == '.' and i < H-1:
            b += 1
            t += 1
        elif data[i][j] == '#':
            for k in range(f,t):
                B[k][j] = b
            t = i+1
            f = i+1
            b = 0
        else:
            for k in range(f,t+1):
                B[k][j] = b+1
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans,A[i][j]+B[i][j])
print(ans-1)