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

Fixed submission:
n = int(input())
s = input()
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            p=0
            for f in range(n):
                if p == 0 and s[f] == str(i):
                    p = 1
                elif p == 1 and s[f] == str(j):
                    p = 2
                elif p == 2 and s[f] == str(k):
                    ans += 1
                    break
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            for f in range(n):
                if p == 0 and s[f] == str(i):
                    p = 1
                elif p == 1 and s[f] == str(j):
                    p = 2
                elif p == 2 and s[f] == str(k):
                    ans += 1
                    break
print(ans)
Problem p02937 (python)

Fixed submission:
from bisect import bisect_left,bisect
s = list(input())
sn = len(s)
t = list(input())
tn = len(t)
kouho = []
for i in range(26):
    kar = []
    now = chr(ord('a') + i)
    for j in range(sn):
        if s[j] == now:
            kar.append(j)
    kouho.append(kar)

cou = 0
now = -1
for i in range(tn):
    u = ord(t[i])-ord("a")
    if kouho[u]:
        tugi = bisect(kouho[u],now)
        if tugi == len(kouho[u]):
            cou += 1
            now = kouho[u][0]
        else:
            now = kouho[u][tugi]
    else:
        print(-1)
        exit()

print(cou*sn + now + 1)

Buggy submission (verdict: Runtime Error):
import copy
from collections import deque
sima = [list(input()) for i in range(10)]
riku = 0
ikisaki = [(1,0),(-1,0),(0,1),(0,-1)]

for i in range(10):
    for j in range(10):
        if sima[i][j] == "o":
            riku += 1

for i in range(10):
    for j in range(10):
        if sima[i][j] == "o":
            continue
        cou = 0
        karisima = copy.deepcopy(sima)
        karisima[i][j] = "o"
        d = deque()
        d.append((i,j))
        tansaku = [[True for p in range(10)] for q in range(10)]
        while d:
            y , x = d.popleft()
            tansaku[y][x] = False
            cou += 1
            for ney , nex in ikisaki:
                if 0 <= x + nex <= 9 and 0 <= y + ney <= 9:
                    if tansaku[y+ney][x+nex] and karisima[y+ney][x+nex] == "o":
                        d.append((y+ney,x+nex))
        if cou == riku + 1:
            print("YES")
            exit()
print("NO")
Problem p02963 (python)

Fixed submission:
s = int(input())
x = s % 10**9
y = s // 10**9
if x > 0:
    x -= 10**9
    y += 1
print(0,0,10**9,1,-x,y)

Buggy submission (verdict: Runtime Error):
m = int(input())
print("0 0 1000000000 1 " + str(10**9-(m%(10**9)))+ " " + str(m//(10**9) + 1)))
Problem p02975 (python)

Fixed submission:
import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)

if len(c) > 3:
    print("No")
    exit()
elif len(c) == 3:
    if n % 3 != 0:
        print("No")
        exit()
    p = []
    for k , v in c.items():
        if v != n//3:
            print("No")
            exit()
        p.append(k)
    if (p[0] ^ p[1]) ^ p[2] != 0:
        print("No")
        exit()
elif len(c) == 2:
    if n % 3 != 0:
        print("No")
        exit()
    for k,v in c.items():
        if k == 0:
            if v != n//3:
                print("No")
                exit()
        else:
            if v != 2*n//3:
                print("No")
                exit()
elif len(c) == 1:
    for k in c.keys():
        if k != 0:
            print("No")
            exit()
            
print("Yes")

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)

if len(c) > 3:
    print("No")
    exit()
elif len(c) == 3:
    if n % 3 != 0:
        print("No")
        exit()
    p = []
    for k , v in c.items():
        if v != n//3:
            print("No")
            exit()
        p.append(k)
    if (p[0] ^ p[1]) ^ p[2] != 0:
        print("No")
        exit()
elif len(c) == 2:
    if n % 3 != 0:
        print("No")
        exit()
    for k,v in c.items():
        if k == 0:
            if v != n//3:
                print("No")
                exit()
        elif:
            if v != 2*n//3:
                print("No")
                exit()
elif len(c) == 1:
    for k in c.keys():
        if k != 0:
            print("No")
            exit()
            
print("Yes")
Problem p02983 (python)

Fixed submission:
l , r = map(int,input().split())
p = []
if r - l >= 2018:
    print(0)
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            p.append((i*j)%2019)
    print(min(p))

Buggy submission (verdict: Runtime Error):
l , r = map(int,input().split())

if r - l >= 2020:
    print(0)
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            p.append((i*j)%2019)
    print(min(p))
Problem p03007 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort()
aminus = []
aplus = []
p = 0
q = 0
for i in a:
    if i >= 0:
        aplus.append(i)
        p += 1
    elif i < 0:
        aminus.append(i)
        q += 1
ans = []
cou = 0
if aplus and aminus:
    now = aminus[0]
    for i in range(p-1):
        ans.append((now,aplus[i]))
        now = now - aplus[i]
    aminus[0] = now
    now = aplus[p-1]
    for i in range(q):
        ans.append((now,aminus[i]))
        now = now - aminus[i]
    cou = now
elif aplus:
    now = aplus[0]
    for i in range(1,p-1):
        ans.append((now,aplus[i]))
        now = now - aplus[i]
    ans.append((aplus[p-1],now))
    cou = aplus[p-1] - now
elif aminus:
    now = aminus[q-1]
    for i in range(q-1):
        ans.append((now,aminus[i]))
        now = now - aminus[i]
    cou = now

print(cou)
for i in range(n-1):
    print(*ans[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a.sort()
aminus = []
aplus = []
p = 0
q = 0
for i in a:
    if i >= 0:
        aplus.append(i)
        p += 1
    elif i < 0:
        aminus.append(i)
        q += 1
ans = []
cou = 0
if aplus and aminus:
    now = aminus[0]
    for i in range(p-1):
        ans.append((now,aplus[i]))
        now = now - aplus[i]
    aminus[0] = now
    now = aplus[p-1]
    for i in range(q):
        ans.append((now,aminus[i]))
        now = now - aminus[i]
    cou = now
elif aplus:
    now = aplus[0]
    for i in range(1,p-1):
        ans.append((now,aplus[i]))
        now = now - aplus[i]
    ans.append((aplus[p-1],now))
    cou = aplus[p-1] - now
elif aminus:
    now = aminus[q-1]
    for i in range(q-1):
        ans.append(now,aminus[i])
        now = now - aminus[i]
    cou = now
print(cou)
for i in range(n-1):
    print(*ans[i])
Problem p03035 (python)

Fixed submission:
a , b = map(int,input().split())
if a >= 13:
    print(b)
elif 6 <= a <= 12:
    print(b//2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import heapq

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

for i in range(m):
    b , c = map(int,input().split())
    for j in range(b):
        p = heapq.heappop(a)
        if p >= c:
            heapq.heappush(a,p)
            break
        else:
            heapq.heappush(a,c)

print(sum(a))
Problem p03047 (python)

Fixed submission:
n,k=map(int,input().split())
print(n-k+1)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
r , g , b , n = map(int,input().split())
ans = 0
R = -(-n//r)
G = -(-n//g)
for i in range(R+1):
    for j in range(G+1):
        su = n-r*i-g*j
        if n-r*i-g*j < 0:
            break
        else:
            if (su/b).is_integer():
                ans += 1
print(ans)
Problem p03069 (python)

Fixed submission:
n = int(input())
s = input()
migi = s.count(".")
hidari = 0
ans = migi
for i in range(n):
    if s[i] == "#":
        hidari += 1
    elif s[i] == ".":
        migi -= 1
    ans = min(ans,hidari+migi)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
print(min(s[s.find("#"):s.rfind(".")].count("#"),s[s.find("#"):s.rfind(".")+1].count("."))
Problem p03074 (python)

Fixed submission:
n,k = map(int,input().split())
s = input()
cou = 0
p = 1
nagasa = []
for i in range(n):
    if int(s[i]) == p:
        cou += 1
    elif int(s[i]) != p:
        if p == 1:
            p = 0
        elif p == 0:
            p = 1
        nagasa.append(cou)
        cou = 1
nagasa.append(cou)
if len(nagasa) % 2 == 0:
    nagasa.append(0)
h = len(nagasa)

if h // 2 <= k:
    print(n)
    exit()
lef = 0
rig = 2*k+1
now = sum(nagasa[lef:rig])
ans = now
while True:
    if rig == h:
        break
    now = now - nagasa[lef] - nagasa[lef+1] + nagasa[rig] + nagasa[rig+1]
    ans = max(ans,now)
    lef += 2
    rig += 2
print(ans)

Buggy submission (verdict: Runtime Error):
h = len(nagasa)

if h // 2 <= k:
    print(n)
    exit()
lef = 0
rig = 2*k+1
now = sum(nagasa[lef:rig])
ans = now
while True:
    if rig == h:
        break
    now = now - nagasa[lef] - nagasa[lef+1] + nagasa[rig] + nagasa[rig+1]
    ans = max(ans,now)
    lef += 2
    rig += 2
print(ans)
Problem p03085 (python)

Fixed submission:
b = input()
if b == "A":
    print("T")
if b == "T":
    print("A")
if b == "G":
    print("C")
if b == "C":
    print("G")

Buggy submission (verdict: Runtime Error):
b = input()
if b = "A":
    print("T")
if b = "T":
    print("A")
if b = "G":
    print("C")
if b = "C":
    print("G")
Problem p03096 (python)

Fixed submission:
n = int(input())
iro = [-1 for i in range(2*(10**5)+1)]
dp = [1 for i in range(n+1)]
mod = 10**9 + 7
for i in range(1,n+1):
    dp[i] = dp[i-1]
    now = int(input())
    if iro[now] != -1 and iro[now] != i-1:
        dp[i] += dp[iro[now]]
    iro[now] = i
    dp[i] %= mod
print(dp[n])

Buggy submission (verdict: Runtime Error):
n = int(input())
iro = [-1 for i in range(n+1)]
dp = [1 for i in range(n+1)]
mod = 10**9 + 7
for i in range(1,n+1):
    dp[i] = dp[i-1]
    now = int(input())
    if iro[now] != -1 and iro[now] != i-1:
        dp[i] += dp[iro[now]]
    iro[now] = i
    dp[i] %= mod
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
iro = [-1 for i in range(n+1)]
dp = [1 for i in range(n+1)]
mod = 10**9 + 7
for i in range(1,n+1):
    dp[i] = dp[i-1]
    now = int(input())
    if iro[now] == -1:
        iro[now] = i
    elif iro[now] != i-1:
        dp[i] += dp[iro[now]]
    iro[now] = i
    dp[i] %= mod
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
iro = [-1 for i in range(n+1)]
dp = [1 for i in range(n+1)]
mod = 10**9 + 7
for i in range(1,n+1):
    dp[i] = dp[i-1]
    now = int(input())
    if iro[now] == -1:
        iro[now] = i
    elif iro[now] != i-1:
        dp[i] += dp[iro[now]]
    iro[now] = i
    dp[i] %= mod
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
iro = [-1 for i in range(n+1)]
dp = [1 for i in range(n+1)]
mod = 10**9 + 7
for i in range(1,n+1):
    dp[i] = dp[i-1]
    now = int(input())
    if iro[now] == -1:
        iro[now] = i
    elif iro[now] != i-1:
        dp[i] += dp[iro[now]]
    iro[now] = i
    dp[i] %= mod
print(dp)

Buggy submission (verdict: Runtime Error):
n = int(input())
iro = [-1 for i in range(n+1)]
dp = [1 for i in range(n+1)]
mod = 10**9 + 7
for i in range(1,n+1):
    dp[i] = dp[i-1]
    now = int(input())
    if iro[now] == -1:
        iro[now] = i
    elif iro[now] != i-1:
        dp[i] += dp[iro[now]]
        iro[now] = i
    dp[i] %= mod
print(dp[n])

Buggy submission (verdict: Runtime Error):
n = int(input())
iro = [-1 for i in range(n+1)]
dp = [1 for i in range(n+1)]

for i in range(1,n+1):
    dp[i] = dp[i-1]
    now = int(input())
    if iro[now] == -1:
        iro[now] = i
    elif iro[now] != i-1:
        dp[i] += dp[iro[now]]
        iro[now] = i
print(dp[-1])
Problem p03196 (python)

Fixed submission:
n , p = map(int,input().split())
pf={}
for i in range(2,int(p**0.5)+1):
    while p%i==0:
        pf[i]=pf.get(i,0)+1
        p//=i
if p>1:
    pf[p]=1

ans = 1

for k,v in pf.items():
    ans *= k**(v//n)
print(ans)

Buggy submission (verdict: Runtime Error):
n , p = map(int,input().split())
pf={}
for i in range(2,int(p**0.5)+1):
    while p%i==0:
        pf[i]=pf.get(i,0)+1
        p//=i
if p>1:pf[m]=1

ans = 1

for k,v in pf.items():
    if v//n >= 1:
        ans *= k*(v//n)
print(ans)
Problem p03231 (python)

Fixed submission:
import fractions
n , m = map(int,input().split())
s = input()
t = input()
l = n*m//fractions.gcd(n,m)
p = l//n
q = l//m

for i in range(10**9):
    if q*i >= n or p*i >= m:
        print(l)
        exit()
    if s[q*i] != t[p*i]:
        print(-1)
        exit()

Buggy submission (verdict: Runtime Error):
n , m = map(int,input().split())
s = input()
t = input()
l = n*m//fractions.gcd(n,m)
p = l//n
q = l//m

for i in range(10**9):
    if q*i >= n or p*i >= m:
        print(l)
        exit()
    if s[q*i] != t[p*i]:
        print(-1)
        exit()
Problem p03262 (python)

Fixed submission:
import fractions
n , x = map(int,input().split())
p = list(map(int,input().split()))
ans = abs(x - p[0])
for i in range(n):
    ans = fractions.gcd(ans,abs( x - p[i] ))
    
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n , x = map(int,input().split())
p = list(map(int,input().split()))
ans = abs(x - p[0])
for i in range(n):
    ans = math.gcd(ans,abs( x - p[i] ))
    
print(ans)
Problem p03292 (python)

Fixed submission:
a , b , c = map(int,input().split())
print(min(abs(a-b)+abs(b-c),abs(b-a)+abs(a-c),abs(a-c)+abs(c-b)))

Buggy submission (verdict: Runtime Error):
a , b , c = map(int,input().split())
print(min(abs(a-b)+abs(b-c),abs(b-a)+abs(a-c),abs(a-c)+abs(c-b))
Problem p03304 (python)

Fixed submission:
n , m , d = map(int,input().split())
cou = 0
if d == 0:
    cou += n
else:
    cou += 2*(n-d)
print(cou*(m-1)/pow(n,2))

Buggy submission (verdict: Runtime Error):
n , m , d = map(int,input().split())
cou = 0
if d == 0:
    cou += n
elif d+1 <= n-d:
    cou += 2*n-2*d-2
else:
    cou += n
print(pow(cou,m-1)*(m-1)/pow(n,m))
Problem p03385 (python)

Fixed submission:
s = input()
if s.count("a")*s.count("b")*s.count("c") == 1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = input()
if s.count("a")*s.count("b")*s.count("c") == 1:
  print("Yes)
else:
        print("No")
Problem p03450 (python)

Fixed submission:
from collections import deque
n , m = map(int,input().split())
z = [[] for i in range(n)]
for i in range(m):
    l , r , d = map(int,input().split())
    z[l-1].append((r-1,d))
    z[r-1].append((l-1,-d))

visit = [False for i in range(n)]
x = [-1 for i in range(n)]
for i in range(n):
    if visit[i]:
        continue
    visit[i] = True
    q = deque()
    q.append(i)
    x[i] = 0
    while q:
        now = q.popleft()
        for t , d in z[now]:
            if not visit[t]:
                visit[t] = True
                x[t] = x[now] + d
                q.append(t)
            elif visit[t]:
                if x[t] - x[now] != d:
                    print("No")
                    exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
from collections import deque
n , m = map(int,input().split())
z = [[] for i in range(n)]
for i in range(m):
    l , r , d = map(int,input().split())
    z[l-1].append((r-1,d))
    z[r-1].append((l-1,-d))

visit = [False for i in range(n)]
x = [-1 for i in range(n)]
for i in range(n):
    if visit[i]:
        continue
    visit[i] = True
    d = deque()
    d.append(i)
    x[i] = 0
    while d:
        now = d.popleft()
        for t , d in z[now]:
            if not visit[t]:
                visit[t] = True
                x[t] = x[now] + d
                d.append(t)
            elif visit[t]:
                if x[t] - x[now] != d:
                    print("No")
                    exit()
print("Yes")
Problem p03493 (python)

Fixed submission:
s=input()
print(s.count("1"))

Buggy submission (verdict: Runtime Error):
s=input()
print(s.count(“1”))
Problem p03544 (python)

Fixed submission:
p = [2,1]
n = int(input())

if n >= 2:
    for i in range(2,n+1):
        p.append(p[i-2]+p[i-1])

print(p[n])

Buggy submission (verdict: Runtime Error):
p = [2,1]
n = int(input())

if n >= 3:
    for i in range(2,n+1):
        p.append(p[i-2]+p[i-1])

print(p[n])
Problem p03565 (python)

Fixed submission:
s = input()
t = input()

a = len(s)
b = len(t)
ans = []
if a-b+1 < 0:
    print("UNRESTORABLE")
    exit()

for i in range(a-b+1):
    p = 0
    for j in range(b):
        if s[i+j] != t[j] and s[i+j] != "?":
            p = 1
            break
    if p == 0:
        kar = s[:i] + t + s[i+b:]
        kar = kar.replace("?","a")
        ans.append(kar)
if len(ans) == 0:
    print("UNRESTORABLE")
else:
    ans.sort()
    print(ans[0])

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s)
t = input()
m = len(t)

if n < m:
    print("UNRESTORABLE")
    exit()
p = False
for i in reversed(range(n-m+1)):
    flag = True
    for j in range(m):
        if s[i+j] != "?" and s[i+j] != t[j]:
            flag = False
            break
    if flag:
        s = s[:i] + t
        p = True
        break

if not p:
    print("UNRESTORABLE")
    exit()
elif p:
    for i in range(n):
        if s[i] == "?":
            s = s[:i] + "a" + s[i+1:]
print(s)
Problem p03660 (python)

Fixed submission:
from heapq import heappop, heappush
from collections import deque
n = int(input())
mp2 = []
route = [[] for i in range(n)]
for i in range(n-1):
    a , b = map(lambda x:int(x)-1,input().split())
    mp2.append((a,b,1))
    mp2.append((b,a,1))
    route[a].append(b)
    route[b].append(a)
inf=float('inf')
d=[inf for i in range(n)]
d[0]=0
prev=[None]*n
p=dict()
for i,j,k in mp2: p[i]=p.get(i,[])+[(j,k)]

q=[]
heappush(q,(d[0],0))
while q:
    du, u = heappop(q)
    if d[u]<du: continue
    for v,weight in p.get(u,[]):
        alt=du+weight
        if d[v]>alt:
            d[v]=alt
            prev[v]=u
            heappush(q, (alt,v))

p=[n-1]
while prev[p[-1]]!=None: p.append(prev[p[-1]])

p = p[::-1]
t = p[-(-len(p)//2)-1]

d = deque()
d.append(n-1)
visit = [False for i in range(n)]
siro = 1
visit[n-1] = True
visit[t] = True
while d:
    now = d.popleft()
    for i in route[now]:
        if not visit[i] and i != t:
            visit[i] = True
            d.append(i)
            siro += 1
kuro = n - siro
if kuro <= siro:
    print("Snuke")
elif kuro > siro:
    print("Fennec")

Buggy submission (verdict: Runtime Error):
from collections import deque
def f(x,q):
    for i in route[x]:
        if not visit[i]:
            visit[i] = True
            f(i,q+[i])
            visit[i] = False
            if i == n-1:
                p = q + [i-1]
                flag = True
                return p
n = int(input())
route = [[] for i in range(n)]
for i in range(n-1):
    a , b = map(lambda x:int(x)-1,input().split())
    route[a].append(b)
    route[b].append(a)
visit = [False for i in range(n)]
p = f(0,[0])
t = p[-(-len(p)//2)-1]

d = deque()
d.append(n-1)
visit = [False for i in range(n)]
siro = 1
while d:
    now = d.popleft()
    for i in route[now]:
        if not visit[i] and i != t:
            visit[i] = True
            d.append(i)
            siro += 1
kuro = n - siro
if kuro <= siro:
    print("Snuke")
elif kuro > siro:
    print("Fennec")
Problem p03818 (python)

Fixed submission:
import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)

p = []
ans = 0
for k,v in c.items():
    ans += 1
    if v != 1:
        p.append([k,v])
p.sort()
lef = 0
rig = len(p)-1

while True:
    if lef == rig:
        if p[lef][1] % 2 == 1:
            print(ans)
            exit()
        elif p[lef][1] % 2 == 0:
            print(ans-1)
            exit()
    elif lef > rig:
        print(ans)
        exit()
    p[lef][1] -= 1
    p[rig][1] -= 1
    if p[lef][1] == 1:
        lef += 1
    if p[rig][1] == 1:
        rig -= 1

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)

p = []
ans = 0
for k,v in c.items():
    ans += 1
    if v != 1:
        p.append([k,v])
p.sort()
lef = 0
rig = len(p)-1

while True:
    if lef == rig:
        if p[lef][1] % 2 == 1:
            print(ans)
            exit()
        elif p[lef][1] % 2 == 0:
            print(ans-1)
            exit()
    elif lef > rig:
        print(ans)
    p[lef][1] -= 1
    p[rig][1] -= 1
    if p[lef][1] == 1:
        lef += 1
    if p[rig][1] == 1:
        rig -= 1

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)

p = []
ans = 0
for k,v in c.items():
    ans += 1
    if v != 1:
        p.append([k,v])
p.sort()
lef = 0
rig = len(p)-1

while True:
    p[lef][1] -= 1
    p[rig][1] -= 1
    if p[lef][1] == 1:
        lef += 1
    if p[rig][1] == 1:
        rig -= 1
    if lef == rig:
        if p[lef][1] % 2 == 1:
            print(ans)
            exit()
        elif p[lef][1] % 2 == 0:
            print(ans-1)
            exit()
Problem p04045 (python)

Fixed submission:
from collections import deque
n , k = map(int,input().split())
d = set(list(map(int,input().split())))
kouho =list({0,1,2,3,4,5,6,7,8,9} - d)
kouho.sort()

p = deque()
p.append(0)

while p:
    now = p.popleft()
    if now >= n:
        print(now)
        exit()
    for i in kouho:
        p.append(now*10+i)

Buggy submission (verdict: Runtime Error):
n , k = map(int,input().split())
d = set(list(map(int,input().split())))
kouho =list({0,1,2,3,4,5,6,7,8,9} - d)
kouho.sort()

def f(now):
    if now >= n:
        print(now)
        exit()
    for i in kouho:
        f(now*10 + i)

f(0)
Problem p02768 (python)

Fixed submission:
def cmb(n, r, p):
    A = 1
    B = 1
    r = min(r, n - r)
    for i in range(r):
        A = A * (n-i) % p
        B = B * (i+1) % p
    return A * pow(B, p-2, p) % p

n, a, b = map(int, input().split())
p = 10**9 + 7
A = pow(2, n, p) - 1 - cmb(n, a, p) - cmb(n, b, p)
A = A%p
print(A)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
p = 10**9 + 7
def ModComb(n, r, p):
    N = n%p
    R = r%p
    if N<R:
        return 0
    if N < 2*R:
        R = N-R
    if R == 0:
        return 1
    else:
        return (n*pow(r, p-2, p))%p*ModComb(n-1, r-1, p)

ans = 1
for i in range(N):
  ans *= 2
  ans = ans%p
ans = ans - 1 - ModComb(n, a, p) - ModComb(n, b, p)
ans = ans%p
print(ans)
Problem p02845 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
L = [0 for i in range(max(A)+2)]
ans = 1
L[0] = 3
p = 10 ** 9 + 7
for i in range(N):
  ai = A[i]
  ans *= (L[ai] - L[ai + 1])
  ans = ans % p
  L[ai + 1] += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input)
A = list(map(int, input().split()))
L = [0 for i in range(max(A)+2)]
ans = 1
L[0] = 3
p = 10 ** 9 + 7
for i in range(N):
  ai = A[i]
  ans *= (L[ai] - L[ai + 1])
  ans = ans % p
  L[ai + 1] += 1
print(ans)
Problem p02971 (python)

Fixed submission:
N = int(input())
M = 1
prev_M = 0
A = []
for i in range(N):
  a = int(input())
  A += [a]
  if a == M:
    prev_M = M
  elif a > M:
    prev_M = M
    M = a
  elif a > prev_M:
    prev_M = a
for i in range(N):
  if A[i] != M:
    print(M)
  else:
    print(prev_M)

Buggy submission (verdict: Runtime Error):
N = int(input())
M = 1
prev_M = 0
A = []
for i in range(N):
  a = int(input())
  A += [a]
  if a == M:
    prev_M = M
  elif a > M:
    M = a
for i in range(N):
  if a[i] != M:
    print(M)
  else:
    print(prev_M)