Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict

d=defaultdict(int)
m=10**6+1
sieve=[-1]*m
n=IN()
a=sorted(LI())
for i in a:
    d[i]+=1
    for j in range(2*i,m,i):
        sieve[j]=1
ans=0
for i in a:
    if sieve[i]==-1 and d[i]==1:
        ans+=1
print(ans)

Fixed submission:
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict

d=defaultdict(int)
m=10**6+1
sieve=[-1]*m
n=IN()
a=sorted(LI())
for i in a:
    if d[i]==0:
        d[i]+=1
        for j in range(2*i,m,i):
            sieve[j]=1
    else:
        sieve[i]=1
ans=0
for i in a:
    if sieve[i]==-1:
        ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict

d=defaultdict(int)
m=10**6
sieve=[-1]*10**6
n=IN()
a=LI()
for i in range(n):
    d[a[i]]+=1
    for j in range(2*a[i],m,a[i]):
        sieve[j]=1
ans=0
for i in a:
    if sieve[i]==-1 and d[i]==1:
        ans+=1
print(ans)

Fixed submission:
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict

d=defaultdict(int)
m=10**6+1
sieve=[-1]*m
n=IN()
a=sorted(LI())
for i in a:
    if d[i]==0:
        d[i]+=1
        for j in range(2*i,m,i):
            sieve[j]=1
    else:
        sieve[i]=1
ans=0
for i in a:
    if sieve[i]==-1:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict

a,b=input.split()
b.remove(".")
ans=int(a)*int(b)
print(ans//100)


Fixed submission:
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict

a,b=input().split()
b=b.replace(".","")
ans=int(a)*int(b)
print(ans//100)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
if A[m]<sum(A)/4/m:
    print('No')
else:
    print('Yes')

Fixed submission:
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
if A[m-1]<sum(A)/4/m:
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
M,N,X=map(int,input().split())
C=[list(map(int,input().split())) for i in range(N)]
INF=float("inf")
ans=INF

for i in range(1,2**N):
    skills=[0]*M
    total_cost=0
    for j in range(N):
        if ((i>>j)&1):
            total_cost+=C[j][0]
            for k in range(M):
                skills[k]+=C[j][k+1]
    if min(skills)>=X:
        ans=min(ans,total_cost)
        
print(ans if ans != INF else -1)

Fixed submission:
N,M,X=map(int,input().split())
C=[list(map(int,input().split())) for i in range(N)]
INF=float("inf")
ans=INF

for i in range(1,2**N):
    skills=[0]*M
    total_cost=0
    for j in range(N):
        if ((i>>j)&1):
            total_cost+=C[j][0]
            for k in range(M):
                skills[k]+=C[j][k+1]
    if min(skills)>=X:
        ans=min(ans,total_cost)
        
print(ans if ans != INF else -1)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d=map(int,input().split())
while a*c!=0:
    c-=b
    if c<=0:
        print("Yes")
    else:
        a-=d
        if a<=0:
            print("No")
        else:
            continue


Fixed submission:
a,b,c,d=map(int,input().split())
while a*c!=0:
    c-=b
    if c<=0:
        print("Yes")
        exit()
    else:
        a-=d
        if a<=0:
            print("No")
            exit()
Buggy python submission (verdict: Runtime Error):
X,Y,A,B,C=map(int,input().split())
red=sorted(list(map(int,input().split())),reverse=True)
green=sorted(list(map(int,input().split())),reverse=True)
nocolor=sorted(list(map(int,input().split())),reverse=True)

X_cnt=0
Y_cnt=0
ans=[]

for i in range(X):
    ans.append(red[i])
    X_cnt+=1
    if X_cnt==X:
        break
    elif X_cnt<X:
        continue
for i in range(Y):
    ans.append(green[i])
    Y_cnt+=1
    if Y_cnt==Y:
        break
    elif Y_cnt<Y:
        continue

ans=sorted(ans)
ans_sum=sum(ans)    
for i in range(C):
    if ans[i]<nocolor[i]:
        ans_sum=ans_sum+nocolor[i]-ans[i]
        
print(ans_sum)



Fixed submission:
X,Y,A,B,C=map(int,input().split())
R=sorted(list(map(int,input().split())),reverse=True)
G=sorted(list(map(int,input().split())),reverse=True)
RG=sorted(list(map(int,input().split())),reverse=True)


d=R[:X]+G[:Y]+RG
d.sort(reverse=True)
 
print(sum(d[:X+Y]))

Buggy python submission (verdict: Runtime Error):
X,Y,A,B,C=map(int,input().split())
red=sorted(list(map(int,input().split())),reverse=True)
green=sorted(list(map(int,input().split())),reverse=True)
nocolor=sorted(list(map(int,input().split())),reverse=True)

X_cnt=0
Y_cnt=0
ans=[]

for i in range(X):
    ans.append(red[i])
    X_cnt+=1
    if X_cnt==X:
        break
    elif X_cnt<X:
        continue
for i in range(Y):
    ans.append(green[i])
    Y_cnt+=1
    if Y_cnt==Y:
        break
    elif Y_cnt<Y:
        continue

ans=sorted(ans)
ans_sum=sum(ans)    
for i in range(C):
    if ans[i]<nocolor[i]:
        ans_sum=ans_sum_nocolor[i]-ans[i]
        
print(ans_sum)



Fixed submission:
X,Y,A,B,C=map(int,input().split())
R=sorted(list(map(int,input().split())),reverse=True)
G=sorted(list(map(int,input().split())),reverse=True)
RG=sorted(list(map(int,input().split())),reverse=True)


d=R[:X]+G[:Y]+RG
d.sort(reverse=True)
 
print(sum(d[:X+Y]))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))

b=[0]*N
for a in A:
    b[a-1]+=1
    
c=[0]*N
tmp=b
for i in range(N):
    c[i]+=tmp[i]*(tmp[i]-1)//2
    
for a in A:
    b[a-1]-=1
    print(sum(c)-c[a-1]+b[a-1]*(b[a-1]-1)//2)
    b[a-1]+=1
    

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

b=[0]*N
for a in A:
    b[a-1]+=1
    
c=[0]*N
tmp=b
for i in range(N):
    c[i]+=tmp[i]*(tmp[i]-1)//2
sum_c=sum(c)

for a in A:
    b[a-1]-=1
    print(sum_c-c[a-1]+b[a-1]*(b[a-1]-1)//2)
    b[a-1]+=1

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

b=[0]*N
for a in A:
    b[a-1]+=1
    
cnt=0

for k in range(N):
    tmp=b
    tmp[A[k]-1]-=1
    for i in range(N):
        cnt+=tmp[i]*(tmp[i]-1)//2
        if i==N-1:
            print(cnt)
            cnt=0
            tmp[A[k]-1]+=1    

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

b=[0]*N
for a in A:
    b[a-1]+=1
    
c=[0]*N
tmp=b
for i in range(N):
    c[i]+=tmp[i]*(tmp[i]-1)//2
sum_c=sum(c)

for a in A:
    b[a-1]-=1
    print(sum_c-c[a-1]+b[a-1]*(b[a-1]-1)//2)
    b[a-1]+=1
Buggy python submission (verdict: Runtime Error):
import sympy

a,b,c=map(int,input().split())

r_ab=sympy.sqrt(a*b)

print("Yes" if a+b+2*r_ab -c <0 else "No")

Fixed submission:
a,b,c=map(int,input().split())
print("Yes" if 4*a*b-(c-a-b)**2<0 and c-a-b>0 else "No")
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
P=list(map(int,input().split()))

ans=(sum(P[:K])+K)/2
for i in range(1,N-K+1):
    s=(sum(P[i-1:K+i-1])+K)/2
    ans=max(ans,s-(P[i-1]+1)/2+(P[i+K-1]+1)/2)
    
print(ans)

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

s=(sum(P[:K])+K)/2
ans=s

for i in range(1,N-K+1):
    ans=max(ans,s-(P[i-1]+1)/2+(P[i+K-1]+1)/2)
    s=s-(P[i-1]+1)/2+(P[i+K-1]+1)/2
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
mem=[[0] * 10 for _ in range(10)]

for i in range(1, N+1):
    s = str(i)
    mem[int(s[0])][int(s[-1])] += 1 
    
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += mem[i][j] * mem[j][i]
print(ans)


Fixed submission:
N = int(input())
mem = [[0]*10 for _ in range(10)]

for i in range(1,N+1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    mem[a][b] += 1

ans = 0
for i in range(1,N+1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    ans += mem[b][a]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
m=[]
for i in range(M):
    m.append(list(input().split()))
cnt_ac=0
cnt_wa=0
num=1
while num <=N:
    for i in range(M):
        if int(m[i][0])==num:
            if m[i][1]=="AC":
                cnt_ac+=1
                num +=1
            else:
                cnt_wa+=1
        elif i <M-1:
            continue
        else:
            num +=1
print(cnt_ac,cnt_wa)

Fixed submission:
N, M = map(int, input().split())
ac = [0] * (N+1)  
wa = [0] * (N+1)
ans= [0, 0]

for i in range(M):
    p, s = input().split()
    p = int(p)-1
    if ac[p] == 1:
        continue
    elif s == "WA":
        wa[p] += 1
    else:
        ans[0] += 1
        ans[1] += wa[p]
        ac[p] = 1
print(*ans)
Buggy python submission (verdict: Runtime Error):
 N=int(input())
X=[]
for i in range(N):
    X.append(list(map(int,input().split())))

total_d=0
for i in range(N):
    for j in range(i):
        total_d+=((X[i][0]-X[j][0])**2+(X[i][1]-X[j][1])**2)**0.5
ans=total_d*2/N
print(ans)

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

total_d=0
for i in range(N):
    for j in range(i):
        total_d+=((X[i][0]-X[j][0])**2+(X[i][1]-X[j][1])**2)**0.5
ans=total_d*2/N
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
ans=[]
for j in range(1,N+1):
    for i in range(N): 
        if A[i]==j:
            ans.append(i+1)
print(*ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = [0] * N
for i, a in enumerate(A):
    ans[a-1] = i+1
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=[]
cnt=0
for _ in range(N):
    S.append(sorted(list(input())))
    
for i in range(N):
    for j in range(i+1,N):
        if S[i] == S[j]:
            cnt += 1

print(cnt)

Fixed submission:
N = int(input())
d = {}
for _ in range(N):
    S = "".join(sorted(input()))
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
ans = 0
for v in d.values():
    ans += v * (v - 1) // 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[]
for _ in range(N):
    A.append(int(input()))

print(max(A[1:]))
for i in range(1,N-1):
    print(max(max(A[:i]),max(A[i+1:])))
print(max(A[:N]))

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A)[::-1]
mx1 = B[0]
mx2 = B[1]

for i in A:
    if i == mx1:
        print(mx2)
    else:
        print(mx1)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
def lcm(a,b):
    return (a * b) // math.gcd(a, b)

A,B,C,D=map(int,input().split())

E=lcm(C,D)

num_C=B//C-(A-1)//C
num_D=B//D-(A-1)//D
num_CD=B//E-(A-1)//E

ans=(B-A+1)-(num_C+num_D-num_CD)
print(ans)

Fixed submission:
from fractions import gcd
def lcm(a,b):
    return (a * b) // gcd(a, b)

A,B,C,D=map(int,input().split())

E=lcm(C,D)

num_C=B//C-(A-1)//C
num_D=B//D-(A-1)//D
num_CD=B//E-(A-1)//E

ans=(B-A+1)-(num_C+num_D-num_CD)
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
def lcm(a,b):
    return (a * b) // math.gcd(a, b)

A,B,C,D=map(int,input().split())
E=lcm(C,D)

num_C=B//C-(A-1)//C
num_D=B//D-(A-1)//D
num_CD=B//E-(A-1)//E

ans=(B-A+1)-(num_C+num_D-num_CD)
print(ans)

Fixed submission:
from fractions import gcd
def lcm(a,b):
    return (a * b) // gcd(a, b)

A,B,C,D=map(int,input().split())

E=lcm(C,D)

num_C=B//C-(A-1)//C
num_D=B//D-(A-1)//D
num_CD=B//E-(A-1)//E

ans=(B-A+1)-(num_C+num_D-num_CD)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,k=map(int,input().split())
h=list(map(int,input().split()))

dp = [0] * N

for i in range(1,N):
    dp[i] = min(dp[j] + abs(h[i] - h[j])  for j in range(max(i - k, 0), i) )
    
print(dp[-1])

Fixed submission:
import numpy as np

N,k=map(int,input().split())
h = np.array(list(map(int,input().split())))

dp = np.zeros(N, dtype=int)

for i in range(1,N):
    start = max(i-k,0)
    dp[i] = np.min(dp[start:i] + np.abs(h[i] - h[start:i]))
    
print(dp[-1])

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

INF = float('inf')
dp = [INF] * N
dp[0]=0

for i in range(1,N):
    dp[i] = min(dp[j] + abs(h[i] - h[j])  for j in range(max(i - k, 0), i) )
    
print(dp[-1])

Fixed submission:
import numpy as np

N,k=map(int,input().split())
h = np.array(list(map(int,input().split())))

dp = np.zeros(N, dtype=int)

for i in range(1,N):
    start = max(i-k,0)
    dp[i] = np.min(dp[start:i] + np.abs(h[i] - h[start:i]))
    
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))

ans=[INF,INF]

for i in range(N):
    if ans[1]> abs(A-(T-H[i]*0.006)):
        ans[0]=i+1
        ans[1]=abs(A-(T-H[i]*0.006))
        
print(ans[0])

Fixed submission:
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
INF=float('inf')
ans=[INF,INF]

for i in range(N):
    if ans[1]> abs(A-(T-H[i]*0.006)):
        ans[0]=i+1
        ans[1]=abs(A-(T-H[i]*0.006))
        
print(ans[0])
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N==1:
    print("Hello World")
else:
    a,b=map(int,input().split())
    print(a+b)

Fixed submission:
N=int(input())
if N==1:
    print("Hello World")
else:
    a=int(input())
    b=int(input())
    print(a+b)
Buggy python submission (verdict: Runtime Error):
A=sorted(list(map(int,input())))
print(A[2]-A[0])

Fixed submission:
A=sorted(list(map(int,input().split())))
print(A[2]-A[0])
Buggy python submission (verdict: Runtime Error):
S=set(input())
print("Yes" len(S)==3 else "No")

Fixed submission:
S=set(input())
print("Yes" if len(S)==3 else "No")
Buggy python submission (verdict: Runtime Error):
N,Y=map(int,input().split())
a=-1
b=-1
c=-1
for i in range(0,N+1):
    for j in range(0,N-i+1):
        if 10000*i+5000*j+1000*(N-i-j) == Y:
                a=i
                b=j
                c=N-i-j
print(a,b,c)

Fixed submission:
S=input()
print("2018"+S[4:])
Buggy python submission (verdict: Runtime Error):
S=input()
T=input()
pront('YES' if S==T[::-1] else 'NO')

Fixed submission:
S=input()
T=input()
print('YES' if S==T[::-1] else 'NO')
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=[list(input()) for i in range(N)]
B=[list(input()) for i in range(M)]

ans=0

for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j]==B[0][0]:
            for k in range(0,M):
                for l in range(0,M):
                    if A[i+k][j+l]==B[k][l]:
                        ans+=1
                        if ans==M**2:
                            flag=1
                    else:
                        ans=0
                        break
    
print("Yes" if flag else "No")
                

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

ans=0
flag=0

for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j]==B[0][0]:
            for k in range(0,M):
                for l in range(0,M):
                    if A[i+k][j+l]==B[k][l]:
                        ans+=1
                        if ans==M**2:
                            flag=1
                    else:
                        ans=0
                        break
    
print("Yes" if flag else "No")
Buggy python submission (verdict: Runtime Error):
N=int(input())
K=int(input())
X=int(input())
Y=int(input())

if N-K>0:
    print(K*X+(N-K)*ren*Y)
else:
    print(N*X)

Fixed submission:
N=int(input())
K=int(input())
X=int(input())
Y=int(input())

if N-K>0:
    print(K*X+(N-K)*Y)
else:
    print(N*X)
Buggy python submission (verdict: Runtime Error):
print(input().split().index("0") + 1)


Fixed submission:
print(input()[:3])
Buggy python submission (verdict: Runtime Error):
print((int(input() + 1) // 2)

Fixed submission:
print(-(-int(input()) // 2))
Buggy python submission (verdict: Runtime Error):
n, r = map(int, (input().split()))
print(100 * max(0, (10 - n) + r)


Fixed submission:
n, r = map(int, (input().split()))
print(r + (100 * max(0, (10 - n))))
Buggy python submission (verdict: Runtime Error):
print(int(input() ** 2)


Fixed submission:
print(int(input())**2)
Buggy python submission (verdict: Runtime Error):
n, m, d = map(int, input().split())
if d != 0:
    print((2 * (n - d) * (m - 1)) / (n ** 2))
else:
    print((m - 1) / n)


Fixed submission:
a, b = map(int, input().split())
if a + b == 15:
    print("+")
elif a * b == 15:
    print("*")
else:
    print("x")
Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
k = int(input())
subs = set()
for i in range(len(s)):
    for j in range(i + 1, len(s) + 1):
        subs.add(s[i:j])
print(sorted(list(subs))[k - 1])


Fixed submission:
s = str(input())
k = int(input())
subs = set()
for i in range(len(s)):
    for j in range(i + 1, i + k + 1):
        subs.add(s[i:j])
print(sorted(list(subs))[k - 1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = map(int, input().split())
ans = "YES"

for ti in t:
    if ti in d:
        d.remove(ti)
    else:
        ans = "NO"
print(ans)


Fixed submission:
from collections import Counter
n = input()
d = Counter(map(int, input().split()))
m = input()
t = Counter(map(int, input().split()))
d.subtract(t)
print("NO" if -d else "YES")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted(list(map(int, input().split())))

b = 0
c = 0
while a:
    if a.pop() in a:
        if b == 0:
            b = a.pop()
        elif c == 0:
            c = a.pop()
        else:
            break
print(b * c)


Fixed submission:
from collections import Counter

n = int(input())
c = Counter(map(int, input().split()))
h = w = 0
for k, v in c.items():
    if v >= 2 and k > w:
        if k > h:
            if v >= 4:
                h = k
                w = k
            else:
                w = h
                h = k
        else:
            w = k
print(h * w)
Buggy python submission (verdict: Runtime Error):
from functools import reduce
from math import gcd

n = int(input())
clocks = []
for i in range(n):
    clocks.append(int(input()))
print(reduce(lambda x, y: (x * y) // gcd(x, y), clocks))


Fixed submission:
from functools import reduce
from fractions import gcd

n = int(input())
clocks = []
for i in range(n):
    clocks.append(int(input()))
print(reduce(lambda x, y: (x * y) // gcd(x, y), clocks))

Buggy python submission (verdict: Runtime Error):
from functools import reduce
from math import gcd

n = int(input())
clocks = []
for i in range(n):
    clocks.append(int(input()))
print(reduce(lambda x, y: (x * y) // gcd(x, y), clocks, 1))


Fixed submission:
from functools import reduce
from fractions import gcd

n = int(input())
clocks = []
for i in range(n):
    clocks.append(int(input()))
print(reduce(lambda x, y: (x * y) // gcd(x, y), clocks))
Buggy python submission (verdict: Runtime Error):
n = input()
a = (input() for i in range(n))
counter = 0
i = 1
while counter < n:
    i = a[i - 1]
    counter += 1
    if i == 2:
        print(counter)
        break
else:
    print(-1)


Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
counter = 0
i = 1
while counter <= n:
    i = a[i - 1]
    counter += 1
    if i == 2:
        print(counter)
        break
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial

n, m = map(int, input().split())
if n == m:
    print(2 * factorial(n)**2 % 1000000007)
elif abs(n - m) < 2:
    print(factorial(max(n, m)) * factorial(min(n, m) % 1000000007))
else:
    print(0)


Fixed submission:
from math import factorial

n, m = map(int, input().split())
if n == m:
    print(2 * factorial(n)**2 % 1000000007)
elif abs(n - m) < 2:
    print(factorial(n) * factorial(m) % 1000000007)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
from string import ascii_lowercase

n = int(input())
ans_l = [100 for i in range(26)]

for i in range(n):
    s = str(input())
    for i, j in enumerate(ascii_lowercase):
        ans_l[i] = min(ans_l[i], s.count(j))
print("".join(i * j for i, j in zip(ascii_lowercase, ans_l)))


Fixed submission:
a, b, c = map(int, input().split())
print("YES" if b - a == c - b else "NO")
Buggy python submission (verdict: Runtime Error):
X, Y = map(int, input().split())

result = 'No'
li = []
for _ in range(X):
    li.append(2)
    if sum(li) == Y:
        result = 'Yes'
        break

for i in range(X):
    li[i] = 4
    if sum(li) == Y:
        result = 'Yes'
        break

print(result)


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

result = 'No'
li = []
for i in range(X):
    li.append(4)
if sum(li) == Y:
    result = 'Yes'
else:
    for i in range(X):
        li[i] = 2
        if sum(li) == Y:
            result = 'Yes'
            break

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

ans = 1
for i in range(N):
    ans *= A[i]
    if 0 == A[i]:
        break
if 10 ** 18 < ans:
    print(-1)
else:
    print(ans)


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

ans = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        ans *= A[i]
        if 10 ** 18 < ans:
            ans = -1
            break
    print(ans)

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

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


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

ans = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        ans *= A[i]
        if 10 ** 18 < ans:
            ans = -1
            break
    print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
X = list(map(int, input().split()))

minX = min(X)
maxX = max(X)
li = []
for i in range(minX, maxX):
    temp = 0
    for j in range(N):
        temp += (X[j] - i)**2
    li.append(temp)

print(min(li))


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

minX = min(X)
maxX = max(X)
li = []
for i in range(100):
    temp = 0
    for j in range(N):
        temp += (X[j] - i)**2
    li.append(temp)

print(min(li))
Buggy python submission (verdict: Time Limit Exceeded):
import re
S = input()

result = 0
while re.search(r'01|10', S):
    count = len(re.findall(r'01|10', S))
    S = re.sub(r'01|10', '', S, count)
    result += 2 * count
print(result)


Fixed submission:
S = input()
temp0 = S[:int(len(S)/2)]
temp1 = S[int(len(S)/2):]
temp01 = min(temp0.count('0'), temp1.count('1'))
temp10 = min(temp0.count('1'), temp1.count('0'))
print(temp01 * 2 + temp10 * 2)

Buggy python submission (verdict: Time Limit Exceeded):
import re
S = input()

result = 0
while re.search(r'01|10', S):
    S = re.sub(r'01|10', '', S, 1)
    result += 2
print(result)


Fixed submission:
S = input()
temp0 = S[:int(len(S)/2)]
temp1 = S[int(len(S)/2):]
temp01 = min(temp0.count('0'), temp1.count('1'))
temp10 = min(temp0.count('1'), temp1.count('0'))
print(temp01 * 2 + temp10 * 2)

Buggy python submission (verdict: Time Limit Exceeded):
import re
S = input()

result = 0
for i in range(len(S)):
    if re.search(r'01|10', S):
        result += 2
        S = re.sub(r'01|10', '', S, 1)
print(result)


Fixed submission:
S = input()
temp0 = S[:int(len(S)/2)]
temp1 = S[int(len(S)/2):]
temp01 = min(temp0.count('0'), temp1.count('1'))
temp10 = min(temp0.count('1'), temp1.count('0'))
print(temp01 * 2 + temp10 * 2)