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

Fixed submission:
N = int(input())

a = N%100
a = a%10

if a == 0 or a == 1 or a == 6 or a == 8:
    print("pon")
elif a == 3:
    print("bon")
else:
    print("hon")

Buggy submission (verdict: Runtime Error):
import math
A,B,H,M = map(int,input().split())

a = H * 30 + M * 0.5
b = M * 6
c = abs(a-b)
c = math.radians(c)
c = abs(math.cos(c))
if c == 0:
    print(abs(B-A))
else:
    d = math.sqrt(A**2 + B**2 - 2 * A * B * c)
    print(d)

Buggy submission (verdict: Runtime Error):
N = int(input())

a = N%100
a = a%10

if a == 0 or a == 1 or a == 6 or a == 8:
    print("pon")
elif a == 3:
    print("bon")
else:
    print("hon"

Buggy submission (verdict: Runtime Error):
import math
A,B,H,M = map(int,input().split())

a = H * 30 + M * 0.5
b = M * 6
c = abs(a-b)
c = c - 180 if c > 180 else c
c = math.radians(c)
d = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(c))
print(d)

Buggy submission (verdict: Runtime Error):
import math
A,B,H,M = map(int,input().split())

a = H * 30 + M * 0.5
b = M * 6
c = abs(a-b)
c = c - 180 if c > 180 else c
c = math.radians(c)
d = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(c))
print(d)

Buggy submission (verdict: Runtime Error):
import math
A,B,H,M = map(int,input().split())

a = H * 30 + M * 0.5
b = M * 6
c = abs(a-b)
c = c - 180 if c > 180 else c
c = math.radians(c)
d = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(c))
print(d)

Buggy submission (verdict: Runtime Error):
N = int(input())

a = N%100
a = a%10

if a == 0 or a == 1 or a == 6 or a == 8:
    print("pon")
elif a == 3:
    print("bon")
else:
    print("hon"
Problem p02705 (python)

Fixed submission:
import math
R = int(input())
p = math.pi
print(2*R*p)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
s = 0
a = 0
b = N

for i in range(1,K):
    s += b - a + 1
    a += i
    b += N - i

u = 0
a = 0
b = N
for i in range(1,N+2):
    u += b - a + 1
    a += i
    b += N - i
print(u-s)

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

s = sum(A)
if N-s<0:
    print(-1)
else:
    print(N-s)
Problem p02717 (python)

Fixed submission:
box = list(map(int,input().split()))
print("%d %d %d"%(box[2],box[0],box[1]))

Buggy submission (verdict: Runtime Error):
box = list(map(int,input().split()))
box.reverse()
for x in box:
    print(x,end = " \0")
print("\n",end = "\0"
Problem p03280 (python)

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

print((a-1)*(b-1))

Buggy submission (verdict: Runtime Error):
a,b = int(input())

a-=1
b-=1

print(a*b)

Buggy submission (verdict: Runtime Error):
a,b=int(input())

a-=1
b-=1

print(a*b)
Problem p02579 (python)

Fixed submission:
from collections import deque
h, w = map(int, input().split())
c_h, c_w = map(int, input().split())
d_h, d_w = map(int, input().split())
#スタートとゴールの座標を設定
start_h = c_h - 1
start_w = c_w - 1
goal_h = d_h - 1
goal_w = d_w - 1
#迷路の読み込み
maze = [input() for _ in range(h)]
inf = float("inf")
dist = [[inf] * w for _ in range(h)]



def bfs(x, y):
    dist[x][y] = 0
    q = deque()
    q.append((x, y))
    while q:
        x, y = q.popleft() 
        d = dist[x][y]
        for dx, dy in [(0,1),(1,0),(0,-1),(-1,0)]:
            nx = x + dx
            ny = y + dy 
            if not 0 <= nx < h or not 0 <= ny < w:
                continue
            if maze[nx][ny] == "#":
                continue
            if dist[nx][ny] <= d:
                continue
            dist[nx][ny] = d           
            q.appendleft((nx, ny))

        for dxx in range(-2, 3):
            for dyy in range(-2, 3):
                 nxx = x + dxx
                 nyy = y + dyy 
                 if not 0 <= nxx < h or not 0 <= nyy < w:
                    continue
                 if maze[nxx][nyy] == "#":
                    continue
                 if dist[nxx][nyy] <= d+1:
                    continue
                 dist[nxx][nyy] = d+1
                 q.append((nxx, nyy))
                



bfs(start_h, start_w)
if dist[goal_h][goal_w] == inf:
    print("-1")
else:
    print(dist[goal_h][goal_w])

Buggy submission (verdict: Runtime Error):
from collections import deque
h, w = map(int, input().split())
c_h, c_w = map(int, input().split())
d_h, d_w = map(int, input().split())
#スタートとゴールの座標を設定
start_h = c_h - 1
start_w = c_w - 1
goal_h = d_h - 1
goal_w = d_w - 1
#迷路の読み込み
maze = [input() for _ in range(h)]
inf = float("inf")
dist = [[inf] * w for _ in range(h)]



def bfs(x, y):
    dist[x][y] = 0
    q_walk = deque()
    q_warp = deque()
    q_walk.append((x, y))
    while q_walk > 0:
        x, y = q_walk.popleft() 
        q_warp.append((x, y))
        d = dist[x][y]
        for dx, dy in [(0,1),(1,0),(0,-1),(-1,0)]:
            nx = x + dx
            ny = y + dy 
            if not 0 <= nx < h or not 0 <= ny < w:
                continue
            if maze[nx][ny] == "#":
                continue
            if dist[nx][ny] <= d:
                continue
            dist[nx][ny] = d           
            q_walk.append((nx, ny))
        if len(q_wark) == 0:
            while len(q_warp) > 0:
                x2, y2 = q_warp.popleft()
                for dxx in range(-2, 3):
                    for dyy in range(-2, 3):
                        nxx = x2 + dxx
                        nyy = y2 + dyy 
                        if not 0 <= nxx < h or not 0 <= nyy < w:
                            continue
                        if maze[nxx][nyy] == "#":
                            continue
                        if dist[nxx][nyy] <= d+1:
                            continue
                        dist[nxx][nyy] = d+1
                        q_warp.append((nxx, nyy))
                



bfs(start_h, start_w)
if dist[goal_h][goal_w] == inf:
    print("-1")
else:
    print(dist[goal_h][goal_w])
Problem p02705 (python)

Fixed submission:
import math
r = int(input())
x = math.pi
print(r*2*x)

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

Fixed submission:
import math
k = int(input())
a = []
for i in range(1, k+1):
    for j in range(1, k+1):
        x = math.gcd(i, j)
        for l in range(1, k+1):
            y = math.gcd(l, x)
            a.append(y)
print(sum(a))

Buggy submission (verdict: Runtime Error):
import itertools
import fractions
from functools import reduce
k = int(input())
num = []
for i in range(1, k+1):
    num.append(i)
    num.append(i)
    num.append(i)
permutation_num = set(itertools.permutations(num, 3))
x = []
for j in s:
    y = reduce(fractions.gcd, j)
    x.append(y)

print(sum(x))
Problem p02719 (python)

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

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = abs(n - k)
if k == 1:
    print(0)
elif a > n:
    print(n)
else:
    while n // k > 0:
        tmp = n % k
        n = n // k
    print(abs(tmp - k))
Problem p02888 (python)

Fixed submission:
import bisect
n = int(input())
l = list(map(int, input().split()))
sort_l = sorted(l)
count = 0

for a in range(n):
    for b in range(a+1, n):
        c = bisect.bisect_left(sort_l, sort_l[a] + sort_l[b])
        if c > b:
            count += c - b -1
        else:
            pass     
        

print(count)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left
n = int(input())
l = list(map(int, input().split()))
sort_l = sorted(l)
count = 0

for a in range(n-1):
    for b in range(i+1, n):
        c = bisect_left(sort_l, sort_l[a] + sort_l[b])
        if c > b:
            count += c - b -1
        else:
            pass     
        

print(count)
Problem p03076 (python)

Fixed submission:
dishes = []
serve = []
for i in range(5):
    dish = int(input())
    dishes.append(dish)
    if dish % 10 != 0:
        time = 10 - dish%10
        serve.append(time)
if serve == []:
    print(sum(dishes))
else:
    sort_serve = sorted(serve)
    sort_serve.remove(sort_serve[len(sort_serve)-1])
    ans = sum(dishes) + sum(sort_serve)
    print(ans)

Buggy submission (verdict: Runtime Error):
dishes = []
serve = []
for i in range(5):
    dish = int(input())
    dishes.append(dish)
    if dish % 10 != 0:
        time = 10 - dish%10
        serve.append(time)
sort_serve = sorted(serve)
sort_serve.remove(sort_serve[len(sort_serve)-1])
if sort_serve == []:
    print(sum(dishes))
else:
    ans = sum(dishes) + sum(sort_serve)
    print(ans)

Buggy submission (verdict: Runtime Error):
dishes = []
serve = []
for i in range(5):
    dish = int(input())
    dishes.append(dish)
    if dish % 10 != 0:
        time = 10 - dish%10
        serve.append(time)
sort_serve = sorted(serve)
sort_serve.remove(sort_serve[len(sort_serve)-1])
ans = sum(dishes) + sum(sort_serve)
print(ans)
Problem p02630 (python)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
count = [0]*(10**5 +1)
for a in A:
    count[a] += 1
    
ans = 0
for i in range(10**5 +1):
    if count[i]==0:
        continue
    else:
        ans += i*count[i]

q = int(input())
bc = [list(map(int,input().split())) for _ in range(q)]
for i in range(q):
    b,c = bc[i]
    ans += (c-b)*count[b]
    count[c] += count[b]
    count[b] = 0
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
count = [0]*(10**5)
for a in A:
    count[a] += 1
    
ans = 0
for i in range(10**5):
    if count[i]==0:
        continue
    else:
        ans += i*count[i]

q = int(input())
bc = [list(map(int,input().split())) for _ in range(q)]
for i in range(q):
    b,c = bc[i]
    ans += (c-b)*count[b]
    count[c] += count[b]
    count[b] = 0
    print(ans)
Problem p02900 (python)

Fixed submission:
import math
def gcd(a,b):
    if a==0: return b
    return gcd(b%a,a)
def div(n):
    cnt = 0
    temp = n
    for i in range(2,int(math.sqrt(n))+1):
        if temp%i==0:
            while temp%i==0:
                temp //= i
            cnt += 1
    if temp!=1:
        cnt+=1
    return cnt+1

a,b = map(int,input().split())
print(div(gcd(a,b)))

Buggy submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())

prime = []
n = max(a,b)
limit = math.sqrt(n)
data = [i+1 for i in range(1,n)]
while True:
    p = data[0]
    if limit<=p:
        prime = prime + data
        break
    prime.append(p)
    data = [e for e in data if e%p != 0]

def divisor(n):
    l = list()
    for i in prime:
        if n%i==0:
            l.append(i)
    return l

div = sorted(divisor(a) + divisor(b))
ans = 0
for i in range(len(div)-1):
    if div[i]==div[i+1]:
        ans+=1
print(ans+1)

Buggy submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())

prime = []
n = max(a,b)
limit = math.sqrt(n)
data = [i+1 for i in range(1,n)]
while True:
    p = data[0]
    if limit<=p:
        prime = prime + data
        break
    prime.append(p)
    data = [e for e in data if e%p != 0]

def divisor(n):
    l = list()
    for i in prime:
        if n==1:
            break
        if n%i==0:
            while n%i==0:
                n//=i
            l.append(i)
    if n!=1 or l==[]:
        l.append(n)
    return l

div = sorted(divisor(a) + divisor(b))
ans = 0
for i in range(len(div)-1):
    if div[i]==div[i+1]:
        ans+=1
print(ans+1)
Problem p03062 (python)

Fixed submission:
n = int(input())
plus = []
minus = []
for a in map(int,input().split()):
    if a>=0:
        plus.append(a)
    else:
        minus.append(a)
ans = sum(plus)-sum(minus)
if len(minus)%2==1:
    if plus==[]:
        ans = ans + 2*max(minus)
    else:
        ans = ans - 2*min(abs(max(minus)),min(plus))
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
plus = []
minus = []
for a in map(int,input().split()):
    if a>=0:
        plus.append(a)
    else:
        minus.append(a)
ans = sum(plus)-sum(minus)
if len(minus)%2==1:
    ans = ans - 2*min(abs(max(minus)),min(plus))
print(ans)
Problem p03074 (python)

Fixed submission:
#ABC124 D-Handstand
n,k = map(int,input().split())
s = []
count = 0
last = 1
for i in input():
    if i=='1':
        if last==1:
            count+=1
        else:
            s.append(count)
            count=1
        last = 1
    else:
        if last==0:
            count+=1
        else:
            s.append(count)
            count=1
        last = 0
s.append(count)
if last==0:
    s.append(0)

k = min(k,len(s)//2)
ans = 0

for j in range(len(s)//2-k+1):
    if j==0:
        now = sum(s[:k*2+1])
        ans = now
    else:
        now = now-s[j*2-1]-s[j*2-2]+s[(j+k)*2]+s[(j+k)*2-1]
        ans = max(ans,now) 
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = []
count = 0
last = 1
for i in input():
    if i=='1':
        if last==1:
            count+=1
        else:
            s.append(count)
            count=1
        last = 1
    else:
        if last==0:
            count+=1
        else:
            s.append(count)
            count=1
        last = 0
s.append(count)
if last=='0':
    s.append(0)

k = min(k,len(s)//2)
ans = 0

for j in range(len(s)//2-k+1):
    if j==0:
        now = sum(s[:k*2+1])
        ans = now
    else:
        now = now-s[j*2-1]-s[j*2-2]+s[(j+k)*2]+s[(j+k)*2-1]
        ans = max(ans,now) 
print(ans)
Problem p03848 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
count = [0]*n
for i in a:
    count[i] += 1
    
ans = 0
if n%2 == 0:
    if all(count[2*f]==0 for f in range(n//2)) and all(count[2*k-1]==2 for k in range(1,n//2)):  
        ans = 1
else:
    if count[0] == 1 and all(count[2*f]==2 for f in range(1,n//2)) and all(count[2*k-1]==0 for k in range(1,n//2)):
        ans = 1
        
if ans == 1:
    for i in range(n//2):
        ans = (ans*2) % (1e+9+7)

print(int(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
count = [0]*n
for i in a:
    count[i] += 1
    
ans = 0
if n%2 == 0:
    if all(count[2*f]==0 for f in range(n//2)) and all(count[2*k-1]==2 for k in range(1,n//2)):  
        ans = (2**(n//2)) % (1e+9 + 7)
else:
    if count[0] == 1 and all(count[2*f]==2 for f in range(1,n//2)) and all(count[2*k-1]==0 for k in range(1,n//2)):
        ans = (2**(n//2)) % (1e+9 + 7)

print(int(ans))
Problem p02582 (python)

Fixed submission:
m=input()
s=list(m)
a=[]
n=len(s)
j=0
while (j<n):
    x=0
    if s[j] == 'R':
        y=j+1
        for k in range (j,n):
            y=k+1
            if s[k]=='S':
                y=k+1
                break
            else:
                x+=1
        a.append(x)
        j=y

    else:
        j+=1

a.sort(reverse=True)
if len(a)==0:
    print (0)
else:
    print(a[0])

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
count=0
for i in range (n-2):
    for j in range (i+1,n-1):
        if l[i]==l[j]:
            continue
        l[i]+l[j]
        for k in range (j+1,n):
            if l[k]==l[i] or l[k]==l[l]:
                continue
            if l[k]<l[i]+l[j] and l[i]<l[j]+l[k] and l[j]<l[k]+l[i] :
                count+=1
print(count)
Problem p02583 (python)

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

count=0
for i in range (n-2):
    for j in range (i+1,n-1):
        if l[i]==l[j]:
            continue
        for k in range (j+1,n):
            
            if l[k]==l[i] or l[k]==l[j]:
                continue
            if l[k]<l[i]+l[j] and l[i]<l[j]+l[k] and l[j]<l[k]+l[i] :
                count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
count=0
for i in range (n-2):
    for j in range (i+1,n-1):
        if l[i]==l[j]:
            continue
        l[i]+l[j]
        for k in range (j+1,n):
            if l[k]==l[i] or l[k]==l[l]:
                continue
            if l[k]<l[i]+l[j] and l[i]<l[j]+l[k] and l[j]<l[k]+l[i] :
                count+=1
print(count)
Problem p02681 (python)

Fixed submission:
s=input()
t=input()
if len(t)-len(s)!=1:
    print('No')
else:
    for i in range(0,len(s)):
        if s[i]!=t[i]:
            print('No')
            break
    else:
        print('Yes')

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=list(map(int,input().split()))
d={}
for i in range(0,len(l)):
    d[i+1]=l[i]
ans=1
s=set()
seq=[]
e=0
for i in range(0,k):
    ans=d[ans]
    if ans in s:
        seq.append(ans)
        break
    else:
        s.add(ans)
    seq.append(ans)
else:
    print(ans)
    e=1
if e==0:
    b = seq.index(seq[-1])
    rep = seq[b:-1]
    sl = len(seq) - seq.index(seq[-1]) - 1
    k = k - b - 1
    ans = seq[b]
    x = k % sl
    # print(x,sl)
    print(rep[x])
Problem p02684 (python)

Fixed submission:
n,k=map(int,input().split())
l=list(map(int,input().split()))
d={}
for i in range(0,len(l)):
    d[i+1]=l[i]
ans=1
s=set()
seq=[]
e=0
for i in range(0,k):
    ans=d[ans]
    if ans in s:
        seq.append(ans)
        break
    else:
        s.add(ans)
    seq.append(ans)
else:
    print(ans)
    e=1
if e==0:
    b = seq.index(seq[-1])
    rep = seq[b:-1]
    sl = len(seq) - seq.index(seq[-1]) - 1
    k = k - b - 1
    ans = seq[b]
    x = k % sl
    # print(x,sl)
    print(rep[x])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=list(map(int,input().split()))
d={}
for i in range(0,len(l)):
    d[i+1]=l[i]
ans=1
s=set()
seq=[]
for i in range(0,k):
    ans=d[ans]
    if ans in s:
        seq.append(ans)
        break
    else:
        s.add(ans)
    seq.append(ans)
else:
    print(ans)
b=seq.index(seq[-1])
rep=seq[b:-1]
sl=len(seq)-seq.index(seq[-1])-1
k=k-b-1
ans=seq[b]
x=k%sl
#print(x,sl)
print(rep[x])
Problem p02691 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
count=0
new=[]
s=set()
d={}
for i in range(0,len(l)):
    new.append(i+1-l[i])
    s.add(i+1+l[i])
    if i+1+l[i] in d.keys():
        d[i+1+l[i]]+=1
    else:
        d[i+1+l[i]]=1
for i in range(0,len(new)):
    if new[i] in s:
        count+=d[new[i]]
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
count=0
d={}
def diff(a,b):
    if a>b:
        return(a-b)
    else:
        return(b-a)
for i in range(0,len(l)):
    if l[i]>2*10**5:
        pass
    else:
        d[i+1]=l[i]
l=list(d.keys()):
for i in range(0,len(l)):
    for j in range(i+1,len(l)):
        if diff(i,j)==d[j]+d[i]:
            count+=1
print(count)
Problem p02702 (python)

Fixed submission:
s=input()
r=set()
last=0
power=1
d={0:0}
total=0
rem=0
for i in range(len(s)-1,-1,-1):#handling of 0's as n and rem
    n=int(s[i])*power+rem
    power*=10
    power=power%2019
    rem=n%2019
    if rem in d.keys():
        d[rem]+=1
    else:
        d[rem]=1
    total+=d[rem]-1
print(total+d[0])

Buggy submission (verdict: Runtime Error):
s=input()
r=set()
last=0
power=1
d={0:0}
total=0
for i in range(len(s)-1,-1,-1):
    n=int(s[i])*power+rem
    power*=10
    power=power%2019
    rem=n%2019
    if rem in r:
        d[rem]+=1
        total+=d[rem]-1
    else:
        r.add(rem)
        d[rem]=1
if d[0]==1:
    print(total+1)
else:
    print(total)

Buggy submission (verdict: Runtime Error):
s=input()
r=set()
last=0
power=0
d={}
total=0
for i in range(len(s)-1,-1,-1):
    n=int(s[i])*(10**(power))+last
    power+=1
    last=n%2019
    rem=n%2019
    if rem==0:
        total+=1
        r.add(rem)
    if rem in r:
        d[rem]+=1
        total+=d[rem]-1
    else:
        r.add(rem)
        d[rem]=1
        
print(total)

Buggy submission (verdict: Runtime Error):
s=input()
c=0
for k in range(4,len(s)+1):
  for i in range(0,s+1-k):
    if int(s[i:i+k])%2019==0:
      c+=1
print(c)
Problem p02660 (python)

Fixed submission:
from  collections import defaultdict

n=int(input())

def prime_factorize(n):
    d=defaultdict(int) 
    while n % 2 == 0:
        d[2]+=1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            d[f]+=1
            n //= f
        else:
            f += 2
    if n != 1:
        d[n]+=1
    return d

u=prime_factorize(n) 
cnt=0
for key,value in u.items():
    r=10**12
    l=0 
    while r-l>1:
        mid=(r+l)//2
        if mid*(mid+1)//2<=value:
            l=mid 
        else:
            r=mid
    cnt+=l
print(cnt)

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

def prime_factorize(n):
    d=defaultdict(int) 
    while n % 2 == 0:
        d[2]+=1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            d[f]+=1
            n //= f
        else:
            f += 2
    if n != 1:
        d[n]+=1
    return d

u=prime_factorize(n) 
cnt=0
for key,value in u.items():
    r=10**12
    l=0 
    while r-l>1:
        mid=(r+l)//2
        if mid*(mid+1)//2<=value:
            l=mid 
        else:
            r=mid
    cnt+=l
print(cnt)
Problem p02662 (python)

Fixed submission:
mod = 998244353
N, S = map(int,input().split())
A = list(map(int,input().split()))
dp = [[0 for i in range(S+1)] for j in range(N+1)]
dp[0][0] = 1

for i in range(N):
    for j in range(S+1):
        dp[i+1][j] += dp[i][j] * 2
        if j + A[i] <= S:
            dp[i+1][j+A[i]] += dp[i][j]
        dp[i+1][j] %= mod

print(dp[N][S])

Buggy submission (verdict: Runtime Error):
mod = 998244353
N, S = map(int,input().split())
A = list(map(int,input().split()))
dp = [[0 for i in range(S+1)] for j in range(N+1)]
dp[0][0] = 1

for i in range(N):
    for j in range(S+1):
        dp[i+1][j] += dp[i][j] * 2
        if j + A[i] <= S:
            dp[i+1][j+A[i]] += dp[i][j]
        dp[i+1][j] %= mod

print(dp[N][S])
z
Problem p02684 (python)

Fixed submission:
def ma():
    return map(int,input().split())
def main():
    n,k=ma()
    A=list(ma())
    ans=[]
    exp=[0]*(n+1)
    now=1
    
    while True:
        ans.append(now)
        exp[now]=1
        now=A[now-1]
        if exp[now]==1:
            use=ans.index(now)
            tool=len(ans)-use
            break 

    if use>=k:
        print(ans[k])
        exit()
    else:
        p=(k-use)%tool
        print(ans[use+p])

main()

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

def ma():
    return map(int,input().split())
def main():
    n,k=ma()
    A=list(ma())
    ans=[0]*(n+1)
    now=1
    while True:
        ans[now]=1
        now=A[now-1]
        if ans[now]==1:
            use=ans.index(now)
            tool=len(ans)-use
            break 

    if use>=k:
        print(ans[k])
        exit()
    else:
        p=(k-use)%tool
        print(ans[use+p])

main()
Problem p02720 (python)

Fixed submission:
from collections import deque 
k=int(input())
dq=deque()
for i in range(1,10):
    dq.append(i)

cnt=1
while cnt<k:
    now=dq.popleft()
    if now%10>=1:
        dq.append(now*10+now%10-1)
    dq.append(now*10+now%10)
    if now%10<=8:
        dq.append(now*10+now%10+1)
    cnt+=1
print(dq.popleft())

Buggy submission (verdict: Runtime Error):
k=int(input())

from collections import deque
g=deque((1,2,3,4,5,6,7,8,9))

b=[[str(k) for k in range(10) if -2<=k-i<3] for i in range(10)]

for i in range(10,1000000):
  i1=list(str(i))
  e1=len(i1)
  for h in range(e1-1):
    if not i1[h+1] in b[int(i1[h])]:
      break
  else:g.append(i)


print(g[k-1])
Problem p02731 (python)

Fixed submission:
l=int(input())
v=float((l/3)**3)
print(v)

Buggy submission (verdict: Runtime Error):
l=int(input())
v=float((l/3)**3)
print(f'{v:.15e}')

Buggy submission (verdict: Runtime Error):
l=int(input())
v=float((l/3)**3)
print(f'{v:.18e}')
Problem p02741 (python)

Fixed submission:
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
b=int(input())
print(a[b-1])

Buggy submission (verdict: Runtime Error):
a=list(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
b=input()
print(a[b])

Buggy submission (verdict: Runtime Error):
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
b=input()
print(a[b])