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

Fixed submission:
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


def calc(x, isTrans):
    if isTrans:
        y = np.copy(x.T)
    else:
        y = np.copy(x)

    for i in range(len(y)):
        xxx = np.copy(y[i])
        tmp_l = np.arange(len(xxx))
        tmp_l[xxx > 0] = 0
        np.maximum.accumulate(tmp_l, out=tmp_l)
        left = tmp_l

        xxx_reverse = xxx[::-1]
        tmp_r = np.arange(len(xxx_reverse))
        tmp_r[xxx_reverse > 0] = 0
        np.maximum.accumulate(tmp_r, out=tmp_r)
        right = len(xxx)-tmp_r[::-1]-1

        y[i] = right-left-1
        y[i][xxx == 0] = 0

    if isTrans:
        return np.transpose(y)
    else:
        return y


if __name__ == "__main__":
    h, w = map(int, readline().split())
    room = np.zeros((h+2, w+2), dtype=np.int)
    for i in range(1, h+1):
        room[i][1:-1] = [0 if i == "#" else 1 for i in input()]

    a = calc(room, True)
    b = calc(room, False)
    ans = (a + b).max() - 1
    print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)


def calc(x, isTrans):
    if isTrans:
        y = np.copy(x.T)
    else:
        y = np.copy(x)

    for i in range(len(y)):
        xxx = np.copy(y[i])
        tmp_l = np.arange(len(xxx))
        tmp_l[xxx > 0] = 0
        np.maximum.accumulate(tmp_l, out=tmp_l)
        left = tmp_l

        xxx_reverse = xxx[::-1]
        tmp_r = np.arange(len(xxx_reverse))
        tmp_r[xxx_reverse > 0] = 0
        np.maximum.accumulate(tmp_r, out=tmp_r)
        right = len(xxx)-tmp_r[::-1]-1

        y[i] = right-left-1
        y[i][xxx == 0] = 0

    if isTrans:
        return np.transpose(y)
    else:
        return y


if __name__ == "__main__":
    h, w = map(int, readline().split())
    room = np.zeros((h+2, w+2), dtype=np.int)
    for i in range(1, h+1):
        room[i][1:-1] = [0 if i == "#" else 1 for i in input()]

    a = calc(room, True)
    b = calc(room, False)
    ans = (a + b).max() - 1
    print(ans)
Problem p03030 (python)

Fixed submission:
n=int(input())
sp=[]
for i in range(1, n+1):
    s,p=input().split()
    sp.append((s, -int(p), i))

sp.sort()
for s,p,i in sp:
    print(i)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
n=int(input())

def guidebook(n):
    SPlist=defaultdict(list)
    for i in range(n):
        s,p=input().split()
        SPlist[s].append((int(p), i+1))

    if n==1:
        print(1)
        return

    ans=[]
    SPlist=[(k, v) for k, v in SPlist.items()]
    SPlist.sort()
    ans=[]
    count=1
    for sp in SPlist:
        p=sp[1]
        if len(p)>1:
            p.sort(reverse=True)
            for i in p:
                ans.append((count, i[1]))
                count+=1
        else:
            ans.append((count, p[1]))

    for i in ans:
        print(i[1])
    return

guidebook(n)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
n=int(input())

SPlist=defaultdict(list)
for i in range(n):
    s,p=input().split()
    SPlist[s].append((int(p), i+1))

ans=[]
SPlist=[(k, v) for k, v in SPlist.items()]
SPlist.sort()
ans=[]
count=1
for sp in SPlist:
    p=sp[1]
    if len(p)>1:
        p.sort(reverse=True)
        for i in p:
            ans.append((count, i[1]))
            count+=1
    else:
        ans.append((count, p[1]))

for i in ans:
    print(i[1])
Problem p03087 (python)

Fixed submission:
n,q=map(int,input().split())
S=input()
cnt=[0]*n

for i in range(1, n):
    s=S[i-1]+S[i]
    if s=="AC":
        cnt[i]+=1

for i in range(1, n):
    cnt[i]+=cnt[i-1]

for _ in range(q):
    l, r=map(int,input().split())
    ans=cnt[r-1]-cnt[l-1]
    print(ans)

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
ind=[]
z=0
for i,j in zip(s[:-1],s[1:]):
    if i+j=="AC":
        ind.append(z)
    z+=1

aa=len(ind)
for i in range(q):
    l,r=map(int,input().split())
    l-=1
    r-=1
    for ii,jj in enumerate(ind):
        if jj>=l:
            start=ii
            break
    for ii,jj in enumerate(ind[::-1]):
        if jj<r:
            end=ii
            break
    print(max(0,aa-(start+end)))
Problem p03096 (python)

Fixed submission:
from collections import defaultdict
N = int(input())
tmp = [int(input()) for _ in range(N)]
mod = 10 ** 9 + 7
C = []
for c in tmp:
    if not C:
        C.append(c)
        continue
    if C[-1] != c:
        C.append(c)
N = len(C)

last = defaultdict(int)
ans = 1

for c in C:
    ans += last[c]
    ans %= mod
    last[c] = ans

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N = int(input())
C = [int(input()) for _ in range(N)]
C = C[::-1]
mod = 10 ** 9 + 7

newC = []
while C:
    c = C.pop()
    if not newC or newC[-1] != c:
        newC.append(c)
N = len(newC)

seen = [0] * (10 ** 5 + 10)
dp = [0] * (N + 1)
dp[0] = 1
seen[newC[0]] = 1

for i, c in enumerate(newC[1:], start=1):
    cnt = seen[c]
    seen[c] = (seen[c] + dp[i - 1]) % mod
    dp[i] = (dp[i - 1] + cnt) % mod

ans = dp[N - 1]
print(ans)
Problem p03128 (python)

Fixed submission:
d = {
    1: 2,
    2: 5,
    3: 5,
    4: 4,
    5: 5,
    6: 6,
    7: 3,
    8: 7,
    9: 6,
}
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

inf = 10**9
dp = [-inf]*(N+1)
dp[0] = 0


for a in A:
    for j in range(d[a], N + 1):
        dp[j] = max(dp[j], dp[j - d[a]] + 1)

ans = ""
remain = dp[N]
match = N
while match > 0:
    for a in A:
        if match - d[a] < 0:
            continue
        if dp[match - d[a]] == remain - 1:
            ans += str(a)
            match -= d[a]
            remain -= 1
            break

print(ans)

Buggy submission (verdict: Runtime Error):
d = {
    1: 2,
    2: 5,
    3: 5,
    4: 4,
    5: 5,
    6: 6,
    7: 3,
    8: 7,
    9: 6,
}
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

inf = 10**18
dp = [-inf]*(N+1)
dp[0] = 0


for a in A:
    for j in range(d[a], N + 1):
        dp[j] = max(dp[j], dp[j - d[a]] + 1)

ans = ""
remain = dp[N]
match = N
while match > 0:
    for a in A:
        if dp[match - d[a]] == remain - 1:
            ans += str(a)
            match -= d[a]
            remain -= 1
            break

print(ans)
Problem p03138 (python)

Fixed submission:
import numpy as np
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))

one = np.zeros(40, dtype=int)
for i in range(40):
    one[i] = np.count_nonzero(a % 2)
    a >>= 1
zero = n-one

bk = bin(k)[2:].zfill(40)
bk = bk[::-1]
answer = 0
tmp = 0
for i in range(40 - 1, -1, -1):
    if bk[i] == "0":
        tmp += one[i] * (2 ** i)
    else:
        ans = tmp + one[i] * (2 ** i)
        for j in range(i - 1, -1, -1):
            ans += max(one[j], zero[j]) * (2 ** j)
        answer = max(answer, ans)
        tmp += zero[i] * (2 ** i)
else:
    answer = max(answer, tmp)

print(answer)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
if K == 0:
    print(sum(map(int, input().split())))
    exit()

D = K.bit_length()
bit = [0] * D
for a in map(int, input().split()):
    i = 0
    while a:
        if a & 1:
            bit[i] += 1
        a >>= 1
        i += 1

tight = 0
loose = 0

val = 1 << (D - 1)
for i in reversed(range(D)):
    if (K >> i) & 1:
        loose += val * max(bit[i], N - bit[i])
        loose = max(loose, tight + val * (N - bit[i]))
        tight += val * bit[i]
    else:
        tight += val * (N - bit[i])
        loose += val * max(bit[i], N - bit[i])
    val >>= 1

print(max(loose, tight))
Problem p03142 (python)

Fixed submission:
from collections import deque
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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


add = np.zeros(N+1, dtype=int)
rank = [-1]*(N+1)

# まず根を探す
for i in range(1, N+1):
    add[i] = len(e_to[i])
    if len(e_to[i]) == 0:
        root = i

# BFS
rank[root] = 0
node = deque([root])
while node:
    s = node.popleft()
    add[e_from[s]] -= 1
    for t in e_from[s]:
        if add[t] == 0:
            rank[t] = s
            node.append(t)

print(*rank[1:], sep="\n")

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
e_out = [[] for _ in range(N + 1)]
e_in = [[] for _ in range(N + 1)]
for _ in range(N + M - 1):
    a, b = map(int, readline().split())
    e_out[a].append(b)
    e_in[b].append(a)


# 1. 入次数が0のやつが親
# 2. 親が決まれば、そのこの入次数を減らす,1に戻る

# 親を決めるよ
for i, e in enumerate(e_in[1:], start=1):
    if len(e) == 0:
        root = i
        break

node = [root]
parent = [-1] * (N + 1)
parent[root] = 0
diff = [0] * (N + 1)  # 入次数をどれだけ減らすか

while node:
    s = node.pop()
    for t in e_out[s]:
        diff[t] += 1
        if len(e_in[t]) - diff[t] == 0:
            parent[t] = s
            node.append(t)

print(*parent[1:], sep="\n")
Problem p03148 (python)

Fixed submission:
from collections import defaultdict
import heapq
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
U = 10 ** 5 + 1

N, K = map(int, input().split())
DT = []
for _ in range(N):
    t, d = map(int, input().split())
    DT.append((d, t))

DT.sort(reverse=True)
score = 0
kind = defaultdict(list)
used = [0] * (U + 1)
for d, t in DT[:K]:
    score += d
    used[t] += 1
    kind[t].append(d)

cnt = len(kind)
ans = score + (cnt * cnt)

cand = []  # 交換する可能性のあるやつ, 小さいやつから削除
for key, val in kind.items():
    val.sort(reverse=True)
    while len(val) > 1:
        heapq.heappush(cand, (val.pop(), key))


for d_in, t_in in DT[K:]:
    if not cand:
        break
    if used[t_in]:
        continue

    d_out, t_out = heapq.heappop(cand)
    used[t_in] += 1
    used[t_out] -= 1
    cnt += 1
    score = score - d_out + d_in
    ans = max(ans, score + (cnt * cnt))

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import heapq
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, K = map(int, input().split())
DT = []
for _ in range(N):
    t, d = map(int, input().split())
    DT.append((d, t))

DT.sort(reverse=True)
score = 0
kind = defaultdict(list)
used = [0] * (N + 1)
for d, t in DT[:K]:
    score += d
    used[t] += 1
    kind[t].append(d)

cnt = len(kind)
ans = score + (cnt * cnt)

cand = []  # 交換する可能性のあるやつ, 小さいやつから削除
for key, val in kind.items():
    val.sort(reverse=True)
    while len(val) > 1:
        heapq.heappush(cand, (val.pop(), key))


for d_in, t_in in DT[K:]:
    if not kind:
        break
    if used[t_in]:
        continue

    d_out, t_out = heapq.heappop(cand)
    used[t_in] += 1
    used[t_out] -= 1
    cnt += 1
    score = score - d_out + d_in
    ans = max(ans, score + (cnt * cnt))

print(ans)
Problem p03150 (python)

Fixed submission:
s = input()

w = "keyence"
ans = "NO"

# keyencexxxxx
if s[:7] == w:
    ans = "YES"

# xxxxkeyence
if s[-7:] == w:
    ans = "YES"

# key xxx ence
for i in range(1, 7):
    ss = w[:i]
    tt = w[-7+i:]
    if s[: len(ss)] == ss and s[-len(tt):] == tt:
        ans = "YES"
        break

print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
w = list("keyence")

st = ""
i_w = 0
delete = []

for i in s:
    if i == w[i_w]:
        i_w += 1
        if not st == "":
            delete.append(st)
            st = ""
    else:
        st += i
else:
    if not st == "":
        delete.append(st)

if i_w == 7 and len(delete) <= 1:
    ans = "YES"
else:
    ans = "NO"
print(ans)
Problem p03170 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
max_a = A[-1]

dp = [0] * (K+1)

for a in A:
    dp[a] = 1

for i in range(1, K + 1):
    bl = False
    for a in A:
        if i - a < 0:
            break
        if dp[i - a] == 0:
            bl = True
            break
    dp[i] = 1 if bl else 0


ans = "First" if dp[K] else "Second"
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
max_a = max(A)

dp = [0] * (K+1)

for a in A:
    dp[a] = 1

for i in range(max_a + 1, K + 1):
    for a in A:
        if dp[i - a] == 0:
            dp[i] = 1
            break
    else:
        dp[i] = 0

ans = "First" if dp[i] else "Second"
print(ans)
Problem p03229 (python)

Fixed submission:
from collections import deque
n = int(input())
a = [int(input()) for _ in range(n)]
a.sort()
x = deque(a)
y = deque(a)


def align(a, fromLeft=1):
    if fromLeft:
        p = a.popleft()
    else:
        p = a.pop()
    q = p

    res = 0
    fromLeft = 1 - fromLeft
    while a:
        p1 = a.popleft() if fromLeft else a.pop()
        if a:
            q1 = a.popleft() if fromLeft else a.pop()
            res += abs(p - p1) + abs(q - q1)
            p = p1
            q = q1
        else:
            res += max(abs(p - p1), abs(q - p1))
        fromLeft = 1 - fromLeft
    return res


ans = max(align(x, 1), align(y, 0))
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys
input = sys.stdin.readline


def solve(N, A, fromR=True):
    res = 0
    L, R = None, None

    while A:
        fromR = 1 - fromR

        if L is None:
            L = A.pop() if fromR else A.popleft()
            R = L
            continue

        if len(A) > 1:
            if fromR:
                x = A.pop()
                y = A.pop()
            else:
                x = A.popleft()
                y = A.popleft()
            res += abs((R + L) - (x + y))
            R, L = x, y
            continue

        if len(A) == 1:
            x = A.pop()
            res += max(abs(R - x), abs(L - x))
            continue

    return res


if __name__ == "__main__":
    N = int(input())
    A = [int(input()) for _ in range(N)]
    A = deque(sorted(A))

    ans1 = solve(N, A.copy(), 0)
    ans2 = solve(N, A, 1)
    ans = max(ans1, ans2)
    print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(input())
a = [int(readline()) for _ in range(n)]

a.sort()
deq = deque(a)

ans = 0

left, right = deq.popleft(), 0
cnt = 1


def comparison(left, right, x, y):
    if y == 0:
        return max(abs(left - x), abs(right - x))

    if right == 0:
        return abs(left*2 - x - y)
    else:
        return abs(left+right-x-y)


while deq:
    if len(deq) == 1:
        x = deq.pop()
        y = 0
    else:
        if cnt:
            x = deq.pop()
            y = deq.pop()
        else:
            x = deq.popleft()
            y = deq.popleft()

    ans += comparison(left, right, x, y)
    left, right = x, y
    cnt = 1-cnt

print(ans)
Problem p03231 (python)

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


def euclid(x, y):
    x, y = max(x, y), min(x, y)
    if y == 0:
        return x
    return euclid(y, x % y)


lcm = n * m // euclid(n, m)
nn = lcm // n
mm = lcm // m
ss = s[0::mm]
tt = t[0::nn]

if ss == tt:
    print(lcm)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
from math import gcd
N, M = map(int, input().split())
S = input()
T = input()

L = N // gcd(N, M) * M
memo = [0] * (L + 10)


ok = True

ds = L // N
for i in range(N):
    memo[i * ds] = S[i]
dt = L // M
for i in range(M):
    if not memo[i * dt]:
        continue
    if memo[i * dt] != T[i]:
        ok = False

if ok:
    print(L)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
from math import gcd
N, M = map(int, input().split())
S = input()
T = input()

L = N // gcd(N, M) * M
memo = [0] * L


ok = True

ds = L // N
for i in range(N):
    memo[i * ds] = S[i]
dt = L // M
for i in range(M):
    if not memo[i * dt]:
        continue
    if memo[i * dt] != T[i]:
        ok = False

if ok:
    print(L)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
from math import gcd
N, M = map(int, input().split())
S = input()
T = input()

g = N // gcd(N, M) * M
res = [-1] * g
for i, s in enumerate(S):
    x = (g // N) * i
    res[x] = s

for i, s in enumerate(T):
    x = (g // M) * i
    if res[x] == -1:
        res[x] = s
    elif res[x] != s:
        print(-1)
        exit()

print(g)
Problem p03238 (python)

Fixed submission:
n=int(input())
if n==1:
  print("Hello World")
else:
  print(int(input())+int(input()))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=int(input())
b=int(input())
if n==1:
  print("Hello World")
else:
  print(a+b)
Problem p03262 (python)

Fixed submission:
N, X=map(int, input().split())
x=[abs(int(i)-X) for i in input().split()]

def gcd(x, y):
    x, y=max(x,y), min(x,y)
    if y==0:
        return x
    else:
        return gcd(y, x%y)

ans=1
for i in range(N):
    if i==0:
        ans=x[i]
    else:
        ans=gcd(ans, x[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)

dif = np.abs(A - K)
ans = np.gcd.reduce(dif)
print(ans)
Problem p03294 (python)

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

print(sum(a)-n)

Buggy submission (verdict: Runtime Error):
def gcd(x, y):
    x, y=max(x,y), min(x,y)
    if y==0:
        return x
    return gcd(y, x%y)

def lcm(x, y):
    return int(x*y/gcd(x, y))

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

a_lcm=1
for i in range(n):
    a_lcm=lcm(a_lcm, a[i])

ans=0
for i in a:
    ans+=(a_lcm-1)%i
print(ans)
Problem p03378 (python)

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

route=[0]*n
for i in a:
  route[i-1]=1
ans=min(sum(route[:x]),sum(route[x:]))
print(ans)

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

route=[0]*n
for i in a:
  route[i-1]=1
ans=min(sum(route[:x]),sum(route[x:]))
print(ans(
Problem p03385 (python)

Fixed submission:
s=input()
if "".join(sorted(s))=="abc":
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s=input()
if "".join(sorted(s)=="abc":
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s=input()
if s.sort()=="abc":
  print("Yes")
else:
  print("No")
Problem p03386 (python)

Fixed submission:
a,b,k=map(int,input().split())
ans=[]
for i in range(k):
    if a+i>b or b-i<a:
        break
    ans.append(a+i)
    ans.append(b-i)
ans=list(set(ans))
ans.sort()
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input())
if b-a-1<=k:
  for i in range(a,b+1):
    print(i)
else:
  for i in range(a,a+k):
    print(i)
  for i in range(b-k+1,b+1):
    print(i)
Problem p03387 (python)

Fixed submission:
abc=list(map(int,input().split()))
a,b,c=sorted(abc)

ans=0

#まず+1, +1を限界まで
b_plus=c-b
b+=b_plus
a+=b_plus
ans+=b_plus

#次に+2を限界まで
a_plus=(c-a)//2
a+=a_plus*2
ans+=a_plus

#微調整
if a!=b:
    ans+=2

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
A, B, C = sorted(list(map(int, input().split())))

d = C - B
A += d
B += d


if (B - A) % 2 == 0:
    ans = d + (B - A) // 2
else:
    ans = d + (B - A + 1) // 2 + 1
print(ans)
Problem p03393 (python)

Fixed submission:
s = input()
alp = "abcdefghijklmnopqrstuvwxyz"

if len(s) < 26:
    for i in alp:
        if not i in s:
            ans = s + i
            break

else:
    tmp = []
    ss = list(s)
    for i in range(len(ss)):
        if i == 0:
            tmp.append(ss.pop())
            continue

        if alp.index(ss[-1]) > alp.index(tmp[-1]):
            tmp.append(ss.pop())
            continue
        else:
            remove = ss.pop()
            tmp.sort()
            for j in tmp:
                if j > remove:
                    renew = j
                    break
            ans = "".join(ss) + renew
            break
    else:
        ans = -1

print(ans)

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

if len(c) < 26:
    for i in "abcdefghijklmnopqrstuvwxyz":
        if not i in s:
            ans = s + i
            break

else:
    tmp = ""
    ss = list(s)
    for i in range(len(ss)):
        if i == 0:
            tmp += ss.pop()
            continue

        if ss[-1] > tmp[-1]:
            tmp += ss.pop()
        else:
            ss.pop()
            ans = "".join(ss) + min(tmp)
            break
    else:
        ans = -1

print(ans)
Problem p03424 (python)

Fixed submission:
n=int(input())
s=list(input().split())
if len(set(s))==3:
  print("Three")
if len(set(s))==4:
  print("Four")

Buggy submission (verdict: Runtime Error):
from collections import Counter
N=input()
c = Counter(list(map(int,input().split())))
if len(c)==4:
  print("Four")
else:
  print("Three")
Problem p03478 (python)

Fixed submission:
n,a,b=map(int,input().split())
ans=0
for i in range(1, n+1):
  s=list(str(i))
  l=list(map(int,s))
  s=sum(l)
  if a<=s and s<=b:
    ans+=i
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
ans=0
for i in range(1, n+1):
  s=sum(list(str(i)))
  if a<=s and s<=b:
    ans+=1
print(ans)
Problem p03501 (python)

Fixed submission:
n,a,b=map(int,input().split())
print(min(n*a,b))

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
print(min(n*a,b)
Problem p03504 (python)

Fixed submission:
N, C = map(int, input().split())
tmp = []

for _ in range(N):
    s, t, c = map(int, input().split())
    tmp.append((s, t, c))
tmp.sort()

# そもそもCが小さいから力技で行けるはず
video = [(0, 0)]  # t,c
for s, t, c in tmp:
    for i, v in enumerate(video):
        ti, ci = v
        if c == ci:
            video[i] = (t, c)
            break
        if s > ti:
            video[i] = (t, c)
            break
    else:
        video.append((t, c))
    video.sort(reverse=True)

ans = len(video)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N, C = map(int, input().split())
STC = [tuple(map(int, input().split())) for _ in range(N)]
STC.sort(reverse=True, key=lambda x: x[1])  # tを基準に降順ソート

record = []
while STC:
    s_now, t_now, c_now = STC.pop()

    for i in range(len(record)):
        t, s, c = record[i]
        if c == c_now:
            record[i] = (t_now, s_now, c_now)
            break
        elif s_now > t:
            record[i] = (t_now, s_now, c_now)
            break
    else:
        record.append((t_now, s_now, c_now))

    ans = max(ans, len(record))

print(len(ans))
Problem p03543 (python)

Fixed submission:
n=list(input())
if len(set(n[:-1]))==1 or len(set(n[1:]))==1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s=input()
if len(set(s[:-1])==1 or len(set([1:])==1:
    print("Yes")
else:
    print("No")
Problem p03567 (python)

Fixed submission:
s=input()
for i,j in zip(s[:-1],s[1:]):
  if i+j=="AC":
    print("Yes")
    exit()
print("No")

Buggy submission (verdict: Runtime Error):
print("Yes") "AC" in input() else "No"
Problem p03606 (python)

Fixed submission:
n=int(input())
ans=0
for _ in range(n):
    l,r=map(int,input().split())
    ans+=r-l+1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
seat = np.zeros(N + 100, dtype=int)
L, R = np.array([input().split() for _ in range(N)], dtype=int).T

np.add.at(seat, L, 1)
np.add.at(seat, R+1, -1)
np.cumsum(seat, out=seat)
print(seat.sum())