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

Fixed submission:
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())

N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]

uf = UnionFind(N)
for a,b in AB:
    uf.union(a-1,b-1)

print(uf.group_count() - 1)

Buggy submission (verdict: Runtime Error):
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())

N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]

uf = UnionFind(N)
for a,b in AB:
    uf.union(a,b)

print(uf.group_count() - 1)
Problem p02664 (python)

Fixed submission:
T = list(input())

if len(T) == 1:
    if T[0] == '?':
        T[0] = 'D'

else:
    if T[0] == '?':
        if T[1] == 'D' or T[1] == '?':
            T[0] = 'P'
        if T[1] == 'P':
            T[0] = 'D'

    for i in range(len(T)-1):
        if T[i] == '?':
            if T[i+1] == 'D' and T[i-1] == 'P':
                T[i] = 'D'
            if T[i+1] == 'D' and T[i-1] == 'D':
                T[i] = 'P'
            if T[i+1] == 'P':
                T[i] = 'D'
            if T[i+1] == '?' and T[i-1] == 'P':
                T[i] = 'D'
            if T[i+1] == '?' and T[i-1] == 'D':
                T[i] = 'P'

    if T[-1] == '?':
        T[-1] = 'D'

ans = ''.join(T)
print(ans)

Buggy submission (verdict: Runtime Error):
T = list(input())

if T[0] == '?':
    if T[1] == 'D' or T[1] == '?':
        T[0] = 'P'
    if T[1] == 'P':
        T[0] = 'D'

for i in range(len(T)-1):
    if T[i] == '?':
        if T[i+1] == 'D' and T[i-1] == 'P':
            T[i] = 'D'
        if T[i+1] == 'D' and T[i-1] == 'D':
            T[i] = 'P'
        if T[i+1] == 'P':
            T[i] = 'D'
        if T[i+1] == '?' and T[i-1] == 'P':
            T[i] = 'D'
        if T[i+1] == '?' and T[i-1] == 'D':
            T[i] = 'P'

if T[-1] == '?':
    T[-1] = 'D'

ans = ''.join(T)
print(ans)

Buggy submission (verdict: Runtime Error):
T = list(input())

if T[0] == '?':
    if T[1] == 'D' or T[1] == '?':
        T[0] = 'P'
    if T[1] == 'P':
        T[0] = 'D'

for i in range(len(T)-1):
    if T[i] == '?':
        if T[i+1] == 'D':
            T[i] = 'P'
        if T[i+1] == 'P':
            T[i] = 'D'
        if T[i+1] == '?' and T[i-1] == 'P':
            T[i] = 'D'
        if T[i+1] == '?' and T[i-1] == 'D':
            T[i] = 'P'
if T[-1] == '?':
    T[-1] = 'D'

ans = ''.join(T)
print(ans)
Problem p02678 (python)

Fixed submission:
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
import sys
ans = [-1] * (N+1)
todo = deque([(1,0)])
while todo:
    x,parent = todo.popleft()
    # ans[x] = parent
    for y in graph[x]:
        if y == parent:
            continue
        if ans[y] != -1:
            continue
        ans[y] = x
        todo.append((y,x))
        

if -1 in ans[2:]:
    print('No')
else:
    print('Yes')
    for i in range(2,N+1):
        print(ans[i])

Buggy 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)

for i in range(N+1):
    graph[i].sort()
    
from collections import deque
todo = deque([(1,0)])
while todo:
    x,parent = todo.pop()
    ans[x] = parent
    for y in graph[x]:
        if y == parent:
            continue
        if ans[y] == -1:
            todo.append((y,x))
print('Yes')
for i in range(2,N+2):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
ans = [-1] * (N+1)
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

for i in range(N+1):
    graph[i].sort()
    
from collections import deque
todo = deque([(1,0)])
while todo:
    x,parent = todo.pop()
    ans[x] = parent
    for y in graph[x]:
        if y == parent:
            continue
        if ans[y] == -1:
            todo.append((y,x))
print('Yes')
for i in range(2,N+2):
    print(ans[i])
Problem p02767 (python)

Fixed submission:
N=int(input())
X=list(map(int,input().split()))
def tairyoku(n):
    return (n-i)**2
i=1
XT=list(map(tairyoku,X))
ans=sum(XT)
for i in range(2,101):
    XT=list(map(tairyoku,X))
    ans=min(ans,sum(XT))
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
X=list(map(int,input().split()))
i=1
XT=list(map(tairyoku,X))
ans=sum(XT)
for i in range(2,101):
    XT=list(map(tairyoku,X))
    ans=min(ans,sum(XT))
print(ans)
Problem p02921 (python)

Fixed submission:
S = input()
T = input()
ans = 0

if S[0] == T[0]:
    ans += 1
if S[1] == T[1]:
    ans += 1
if S[2] == T[2]:
    ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
HL = list(map(int,input().split()))
HL.append(10**9+1)  #HLの最後に(最大値+1)をappend
cnt = 0
tmp_c = 0

for i in range(N):
    if HL[i] >= HL[i+1]:
        tmp_c += 1
    else:
        if cnt <= tmp_c:
            cnt = tmp_c
            tmp_c = 0
        else:
            tmp_c = 0

print(cnt)
Problem p02936 (python)

Fixed submission:
N,Q = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(N-1)]
px = [list(map(int,input().split())) for i in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in px:
    value[p] += x

from collections import deque
todo = deque([(1,0)])
while len(todo) > 0:
    x,parent = todo.pop()
    value[x] += value[parent]
    for y in graph[x]:
        if y == parent:
            continue
        todo.append((y,x))

answer = ' '.join(map(str,value[1:]))
print(answer)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
 
# 遅延評価で加えてあげるだけ
 
N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)
 
value = [0] * (N+1)
for p,x in px:
    value[p] += x
    
q = [(1,0)]
while q:
    x,parent = q.pop()
    value[x] += value[parent]
    for y in graph[x]:
        if y == parent:
            continue
        q.append((y,x))
 
answer = ' '.join(map(str,value[1:]))
print(answer)

Buggy submission (verdict: Runtime Error):
N,Q = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(N-1)]
px = [list(map(int,input().split())) for i in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in px:
    value[p] += x

from collections import deque
todo = deque([(1,0])])
while len(todo) > 0:
    x,parent = todo.pop()
    value[x] += value[parent]
    for y in graph[x]:
        if y == parent:
            continue
        todo.append((y,x))

print(*value[1:])
Problem p02582 (python)

Fixed submission:
s=input()
a=s.count('R')
if a==0:
    print(a)
elif s[1]=='S' and a==2:
    print(a-1)
else:
    print(a)

Buggy submission (verdict: Runtime Error):
a=s.count('R')
if a==0:
    print(a)
elif s[1]=='S':
    print(a-1)
else:
    print(a)
Problem p02645 (python)

Fixed submission:
n=input()
b=n[:3]
print(b)

Buggy submission (verdict: Runtime Error):
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
x=a+v*t
y=b+w*t
if x>=y:
    print('YES')
else:
    print('NO')
Problem p02646 (python)

Fixed submission:

a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
if a>b:
    x=a-v*t
    y=b-w*t
    if x<=y:
        print('YES')
    else:
        print('NO')
else:
    x=a+v*t
    y=b+w*t
    if x>=y:
        print('YES')
    else:
        print('NO')

Buggy submission (verdict: Runtime Error):
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
if a>b:
    x=a-v+t
    y=b-w*t
else:
    x=a+v*t
    y=b+w*t
    if abs(x)>=abs(y) or abs(x)=0:
        print('YES')
    else:
        print('NO')
Problem p02730 (python)

Fixed submission:
s=input()
n=len(s)
k=n//2
a=s[:k]
b=s[-k:]
if s==s[::-1] and a==a[::-1] and b==b[::-1]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
if s[0]==s[-1] and s[0]==s[int((n-1)/2-1)] and s[int((n+3)/2-1)]==s[-1] and s[1]==s[-2] and s[2]==s[-3] and s[int((n+3)/2)]==s[-2]:
    print('Yes')
else:
    print('No')
Problem p03455 (python)

Fixed submission:
a,b = map(int, input().split())
if a*b % 2 == 0:
    print('Even')
else:
    print('Odd')

Buggy submission (verdict: Runtime Error):
input_unko = input('number')
input_tinko = input('number')
if input_unko * input_tinko % 2 == 0:
    print('Even')
else:
    print('Odd')
Problem p02574 (python)

Fixed submission:
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

# 素因数分解、リストで返す
#############################################################


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    a.sort()
    return a
#############################################################


primes = defaultdict(int)

for i in range(N):
    p = prime_factorize(A[i])
    p_set = set(p)
    for pi in p_set:
        primes[pi] += 1

# print(primes)

if len(primes) == 0:
    print("pairwise coprime")
    exit()

max_cnt = max(primes.values())
min_cnt = min(primes.values())

if max_cnt == 1:
    print("pairwise coprime")
elif max_cnt != N:
    print("setwise coprime")
else:
    print("not coprime")

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

# 素因数分解、リストで返す
#############################################################


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    a.sort()
    return a
#############################################################


primes = defaultdict(int)

for i in range(N):
    p = prime_factorize(A[i])
    p_set = set(p)
    for pi in p_set:
        primes[pi] += 1

max_cnt = max(primes.values())
min_cnt = min(primes.values())
if max_cnt == N:
    print("not coprime")
elif min_cnt >= 2:
    print("setwise coprime")
else:
    print("pairwise coprime")
Problem p02724 (python)

Fixed submission:
X = int(input())
ans = 0
ans += 1000 * (X // 500)
X = X % 500
ans += 5 * (X // 5)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
import copy

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)

p1 = deque(p)
q1 = deque(q)
r1 = deque(r)
p2 = copy.deepcopy(p1)
q2 = copy.deepcopy(q1)
r2 = copy.deepcopy(r1)


ans = 0

ans1 = 0
for _ in range(X):
    if len(r1) > 0:
        if p1[0] > r1[0]:
            ans1 += p1.popleft()
        else:
            ans1 += r1.popleft()
    else:
        ans1 += p1.popleft()

for _ in range(Y):
    if len(r1) > 0:
        if q1[0] > r1[0]:
            ans1 += q1.popleft()
        else:
            ans1 += r1.popleft()
    else:
        ans1 += q1.popleft()

ans2 = 0
for _ in range(Y):
    if len(r2) > 0:
        if q2[0] > r2[0]:
            ans2 += q2.popleft()
        else:
            ans2 += r2.popleft()
    else:
        ans2 += q2.popleft()

for _ in range(X):
    if len(r2) > 0:
        if p2[0] > r2[0]:
            ans2 += p2.popleft()
        else:
            ans2 += r2.popleft()
    else:
        ans2 += p2.popleft()

ans = max(ans1, ans2)
print(ans)
Problem p02727 (python)

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)

p = p[:X]
q = q[:Y]

all = p + q + r
all.sort(reverse=True)
ans = sum(all[:X + Y])
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque

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)

p = deque(p)
q = deque(q)
r = deque(r)

ans = 0
for _ in range(X):
    if p[0] >= r[0]:
        ans += p.popleft()
    else:
        ans += r.popleft()
for _ in range(Y):
    if q[0] >= r[0]:
        ans += q.popleft()
    else:
        ans += r.popleft()

print(ans)
Problem p02960 (python)

Fixed submission:
S = str(input())

# 桁数
N = len(S)
MOD = 10**9 + 7

# dp[i][j] := Sの上からi桁目までを考えた時、それを13で割った余りがjになる方法の数
dp = [[0 for _ in range(13)]for _ in range(N + 1)]

# １桁目について
if S[0] == "?":
    # ?に0, 1, ..., 9を入れることができる
    for i in range(10):
        dp[1][i] = 1
else:
    dp[1][int(S[0])] = 1

# 1, 2, ..., N-1桁から、
# 2, 3, ..., N桁についての遷移を考える
for i in range(1, N):
    for j in range(13):
        if S[i] == "?":
            for k in range(10):
                dp[i + 1][(j * 10 + k) % 13] += dp[i][j]
                dp[i + 1][(j * 10 + k) % 13] %= MOD
        else:
            dp[i + 1][(j * 10 + int(S[i])) % 13] += dp[i][j]
            dp[i + 1][(j * 10 + int(S[i])) % 13] %= MOD

print(dp[N][5] % MOD)

Buggy submission (verdict: Runtime Error):
S = input()

# 桁数
N = len(S)
MOD = 10**9 + 7

# dp[i][j] := Sの上からi桁目までを考えた時、それを13で割った余りがjになる方法の数
dp = [[0 for _ in range(13)]for _ in range(N + 1)]

# １桁目について
if S[0] == "?":
    # ?に0, 1, ..., 9を入れることができる
    for i in range(10):
        dp[1][i] = 1
else:
    dp[1][S[0]] = 1

# 1, 2, ..., N-1桁から、
# 2, 3, ..., N桁についての遷移を考える
for i in range(1, N):
    for j in range(13):
        if S[i] == "?":
            for k in range(10):
                dp[i + 1][(j * 10 + k) % 13] += dp[i][j]
                dp[i + 1][(j * 10 + k) % 13] %= MOD
        else:
            dp[i + 1][(j * 10 + int(S[i])) % 13] += dp[i][j]
            dp[i + 1][(j * 10 + int(S[i])) % 13] %= MOD

print(dp[N][5] % MOD)
Problem p03001 (python)

Fixed submission:
W, H, x, y = map(int, input().split())

if x == W / 2 and y == H / 2:
    print(W * H / 2, 1)
else:
    print(W * H / 2, 0)

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())

if W == 0 or H == 0:

elif x == W / 2 and y == H / 2:
    print(W * H / 2, 1)
else:
    print(W * H / 2, 0)
Problem p03150 (python)

Fixed submission:
S=input()
l = len(S)
#keyencexxxxx
if S[:7]=="keyence":
  print("YES")
#kxxxxxeyence
elif S[:1]=="k" and S[l-6:]=="eyence":
  print("YES")
#kexxxxxyence
elif S[:2]=="ke" and S[l-5:]=="yence":
  print("YES")
#keyxxxxxence
elif S[:3]=="key" and S[l-4:]=="ence":
  print("YES")
#keyexxxxxnce
elif S[:4]=="keye" and S[l-3:]=="nce":
  print("YES")
#keyenxxxxxce
elif S[:5]=="keyen" and S[l-2:]=="ce":
  print("YES")
#keyencxxxxxe
elif S[:6]=="keyenc" and S[l-1:]=="e":
  print("YES")
#xxxxxkeyence
elif S[l-7:]=="keyence":
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
S=input()
l = len(S)
#keyencexxxxx
if s[:7]=="keyence":
  print("YES")
#kxxxxxeyence
elif s[:1]=="k" and s[l-6:]=="eyence":
  print("YES")
#kexxxxxyence
elif s[:2]=="ke" and s[l-5:]=="yence":
  print("YES")
#keyxxxxxence
elif s[:3]=="key" and s[l-4:]=="ence":
  print("YES")
#keyexxxxxnce
elif s[:4]=="keye" and s[l-3:]=="nce":
  print("YES")
#keyenxxxxxce
elif s[:5]=="keyen" and s[l-2:]=="ce":
  print("YES")
#keyencxxxxxe
elif s[:6]=="keyenc" and s[l-1:]=="e":
  print("YES")
#xxxxxkeyence
elif s[l-7:]=="keyence":
  print("YES")
else:
  print("NO")
Problem p03166 (python)

Fixed submission:
# デフォルトだと再帰の上限が設定されている(1000)、足りない場合があるので上げる
import sys
sys.setrecursionlimit(10**9)


N, M = map(int, input().split())

G = [[] for _ in range(N + 1)]
for i in range(M):
    x, y = map(int, input().split())
    G[x] += [y]
# print(G)

dp = [-1] * (N + 1)


def func(n):
    if dp[n] != -1:
        return dp[n]
    cnt = 0
	# 先にノードが存在する場合
	# ノードが存在しない場合は、cnt=0のままforをすっ飛ばす
    for m in G[n]:
        cnt = max(cnt, func(m) + 1)
    dp[n] = cnt
    return cnt


for i in range(1, N + 1):
    func(i)

# print(dp)
print(max(dp))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())

G = [[] for _ in range(N + 1)]
for i in range(M):
    x, y = map(int, input().split())
    G[x] += [y]
# print(G)

dp = [-1] * (N + 1)


def func(n):
    if dp[n] != -1:
        return dp[n]
    cnt = 0
	# 先にノードが存在する場合
	# ノードが存在しない場合は、cnt=0のままforをすっ飛ばす
    for m in G[n]:
        cnt = max(cnt, func(m) + 1)
    dp[n] = cnt
    return cnt


for i in range(1, N + 1):
    func(i)

# print(dp)
print(max(dp))
Problem p03386 (python)

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

ans = set()
for i in range(A, min(B + 1, A + K)):
    ans.add(i)

for i in range(max(A, B - K + 1), B + 1):
    ans.add(i)
ans = sorted(list(ans))
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
N = B - A + 1
nums = list(range(A, B + 1))
ans = set()

for i in range(min(K, N)):
    ans.add(nums[i])

nums.reverse()
for i in range(min(K, N)):
    ans.add(nums[i])


ans = list(ans)
ans.sort()
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
N = B - A + 1
nums = list(range(A, B + 1))
ans = set()

for i in range(min(K, N)):
    ans.add(nums[i])

nums.reverse()
for i in range(min(K, N)):
    ans.add(nums[i])


ans = list(ans)
ans.sort()
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

l = B - A + 1

nums = list(range(A, B + 1))
ans = set(nums[:min(K, l + 1)]) | set(nums[-min(K, l):])
ans = list(ans)
ans.sort()
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
if B - A + 1 <= K:
    for i in range(A, B + 1):
        print(i)
    exit()

nums = list(range(A, B + 1))
ans = set(nums[:K]) | set(nums[-K:])
ans = list(ans)
ans.sort()
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
nums = list(range(A, B + 1))
ans = set(nums[:K]) | set(nums[-K:])
ans = list(ans)
ans.sort()
for i in ans:
    print(i)
Problem p03409 (python)

Fixed submission:
N = int(input())
red = [list(map(int, input().split())) for _ in range(N)]
blue = [list(map(int, input().split())) for _ in range(N)]
# y座標で降順ソート
red.sort(reverse=True)
# x座標でソート
blue.sort(key=lambda x: x[1])

# print(blue)
# print(red)
blue_list = [0] * N
red_list = [0] * N


for b in range(N):
    for r in range(N):
        if blue_list[b] == 1 or red_list[r] == 1:
            continue
        if red[r][0] < blue[b][0] and red[r][1] < blue[b][1]:
            # print(b, r)
            blue_list[b] = 1
            red_list[r] = 1
            break

print(sum(blue_list))

Buggy submission (verdict: Runtime Error):
N = int(input())
red = [list(map(int, input().split())) for _ in range(N)]
blue = [list(map(int, input().split())) for _ in range(N)]

# x座標でソート
blue.sort(key=lambda x: x[1])

# y座標で降順ソート
red.sort(reverse=True)

# print(blue)
# print(red)

# blue_list = [0] * N
red_list = [0] * N


for b in range(N):
    for r in range(N):
        if red_list[r] == 1:
            continue
        if red[r][0] < blue[b][0] and red[r][1] < blue[b][1]:
            # print(b, r)
            # blue_list[b] = 1
            red_list[r] = 1
            break

print(sum(blue_list))
Problem p03680 (python)

Fixed submission:
N = int(input())
a = [int(input()) for i in range(N)]

#最初はボタン１が光っている
index = 1

#押した回数0からスタート
count = 0

while count < N:
  
  if a[index-1]==2:
    count += 1
    #print(str(2) + "!!")
    print(count)
    exit()
    
  else:
    #ボタン押す
    count += 1
    #次に光るボタンの番号
    index=a[index-1]
    #print(str(index) + "!!")

print(-1)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(input()) for i in range(n)]

#最初はボタン１が光っている
index = 1
#押した回数0からスタート
count = 0

while count < N:
  
  if a[index-1]==2:
    count += 1
    print(count)
    exit()
    
  else:
    count += 1
    #次に光るボタン
    index=a[index-1]

print(-1)
Problem p02705 (python)

Fixed submission:
r=int(input())
print(2*r*3.141592)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(input().split()))
for i in range(1,n+1):
    print(a.count(str(i)))
Problem p02767 (python)

Fixed submission:
n=int(input())
man=list(map(int,input().split()))
can=[]
for i in range(1,101):
	pp=0
	for j in range(len(man)):
		bp=(man[j]-i)**2
		pp+=bp
	can.append(pp)
can.sort(key=int)
print(can[0])

Buggy submission (verdict: Runtime Error):
n=int(input())
man=list(map,int(input().split()))
can=list[]
for i in range(1,101):
  for j in range(len(man)):
    p=(man[j]-i)**2
	pp+=p
  can.append(pp)
can.sort(key=int)
print(can[0])
Problem p02842 (python)

Fixed submission:
import math
n=int(input())
xc=math.ceil(n/1.08)
nn=xc*1.08
if math.floor(nn)==n:    
	print(xc)
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
n=int(input())
x=n/1.08
nn=x*1.08
if n<=nn<n+1:
    if x*10%10>=5:    
		print(int(x)+1)
    else:
        print(int(x))
else:
  print(":(")
Problem p02922 (python)

Fixed submission:
a,b=map(int,input().split())
if b==1:
	print(0)
else:
	ans=1
	bb=b-a
	while bb>0:
  		bb=bb-(a-1)
  		ans+=1
	print(ans)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
ans=1
bb=b-a
while bb=>0:
  bb=bb-(a-1)
  ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
a,b=int(input().split())
ans=1
bb=b-a
while bb>0:
  bb=bb-(a-1)
  ans+=1
print(ans)