Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02755 (python)

Fixed submission:
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# /PycharmProjects/atcoder/C-TaxIncrease.py
#
A, B = map(int, input().split())
ans = -1
for i in range (1000 + 1):
    if (int(i*0.08) == A) and (int(i*0.10) == B):
        ans = i
        break
print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# /home/remina/PycharmProjects/atcoder/C-TaxIncrease.py
#
import sys
import math


def calc_notaxincluded_min_from_tax8(tax8: int) -> int:
    notaxincluded_min = int(tax8 / 0.08)
    return notaxincluded_min


def calc_notaxincluded_max_from_tax8(tax8: int) -> int:
    notaxincluded_max = math.ceil((tax8 + 1) / 0.08)
    return notaxincluded_max


def calc_notaxincluded_min_from_tax10(tax10: int) -> int:
    notaxincluded_min = int(tax10 / 0.1)
    return notaxincluded_min


def calc_notaxincluded_max_from_tax10(tax10: int) -> int:
    notaxincluded_max = math.ceil((tax10 + 1) / 0.1)
    return notaxincluded_max


tax_8, tax_10 = map(int, sys.stdin.readline().split())
notax_min_from8 = calc_notaxincluded_min_from_tax8(tax_8)
notax_min_from10 = calc_notaxincluded_min_from_tax10(tax_10)
notax_max_from8 = calc_notaxincluded_max_from_tax8(tax_8)
notax_max_from10 = calc_notaxincluded_max_from_tax10(tax_10)

print(notax_min_from8)
print(notax_min_from10)
print(notax_max_fromA8)
print(notax_max_from10)


if (notax_min_from10 > notax_max_from8) or (notax_min_from8 > notax_min_from10):
    print(-1)
elif notax_min_from8 <= notax_min_from10:
    print(notax_min_from8)
else:
    print(notax_min_from10)
Problem p02995 (python)

Fixed submission:
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-RemainderMinimization.py
#
# import math
from fractions import gcd
a, b, c, d = map(int, input().split())
# cd_lcm = (c * d) // math.gcd(c, d)
cd_lcm = (c * d) // gcd(c, d)
ab_c = b//c - (a-1)//c
ab_d = b//d - (a-1)//d
ab_cd_both = b//cd_lcm - (a-1)//cd_lcm
ab_cd_either = ab_c + ab_d - ab_cd_both
ab_cd_neither = b-a+1 - ab_cd_either

print(ab_cd_neither)

Buggy submission (verdict: Runtime Error):
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-RemainderMinimization.py
#
import math
a, b, c, d = map(int, input().split())
cd_lcm = (c * d) // math.gcd(c, d)
ab_c = b//c - (a-1)//c
ab_d = b//d - (a-1)//d
ab_cd_both = b//cd_lcm - (a-1)//cd_lcm
ab_cd_either = ab_c + ab_d - ab_cd_both
ab_cd_neither = b-a+1 - ab_cd_either

print(ab_cd_neither)

Buggy submission (verdict: Runtime Error):
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-RemainderMinimization.py
#
import math
a, b, c, d = map(int, input().split())
cd_lcm = (c * d) // math.gcd(c, d)
ab_c = b//c - (a-1)//c
ab_d = b//d - (a-1)//d
ab_cd_both = b//cd_lcm - (a-1)//cd_lcm
ab_cd_either = ab_c + ab_d - ab_cd_both
ab_cd_neither = b-a+1 - ab_cd_either
# print("cd_lcm ab_cd_either {} {}".format(cd_lcm, ab_cd_either))

print(ab_cd_neither)

Buggy submission (verdict: Runtime Error):
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-RemainderMinimization.py
#
import math
a, b, c, d = map(int, input().split())
cd_lcm = (c * d) // math.gcd(c, d)
ab_c = b//c - (a-1)//c
ab_d = b//d - (a-1)//d
ab_cd_both = b//cd_lcm - (a-1)//cd_lcm
ab_cd_either = ab_c + ab_d - ab_cd_both
ab_cd_neither = b-a+1 - ab_cd_either
# print("cd_lcm ab_cd_either {} {}".format(cd_lcm, ab_cd_either))

print(ab_cd_neither)
Problem p03001 (python)

Fixed submission:
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-RectangleCutting.py
#
w, h, x, y = map(int, input().split())
cutting = 0
if w == 2 * x and h == 2 * y:
  cutting += 1
print(w*h/2, cutting)

Buggy submission (verdict: Runtime Error):
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-RectangleCutting.py
#
w, h, x, y = map(int, input().split())
if x == w or y == h:
    print(0, 0)
    exit()

left = x * h
right = (w - x) * h
up = w * (h - y)
# down = w * y
area = left
cutting = 0
print("left, right, up, down : {} {} {} {}".format(left, right, up, down))

if left == right:
    area = left
elif up == down:
    area = up
elif left < right:
    if up < down:
        if left == up:
            area = left
            cutting = 1
        elif left < up:
            area = left
        else:
            area = up
    else:
        if left == down:
            area = left
            cutting = 1
        elif left < down:
            area = left
        else:
            area = down
else:
    if up < down:
        if right == up:
            area = right
            cutting = 1
        elif right < up:
            area = right
        else:
            area = up
    else:
        if right == down:
            area = right
            cutting = 1
        elif right < down:
            area = right
        else:
            area = down

print(area, cutting)
Problem p02694 (python)

Fixed submission:
X=int(input())
year = 0
deposit = 100 
while  deposit < X :
    deposit = deposit*101//100
    year += 1
print(year)

Buggy submission (verdict: Runtime Error):
X=int(input())
year = 0
deposit = 100 
while  deposit < x :
    deposit = deposit*101//100
    year += 1
print(year)

Buggy submission (verdict: Runtime Error):
X=int(input())
year = 0
deposit = 100 
while  deposit < x :
    deposit+=deposit*101//100
    year += 1
print(year)
Problem p02853 (python)

Fixed submission:
X,Y=map(int,input().split())
if X==1 :
    x=300000
elif X==2 :
    x=200000
elif X==3 :
    x=100000
else :
    x=0
if Y==1 :
    y=300000
elif Y==2 :
    y=200000
elif Y==3 :
    y=100000
else :
    y=0
if X==1 and Y==1 :
    print(x+y+400000)
else :
    print(x+y)

Buggy submission (verdict: Runtime Error):
X,Y=map(int,input().split())
if X==1 :
    x=300000
elif X==2 :
    x=200000
elif X==3 :
    x=100000
if Y==1 :
    y=300000
elif Y==2 :
    y=200000
elif Y==3 :
    y=100000
if X==1 and Y==1 :
    print(x+y+400000)
else :
    print(x+y)

Buggy submission (verdict: Runtime Error):
X,Y=map(int,input().split())
if X==1 :
    x=300000
elif X==2 :
    x=200000
elif X==3 :
    x=100000
if Y==1 :
    y=300000
elif Y==2 :
    y=200000
elif Y==3 :
    y=100000
if X==1 and Y==1 :
    print(x+y+400000)
else :
    print(x+y)
Problem p03206 (python)

Fixed submission:
D=int(input())
if D==25 :
    print('Christmas')
elif D==24 :
    print('Christmas Eve')
elif D==23 :
    print('Christmas Eve Eve')
elif D==22 :
    print('Christmas Eve Eve Eve')

Buggy submission (verdict: Runtime Error):
D=input()
if D=25 :
    print('Christmas')
elif D=24 :
    print('Christmas Eve')
elif D=23 :
    print('Christmas Eve Eve')
elif D=22 :
    print('Christmas Eve Eve Eve')
Problem p03211 (python)

Fixed submission:
s = input()
ans = 9999
for i in range(len(s)-2):
  ans = min(ans,abs( int(s[i:i+3]) - 753 ))
print(ans)

Buggy submission (verdict: Runtime Error):
S=list(input())
X=753
ans=0
for i in range(0,8,1) :
    for j in range(0,8,1) :
        if int(S[i]) == j :
            demo = int(S[i]+S[i+1]+S[i+2])
            if demo >= ans :
                ans = demo
print(abs(X-ans))
Problem p02724 (python)

Fixed submission:
# -*- coding: <encoding name> -*-

x = int(input())
print(1000 * (x // 500) + 5 * (x % 500 // 5))

Buggy submission (verdict: Runtime Error):
# -*- coding: <encoding name> -*-

x = int(input())
print(1000 * (x // 500) + 5 * (x % 500 // 5)
Problem p02730 (python)

Fixed submission:
S = input()
N = len(S)
S1 = S[0:(N-1)//2]
S2 = S[(N+3)//2-1:N+1]
print("Yes" if S == S[::-1] and S1 == S1[::-1] and S2 == S2[::-1] else "No")

Buggy submission (verdict: Runtime Error):
# -*- coding: <encoding name> -*-

s = input()
s_former = s[:(len(s) - 1) // 2]
s_latter = s[(len(s) + 3) // 2 - 1:]
print('Yes' if s == s[::-1] and s_former == s_former[::-1] and s_latter == s_latter[::-1] else 'No')
v

Buggy submission (verdict: Runtime Error):
# -*- coding: <encoding name> -*-

s = input()
s_former = s[:(len(s) - 1) / 2]
s_latter = s[(len(s) + 3) / 2 - 1:]
print('Yes' if s == s[::-1] and s_former == s_former[::-1] and s_latter == s_latter[::-1] else 'No')

Buggy submission (verdict: Runtime Error):
# -*- coding: <encoding name> -*-

s = input()
s_former = s[:(len(s) - 1) / 2 + 1]
s_latter = s[(len(s) + 3) / 2 + 1:]
print('Yes' if s == s[::-1] and s_former == s_former[::-1] and s_latter == s_latter[::-1] else 'No')

Buggy submission (verdict: Runtime Error):
# -*- coding: <encoding name> -*-

s = input()
s_former = s[:(n - 1) / 2 + 1]
s_latter = s[(n + 3) / 2 + 1:]
print('Yes' if s == s[::-1] and s_former == s_former[::-1] and s_latter == s_latter[::-1] else 'No')

Buggy submission (verdict: Runtime Error):
# -*- coding: <encoding name> -*-

s = input()
s_former = s[:(n - 1) / 2 + 1]
s_latter = s[(n + 3) / 2 + 1:]
print('Yes' if s == s[::-1] and s_former == s_former[::-1] and s_latter == s_latter[::-1])
Problem p02898 (python)

Fixed submission:
# -*- coding: <encoding name> -*-

n, k = map(int, input().split())
h = list(map(int, input().split()))

count = 0

for i in h:
	if i >= k:
		count += 1

print(count)

Buggy submission (verdict: Runtime Error):
# -*- coding: <encoding name> -*-

n, k = map(int, input().split())
h = list(map(int, input().split()))

count = 0

for i in h:
	if i >= k:
		count++

print(count)

Buggy submission (verdict: Runtime Error):
# -*- coding: <encoding name> -*-

n, k = map(int, input().split())
h = list(map(int, input().split()))

count = 0

for i in h:
	if i >=:
		count++

print(count)
Problem p02922 (python)

Fixed submission:
# -*- coding: <encoding name> -*-

import math
a, b = map(int, input().split())
# range = d * 2 + 1
# c == 1 + a * n - n >= b
print(math.ceil((b - 1) / (a - 1)))

Buggy submission (verdict: Runtime Error):
# -*- coding: <encoding name> -*-

import math
a, b = map(int, input().split())
# range = d * 2 + 1
# c == 1 + a * n - n >= b
print(math.ceil((b - 1) / (a - 1))
Problem p02969 (python)

Fixed submission:
# -*- coding: <encode name> -*-

r = int(input())
print(3 * r * r)

Buggy submission (verdict: Runtime Error):
# -*- coding: <encode name> -*-

r = int(input())
input(3 * (r ** 2))

Buggy submission (verdict: Runtime Error):
# -*- coding: <encode name> -*-

r = int(input())
input(3 * r * r)
Problem p03219 (python)

Fixed submission:
# -*- coding: <encoding name> -*-

X, Y = map(int, input().split())
print(X + Y // 2)

Buggy submission (verdict: Runtime Error):
# -*- coding: <encoding name> -*-

X, Y = map(int, input())
print(X + Y // 2)
Problem p03407 (python)

Fixed submission:
# -*- coding: <encoding name> -*-

a, b, c = map(int, input().split())
print('Yes' if a + b >= c else 'No')

Buggy submission (verdict: Runtime Error):
# -*- coding: <encoding name> -*-

a, b, c = map(int, input().split())
print('Yes' if A + B >= C else 'No')

Buggy submission (verdict: Runtime Error):
# -*- coding: <encoding name> -*-

a, b, c = map(int, input().split())
print('Yes' if A + B >= C else 'No')
Problem p03555 (python)

Fixed submission:
# -*- coding: <encoding name> -*-

line_1 = input()
line_2 = input()
line = line_1 + line_2
print('YES' if line == line[::-1] else 'NO')

Buggy submission (verdict: Runtime Error):
# -*- coding: <encoding name> -*-

line_1 = input
line_2 = input
line = line_1 + line_2
print('YES' if line == line[::-1] else 'NO')
Problem p03573 (python)

Fixed submission:
# -*- coding: <encoding name> -*-

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

Buggy submission (verdict: Runtime Error):
# -*- coding: <encoding name> -*-

a, b, c = map(int, input())
print('a' if b ==c else 'b' if c == a else 'c')
Problem p03605 (python)

Fixed submission:
# -*- coding: <encoding name> -*-

n = input()
if '9' in n:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
# -*- coding: <encoding name> -*-

n = int(input())
if '9' in n:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
# -*- coding: <encoding name> -*-

n = int(input())
if 9 in n:
	print('Yes')
else:
	print('No')
Problem p03694 (python)

Fixed submission:
# -*- coding: <encoding name> -*-

n = int(input())
a = list(map(int, input().split()))

A = sorted(a)
print(A[-1] - A[0])

Buggy submission (verdict: Runtime Error):
# -*- coding: <encoding name> -*-

n = int(input())
a = list(map(int(), input().split()))

A = sorted(a)
print(A[-1] - A[0])

Buggy submission (verdict: Runtime Error):
# -*- coding: <encoding name> -*-

n = int(input())
a = list[map(int(), input().split())]

A = sorted(a)
print(A[-1] - A[0])
Problem p03085 (python)

Fixed submission:
b = str(input())
if b == 'A':
    print('T')
elif b == 'C':
    print('G')
elif b == 'G':
    print('C')
else:
    print('A')

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e - a <= k:
    print('Yay!')
else:
    print(':(')
Problem p02706 (python)

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

l = list(map(int,input().split()))

s = sum(l)

ans = n-s
if ans>=0:
  print(ans)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())

l = list()
for i in range(m):
  k = int(input())
  l.append(k)
s = sum(l)

ans = n-s
if ans>=0:
  print(ans)
else:
  print(-1)
Problem p02714 (python)

Fixed submission:
n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")
ans = r*g*b

for i in range(n):
    for j in range(1,n//2+1):
        if i+2*j>=n:
            break
        
        if s[i]!=s[i+j] and s[i+j]!=s[i+2*j] and s[i]!=s[i+2*j]:
            ans -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()

ans = 0
for a in range(0,n-2):
    for b in range(a,n-1):
        e = b-a
        #if s[a]!=s[b]:
            for c in range(b,n):
                f = c-b
                if e!=f:
                    if s[a]!=s[c] and s[b]!=s[c] and s[a]!=s[b]:
                        ans += 1

print(ans)
Problem p02811 (python)

Fixed submission:
k, x = map(int, input().split())
if k*500>=x:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
k, x = map(int, input().sprit())
if k*500>=x:
  print('Yes')
else:
  print('No')
Problem p02886 (python)

Fixed submission:
n=int(input())
S=list(map(int,input().split()))
c=0

for i in range(n):
    for j in range(n):
        if i!=j:
            c+=S[i]*S[j]


print(int(c/2))

Buggy submission (verdict: Runtime Error):
n=int(input())
S=list(map(int,input().split()))
c=0

print(n,S)

for i in range(7):
    for j in range(7):
        if i!=j:
            c+=S[i]*S[j]


print(int(c/2))
Problem p02981 (python)

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

Buggy submission (verdict: Runtime Error):
L,R = map(int, input().split())
MIN = 2019
for i in range(L,R):
    for j in range(i+1, R+1):
        mod = ij % 2019

        if MIN > mod:
            MIN = mod
 
print(MIN)

Buggy submission (verdict: Runtime Error):
L,R = map(int, input().split())
MIN = R*2
for i in range(L,R):
    for j in range(i+1, R+1):
        mod = ij % 2019

        if MIN > mod:
            MIN = mod
 
print(MIN)
Problem p02694 (python)

Fixed submission:
t=int(input())
k=100000
p=100
for i in range(1,k):
	p=int(p*1.01)
	if (p>=t):
		print (i)
		break

Buggy submission (verdict: Runtime Error):
t=input()
import math
print (math.log(t)-math.log(100))/math.log(1.01)
Problem p02866 (python)

Fixed submission:
# ？？？？？？？？？？？？？？？？？？？？？？？？？？
# ケース12と13、完全にバグとしか思えないのですが?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

# もしかして：頂点1は必ず0？

n = int(input())
a = list(map(int, input().split()))
if a[0] != 0:
    print(0)
    exit()
a = sorted(a)
d = {}
for av in a:
    if av not in d:
        d[av] = 1
    else:
        d[av] += 1

if a[0] != 0 or d[0] != 1 or len(set(d.keys())) != a[-1] + 1:
    print(0)
    exit()
MOD = 998244353
ans = 1
for i in range(2, a[-1] + 1):
    ans *= pow(d[i - 1], d[i], MOD)
print(ans % MOD)

Buggy submission (verdict: Runtime Error):
# ？？？？？？？？？？？？？？？？？？？？？？？？？？
# ケース12と13、完全にバグとしか思えないのですが?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

# もしかして：頂点1は必ず0？

n = int(input())
a = list(map(int, input().split()))
if a[0] != 0:
    print(0)
    exit()
a = sorted(a)
d = {}
for av in a:
    if av not in d:
        d[av] = 1
    else:
        d[av] += 1
if d[0] != 1
    print(0)
    exit()
MOD = 998244353

ans = 1
for i in range(1, a[-1] + 1):
    if i not in d:
        ans = 0
        break
    ans *= pow(d[i - 1], d[i], MOD)
print(ans % MOD)

Buggy submission (verdict: Runtime Error):
# ？？？？？？？？？？？？？？？？？？？？？？？？？？

n = int(input())
# たしかpythonの辞書は順番も守ってくれた気がするのでソートしとく
a = sorted(list(map(int, input().split())))
d = {}
for av in a:
    if av not in d:
        d[av] = 1
    else:
        d[av] += 1

# if a[0] != 0 or d[0] != 1 or len(set(d.keys())) != a[-1] + 1: もしかしてこれの最後の条件のせい？？？？？？？？？？？？
# いやおかしいだろ 0から最大値まで揃ってなきゃ構築できねぇだろうが
if a[0] != 0 or d[0] != 1:
    print(0)
    exit()
MOD = 998244353
ans = 1
for i in range(2, a[-1] + 1):
    ans *= pow(d[i - 1], d[i], MOD)
print(ans % MOD)

Buggy submission (verdict: Runtime Error):
# ？？？？？？？？？？？？？？？？？？？？？？？？？？

n = int(input())
# たしかpythonの辞書は順番も守ってくれた気がするのでソートしとく
a = sorted(list(map(int, input().split())))
d = {}
for av in a:
    if av not in d:
        d[av] = 1
    else:
        d[av] += 1

if a[0] != 0 or d[0] != 1 or len(set(d.keys())) != a[-1] + 1:
    print(0)
    exit()
MOD = 998244353
ans = 1
# for i in range(2, a[-1] + 1):  なんでこれじゃだめなの？
for i in range(1, a[-1] + 1)
    ans *= pow(d[i - 1], d[i], MOD)
print(ans % MOD)
Problem p03001 (python)

Fixed submission:
# 真ん中を通れば必ず二分できてこれが最大値だが、自分自身が真ん中の座標の場合は自分自信を通るどんな直線も二分できる
w, h, x, y = map(int, input().split())
ans1 = (w * h) / 2.0
ans2 = 1 if w / 2 == x and h / 2 == y else 0
print(ans1, ans2)

Buggy submission (verdict: Runtime Error):
# 真ん中を通れば必ず二分できてこれが最大値だが、自分自身が真ん中の座標の場合は自分自信を通るどんな直線も二分できる
w, h, x, y = map(int, input().split())
ans1 = (w * h) / 2.0
ans2 = 1 if w // x == h // y == 2 else 0
print(ans1, ans2)

Buggy submission (verdict: Runtime Error):
# 結局平行線か45度かのminな気がする 真ん中は(H+W-2)
# 頂点にある場合もある
w, h, x, y = map(int, input().split())
ans = 0
if 0 == x or x == w and 0 == y or y == h:
    ans = min(w / 2, h / 2)
    print(ans, endl=" ")
    print(1 if w == h else 0)
    exit()
if 0 == x or x == w:
    # y軸で切る or 0かwの近い方への差
    if y < h // 2:
        ans = min(y * w, y / 2)
    else:
        ans = min((h - y) * y, (h - y) / 2)
elif 0 == y or y == h:
    # x軸で切る
    if x < w // 2:
        ans = min(x * h, x / 2)
    else:
        ans = min((w - x) * x, (w - x) / 2)

if ans != 0:
    print(ans, 0)
else:
    if x == w/2 or y == h/2:
        if w == y:
            # 真ん中
            print(x * y, 1)
        else:
            print(min(x * y, (w - x) * y, (h - y) * x), 1)
    else:
        print(min([y * w, y / 2, (h - y) * y, (h - y) / 2,
                   x * h, x / 2, (w - x) * x, (w - x) / 2]), 0)
Problem p03110 (python)

Fixed submission:
n = int(input())
ans = 0
for _ in range(n):
    x, y = input().split()
    x = float(x)
    if y == "JPY":
        ans += x
    else:
        ans += x * 380000.0
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
for _ in range(n):
    x, y = map(int, input().split())
    if y == "JPY":
        ans += x
    else:
        ans += 380000
print(ans)
Problem p03419 (python)

Fixed submission:
# 書けばわかる 裏になるのは奇数回訪れる場所
n, w = map(int, input().split())
print(abs(n*w-(2*n+2*w-4)))

Buggy submission (verdict: Runtime Error):
# マジで納得がいかねぇので01がなんのケースなのかわざわざ調べてやる

n, m = map(int, input().split())

if n == 1 or m == 1:  # どうせこれだろ
    print(f"kasu")
    print(1 / 0)
Problem p03557 (python)

Fixed submission:
# それぞれソート済みとして, 整数でAi<BjかつBj<Ckとなるjを求める(にぶたん)

N = int(input())
A = list(sorted(list(map(int, input().split()))))
B = list(sorted(list(map(int, input().split()))))
C = list(sorted(list(map(int, input().split()))))


def lower_bound(arr, target):
    # targetを超える最小の値のインデックス
    if target > arr[-1]:
        return None
    left, right = 0, len(arr)
    while left < right:
        mid = (left + right) // 2
        if arr[mid] > target:
            right = mid
        else:
            left = mid + 1
    return right


def upper_bound(arr, target):
    # target以上の最小の値のインデックス
    if target < arr[0]:
        return None
    left, right = 0, len(arr)
    while left < right:
        mid = (left + right) // 2
        if arr[mid] >= target:
            right = mid
        else:
            left = mid + 1
    return right


count = 0

for b in B:
    ai = upper_bound(A, b)
    ci = lower_bound(C, b)
    if ai is not None and ci is not None:
        count += ai * (N - ci)

print(count)

Buggy submission (verdict: Runtime Error):
# それぞれソート済みとして, 整数でAi<BjかつBj<Ckとなるjを求める(にぶたん)

N = int(input())
A = list(sorted(list(map(int, input().split()))))
B = list(sorted(list(map(int, input().split()))))
C = list(sorted(list(map(int, input().split()))))


def lower_bound(arr, target):
    # targetを超える最小の値のインデックス
    if target > arr[-1]:
        return None
    left, right = 0, len(arr)
    while left < right:
        mid = (left + right) // 2
        if arr[mid] > target:
            right = mid
        else:
            left = mid + 1
    return right


def upper_bound(arr, target):
    # target以上の最小の値のインデックス
    if target < arr[0]:
        return None
    left, right = 0, len(arr)
    while left < right:
        mid = (left + right) // 2
        if arr[mid] >= target:
            right = mid
        else:
            left = mid + 1
    return right


count = 0

for b in B:
    ai = upper_bound(A, b)
    ci = N - lower_bound(C, b)
    if ai is not None and ci is not None:
        count += ai * ci

print(count)

Buggy submission (verdict: Runtime Error):
# それぞれソート済みとして, 整数でAi<BjかつBj<Ckとなるjを求める(にぶたん)

N = int(input())
A = list(sorted(list(map(int, input().split()))))
B = list(sorted(list(map(int, input().split()))))
C = list(sorted(list(map(int, input().split()))))


def lower_bound(arr, target):
    # targetを超える最小の値のインデックス
    if target > arr[-1]:
        return None
    left, right = 0, len(arr)
    while left < right:
        mid = (left + right) // 2
        if arr[mid] > target:
            right = mid
        else:
            left = mid + 1
    return right


def upper_bound(arr, target):
    # target以上の最小の値のインデックス
    if target < arr[0]:
        return None
    left, right = 0, len(arr)
    while left < right:
        mid = (left + right) // 2
        if arr[mid] >= target:
            right = mid
        else:
            left = mid + 1
    return right


count = 0

for b in B:
    ai = upper_bound(A, b)
    ci = N - lower_bound(C, b)
    if ai is not None and ci is not None:
        count += ai * ci

print(count)
Problem p03611 (python)

Fixed submission:
# ハッシュで数えてキーでソートして+-1を全探索
# と思ったけど登場してないやつでもいける 3 5 なら4が2個になるのでN個から全探索

n = int(input())
arr = list(map(int, input().split()))
lis = [0 for _ in range(10**5+1)]
hash = dict()
for a in arr:
    lis[a] += 1

ans = 1
for i in range(1, 10**5):
    ans = max(ans, lis[i-1]+lis[i]+lis[i+1])

print(ans)

Buggy submission (verdict: Runtime Error):
# ハッシュで数えてキーでソートして+-1を全探索
n = int(input())
arr = list(map(int, input().split()))
hash = dict()
for a in arr:
    if a in hash:
        hash[a] += 1
    else:
        hash[a] = 1

lis = list(sorted(hash.items(), key=lambda x: x[0]))

ans = 0
for i in range(1, n - 2):
    temp = lis[i][1]
    if lis[i - 1][0] + 1 == lis[i][0]:
        temp += lis[i - 1][1]
    if lis[i + 1][0] - 1 == lis[i][0]:
        temp += lis[i + 1][1]
    ans = max(ans, temp)

print(ans)