Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import collections
n=int(input())
s=[]
for _ in range(n):
    s.append(str(input()))
ans=collections.Counter(s)
a=max(ans.values())
ans=[i for i,k in ans.items() if a==k]
print(*ans.sort(),sep="\n")

Fixed submission:
import collections
n=int(input())
s=[]
for _ in range(n):
    s.append(str(input()))
ans=collections.Counter(s)
a=max(ans.values())
ans=[i for i,k in ans.items() if a==k]
print(*sorted(ans),sep="\n")

Buggy python submission (verdict: Runtime Error):
import collections
n=int(input())
s=[]
for _ in range(n):
    s.append(str(input()))
ans=collections.Counter(s)
values,count=zip(*ans)
for l in range(len(count)):
    if max(count)==count[l]:
        print(values[l])

Fixed submission:
import collections
n=int(input())
s=[]
for _ in range(n):
    s.append(str(input()))
ans=collections.Counter(s)
a=max(ans.values())
ans=[i for i,k in ans.items() if a==k]
print(*sorted(ans),sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[]
ans=set()
for _ in range(n):
    s.append(str(input()))
count=[0]*len(set(s))
for i in range(len(set(s))):
    count[i]+=s.count(list(set(s))[i])
for k in range(len(set(s))):
    if max(count)==count[k]:
        ans.add(list(set(s))[k])
for l in range(len(ans)):
    print(sorted(ans)[l])

Fixed submission:
import collections
n=int(input())
s=[]
for _ in range(n):
    s.append(str(input()))
ans=collections.Counter(s)
a=max(ans.values())
ans=[i for i,k in ans.items() if a==k]
print(*sorted(ans),sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[]
ans=set()
for _ in range(n):
    s.append(str(input()))
count=[0]*len(set(s))
for i in range(len(set(s))):
    for j in range(len(s)):
        if list(set(s))[i]==s[j]:
            count[i]+=1
for k in range(len(set(s))):
    if max(count)==count[k]:
        ans.add(list(set(s))[k])
for l in range(len(ans)):
    print(sorted(ans)[l])

Fixed submission:
import collections
n=int(input())
s=[]
for _ in range(n):
    s.append(str(input()))
ans=collections.Counter(s)
a=max(ans.values())
ans=[i for i,k in ans.items() if a==k]
print(*sorted(ans),sep="\n")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(n):
    if p[i]==min(p[:i+1]):
        ans+=1
print(ans)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
ans=0
MIN=p[0]
for i in range(n):
    if p[i]<=MIN:
        MIN=p[i]
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
P,S=[],[]
ans,pen=0,0
task=[0]*N
for _ in range(M):
    A,B=map(str,input().split())
    P.append(int(A))
    S.append(B)

for j in range(M):
    if task[A[M]-1]!=-1 and S[j]=="WA":
        pen+=1
    elif task[A[M]-1]!=-1 and S[j]=="AC":
        ans+=1
        task[A[M]]=-1
        break
print(ans,pen)

Fixed submission:
N,M=map(int,input().split())
P,S=[],[]
ans,pen=0,0
task=[0]*N
for _ in range(M):
    A,B=map(str,input().split())
    P.append(int(A))
    S.append(B)

for j in range(M):
    if task[P[j]-1]!=-1 and S[j]=="WA":
        task[P[j]-1]+=1
    elif task[P[j]-1]!=-1 and S[j]=="AC":
        ans+=1
        pen+=task[P[j]-1]
        task[P[j]-1]=-1
print(ans,pen)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
P,S=[],[]
ans,pen=0,0
task=[0]*N
for _ in range(M):
    A,B=map(str,input().split())
    P.append(int(A))
    S.append(B)

for j in range(M):
    if task[A[M]]!=-1 and S[j]=="WA":
        pen+=1
    elif task[A[M]]!=-1 and S[j]=="AC":
        ans+=1
        task[A[M]]=-1
        break
print(ans,pen)

Fixed submission:
N,M=map(int,input().split())
P,S=[],[]
ans,pen=0,0
task=[0]*N
for _ in range(M):
    A,B=map(str,input().split())
    P.append(int(A))
    S.append(B)

for j in range(M):
    if task[P[j]-1]!=-1 and S[j]=="WA":
        task[P[j]-1]+=1
    elif task[P[j]-1]!=-1 and S[j]=="AC":
        ans+=1
        pen+=task[P[j]-1]
        task[P[j]-1]=-1
print(ans,pen)
Buggy python submission (verdict: Runtime Error):
fun main(args:Array<String>){
    val a=readLine()!!.split(" ").map{it.toInt()}
    if (a[0]+a[1]+a[2]>=22){
        println("bust")
    }else{
        println("win")
    }
}

Fixed submission:
A,B,C=tuple(map(int,input().split()))
print("bust" if A+B+C>=22 else "win")
Buggy python submission (verdict: Runtime Error):
N=int(input())
ans=[]
for i in range(1,int(N**.5)):
    if N%i==0:
        ans.append(N//i+i-2)
print(min(ans))

Fixed submission:
N=int(input())
ans=[]
for i in range(1,int(N**.5)+2):
    if N%i<1:
        ans.append(N//i+i-2)
print(min(ans))

Buggy python submission (verdict: Runtime Error):
N=int(input())
ans=[]
for i in range(1,N**.5):
    if N%i==0:
        ans.append(N//i+i-2)
print(min(ans))

Fixed submission:
N=int(input())
ans=[]
for i in range(1,int(N**.5)+2):
    if N%i<1:
        ans.append(N//i+i-2)
print(min(ans))

Buggy python submission (verdict: Runtime Error):
N=int(input())
ans=[]
for i in range(1,N//2):
    if N%i==0:
        ans.append(N//i+i-2)
print(min(ans))

Fixed submission:
N=int(input())
ans=[]
for i in range(1,int(N**.5)+2):
    if N%i<1:
        ans.append(N//i+i-2)
print(min(ans))
Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
if A>2*B:
    print(A-2*B)
else:
    print(0)

Fixed submission:
A, B = map(int,input().split())
if A>2*B:
    print(A-2*B)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
N=int(input())
d = list(map(int, input().split()))
total=0
for n in range(N):
    for j in range(n+1,N):
        total+=d[n]*d[j]
total

Fixed submission:
A, B = map(int,input().split())
if A>2*B:
    print(A-2*B)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
N=int(input())
d=[]
total=0
for i in range(N):
    d.append(int(input()))
for n in range(N):
    for j in range(n+1,N):
        total+=d[n]*d[j]
total

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

Fixed submission:
N=int(input())
values=list(map(int,input().split()))
keys=list(range(1,N+1))
d=dict(zip(keys,values))
e=sorted(d.items(), key=lambda x:x[1])
for i in range(N):
    print(e[i][0],end=" ")
Buggy python submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
count=0
ans=[]
for i in range(1,N):
    if H[i-1]>=H[i]:
        count+=1
        if i==N-1:
            ans.append(count)
    else:
        ans.append(count)
        count=0
print(max(ans))

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
count=0
ans=[]
for i in range(1,N):
    if H[i-1]>=H[i]:
        count+=1
        if i==N-1:
            ans.append(count)
    else:
        ans.append(count)
        count=0

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

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
a=0
for i in range(N-1):
    if a<H[i]:
        a=H[i]
    if a-1>H[i+1]:
        print("No")
        break
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
from itertools import combinations
L,R=map(int,input().split())
ans=L*R%2019
for i in combinations(range(L,R+1),2):
    if L!=0 and R!=0:
        if ans>=i[0]*i[1]%2019:
            ans=i[0]*i[1]%2019
    else:
        ans=0
print(ans)

Fixed submission:
from itertools import combinations
L,R=map(int,input().split())
ans=L*R%2019
if R-L>=2018:
    print(0)
else:
    for i in combinations(range(L,R+1),2):
        if ans>=i[0]*i[1]%2019:
            ans=i[0]*i[1]%2019
    print(ans)

Buggy python submission (verdict: Runtime Error):
from itertools import combinations
L,R=map(int,input().split())
ans=L*R%2019
for i in combinations(range(L,R+1),2):
    if ans>=i[0]*i[1]%2019:
        ans=i[0]*i[1]%2019
    elif L==0 or R==0:
        ans=0
print(ans)

Fixed submission:
from itertools import combinations
L,R=map(int,input().split())
ans=L*R%2019
if R-L>=2018:
    print(0)
else:
    for i in combinations(range(L,R+1),2):
        if ans>=i[0]*i[1]%2019:
            ans=i[0]*i[1]%2019
    print(ans)

Buggy python submission (verdict: Runtime Error):
from itertools import combinations
L,R=map(int,input().split())
ans=L*R%2019
for i in combinations(range(L,R+1),2):
    if ans>=i[0]*i[1]%2019:
        ans=i[0]*i[1]%2019
print(ans)

Fixed submission:
from itertools import combinations
L,R=map(int,input().split())
ans=L*R%2019
if R-L>=2018:
    print(0)
else:
    for i in combinations(range(L,R+1),2):
        if ans>=i[0]*i[1]%2019:
            ans=i[0]*i[1]%2019
    print(ans)
Buggy python submission (verdict: Runtime Error):
A=[int(input()) for i in range(5)]
ans=0
for i in range(5):
    if A[i]%10==0:
        ans+=A[i]
        A[i]=0
B=[str(i) for i in A]
C=[B[i][-1] for i in range(5)]
C=[int(C[i]) for i in range(5)]
D=[None]*5
for i in range(5):
    D[i]=int(B[i])-int(C[i])
try:
    E=list([n for n in(sorted(C,reverse=True)) if n>0])
finally:
    pass
for i in range(len(E)-1):
    ans+=10
ans=ans+E[-1]+int(sum(D))
print(ans)

Fixed submission:
A=[int(input()) for i in range(5)]
ans=0
for i in range(5):
    if A[i]%10==0:
        ans+=A[i]
        A[i]=0
B=[str(i) for i in A]
C=[B[i][-1] for i in range(5)]
C=[int(C[i]) for i in range(5)]
D=[None]*5
for i in range(5):
    D[i]=int(B[i])-int(C[i])
E=list([n for n in(sorted(C,reverse=True)) if n>0])
for i in range(len(E)-1):
    ans+=10
try:
    ans=ans+E[-1]+int(sum(D))
except(IndexError):
    ans=ans+int(sum(D))
print(ans)

Buggy python submission (verdict: Runtime Error):
A=[int(input()) for i in range(5)]
ans=0
for i in range(5):
    if A[i]%10==0:
        ans+=A[i]
        A[i]=0
B=[str(i) for i in A]
C=[B[i][-1] for i in range(5)]
C=[int(C[i]) for i in range(5)]
D=[None]*5
for i in range(5):
    D[i]=int(B[i])-int(C[i])
E=list([n for n in(sorted(C,reverse=True)) if n>0])
for i in range(len(E)-1):
    ans+=10
ans=ans+E[-1]+int(sum(D))
print(ans)

Fixed submission:
A=[int(input()) for i in range(5)]
ans=0
for i in range(5):
    if A[i]%10==0:
        ans+=A[i]
        A[i]=0
B=[str(i) for i in A]
C=[B[i][-1] for i in range(5)]
C=[int(C[i]) for i in range(5)]
D=[None]*5
for i in range(5):
    D[i]=int(B[i])-int(C[i])
E=list([n for n in(sorted(C,reverse=True)) if n>0])
for i in range(len(E)-1):
    ans+=10
try:
    ans=ans+E[-1]+int(sum(D))
except(IndexError):
    ans=ans+int(sum(D))
print(ans)

Buggy python submission (verdict: Runtime Error):
A=[int(input()) for i in range(5)]
ans=0
for i in range(5):
    if A[i]%10==0:
        ans+=A[i]
        A[i]=0
B=[str(i) for i in A]
C=[B[i][-1] for i in range(5)]
C=[int(C[i]) for i in range(5)]
D=[None]*5
for i in range(5):
    D[i]=int(B[i])-int(C[i])
E=list([n for n in(sorted(C,reverse=True)) if n>0])
for i in range(len(E)-1):
    ans+=10
ans=ans+E[-1]+int(sum(D))
print(ans)

Fixed submission:
A=[int(input()) for i in range(5)]
ans=0
for i in range(5):
    if A[i]%10==0:
        ans+=A[i]
        A[i]=0
B=[str(i) for i in A]
C=[B[i][-1] for i in range(5)]
C=[int(C[i]) for i in range(5)]
D=[None]*5
for i in range(5):
    D[i]=int(B[i])-int(C[i])
E=list([n for n in(sorted(C,reverse=True)) if n>0])
for i in range(len(E)-1):
    ans+=10
try:
    ans=ans+E[-1]+int(sum(D))
except(IndexError):
    ans=ans+int(sum(D))
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N==1:
    print("Hello World")
else:
    A,B=tuple(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):
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
count = 0
numa = 0
numb = 0
while True:
    if numa < len(A) and numb < len(B):#リストの番号をどちらも指定できる
        if A[numa] <= B[numb] and count + A[numa] <= K:#AがB以下
            count += A[numb]
            numa += 1
        elif A[numa] > B[numb] and count + B[numb] <= K:#AがBより大きい
            count += B[numb]
            numb +=1
        else:#これ以上本を取り除けない
            break
    
    elif numa >= len(A) and numb < len(B):#Aだけのリストが終了
        if count + B[numb]<=K:
            count += B[numb]
            numb += 1
        else:
            break
    elif numa < len(A) and numb >= len(B):#Bだけのリストが終了
        if count + A[numa]<=K:
            count += B[numa]
            numa += 1
        else:
            break
    else:#リストのどちらも終了
        break

print(numa+numb)
    

Fixed submission:
import bisect
N,M,K = map(int,input().split())
A = [0]+list(map(int,input().split()))
K2 =K
count = 0
numa = 0
numb = 0
count2 = 0
for i in range(N+1):
    count += A[i]
    A[i] = count
#累積和
B = [0]+list(map(int,input().split()))
count = 0
for i in range(M+1):
    count += B[i]
    B[i] = count
#累積和

for i in range(N+1):#Aに対してBを探す
    K = K2
    if A[i] <= K:
        K -= A[i]
        if count2 < i + bisect.bisect_right(B, K):
            count2 = i + bisect.bisect_right(B, K)-1
    else:
        break
print(count2)
Buggy python submission (verdict: Runtime Error):
import itertools
N,K = map(int,input().split())
A = map(int,input().split())
t = list(list(itertools.combinations(A,K)))
ans = sum(t[0])
for i in t:
    ans = min(ans,sum(i))
print(ans)


Fixed submission:
a = input()
print("A" if a in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" else "a")
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N,K = map(int,input().split())
A = map(int,input().split())
t = list(list(itertools.combinations(A,K)))
ans = sum(t[0])
for i in t:
    ans = min(ans,sum(i))
print(ans)


Fixed submission:
N,K = map(int,input().split())
A = sorted(map(int,input().split()))
print(sum(A[:K]))

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N,K = map(int,input().split())
A = map(int,input().split())
t = list(list(itertools.combinations(A,K)))
ans = sum(t[0])
for i in t:
    ans = min(ans,sum(i))
print(ans)


Fixed submission:
N,K = map(int,input().split())
A = sorted(map(int,input().split()))
print(sum(A[:K]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
count = N
for i in range(N):
	for j in range(N):
		if a[i]%a[j] ==0 and i!= j:
			count = count -1
			break
print(count)

Fixed submission:
x = list(map(int,input().split()))
print(x.index(0)+1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
count = 0
flag = 0
for i in range(N):
	for j in range(N):
		if a[i]%a[j] ==0 and i!= j:
			flag = 1
			break
	if(flag == 0):
		count = count +1
	flag = 0
print(count)

Fixed submission:
x = list(map(int,input().split()))
print(x.index(0)+1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
count = 0
flag = 0
for i in range(N):
	for j in range(N):
		if a[i]%a[j] ==0 and i!= j:
			flag = 1
	if(flag == 0):
		count = count +1
	flag = 0
print(count)

Fixed submission:
x = list(map(int,input().split()))
print(x.index(0)+1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
count = 0
flag = 0
for i in range(N):
	for j in range(N):
		if a[i]%a[j] ==0 and i!= j:
			flag = 1
	if(flag == 0):
		count = count +1
	flag = 0
print(count)

Fixed submission:
x = list(map(int,input().split()))
print(x.index(0)+1)
Buggy python submission (verdict: Runtime Error):
x,n = map(int,input().split())
p = list(map(int,input().split()))
t = abs(min(p)-x)+1
u = min(p)-1
for i in range(min(x-1,min(p)-1),max(x+1,max(p)+2)):
	if not( i in p ):
		if abs(i-x)<t:
			t = abs(i-x)
			u = i
		elif  abs(i-x)==t:
			if i < u:
				u = i
print(u)

Fixed submission:
x,n = map(int,input().split())
if n == 0:
	print(x)
else:
	p = list(map(int,input().split()))
	t = abs(min(p)-x)+1
	u = min(p)-1
	for i in range(min(x-1,min(p)-1),max(x+1,max(p)+2)):
		if not( i in p ):
			if abs(i-x)<t:
				t = abs(i-x)
				u = i
			elif  abs(i-x)==t:
				if i < u:
					u = i
	print(u)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 1

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


Fixed submission:
N = int(input())
A = sorted(list(map(int,input().split())))
ans = 1
flag = 0
if(A[0] == 0):
    print(0)
else:
    for i in range(N):
        ans = ans*A[i]
        if ans >10**18:
            flag = 1
            break
    if(flag == 0):
        print(ans)
    else:
        print(-1)

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

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


Fixed submission:
N = int(input())
A = sorted(list(map(int,input().split())))
ans = 1
flag = 0
if(A[0] == 0):
    print(0)
else:
    for i in range(N):
        ans = ans*A[i]
        if ans >10**18:
            flag = 1
            break
    if(flag == 0):
        print(ans)
    else:
        print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
divide = 0
count = 0
for i in range(1000):
    num = str(i)
    while(len(num)<3):
        num = "0"+num
    flag = [0,0,0]
    for j in range(3):
        for k in range(divide,N):
            if num[j] == S[k]:
                flag[j] = 1
                divide = k+1
                break
    divide = 0      
    if(flag == [1,1,1]):
        count +=1
print(count)

Fixed submission:
N = int(input())
S = input()
divide = 0
count = 0
for i in range(1000):
    num = str(i)
    while(len(num)<3):
        num = "0"+num
    flag = [0,0,0]
    for j in range(3):
        for k in range(divide,N):
            if num[j] == S[k]:
                flag[j] = 1
                divide = k+1
                break
    divide = 0      
    if(flag == [1,1,1]):
        count +=1
print(count)
Buggy python submission (verdict: Runtime Error):
N,Q = map(int,input().split())
graph = [[] for _ in range(N)]
#グラフをリストで表現
for _ in range(N-1):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)#リストの番号で頂点を表示するため-1
    graph[b-1].append(a-1)
point = [0]*N
for _ in range(Q):
    a,b = map(int,input().split())
    point[a-1] += b#根にあたる部分にだけコストをプラス


#再帰定義
def dfs(now, prev = -1):#prev,now,nextの三段階を扱う
    for next in graph[now]:#今見ている頂点に連結されているものを見る
        if next == prev:#親だったら飛ばす
            continue
        point[next] += point[now]#子の得点をプラス
        dfs(next,now)#nextが親だけになると自分を呼ぶ前に飛ばされて終わる

dfs(0)#根頂点を指定してスタート
print(*point)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 6)
import sys
N,Q = map(int,input().split())
graph = [[] for _ in range(N)]
#グラフをリストで表現
for _ in range(N-1):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)#リストの番号で頂点を表示するため-1
    graph[b-1].append(a-1)
point = [0]*N
for _ in range(Q):
    a,b = map(int,input().split())
    point[a-1] += b#根にあたる部分にだけコストをプラス


#再帰定義
def dfs(now, prev = -1):#prev,now,nextの三段階を扱う
    for next in graph[now]:#今見ている頂点に連結されているものを見る
        if next == prev:#親だったら飛ばす
            continue
        point[next] += point[now]#子の得点をプラス
        dfs(next,now)#nextが親だけになると自分を呼ぶ前に飛ばされて終わる

dfs(0)#根頂点を指定してスタート
print(*point)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
ans = 0
for i in range(N):#A[i]固定
    ng = -1#A[i]以下
    ok = N#A[i]より大きい
    while ok-ng >1:#A[i]より大きいBのインデックスを探す
        mid = (ng+ok)//2
        if B[mid]>A[i]:
            ok = mid
        else:
            ng = mid
    #okはA[i]より大きい値で最も小さい
    #ngはA[i]より以下の値で最も大きい
    for j in range(ok,N):#B[j]固定
        ng2 = -1#B[j]以下
        ok2 = N#B[j]より大きい
        while ok2-ng2 > 1:#B[j]より大きいCのインデックスを探す
            mid2 = (ng2 + ok2)//2
            if C[mid2] > B[j]:
                ok2 = mid2
            else:
                ng2 = mid2
        ans += N-1 -(ok2-1)
print(ans)

Fixed submission:
N = int(input())
A = sorted(list(map(int,input().split())))
B = list(map(int,input().split()))
C = sorted(list(map(int,input().split())))
ans = 0
for i in range(N):
    #B[i]より小さいAのインデックスを求める
    ok = -1#B[i]より小さい
    ng = N#B[i]より大きい
    while ng-ok>1:#
        mid = (ok + ng)//2
        if A[mid]<B[i]:
            ok = mid
        else:
            ng = mid
    
    #B[i]より大きいCのインデックスを求める
    ok2 = N
    ng2 = -1
    while ok2-ng2>1:
        mid2 = (ok2+ng2)//2
        if C[mid2] > B[i]:
            ok2 = mid2
        else:
            ng2 = mid2
    
    ans += (ok+1)*(N-ok2)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
ans = 0
for i in range(N):#A[i]固定
    ng = -1#A[i]以下
    ok = N#A[i]より大きい
    while ok-ng >1:#A[i]より大きいBのインデックスを探す
        mid = (ng+ok)//2
        if B[mid]>A[i]:
            ok = mid
        else:
            ng = mid
    #okはA[i]より大きい値で最も小さい
    #ngはA[i]より以下の値で最も大きい
    for j in range(ok,N):#B[j]固定
        ng2 = -1#B[j]以下
        ok2 = N#B[j]より大きい
        while ok2-ng2 > 1:#B[j]より大きいCのインデックスを探す
            mid2 = (ng2 + ok2)//2
            if C[mid2] > B[j]:
                ok2 = mid2
            else:
                ng2 = mid2
        ans += N-1 -(ok2-1)
print(ans)

Fixed submission:
N = int(input())
A = sorted(list(map(int,input().split())))
B = list(map(int,input().split()))
C = sorted(list(map(int,input().split())))
ans = 0
for i in range(N):
    #B[i]より小さいAのインデックスを求める
    ok = -1#B[i]より小さい
    ng = N#B[i]より大きい
    while ng-ok>1:#
        mid = (ok + ng)//2
        if A[mid]<B[i]:
            ok = mid
        else:
            ng = mid
    
    #B[i]より大きいCのインデックスを求める
    ok2 = N
    ng2 = -1
    while ok2-ng2>1:
        mid2 = (ok2+ng2)//2
        if C[mid2] > B[i]:
            ok2 = mid2
        else:
            ng2 = mid2
    
    ans += (ok+1)*(N-ok2)

print(ans)
Buggy python submission (verdict: Runtime Error):
x = int(input())
if x==1:
  print(0)
else if x==0:
  print(1)

Fixed submission:
x = int(input())
if x==1:
  print(0)
  
else:
  print(1)
Buggy python submission (verdict: Time Limit Exceeded):

a,b,c,d = [int(x) for x in input().split()]
ans = -999999999999999
for i in range(a,b+1):
    for j in range(c,d+1):
        ans = max(ans,i*j)
        
print(ans)

Fixed submission:
a,b,c,d = [int(x) for x in input().split()]


print(max(a*c,a*d,b*c,b*d))
Buggy python submission (verdict: Runtime Error):
n = int(input())
count = 0
flag = False
for i in range(n):
    a, b = map(int, input().split())
    if a == b:
        if count == 2:
            flag = True
        else:
            count += 1
    else:
        count = 0
if flag:
    print(Yes)
else:
    print("No")

Fixed submission:
n = int(input())
count = 0
flag = False
for i in range(n):
    a, b = map(int, input().split())
    if a == b:
        if count == 2:
            flag = True
        else:
            count += 1
    else:
        count = 0
if flag:
    print("Yes")
else:
    print("No")