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

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

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

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

def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)

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

Buggy submission (verdict: Runtime Error):
N,Q=list(map(int,input().split()))
cnt=[0]*N
dic={}
for _ in range(N-1):
    temp=list(map(int,input().split()))
    dic.setdefault(temp[0],[]).append(temp[1])
p=[]
X=[]
for _ in range(Q):
    temp2=list(map(int,input().split()))
    p.append(temp2[0])
    X.append(temp2[1])
k=dic.keys()

def tree(o):
    for y in dic[o]:
        cnt[y-1]+=add
        if y in k:
            tree(y)

for x in range(Q):
    add=X[x]
    cnt[p[x]-1]+=add
    if p[x] in k:
        tree(p[x])

print(*cnt)

Buggy submission (verdict: Runtime Error):
N,Q=list(map(int,input().split()))
cnt=[0]*N
dic={}
for _ in range(N-1):
    temp=list(map(int,input().split()))
    dic.setdefault(temp[0],[]).append(temp[1])
p=[]
X=[]
for _ in range(Q):
    temp2=list(map(int,input().split()))
    p.append(temp2[0])
    X.append(temp2[1])
k=dic.keys()

def tree(o):
    cnt[o]+=add
    for y in dic[o]:
        if y in k:
            tree(y)

for x in range(Q):
    add=X[x]
    cnt[p[x]]+=add
    if p[x] in k:
        tree(p[x])

print(*cnt)
Problem p02953 (python)

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
if N==1:
    print('Yes')
else:
    for i in range(N-1,0,-1):
        if H[i-1]-H[i]==1:
            H[i-1]=H[i-1]-1
        elif H[i-1]-H[i]>=2:
            print('No')
            break
        elif i==1 and H[1]-H[0]>=0:
            print('Yes')

Buggy submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
if N==1:
    print('Yes')
else:
    for i in range(N-1,0,-1):
        if H[i-1]-H[i]==1:
        H[i-1]=H[i-1]-1
    elif H[i-1]-H[i]>=2:
        print('No')
        break
    elif i==1 and H[1]-H[0]>=0:
        print('Yes')

Buggy submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
if N==1:
    print('Yes')
else:
    for i in range(N-1,0,-1):
        if H[i-1]-H[i]==1:
        H[i-1]=H[i-1]-1
    elif H[i-1]-H[i]>=2:
        print('No')
        break
    elif i==1 and H[1]-H[0]>=0:
        print('Yes')
Problem p02960 (python)

Fixed submission:
def main():
    MOD = 7 + 10**9
    S = tuple(input())
    N = len(S)
    dp = [[0]*13 for _ in range(N+1)]
    dp[0][0] += 1
    s=[1]
    for n in range(1,N):
        s.append((s[n-1]*10)%13)
    for i in range(N):
        for k in range(13):
            if S[-(i+1)] != '?':
                dp[i+1][(k+int(S[-(i+1)])*s[i])%13] += dp[i][k] 
                dp[i+1][(k+int(S[-(i+1)])*s[i])%13] %= MOD
            else:
                for l in range(10):
                    dp[i+1][(k+l*s[i])%13] += dp[i][k]
                    dp[i+1][(k+l*s[i])%13] %= MOD
    print(dp[-1][5])

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    MOD = 7 + 10**9
    S = list(input())
    N = len(S)
    dp = [[0]*13 for _ in range(N)]
    if S[N-1] == '?':
        for m in range(10):
            dp[0][m] = 1
    else:
        tm = int(S[N-1])%13
        dp[0][tm] = 1
    for i in range(1,N):
        if S[N-1-i] == '?':
            for j in range(13):
                for k in range(10):
                    dp[i][j] += [dp[i-1][(j-(k*10**i)%13)%13]%MOD
        else:
            m = (int(S[N-1-i])*10**i) % 13
            for l in range(13):
                dp[i][l] += dp[i-1][(l-m)%13]
    print(dp[N-1][5]%MOD)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    MOD = 7 + 10**9
    S = list(input())
    N = len(S)
    dp = [[0]*13 for _ in range(N)]
    if S[N-1] == '?':
        for m in range(10):
            dp[0][m] = 1
    else:
        tm = int(S[N-1])%13
        dp[0][tm] = 1
    for i in range(1,N):
        if S[N-1-i] == '?':
            for k in range(10):
                dp[i][j] += sum([dp[i-1][(j-(k*10**i)%13)%13]%MOD for j in range(13)])
        else:
            m = (int(S[N-1-i])*10**i) % 13
            for l in range(13):
                dp[i][l] += dp[i-1][(l-m)%13]
    print(dp[N-1][5]%MOD)


if __name__ == '__main__':
    main()
Problem p02963 (python)

Fixed submission:
S=int(input())
x_1=0
y_1=0
x_2=10**9
y_2=1

if S%10**9==0:
    x_3=0
    y_3=S//10**9
else:
    x_3=10**9-S%10**9
    y_3=1+S//10**9

print(x_1,y_1,x_2,y_2,x_3,y_3)

Buggy submission (verdict: Runtime Error):
S=int(input())
x_1=10**9
y_1=10**9
x_2=10**9
y_3=10**9

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

if S % S**(1/2):
    a = divisors(S)
    x=a[len(a)//2 - 1:len(a)//2  + 1]
else:
    x=[S**(1/2),S**(1/2)]



print(x_1,y_1,x_2,(10**9)-x[0],(10**9)-x[1],y_3)

Buggy submission (verdict: Runtime Error):
from sympy import divisors, isprime
S=int(input())
x_1=10**9
y_1=10**9
x_2=10**9
y_3=10**9

m = S
sqrt_m = int(m**(1/2))

if isprime(m):
    x=[1,m]
elif m % sqrt_m:
    a = divisors(m)
    x=a[len(a)//2 - 1:len(a)//2  + 1]
else:
    x=[sqrt_m,sqrt_m]

print(x_1,y_1,x_2,(10**9)-x[0],(10**9)-x[1],y_3)
Problem p02973 (python)

Fixed submission:
import sys
input = sys.stdin.readline
from collections import deque

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

s = deque([a[0]])

from bisect import bisect_left

for i in a[1:]:
    if i <= s[0]:
        s.appendleft(i)
    else:
        s[bisect_left(s, i) - 1] = i

# print(s)
print(len(s))

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

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

s = deque([a[0]])

from bisect import bisect_right

for i in a[1:]:
    if i <= s[0]:
        s.appendleft(i)
    else:
        s[bisect_left(s, i) - 1] = i

# print(s)
print(len(s))
Problem p02982 (python)

Fixed submission:
import math
N,D=map(int,input().split())
X=[]
cnt=0
def distance(x,y):
    d2=[]
    for k in range(D):
        d2.append((X[x][k]-X[y][k])**2)
    return math.sqrt(sum(d2))
for i in range(N):
    X.append(list(map(int,input().split())))
for j in range(N-1):
        for l in range(j+1,N,):
            if float.is_integer(distance(j,l)):
                cnt+=1 
print(cnt)

Buggy submission (verdict: Runtime Error):
L,R=map(int,input().split())
M=[]
for i in range(L,R):
    for j in range(i+1,R+1):
        M.append((i%2019)*(j%2019))
print(min(M))
Problem p02994 (python)

Fixed submission:
N,L=map(int,input().split())
A=[]
B=[]
for i in range(1,N+1):
    A.append(L+i-1)
for j in range(1,N+1):
    B.append(abs(L+j-1))
idx=B.index(min(B))
print(sum(A)-A[idx])

Buggy submission (verdict: Runtime Error):
N,L=input().split()
N=int(N)
L=int(L)
A=0
B=[]
C=[]
for j in range(1,N+1):
    A+=L+j-1
for i in range(1,N+1):
    if L+i-1>=0:
        B.append(L+i-1)
    else:
        C.append(L+i-1)
if min(B)<=abs(max(C)):
    print(A-min(B))
else:
    print(A-max(C))

Buggy submission (verdict: Runtime Error):
N,L=input().split()
N=int(N)
L=int(L)
A=0
B=[]
for j in range(1,N+1):
    A+=L+j-1
for i in range(1,N+1):
    B.append(abs(A-(L+i-1))
print(max(B))
Problem p02995 (python)

Fixed submission:
import fractions

A,B,C,D=map(int,input().split())
c=B//C-(A-1)//C 
d=B//D-(A-1)//D 
l=C*D//fractions.gcd(C,D)
cd=B//l-(A-1)//l
print(int(B-(A-1)-c-d+cd))

Buggy submission (verdict: Runtime Error):
import math

A,B,C,D=map(int,input().split())
c=B//C-(A-1)//C 
d=B//D-(A-1)//D 
l=C*D/math.gcd(C,D)
cd=B//l-(A-1)//l
print(int(B-(A-1)-c-d+cd))
Problem p03000 (python)

Fixed submission:
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=0
cnt=1
for i in L:
    D=D+i
    if D>X:
        break
    cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=0
cnt=1
for j in range(0,N+1):
    D=D+L[j]
    if D>X:
        break
    cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=0
cnt=1
for j in range(0,N+1):
    D=D+L[j]
    if D>X:
        break
    else:
        cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=0
cnt=1
for j in range(0,N+1):
    D=D+L[j]
    if D<=X:
        cnt+=1
    else:
        break
print(cnt)
Problem p03087 (python)

Fixed submission:
def main():
    import sys
    import re
    input = sys.stdin.readline
    N,Q = list(map(int, input().split()))
    S = list(input())
    L = []
    for _ in range(Q):
        temp = list(map(int, input().split()))
        L.append(temp)
    dp = [0] * N
    for i in range(1,N):
        if S[i] == "C" and S[i-1] == "A":
            dp[i] = dp[i-1] + 1
        else:
            dp[i] = dp[i-1]
    for j in range(Q):
        l,r = L[j]
        print(dp[r-1] - dp[l-1])
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readline
    N,Q = list(map(int, input().split()))
    S = list(input())
    L = []
    for _ in range(Q):
    temp = list(map(int, input().split()))
    L.append(temp)
    I = []
    for i in range(len(S)-1):
    if S[i] == "A" and S[i+1] == "C":
        I.append(i)
    for j in range(Q):
    cnt = 0
    l,r = L[j]
    R = []
    for k in range(l-1,r-1):
        R.append(k)
    for i in I:
        if i in R:
            cnt += 1
    print(cnt)
if __name__ == '__main__':
    main()
Problem p03106 (python)

Fixed submission:
import sys
import fractions
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

A, B, K = [int(x) for x in readline().rstrip().split()]
gcd_ = fractions.gcd(A, B)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
print(make_divisors(gcd_)[-K])

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

import numpy as np

A, B, K = [int(x) for x in readline().rstrip().split()]
gcd_ = np.gcd(A, B)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

print(make_divisors(gcd_)[K - 1])
Problem p03138 (python)

Fixed submission:
import sys
input = sys.stdin.readline

n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

bin_k = format(k, 'b').zfill(50)

b = [0] * 50 # ビットごとの1の個数

for i in a:
    bin_i = format(i, 'b').zfill(50)
    for j in range(len(bin_i)):
        if bin_i[j] == "1":
            b[j] += 1

dp = [[0, 0] for _ in range(len(bin_k))]

if bin_k[0] == "0":
    dp[0][0] = b[0] * 2**(len(bin_k) - 1) # 0
else:
    dp[0][0] = (n - b[0]) * 2**(len(bin_k) - 1) # 1
    dp[0][1] = b[0] * 2**(len(bin_k) - 1) # 0

for i in range(1, len(bin_k)):
    if bin_k[i] == "0":
        dp[i][0] = dp[i - 1][0] + b[i] * 2**(len(bin_k) - (i + 1))
        if dp[i - 1][1] > 0:
            dp[i][1] = max(dp[i - 1][1] + b[i] * 2**(len(bin_k) - (i + 1)), dp[i - 1][1] + (n - b[i]) * 2**(len(bin_k) - (i + 1)))
    else:
        dp[i][0] = dp[i - 1][0] + (n - b[i]) * 2**(len(bin_i) - (i + 1))
        dp[i][1] = dp[i - 1][0] + b[i] * 2**(len(bin_k) - (i + 1))
        if dp[i - 1][1] > 0:
            dp[i][1] = max(dp[i][1], dp[i - 1][1] + (n - b[i]) * 2**(len(bin_i) - (i + 1)), dp[i - 1][1] + b[i] * 2**(len(bin_k) - (i + 1))) 

print(max(dp[-1][0], dp[-1][1]))

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

n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

b = [0] * 40 # ビットごとの1の個数

for i in a:
    bin_i = format(i, 'b')
    bin_i = bin_i[::-1]
    for j in range(len(bin_i)):
        if bin_i[j] == "1":
            b[j + 1] += 1

x = []
for i in b[1:]:
    if n - i <= i:
        x.append("0")
    elif n - i > i:
        x.append("1")
x = x[::-1]
i = 0
while int("".join(x), 2) > k:
    x[i] = "0"
    i += 1
x = int("".join(x), 2)

ans = 0

for i in a:
    ans += i ^ x

print(ans)
Problem p03164 (python)

Fixed submission:
import sys
input = sys.stdin.readline

N, W = [int(x) for x in input().split()]
wv = []
for _ in range(N):
    wv.append([int(x) for x in input().split()])
V = 10 ** 5
inf = float("inf")

dp = [[inf] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0
ans = -1

for i in range(N):
    for j in range(V + 1):
        w, v = wv[i]
        if j >= v:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v] + w)
        else:
            dp[i + 1][j] = dp[i][j]
        if dp[i + 1][j] <= W:
            ans = max(ans, j)
print(ans)

Buggy submission (verdict: Runtime Error):
N,W=map(int,input().split())
A=[]
for _ in range(N):
    B=list(map(int,input().split()))
    A.append(B)
dp=[]
for _ in range(N):
    dp.append([0]*(W+1))
for j in range(W+1):
    if j>=A[0][0]:
        dp[0][j]=A[0][1]
for i in range(0,N-1):
    for w in range(W+1):
        if w>=A[i+1][0]:
            dp[i+1][w]=max(dp[i][w-A[i+1][0]]+A[i+1][1],dp[i][w])
        else:
            dp[i+1][w]=dp[i][w]
print(dp[N-1][W])

Buggy submission (verdict: Runtime Error):
N,W=map(int,input().split())
A=[]
for _ in range(N):
    B=list(map(int,input().split()))
    A.append(B)
dp=[]
for _ in range(N):
    dp.append([0]*(W+1))
for j in range(W+1):
    if j>=A[0][0]:
        dp[0][j]=A[0][1]
for i in range(0,N-1):
    for w in range(W+1):
        if w>=A[i+1][0]:
            dp[i+1][w]=max(dp[i][w-A[i+1][0]]+A[i+1][1],dp[i][w])
        else:
            dp[i+1][w]=dp[i][w]
print(dp[N-1][W])
Problem p03240 (python)

Fixed submission:
import sys
input = sys.stdin.readline
N = int(input())
B = [[int(x) for x in input().split()] for _ in range(N)]
def heighti(Cx,Cy,x,y,h):
    return abs(x-Cx) + abs(y-Cy) + h
def Heighti(Cx,Cy,x,y,h):
    return -abs(x-Cx) - abs(y-Cy) + h
ans = []
h0 = []
A = []
for l in B:
    if l[2] == 0:
        h0.append([l[0],l[1]])
    else:
        A.append(l)
if len(A) > 0:
    for i in range(101):
        for j in range(101):
            tempH = heighti(i,j,A[0][0],A[0][1],A[0][2])
            if tempH < 0:
                break
            else:
                flag = 1
                for k in range(1,len(A)):
                    if A[k][2] != 0 and heighti(i,j,A[k][0],A[k][1],A[k][2]) != tempH:
                        flag = 0
                        break
                if flag:
                    ans.append([i,j,tempH])
if len(ans) == 1:
    print(*ans[0])
elif len(ans) == 0:
    for i in range(101):
        for j in range(101):
            for k in range(N):
                if heighti(i,j,B[k][0],B[k][1],B[k][2]) > 0:
                    print(*[i,j,heighti(i,j,B[k][0],B[k][1],B[k][2])])
                    sys.exit()
else:
    for m in ans:
        flag = 1
        for n in h0:
            if Heighti(n[0],n[1],m[0],m[1],m[2]) > 0:
                flag = 0
                break
        if flag:
            print(*m)
            sys.exit()

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
input = sys.stdin.readline
N = int(input())
B = [[int(x) for x in input().split()] for _ in range(N)]
def heighti(Cx,Cy,x,y,h):
    return abs(x-Cx) + abs(y-Cy) + h
ans = []
h0 = []
A = []
for l in B:
    if l[2] == 0:
        h0.append([l[0],l[1]])
    else:
        A.append(l)
for i in range(101):
    for j in range(101):
        tempH = heighti(i,j,A[0][0],A[0][1],A[0][2])
        if tempH < 0:
            break
        else:
            flag = 1
            for k in range(1,len(A)):
                if A[k][2] != 0 and heighti(i,j,A[k][0],A[k][1],A[k][2]) != tempH:
                    flag = 0
                    break
            if flag:
                ans.append([i,j,tempH])
if len(ans) == 1:
    print(*ans[0])
elif len(ans) == 0:
    for i in range(101):
        for j in range(101):
            for k in range(N):
                if heighti(i,j,A[k][0],A[k][1],A[k][2]) > 0:
                    print(*[i,j,heighti(i,j,A[k][0],A[k][1],A[k][2])])
                    sys.exit()
else:
    for m in ans:
        for n in h0:
            if heighti(n[0],n[1],m[0],m[1],m[2]) > 0:
                break
        print(*m)
        sys.exit()
Problem p03243 (python)

Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline
N = int(input())
ans = [111,222,333,444,555,666,777,888,999]
for i in ans:
    if i >= N:
        print(i)
        sys.exit()

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
input = sys.stdin.readline
N = int(input())
ans = [111,222,333,444,555,666,777,888,999]
for i in ans:
    if ans >= N:
        print(ans)
        sys.exit()
Problem p03262 (python)

Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline
N, X = [int(x) for x in input().split()]
x = np.array([int(x) for x in input().split()])
if len(x) == 1:
    print(abs(X-x[0]))
    sys.exit()
x -= X
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
    
x.tolist()
D = gcd(* x)
print(abs(D))

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
input = sys.stdin.readline
N, X = [int(x) for x in input().split()]
x = np.array([int(x) for x in input().split()])
x -= X
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
    
x.tolist()
D = gcd(* x)
print(D)
Problem p03274 (python)

Fixed submission:
import sys
import numpy as np
N, K = [int(x) for x in input().split()]
x = np.array([int(x) for x in input().split()])
if 0 in x:
    K -= 1
x = x[np.nonzero(x)]
if K == 0:
    print(0)
    sys.exit()
ans = []
for i in range(len(x)-K+1):
    if (x[i] < 0) != (x[i+K-1] < 0):
        ans.append(abs(x[i])+abs(x[i+K-1])+min(abs(x[i]),abs(x[i+K-1])))
    else:
        ans.append(max(abs(x[i]),abs(x[i+K-1])))
print(min(ans))

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
N, K = [int(x) for x in input().split()]
x = np.array([int(x) for x in input().split()])
if 0 in x:
    K -= 1
xn = x[(x<0)]
xn = xn[::-1]
xp = x[(x>0)]
ans = []
if len(xn) >= K:
    ans.append(xn[K-1])
if len(xp) >= K:
    ans.append(xp[K-1])

x = x.tolist()
x = sorted(x,key=lambda x:abs(x))[:K]
x = np.array(x)
xn = x[(x<0)]
xp = x[(x>0)]
if len(xp) > 0 and len(xn) > 0:
    ans.append(xp[-1] + abs(xn[-1]) + min(xp[-1],abs(xn[-1])))
print(min(ans))
Problem p03293 (python)

Fixed submission:
import sys
input = sys.stdin.readline
S = list(input().rstrip())
T = list(input().rstrip())
N = len(S)
for i in range(N):
    S = list(S[-1]) + S[:N-1]
    if S == T:
        print("Yes")
        sys.exit()
print("No")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
S = list(input())
T = list(input())
N = len(S)
for i in range(N):
    S = S[-1] + S[:N-1]
    if S == T:
        print("Yes")
        sys.exit()
print("No")
Problem p03316 (python)

Fixed submission:
import sys
input = sys.stdin.readline
N = int(input())
N_str = list(str(N))
a = 0
for i in N_str:
    a += int(i)
if N % a == 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
N_str = list(str(N))
a = 0
for i in N_str:
    cnt += int(i)
if N % a == 0:
    print("Yes")
else:
    print("No")
Problem p03323 (python)

Fixed submission:
import sys
input = sys.stdin.readline
A, B = [int(x) for x in input().split()]
if A <= 8 and B <= 8:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
N_str = list(str(N))
a = 0
for i in N_str:
    a += int(i)
if N % a == 0:
    print("Yes")
else:
    print("No")
Problem p03324 (python)

Fixed submission:
import sys
input = sys.stdin.readline
D, N = [int(x) for x in input().split()]
ans = []
for i in range(1, 1010001):
    if i % (100 ** D) == 0 and i % (100 ** (D + 1)) != 0:
        ans.append(i)
print(ans[N-1])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
D, N = [int(x) for x in input().split()]
ans = []
for i in range(1, 1010000):
    if i % (100 ** D) == 0 and i % (100 ** (D + 1)) != 0:
        ans.append(i)
print(ans[N-1])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
D, N = [int(x) for x in input().split()]
ans = []
for i in range(1, 1010000):
    if i % (100 ** D) == 0 and i % (100 ** (D + 1)) != 0:
        ans.append(i)
print(ans[N-1])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
D, N = [int(x) for x in input().split()]
ans = []
for i in range(1, 101000):
    if i % (100 ** D) == 0:
        ans.append(i)
print(ans[N-1])
Problem p03353 (python)

Fixed submission:
import sys
input = sys.stdin.readline
S = set()
s = list(input().rstrip())
K = int(input())
for i in range(len(s)):
    for j in range(i+1, i+K+1):
        if "".join(s[i:j]) not in S:
            S.add("".join(s[i:j]))
S = list(S)
S.sort()
print("".join(S[K-1]))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
S = []
s = list(input().rstrip())
K = int(input())
for i in range(len(s)):
    for j in range(i+1, i+5):
        if s[i:j] not in S:
            S.append(s[i:j])
S.sort()
print("".join(S[K-1]))
Problem p03355 (python)

Fixed submission:
import sys
input = lambda : sys.stdin.readline().rstrip()

s = input()
n = len(s)
k = int(input())
ans = []
used = set()
"""
from collections import defaultdict
d = defaultdict(list)
for i in range(n):
    d[s[i]].append(i)
""" 
for i in range(n):
    start = list(s[i])
    if s[i] not in used:
        ans.append(s[i])
        used.add(s[i])
    for j in range(i + 1, min(i + k, n)):
        start.append(s[j])
        temp = "".join(start)
        if temp not in used:
            ans.append(temp)
            used.add(temp)
ans.sort()
print(ans[k - 1])

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

s = input()
n = len(s)
k = int(input())
ans = []
used = set()
"""
from collections import defaultdict
d = defaultdict(list)
for i in range(n):
    d[s[i]].append(i)
""" 
for i in range(n):
    start = list(s[i])
    if s[i] not in used:
        ans.append(s[i])
        used.add(s[i])
    for j in range(i + 1, i + k):
        start.append(s[j])
        temp = "".join(start)
        if temp not in used:
            ans.append(temp)
            used.add(temp)
ans.sort()
print(ans[k - 1])
Problem p03380 (python)

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]
a.sort()

ans = [-1, 0, 0]

import bisect

i = a[-1]
idx = [bisect.bisect_left(a, i / 2), bisect.bisect_left(a, i / 2) - 1]

if abs(i / 2 - a[idx[0]]) < abs(i // 2 - a[idx[1]]):
    print(i, a[idx[0]])    
else:
    print(i, a[idx[1]])

Buggy submission (verdict: Runtime Error):
import sys
input = lambda: sys.stdin.readline().rstrip()
 
n = int(input())
a = list(map(int, input().split()))
a.sort()
a_max = a.pop()

import bisect

idx_1 = bisect.bisect_left(a, a_max//2)
idx_2 = bisect.bisect_left(a, a_max//2 + 1)

b = [a[idx_1], a[idx_1 - 1], a[idx_2], a[idx_2 - 1]]
ans = [0, 10**10]
for i in b:
    if a_max - i < ans[1]:
        ans = [i, a_max - i]
print(a_max, ans[0])