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

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
vv = list(map(int, input().split()))
d1 = {}
d2 = {}

for i in range(n):
    v = vv[i]
    if i%2==0:
        if v not in d2:
            d2[v] = 0
        d2[v] += 1
    else:
        if v not in d1:
            d1[v] = 0
        d1[v] += 1

dl1 = sorted(list(d1.keys()), reverse=True, key=lambda k:d1[k])
dl2 = sorted(list(d2.keys()), reverse=True, key=lambda k:d2[k])
i1 = 0
i2 = 0

if len(dl1)==1 and len(dl2)==1:
    if dl1[0]==dl2[0]:
        print(n//2)
    else:
        print(0)
    exit()
elif len(dl1)==1:
    print(sum(sorted(d2.values(), reverse=True)[1:]))
    exit()
elif len(dl2)==1:
    print(sum(sorted(d1.values(), reverse=True)[1:]))
    exit()


if dl1[0]!=dl2[0]:
    res = 0
    res += sum(sorted(d1.values(), reverse=True)[1:])
    res += sum(sorted(d2.values(), reverse=True)[1:])
    print(res)
else:
    res1 = 0
    l = sorted(d1.values(), reverse=True)
    res1 += l[0]
    if len(l)>2:
        res1 += sum(l[2:])
    res1 += sum(sorted(d2.values(), reverse=True)[1:])

    res2 = 0
    l = sorted(d2.values(), reverse=True)
    res2 += l[0]
    if len(l)>2:
        res2 += sum(l[2:])
    res2 += sum(sorted(d1.values(), reverse=True)[1:])
    print(min(res1,res2))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
vv = list(map(int, input().split()))
d1 = {}
d2 = {}

for i in range(n):
    v = vv[i]
    if i%2==0:
        if v not in d2:
            d2[v] = 0
        d2[v] += 1
    else:
        if v not in d1:
            d1[v] = 0
        d1[v] += 1

dl1 = sorted(list(d1.keys()), reverse=True, key=lambda k:d1[k])
dl2 = sorted(list(d2.keys()), reverse=True, key=lambda k:d2[k])
i1 = 0
i2 = 0

if len(dl1)==1 and len(dl2)==1:
    if dl1[0]==dl2[0]:
        print(n//2)
    else:
        print(0)
    exit()
elif len(dl1)==1:
    print(sum(sorted(d2.values(), reverse=True)[1:]))
    exit()
elif len(dl2)==1:
    print(sum(sorted(d1.values(), reverse=True)[1:]))
    exit()


if dl1[0]!=dl2[0]:
    res = 0
    res += sum(sorted(d1.values(), reverse=True)[1:])
    res += sum(sorted(d2.values(), reverse=True)[1:])
    print(res)
else:
    if d1[dl1[0]]<d2[dl2[0]]:
        res = 0
        l = sorted(d1.values(), reverse=True)
        res += sum(l[0]+l[2:])
        res += sum(sorted(d2.values(), reverse=True)[1:])
        print(res)
    else:
        res = 0
        l = sorted(d2.values(), reverse=True)
        res += sum(l[0]+l[2:])
        res += sum(sorted(d1.values(), reverse=True)[1:])
        print(res)
Problem p03262 (python)

Fixed submission:
# -*- coding: utf-8 -*-
from fractions import gcd
n,x = map(int, input().split())
ary = [abs(x-int(i)) for i in input().split()]

d = ary[0]
for i in ary[1:]:
    d = gcd(i,d)

print(d)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from math import gcd
n,x = map(int, input().split())
ary = [abs(x-int(i)) for i in input().split()]

d = ary[0]
for i in ary[1:]:
    d = gcd(i,d)

print(d)
Problem p03304 (python)

Fixed submission:
# -*- coding: utf-8 -*-
from math import log2

line = list(map(int, input().split(" ")))
n = line[0]
m = line[1]
d = line[2]

if 2*d<n and d>0:
    ret1 = 1+(m-2)*log2(n)
    ret2 = log2(n-d)
    ret3 = log2(m-1)
    ret4 = m*log2(n)
    print(2**(ret1+ret2+ret3-ret4))
else:
    ret1 = (m-1)*log2(n)
    ret2 = log2(m-1)
    ret3 = m*log2(n)
    print(2**(ret1+ret2-ret3))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from math import log2

line = list(map(int, input().split(" ")))
n = line[0]
m = line[1]
d = line[2]

if 2*d<n and d>0:
    ret1 = 1+(m-2)*log2(n)
    ret2 = log2(m-d)
    ret3 = log2(m-1)
    ret4 = m*log2(n)
    print(2**(ret1+ret2+ret3-ret4))
else:
    ret1 = (m-1)*log2(n)
    ret2 = log2(m-1)
    ret3 = m*log2(n)
    print(2**(ret1+ret2-ret3))
Problem p03393 (python)

Fixed submission:
# -*- coding: utf-8 -*-
s = input()
x = list("abcdefghijklmnopqrstuvwxyz")

if len(s)<26:
    for c in x:
        if c not in s:
            print(s+c)
            exit()
else:
    s = list(s)
    d = set()
    c = s[-1]
    d.add(c)
    i = len(s)-2
    while True:
        if i<0:
            break
        elif s[i]>c:
            c = s[i]
            i -= 1
            d.add(c)
        else:
            break
    if i>=0:
        minc = None
        for c in d:
            if c<s[i]:
                continue
            elif minc is None:
                minc = c
            elif c<minc:
                minc = c
        if minc is not None:
            s[i] = minc
            s = s[:i+1]
            print("".join(s))
            exit()
print(-1)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

alp = "abcdefghijklmnopqrstuvwxyz"

s = list(input())
ss = set(s)

if len(s)<26:
    for x in list(alp):
        if x not in ss:
            print("".join(s)+x)
            exit()

idx = 0
for (i,x) in enumerate(s):
    if i>1 and s[i-2]<s[i-1] and s[i-1]>s[i]:
        y = min(list(filter(lambda x:x>s[i-2], s[i-1:])))
        print("".join(s[0:i-2])+y)
        exit()
    elif i>1 and s[i-2]>s[i-1] and s[i-1]<s[i]:
        y = min(list(filter(lambda x:x>s[i], s[i-1:])))
        print("".join(s[0:i])+y)
        exit()


print("-1")
Problem p03450 (python)

Fixed submission:
# -*- coding: utf-8 -*-

class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def unite(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]

n,m = map(int, input().split())
uf = WeightedUnionFind(n)
for _ in range(m):
    l,r,d = map(int, input().split())
    if uf.same(l,r):
        if uf.diff(l,r) != d:
            print("No")
            exit()
    else:
        uf.unite(l,r,d)

print("Yes")

Buggy submission (verdict: Runtime Error):
# coding=utf-8

line = input().split(" ")
N = int(line[0])
M = int(line[1])

if M==0:
    print("Yes")
    exit()

l = []
for _ in range(M):
    line = input().split(" ")
    l.append((
        int(line[0])-1
        ,int(line[1])-1
        ,int(line[2])
    ))
l.sort()
o = l[0][0]
for i in range(M):
    l[i] = (
        l[i][0]-o
        ,l[i][1]-o
        ,l[i][2]
    )

def check(l):
    nl = [None for x in range(N)]
    nl[0] = 0

    flag = True
    while flag:
        flag = False
        ll = []
        for c in l:
            if nl[c[0]]!=None and nl[c[0]]>=0 and nl[c[1]]==None:
                nl[c[1]] = nl[c[0]]+c[2]
            elif nl[c[0]]==None and nl[c[1]]!=None and nl[c[1]]>=0:
                nl[c[0]] = nl[c[1]]-c[2]
            elif nl[c[0]]!=None and nl[c[0]]>=0 and nl[c[1]]!=None and nl[c[1]]>=0:
                if nl[c[1]]-nl[c[0]]==c[2]:
                    pass
                else:
                    print("No")
                    exit()
            else:
                ll.append(c)
                flag = True
        if len(l)==len(ll):
            break
        else:
            l = ll.copy()
    for x in nl:
        if x<0:
            print("No")
            exit()
    return l

while len(l)>0:
    l = check(l)
    if len(l)==0:
        break
    l.sort()
    o = l[0][0]
    for i in range(len(l)):
        l[i] = (
            l[i][0]-o
            ,l[i][1]-o
            ,l[i][2]
        )


print("Yes")
Problem p03533 (python)

Fixed submission:
# -*- coding: utf-8 -*-
s = input()

for s1 in ["A",""]:
    for s2 in ["A",""]:
        for s3 in ["A",""]:
            for s4 in ["A",""]:
                if s==(s1+"KIH"+s2+"B"+s3+"R"+s4):
                    print("YES")
                    exit()
print("NO")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
s = list(input())
res = "AKIHABARA"

si = 0
ri = 0
while si<len(s):
    if s[si]==res[ri]:
        si += 1
        ri += 1
    elif res[ri]=="A" and s[si]!="A":
        ri += 1
    else:
        print("NO")
        exit()
print("YES")
Problem p03575 (python)

Fixed submission:
line = input().split(" ")
N = int(line[0])
M = int(line[1])

g = {}
E = []
for _ in range(M):
    line = input().split(" ")
    a = line[0]
    b = line[1]
    E.append((a,b))
    if not a in g:
        g[a] = []
    g[a].append(b)

    if not b in g:
        g[b] = []
    g[b].append(a)

def judge(a, b):
    flags = {}
    for v in g:
        flags[v] = False
    q = [a]
    flags[a] = True
    while len(q)>0:
        v = q.pop(0)
        for u in g[v]:
            if (v==a and u==b) or (v==b and u==a):
                continue
            elif not flags[u]:
                flags[u] = True
                q.append(u)
    ret = True
    for v in flags:
        ret = ret and flags[v]

    return not ret

cnt = 0
for e in E:
    if judge(e[0],e[1]):
        cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
line = input().split(" ")
N = int(line[0])
M = int(line[1])

g = {}
E = []
for _ in range(N):
    line = input().split(" ")
    a = line[0]
    b = line[1]
    E.append((a,b))
    if not a in g:
        g[a] = []
    g[a].append(b)

    if not b in g:
        g[b] = []
    g[b].append(a)

def judge(a, b):
    flags = {}
    for v in g:
        flags[v] = False
    q = [a]
    flags[a] = True
    while len(q)>0:
        v = q.pop(0)
        for u in g[v]:
            if (v==a and u==b) or (v==b and u==a):
                continue
            elif not flags[u]:
                flags[u] = True
                q.append(u)
    ret = True
    for v in flags:
        ret = ret and flags[v]

    return not ret

cnt = 0
for e in E:
    if judge(e[0],e[1]):
        cnt += 1

print(cnt)
Problem p03633 (python)

Fixed submission:
from fractions import gcd
def lcm(a,b): return a*b//gcd(a,b)
 
n = int(input())
res = 1
for i in range(n):
    t = int(input())
    res = lcm(res, t)
print(res)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(input())

def gcd(a, b):
    if b==0:
        return a
    return gcd(b, a%b)

def lcm(a,b):
    return a/gcd(a,b)*b

ans = 1
for _ in range(n):
    t = int(input())
    ans = lcm(ans, t)

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(input())

def gcd(a, b):
    if b==0:
        return a
    return gcd(b, a%b)

def lcm(a,b):
    return a*b/gcd(a,b)

ans = 1
for _ in range(n):
    t = int(input())
    ans = lcm(ans, t)

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(input())
t = []
for _ in range(n):
    t.append(int(input()))

def gcd(a, b):
    if b==0:
        return a
    return gcd(b, a%b)

def lcm(a,b):
    return a*b/gcd(a,b)

def lcmary(x, t):
    if len(t)==0:
        return x
    elif len(t)==1:
        return lcm(x,t[0])
    else:
        xx = lcm(x, t.pop(0))
        return lcmary(xx, t)

print(lcmary(t[0], t[1:]))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(input())
t = []
for _ in range(n):
    t.append(int(input()))

def gcd(a, b):
    if b==0:
        return a
    return gcd(b, a%b)

def lcm(a,b):
    return a*b/gcd(a,b)

def lcmary(x, t):
    if len(t)==0:
        return x
    elif len(t)==1:
        return lcm(x,t[0])
    else:
        xx = lcm(x, t.pop(0))
        return lcmary(xx, t)

print(lcmary(t[0], t[1:]))
Problem p03661 (python)

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
aa = [0]
s = 0
for x in input().split():
    a = int(x)
    aa.append(aa[-1]+a)
    s += a

ret = abs(2*aa[1]-s)
for i in range(1,n):
    if abs(aa[i]-(s-aa[i]))<ret:
        ret = abs(aa[i]-(s-aa[i]))

print(ret)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
aa = [0]
s = 0
for x in input().split():
    a = int(x)
    aa.append(aa[-1]+a)
    s += a

ret = abs(2*a[0]-s)
for i in range(1,n):
    if abs(aa[i]-(s-aa[i]))<ret:
        ret = abs(aa[i]-(s-aa[i]))

print(ret)
Problem p03662 (python)

Fixed submission:
# -*- coding: utf-8 -*-
from collections import deque
n = int(input())
edge = [[] for _ in range(n+1)]
for _ in range(n-1):
    a,b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)

inf = 10**6


fvisited = [inf for _ in range(n+1)]
fvisited[1] = 0
q = deque([1])
while len(q)>0:
    s = q.popleft()
    for e in edge[s]:
        if fvisited[e]==inf:
            fvisited[e] = fvisited[s]+1
            q.append(e)

svisited = [inf for _ in range(n+1)]
svisited[n] = 0
q = deque([n])
while len(q)>0:
    s = q.popleft()
    for e in edge[s]:
        if svisited[e]==inf:
            svisited[e] = svisited[s]+1
            q.append(e)

# print(fvisited)
# print(svisited)
fcnt = 0
scnt = 0
for i in range(1,n+1):
    if fvisited[i]<=svisited[i]:
        fcnt += 1
    else:
        scnt += 1

if fcnt>scnt:
    print("Fennec")
else:
    print("Snuke")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
edge = [[] for _ in range(n+1)]
for _ in range(n-1):
    a,b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)

inf = 10**5

def bfs(visited, s):
    for e in edge[s]:
        if visited[e]==inf:
            visited[e] = visited[s]+1
            bfs(visited, e)


fvisited = [inf for _ in range(n+1)]
fvisited[n] = 0
bfs(fvisited, n)

svisited = [inf for _ in range(n+1)]
svisited[1] = 0
bfs(svisited, 1)

# print(fvisited)
# print(svisited)
fcnt = 0
scnt = 0
for i in range(1,n+1):
    if fvisited[i]<svisited[i]:
        fcnt += 1
    else:
        scnt += 1

if fcnt<scnt:
    print("Fennec")
else:
    print("Snuke")
Problem p03722 (python)

Fixed submission:
# -*- coding: utf-8 -*-
inf = 10**50
n,m = map(int, input().split())

ea = []
eb = []
cost = []

for _ in range(m):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    ea.append(a)
    eb.append(b)
    cost.append(-c)

d = [inf for _ in range(n)]
d[0] = 0
for _ in range(n):
    update = False
    for i in range(m):
        a = ea[i]
        b = eb[i]
        c = cost[i]
        if d[a]!=inf and d[b]>d[a]+c:
            d[b] = d[a]+c
            update = True
    if not update:
        break

ans = d[n-1]
negative = [False for _ in range(n)]
for _ in range(n):
    update = False
    for i in range(m):
        a = ea[i]
        b = eb[i]
        c = cost[i]
        if d[a]!=inf and d[b]>d[a]+c:
            d[b] = d[a]+c
            if not negative[b]:
                update = True
            negative[b] = True
        if negative[a] and not negative[b]:
            negative[b] = True
            update = True
    if not update:
        break
# print(d)
if negative[n-1]:
    print("inf")
else:
    print(-ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
inf = 10**9+1
n,m = map(int, input().split())
edge = [[inf for _ in range(n)] for _ in range(n)]
for _ in range(m):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    edge[a][b] = c


score = [inf for _ in range(n)]
def dfs(v):
    for u in range(n):
        if edge[v][u]<inf:
            if score[u]<inf:
                if score[v]+edge[v][u]>score[u]:
                    print("inf")
                    exit()
            else:
                score[u] = score[v] + edge[v][u]
                dfs(u)

score[0] = 0
dfs(0)
print(score[n-1])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
inf = 10**50
n,m = map(int, input().split())

ea = []
eb = []
cost = []

for _ in range(m):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    ea.append(a)
    eb.append(b)
    cost.append(-c)

d = [inf for _ in range(n)]
d[0] = 0
for _ in range(n):
    update = False
    for i in range(m):
        a = ea[i]
        b = eb[i]
        c = cost[i]
        if d[a]!=inf and d[b]>d[a]+c:
            d[b] = d[a]+c
            update = True
    if not update:
        break

ans = d[n-1]
negative = [False for _ in range(n)]
for _ in range(n):
    update = False
    for i in range(m):
        a = ea[i]
        b = eb[i]
        c = cost[i]
        if d[a]!=inf and d[b]>d[a]+c:
            d[b] = d[a]+c
            negative[b] = True
            update = True
        if negative[a]:
            negative[b] = True
            update = True
    if no update:
        break
# print(d)
if negative[n-1]:
    print("inf")
else:
    print(-ans)
Problem p03817 (python)

Fixed submission:
# -*- coding: utf-8 -*-
x = int(input())

if x<=6:
    print(1)
    exit()
if x<=11:
    print(2)
    exit()

r = x%11
ret = x//11
if r==0:
    print(2*ret)
elif r<=6:
    print(2*ret+1)
elif r<=11:
    print(2*ret+2)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
x = int(input())

if x<=6:
    print(1)
    exit()
if x<=11:
    print(2)
    exit()

r = x%11
ret = x//11
if r<=6:
    print(2*ret+1)
elif t<=11:
    print(2*ret+2)
else:
    print(2*ret)
Problem p03856 (python)

Fixed submission:
# -*- coding: utf-8 -*-

s = input()[::-1]
w = [
    "dream"[::-1]
    ,"dreamer"[::-1]
    ,"erase"[::-1]
    ,"eraser"[::-1]
]

while len(s)>0:
    if s.startswith(w[0]):
        s = s[len(w[0]):]
    elif s.startswith(w[1]):
        s = s[len(w[1]):]
    elif s.startswith(w[2]):
        s = s[len(w[2]):]
    elif s.startswith(w[3]):
        s = s[len(w[3]):]
    else:
        break

if len(s)==0:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def f(s):
    # print(s)
    if s.startswith("dream"):
        return f(s[5:]) or f(s[7:])
    elif s.startswith("erase"):
        return f(s[5:]) or f(s[6:])
    elif s=="":
        return True
    else:
        return False

if f(input()):
    print("YES")
else:
    print("NO")
Problem p03947 (python)

Fixed submission:
s = raw_input()

ans = 0
c = s[0]

for i in range(1,len(s)):
    if c!=s[i]:
        ans += 1
        c = s[i]

print(ans)

Buggy submission (verdict: Runtime Error):
import unittest


class TestFunc(unittest.TestCase):
    def test_1(self):
        self.assertEqual(fun(5,8,[50,30,40,10,20]),2)
        self.assertEqual(fun(3,2,[100,50,200]),1)
        self.assertEqual(fun(10,100,[7,10,4,5,9,3,6,8,2,1]),2)
        self.assertEqual(fun(5,2,[1,2,3,2,4]),1)




def fun(n,t,a):
    aa = []
    b = None
    s = None
    for i in range(n):
        m = -1
        for j in range(i+1,n):
            if a[j]>a[i] and a[j]-a[i]>m:
                m = a[j]-a[i]
        if m>0:
            aa.append(m)

    c = aa[0]
    ans = 1
    for i in range(1,len(aa)):
        if c<aa[i]:
            c = aa[i]
            ans = 1
        elif c==aa[i]:
            ans += 1

    return ans


if __name__=='__main__':
    #unittest.main()                                                                                                                                                              

    n,t = [int(x) for x in raw_input().split(" ")]
    a = [int(x) for x in raw_input().split(" ")]
    print(fun(n,t,a))
Problem p03952 (python)

Fixed submission:
# -*- coding: utf-8 -*-
n,x = map(int, input().split())

if x==1 or x==2*n-1:
    print("No")
    exit()
if n==2:
    print("Yes")
    print(1)
    print(2)
    print(3)
    exit()

ret = [0 for _ in range(2*n-1)]
if x!=2:
    ret[n-1-1] = x-1
    ret[n-1] = x
    ret[n+1-1] = x+1
    ret[n+2-1] = x-2
    d = [x-2,x-1,x,x+1]
else:
    ret[n-1-1] = x+1
    ret[n-1] = x
    ret[n+1-1] = x-1
    ret[n+2-1] = x+2
    d = [x-1,x,x+1,x+2]
i = 0
j = 1
while i<2*n-1:
    if ret[i]==0:
        while j in d:
            j += 1
        ret[i] = j
        j += 1
    i += 1
print("Yes")
for x in ret:
    print(x)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n,x = map(int, input().split())

if x==1 or x==2*n-1:
    print("No")
    exit()
if n==2:
    print("Yes")
    print(1)
    print(2)
    print(3)

ret = [0 for _ in range(2*n-1)]
if x!=2:
    ret[n-1] = x-1
    ret[n] = x
    ret[n+1] = x+1
    ret[n+2] = x-2
    d = [x-2,x-1,x,x+1]
else:
    ret[n-1] = x+1
    ret[n] = x
    ret[n+1] = x-1
    ret[n+2] = x+2
    d = [x-1,x,x+1,x+2]
i = 0
j = 1
while i<2*n-1:
    if ret[i]==0:
        while j in d:
            j += 1
        ret[i] = j
        j += 1
    i += 1
print("Yes")
for x in ret:
    print(x)
Problem p02767 (python)

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

res = float('inf')

for i in range(-100, 101):
    tmp = 0
    for x in X:
        tmp += (i - x) ** 2

    res = min(tmp, res)

print(res)

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

res = float('inf')

for i in range(min(X, 1), max(X, 100) + 1):
    tmp = 0
    for x in X:
        tmp += (i - x) ** 2

    res = min(tmp, res)

print(res)
Problem p02797 (python)

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

M = 10 ** 9

res = [str(S) for _ in range(K)]

res += [("1" if S == M else str(S+1)) for _ in range(N-K)]

print(" ".join(res))

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

M = 10 ** 9

res = [S for _ in range(K)]

res += [("1" if S == M else str(S+1)) for _ in range(N-K)]

print(" ".join(res))

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

M = 10 ** 9

res = [S for _ in range(K)]

res += [(1 if S == M else S+1) for _ in range(N-K)]

print(" ".join(res))

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

M = 10 ** 9

res = [S for _ in range(K)]

res += [(1 if S == M else S+1) for _ in range(N-K)]

print(" ".join(res))

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

M = 10 ** 9

res = [S for _ in range(K)]

res += [1 if S == M else S+1 for _ in range(N-K)]

print(" ".join(res))
Problem p02866 (python)

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

M = max(D)
cnt = [0 for i in range(M + 1)]

for d in D:
    cnt[d] += 1

if D[0] != 0:
    print(0)
    exit()
if cnt[0] != 1 or 0 in cnt:
    print(0)
    exit()

res = 1
MOD = 998244353
for i in range(2, M + 1):
    res *= cnt[i - 1] ** cnt[i]
    res %= MOD

print(res)

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

M = max(D)
cnt = [0 for i in range(N - 1)]

for d in D:
    cnt[d] += 1

if cnt[0] != 1:
    print(0)
    exit()

for c in cnt[:M]:
    if c == 0:
        print(0)
        exit()

res = 1
MOD = 998244353
for i in range(1, M + 1):
    for c in range(cnt[i]):
        res = (res * cnt[i - 1]) % MOD

print(res)

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

M = max(D)
cnt = [0 for i in range(N - 1)]

for d in D:
    cnt[d] += 1

for c in cnt[:M]:
    if c == 0:
        print(0)
        exit()

res = 1
MOD = 998244353
for i in range(1, M + 1):
    res = (res * cnt[i - 1] ** cnt[i]) % MOD

print(res)
Problem p02900 (python)

Fixed submission:
import fractions

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

G = fractions.gcd(A, B)

res = 1

for i in [2] + list(range(3, int(G ** 0.5) + 1, 2)):
    if G % i == 0:
        res += 1
        while G % i == 0:
            G //= i

if G > 2:
    res += 1

print(res)

Buggy submission (verdict: Runtime Error):
import fractions

primes = [2]


def is_prime(n):
    for p in primes:
        if p * p > n:
            break
        if n % p == 0:
            return False

    return True


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

G = fractions.gcd(A, B)

res = 1

if G % 2 == 0:
    res += 1
    G /= 2

for i in range(3, G, 2):
    if i > G:
        break
    if not is_prime(i):
        continue
    primes.append(i)
    if G % i == 0:
        res += 1
        G /= i

if G > 1 and is_prime(G) and G not in primes:
    res += 1

print(res)