Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
input()
S = [i for i in input()]
flag = True
while flag:
  flag = False
  for i in range(0,len(S)-1):
    if S[i] == S[i+1]:
      del S[i]
      flag = True
      break
print(len(S))

Fixed submission:
input()
S = [i for i in input()]
point = 0
del_list = list()
for i in range(point,len(S)-1):
  if S[i] == S[i+1]:
    del_list.append(i)
for i,j in enumerate(del_list,0):
  del S[j-i]
      
print(len(S))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = [int(input()) for i in range(n)]
if 2 not in li:
  print(-1)
else:
  ans = 0
  st = 0
  while st != 1:
    if st == 0 and ans > 0:
      ans = -1
      break
    st = li[st]-1
    ans += 1
  print(ans)

Fixed submission:
n = int(input())
li = [int(input()) for i in range(n)]
if 2 not in li:
  print(-1)
else:
  ans = 0
  st = 0
  while st != 1:
    if (st == 0 and ans > 0) or ans > n:
      ans = -1
      break
    st = li[st]-1
    ans += 1
  print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
and = D = [list(map(int,input().split())) for i in range(N)]  

ans = "No"

for i in range(N-2):
    if D[i][0] == D[i][1]:
        if D[i+1][0] == D[i+1][1]:
            if D[i+2][0] == D[i+2][1]:
                ans = "Yes"
                break
print(ans)

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

ans = "No"

for i in range(N-2):
    if D[i][0] == D[i][1]:
        if D[i+1][0] == D[i+1][1]:
            if D[i+2][0] == D[i+2][1]:
                ans = "Yes"
                break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

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

ans = 0
mod = 10**9+7
for i in range(N):
    ans += (A[i]*tmp[i])%mod
    ans = ans%mod
    
print(ans)

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

tmp = [0]*N
tmp2 = [0]*N
tmp2[0] = A[0]

for i in range(1,N):
    tmp2[i] = A[i] + tmp2[i-1]
sum_A = sum(A)

for i in range(N):
    tmp[i] = sum_A - tmp2[i]

ans = 0
mod = 10**9+7
for i in range(N):
    ans += (A[i]*tmp[i])%mod
    ans = ans%mod
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(N)

for i in range(M):
    A,B = map(int,input().split())
    uf.union(A-1,B-1)

group = list(uf.all_group_members().values())
ans = 0
for i in range(len(group)):
    ans = max(ans,len(group[i]))
print(ans)

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

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(N)

for i in range(M):
    A,B = map(int,input().split())
    uf.union(A-1,B-1)

ans = 0
for i in range(N):
    ans = max(ans,uf.size(i))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = list(map(int,input().split()))

tmp = 1

for i in range(K):
    tmp = tmp * A[i]
    
for i in range(K,N):
    tmp2 = tmp*A[i]//A[i-K]
    if tmp2 > tmp:
        print("Yes")
    else:
        print("No")
    tmp = tmp2

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):
H,W,K = map(int,input().split())
C = [input() for i in range(H)]

ans = 0
for i in 2**H:
    for j in 2**W:
        tmp = 0
        for ii in range(H):
            for jj in range(W):
                
                if C[ii][jj] == '#' and (i >> ii) == 0 and (j >> jj) == 0:
                    tmp += 1
        if tmp == K:
            ans += 1
            
print(ans)    

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

import itertools
h = list(itertools.product([0,1], repeat=H))
w = list(itertools.product([0,1], repeat=W))

ans = 0
for i in h:
    for j in w:
        tmp = 0
        for ii in range(H):
            for jj in range(W):
                if C[ii][jj] == '#' and i[ii] == 0 and j[jj] == 0:
                    tmp += 1
        if tmp == K:
            ans += 1
            
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

A.sort()
ans = A[-1]
count = 1
tmp_count = 1
j = -2
for i in range(N):
    ans += A[j]
    count += 1
    tmp_count +=1
    if count == 2:
        count = 0
        j -= 1
    if tmp_count == N-1:
        break
        
print(ans)
        
    

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

A.sort(reverse = True)
ans = 0

from collections import deque
tmp = deque([A[0]])

for x in A[1:]:
    ans += tmp.popleft()
    tmp.append(x)
    tmp.append(x)
    
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
p = list(map(int,input().split()))

p.sort()
print(sum(p[:K])

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

p.sort()
ans = 0
for i in range(K):
    ans += p[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = list(map(int,input().split()))

for k in range(1,min(K+1,42)):
    B = [0]*N
    for i in range(N):
        l = max(0,i-A[i])
        r = min(N-1,i+A[i])
        B[l] += 1
        if r+1 < N:
            B[r+1] -= 1
            
    for i in range(1,N):
        B[i] += B[i-1]
    A = B
print(*A)

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

for k in range(1,min(K+1,45)):
    B = [0]*N
    for i in range(N):
        l = max(0,i-A[i])
        r = min(N-1,i+A[i])
        B[l] += 1
        if r+1 < N:
            B[r+1] -= 1
            
    for i in range(1,N):
        B[i] += B[i-1]
    A = B
print(*A)

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

for k in range(1,min(K+1,50)):
    B = [0]*N
    for i in range(N):
        l = max(0,i-A[i])
        r = min(N-1,i+A[i])
        B[l] += 1
        if r+1 < N:
            B[r+1] -= 1
            
    for i in range(1,N):
        B[i] += B[i-1]
    A = B
print(*A)

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

for k in range(1,min(K+1,45)):
    B = [0]*N
    for i in range(N):
        l = max(0,i-A[i])
        r = min(N-1,i+A[i])
        B[l] += 1
        if r+1 < N:
            B[r+1] -= 1
            
    for i in range(1,N):
        B[i] += B[i-1]
    A = B
print(*A)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
if K >= 40:
    ans = [N]*N
    print(*ans)
else:
    for i in range(K):
        CA = [0]*N
        for j in range(N):
            CA[max(0,j-A[j]):min(j+A[j]+1,N)] = map(lambda x: x+1,CA[max(0,j-A[j]):min(j+A[j]+1,N)])
        A = [CA[i] for i in range(N)]
    print(*A)


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

for k in range(1,min(K+1,45)):
    B = [0]*N
    for i in range(N):
        l = max(0,i-A[i])
        r = min(N-1,i+A[i])
        B[l] += 1
        if r+1 < N:
            B[r+1] -= 1
            
    for i in range(1,N):
        B[i] += B[i-1]
    A = B
print(*A)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

tmp = 1
import sys

for i in range(N):
    tmp *= A[i]
if tmp > 10**18:
    print(-1)
else:
    print(tmp)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
import sys
tmp = 1
A.sort(reverse = True)
if 0 in A:
    print(0)
else:
    for i in range(N):
        tmp *= A[i]
        if tmp > 10**18:
            print(-1)
            sys.exit()
    print(tmp)
Buggy python submission (verdict: Time Limit Exceeded):
N,S = map(int,input().split())
A = list(map(int,input().split()))

MOD = 998244353

dp = [[0]*(S+1) for _ in range(N+1)]
dp[0][0] = 1

for i in range(N):
    for j in range(S+1):
        dp[i+1][j] += dp[i][j] * 2 % MOD
        if j - A[i] >= 0:
            dp[i+1][j] += dp[i][j-A[i]]
        dp[i+1][j] %= MOD
        
print(dp[N][S])

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

MOD = 998244353

dp = [[0]*(S+1) for _ in range(N+1)]
dp[0][0] = 1

for i in range(N):
    for j in range(S+1):
        dp[i+1][j] += dp[i][j] * 2 % MOD
        if j - A[i] >= 0:
            dp[i+1][j] += dp[i][j-A[i]]
        dp[i+1][j] %= MOD
        
print(dp[N][S])
Buggy python submission (verdict: Runtime Error):
T = input()

tmp = []
for i in T:
    tmp.append(i)

if tmp[0] == '?':
    if tmp[1] == 'P':
        tmp[0] = 'D'
    elif tmp[1] == 'D':
        tmp[0] = 'P'
    else:
        tmp[0] = 'P'
for i in range(1,len(tmp)-1):
    if tmp[i] == '?':
        if tmp[i-1] == 'D' and tmp[i+1] == 'D':
            tmp[i] = 'P'
        elif tmp[i-1] == 'P' and tmp[i+1] == 'P':
            tmp[i] = 'D'
        elif tmp[i-1] == 'D' and tmp[i+1] == 'P':
            tmp[i] = 'D'
        elif tmp[i-1] == 'P' and tmp[i+1] == 'D':
            tmp[i] = 'D'
        elif tmp[i-1] == 'P' and tmp[i+1] == '?':
            tmp[i] = 'D'
        elif tmp[i-1] == 'D' and tmp[i+1] == '?':
            tmp[i] = 'P'
if tmp[-1] == '?':
    if tmp[-2] == 'P':
        tmp[-1] = 'D'
    elif tmp[-2] == 'D':
        tmp[-1] = 'P'
        
print(''.join(tmp))

Fixed submission:
T = input()

tmp = []
for i in T:
    tmp.append(i)
    
import sys
    
if len(T) == 1:
    if T[0] == '?':
        print('D')
    else:
        print(T)
    sys.exit()
    
for i in range(len(tmp)):
    if tmp[i] == '?':
        tmp[i] = 'D'
        
print(''.join(tmp))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]
 
ans = [-1] * (N+1)
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
    
from collections import deque
todo = deque([(1,0)])
while todo:
    x,parent = todo.pop()
    #ans[x] = parent
    for y in graph[x]:
        ans[y] = x
        # if y == parent:
        #     continue
        if ans[y] != -1:
            continue
        todo.append((y,x))
        
            
for i in range(2,N+1):
    if ans[i] == -1:
        print('No')
        sys.exit()
        
print('Yes')
for i in range(2,N+1):
    print(ans[i])


Fixed submission:
from collections import deque
import sys

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

que = deque([1])
ans = [0]*(N+1)

while que:
    x = deque.popleft(que)
    for i in graph[x]:
        if ans[i] != 0:
            continue
        ans[i] = x
        que.append(i)
        
for i in range(2,N+1):
    if ans[i] == 0:
        print('No')
        sys.exit()
        
print('Yes')
for i in range(2,N+1):
    print(ans[i])
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
tmp_A = [0]*N
ans = 0

for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for j in range(d):
        tmp_A[A[j]-1] += 1
        
for i in range(N):
    tmp_A[i] == 0:
        ans += 1
        
print(ans)

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

list_A = [0]*N
ans = 0
d = []
A = []

for i in range(K):
    d.append(int(input()))
    A.append(list(map(int,input().split())))

list_A = [0]*N

for i in range(len(A)):
    for j in A[i]:
        list_A[j-1] += 1
        
for i in range(N):
    if list_A[i] == 0:
        ans += 1
        
print(ans)
Buggy python submission (verdict: Runtime Error):
X = int(input())

import sys

for i in range(1,10**9+1):
    a = pow(i,5)
    f_i = pow(a-X,0.2)
    if f_i.is_integer() == True:
        print(i,pow(a-X,0.2))
        sys.exit()

Fixed submission:
X = int(input())

import sys

for a in range(-120,120+1):
    for b in range(-120,120+1):
        if a**5 - b**5 == X:
            print(a,b)
            sys.exit()
Buggy python submission (verdict: Runtime Error):
// C/C++ キーワード定義ファイル データ型
// cpp_kw1_datatypes.kwd
//
//  Created on: 2015/06/13
//      Author: KeitetsuWorks
// CASE=True

ATOM
BOOL
BOOLEAN
BYTE
CHAR
COLORREF
DWORD
DWORD32
DWORD64
DWORDLONG
DWORD_PTR
FILE
FLOAT
HACCEL
HALF_PTR
HANDLE
HBITMAP
HBRUSH
HCOLORSPACE
HCONV
HCONVLIST
HCURSOR
HDC
HDDEDATA
HDESK
HDROP
HDWP
HENHMETAFILE
HFILE
HFONT
HGDIOBJ
HGLOBAL
HHOOK
HICON
HINSTANCE
HKEY
HKL
HLOCAL
HMENU
HMETAFILE
HMODULE
HMONITOR
HPALETTE
HPEN
HRESULT
HRGN
HRSRC
HSZ
HWINSTA
HWND
INT
INT32
INT64
INT_PTR
LANGID
LCID
LCTYPE
LGRPID
LONG
LONG32
LONG64
LONGLONG
LONG_PTR
LPARAM
LPBOOL
LPBYTE
LPCOLORREF
LPCSTR
LPCTSTR
LPCVOID
LPCWSTR
LPDWORD
LPHANDLE
LPINT
LPLONG
LPSTR
LPTSTR
LPVOID
LPWORD
LPWSTR
LRESULT
PBOOL
PBOOLEAN
PBYTE
PCHAR
PCSTR
PCTSTR
PCWSTR
PDWORD32
PDWORD64
PDWORDLONG
PDWORD_PTR
PFLOAT
PHALF_PTR
PHANDLE
PHKEY
PINT
PINT32
PINT64
PINT_PTR
PLCID
PLONG
PLONG32
PLONG64
PLONGLONG
PLONG_PTR
POINTER_32
POINTER_64
PSHORT
PSIZE_T
PSSIZE_T
PSTR
PTBYTE
PTCHAR
PTSTR
PUCHAR
PUHALF_PTR
PUINT
PUINT32
PUINT64
PUINT_PTR
PULONG
PULONG32
PULONG64
PULONGLONG
PULONG_PTR
PUSHORT
PVOID
PWCHAR
PWORD
PWSTR
SC_HANDLE
SC_LOCK
SERVICE_STATUS_HANDLE
SHORT
SIZE_T
SSIZE_T
TBYTE
TCHAR
UCHAR
UHALF_PTR
UINT
UINT32
UINT64
UINT_PTR
ULONG
ULONG32
ULONG64
ULONGLONG
ULONG_PTR
USHORT
USN
VOID
WCHAR
WORD
WPARAM
_EXCEPTION_POINTERS
_FPIEEE_RECORD
_HEAPINFO
_HFILE
_PNH
__finddata64_t
__int16
__int32
__int64
__int8
__stat64
__time64_t
__timeb64
__wchar_t
__wfinddata64_t
_complex
_dev_t
_diskfree_t
_exception
_finddata_t
_finddatai64_t
_off_t
_onexit_t
_purecall_handler
_stat
_stati64
_timeb
_utimbuf
_wfinddata_t
_wfinddatai64_t
bool
char
clock_t
div_t
double
float
fpos_t
int
intptr_t
jmp_buf
lconv
ldiv_t
long
mbstate_t
ptrdiff_t
short
sig_atomic_t
signed
size_t
terminate_function
time_t
tm
uintptr_t
unsigned
va_list
void
wchar_t
wctrans_t
wctype_t
wint_t


Fixed submission:
R = int(input())

import math

print(2*R*math.pi)
Buggy python submission (verdict: Runtime Error):
// C/C++ キーワード定義ファイル キーワード
// cpp_kw2_keywords.kwd
//
//  Created on: 2015/06/13
//      Author: KeitetsuWorks
// CASE=True

__declspec
__except
__finally
__try
break
case
catch
class
const
const_cast
continue
default
delete
deprecated
dllexport
dllimport
do
dynamic_cast
else
enum
explicit
extern
false
for
friend
goto
if
inline
mutable
naked
namespace
new
noinline
noreturn
nothrow
private
protected
public
register
reinterpret_cast
return
selectany
sizeof
static
static_cast
struct
switch
template
this
thread
throw
true
try
typedef
typeid
typename
union
using
uuid
virtual
volatile
while


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

if sum(A) > N:
    print(-1)
else:
    print(N-sum(A))
Buggy python submission (verdict: Runtime Error):
// C/C++ キーワード定義ファイル 関数
// cpp_kw3_functions.kwd
//
//  Created on: 2015/06/13
//      Author: KeitetsuWorks
// CASE=True

#define
#elif
#else
#endif
#error
#if
#ifdef
#ifndef
#include
#line
#pragma
#undef
abort
abs
acos
asctime
asin
assert
atan
atan2
atexit
atof
atoi
atol
bsearch
calloc
ceil
clearerr
clock
cos
cosh
ctime
difftime
div
errno
exit
exp
fabs
fclose
feof
ferror
fflush
fgetc
fgetpos
fgets
floor
fmod
fopen
fprintf
fputc
fputs
fread
free
freopen
frexp
fscanf
fseek
fsetpos
ftell
fwrite
getc
getchar
getenv
gets
gmtime
isalnum
isalpha
iscntrl
isdigit
isgraph
islower
isprint
ispunct
isspace
isupper
isxdigit
labs
ldexp
ldiv
localeconv
localtime
log
log10
longjmp
malloc
mblen
mbstowcs
mbtowc
memchr
memcmp
memcpy
memmove
memset
mktime
modf
perror
pow
printf
putc
putchar
puts
qsort
raise
rand
realloc
remove
rename
rewind
scanf
setbuf
setjmp
setlocale
setvbuf
signal
sin
sinh
sprintf
sqrt
srand
sscanf
strcat
strchr
strcmp
strcoll
strcpy
strcspn
strerror
strftime
strlen
strncat
strncmp
strncpy
strpbrk
strrchr
strspn
strstr
strtod
strtok
strtol
strtoul
strxfrm
system
tan
tanh
time
tmpfile
tmpnam
tolower
toupper
ungetc
va_arg
va_end
va_start
vfprintf
vprintf
vsprintf
wcstombs
wctomb


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

ans = [0]*N

for i in range(N-1):
    ans[A[i]-1] += 1

for i in range(N):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())

ans = 0

import math

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            tmp = math.gcd(i,j)
            ans += math.gcd(tmp,k)
            
print(ans)
            

Fixed submission:
K = int(input())

ans = 0
ans2 = 0


import math

for i in range(1,K+1):
    for j in range(i,K+1):
        for k in range(j,K+1):
            tmp = math.gcd(i,j)
            ans += math.gcd(tmp,k)
            
for i in range(1,K+1):
    for j in range(i+1,K+1):
        for k in range(j+1,K+1):
            tmp3 = math.gcd(i,j)
            ans2 += math.gcd(tmp3,k)
      
tmp2 = 0

for i in range(1,K+1):
    tmp2 += i
    
print((ans - tmp2 - ans2)*3 + ans2*6 + tmp2)
Buggy python submission (verdict: Runtime Error):
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

alist = []
ans = 0

for i in range(X):
    alist.append(p[i])
    
for j in range(Y):
    alist.append(q[j])
    
alist.sort(reverse=True)
ans = sum(alist)

a2 = [alist[0]]
r2 = [r[0]]

for i in range(1,len(alist)):
    a2.append(alist[i]+a2[i-1])
    r2.append(r[i]+r2[i-1])

ans = a2[-1]

for i in range(C-1):
    ans = max(ans,a2[i]+r2[C-i-1])
    
print(ans)

Fixed submission:
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

alist = []
ans = 0

for i in range(X):
    alist.append(p[i])
    
for j in range(Y):
    alist.append(q[j])
    
for k in range(C):
    alist.append(r[k])
    
alist.sort(reverse=True)
    
for k in range(X+Y):
    ans += alist[k]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

alist = []
ans = 0

for i in range(X):
    alist.append(p[i])
    
for j in range(Y):
    alist.append(q[j])
    
alist.sort(reverse=True)
ans = sum(alist)
    
for k in range(C):
    ans = max(ans,sum(r[:k+1])+sum(alist[:len(alist)-k-1]))

print(ans)

Fixed submission:
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

alist = []
ans = 0

for i in range(X):
    alist.append(p[i])
    
for j in range(Y):
    alist.append(q[j])
    
for k in range(C):
    alist.append(r[k])
    
alist.sort(reverse=True)
    
for k in range(X+Y):
    ans += alist[k]

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
import collections as col
 
num _list= set(A)
ca = col.Counter(A)

num = 0

for i in num_list:
    if ca[i] == 1:
        continue
    else:
        num += (ca[i]*(ca[i]-1))//2
        
for i in A:
    ans = num - (ca[i]-1)
    print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
import collections as col
 
num_list = set(A)
ca = col.Counter(A)

num = 0

for i in num_list:
    if ca[i] == 1:
        continue
    else:
        num += (ca[i]*(ca[i]-1))//2
        
for i in A:
    ans = num - (ca[i]-1)
    print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c = list(map(int,input().split()))

if c-a-b > 0 and 4*a*b < (c-a-b)**2:
    print("Yes")
else:
    print("No")

Fixed submission:
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(a[k-1])
Buggy python submission (verdict: Runtime Error):
N,T = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(N)]

import sys

time = 0
mintime = 10**9

for shop in range(N):
    time += 1
    for i in range(len(ab)):
        t = time + ab[i][0]*time + ab[i][1]
        if t < mintime:
            mintime = t
            go = i
    mintime = 10**9
    time = time + ab[go][0]*time + ab[go][1]
    
    if time > T+0.5:
        print(shop)
        sys.exit()
    
    ab.pop(go)
    
print(shop+1)

Fixed submission:
import sys
from bisect import bisect_right
 
N,T = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(N)]

b0 = []
ab1 = []

#aが0とそれ以外で分ける
for a,b in ab:
    if a == 0:
        #+1は店間の移動を先に考慮
        b0.append(b+1)
    else:
        ab1.append([(b+1)/a, a, b])

N0 = len(b0)
N1 = len(ab1)

b0.sort()

#bは累積和で時間計算可能（最後にどこまで足せるかを調べる）
if N0>0:
    b_ruiseki = [0]*N0
    b_ruiseki[0] = b0[0]
    for i in range(1,N0):
        b_ruiseki[i] = b_ruiseki[i-1] + b0[i]
else:
    b_ruiseki = []
#探索範囲が28店まででいいからソートする
ab1.sort()

INF = T + 100
 
dp = [[INF]*31 for i in range(N1+1)]
dp[0][0] = 0
ans = 0
for i in range(N1):
    # dp[i+1][j] : 0~i番目までの店を見て，j個選ぶときの最小時間
    for j in range(31):
        if j > i+1:
            break
        if j == 0:
            dp[i+1][j] = 0
        else:
            dp[i+1][j] = min(dp[i][j], dp[i][j-1]+1 + ab1[i][1]*(dp[i][j-1]+1) + ab1[i][2])

for j in range(31):
    if dp[N1][j] > T:
        break    
    # a>0をj店舗めぐった後にa=0を何店舗めぐれるか
    num0 = bisect_right(b_ruiseki, T - dp[N1][j])
    ans = max(ans, j + num0)
        
    
print(ans)