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

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())
As.sort()
mini = As.pop(0)
maxi = As.pop()

ans = []
for a in As:
    if a>=0:
        ans.append((mini, a))
        mini -= a
    else:
        ans.append((maxi, a))
        maxi -= a

print(maxi-mini)
for a in ans:
    print(*a)
print(maxi, mini)

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())
As.sort()
mini = As.pop(0)
maxi = As.pop()

ans = []
for a in As:
    if a>=0:
        ans.append((mini, a))
        mini -= a
    else:
        ans.append(print(maxi, a))
        maxi -= a

print(maxi-mini)
for a in ans:
    print(*a)
    print(maxi, mini)
Problem p03046 (python)

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

if K>=(2**M):
    print(-1)
elif M==0:
    if K==0:
        print(0, 0)
    else:
        print(-1)
elif M==1:
    if K==0:
        print(0, 0, 1, 1)
    else:
        print(-1)
else:
    b = [str(i) for i in range(2**M) if not i==K]
    c = [str(i) for i in range(2**M-1, -1, -1) if not i==K]
    ans = b+[str(K)]+c+[str(K)]
    print(' '.join(ans))

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

if K>=(2**M):
    print(-1)
elif M==0:
    if K==0:
        print(0, 0)
    else:
        print(-1)
elif M==1:
    if K==0:
        print(0, 0, 1, 1)
    else:
        print(0)
else:
    b = [i for i in range(2**M)]
    c = reversed([i for i in range(2**M)])
    print(' '.join(b+[K]+c+[K]))
Problem p03049 (python)

Fixed submission:
N = int(input())
S = [input() for _ in range(N)]

cnt = 0
end_a = 0
sta_b = 0
a_b = 0
for s in S:
    cnt += s.count('AB')
    if s[-1]=='A' and s[0]=='B':
        a_b += 1
    elif s[-1]=='A':
        end_a += 1
    elif s[0]=='B':
        sta_b += 1
if a_b>=1:
    cnt += a_b-1
    if end_a>=1:
        end_a -= 1
        cnt += 1
    if sta_b>=1:
        sta_b -=1
        cnt+=1
cnt += min(end_a, sta_b)

print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [input() for _ in range(N)]

cnt = 0
end_a = 0
sta_b = 0
a_b = 0
for s in S:
    cnt += s.count('AB')
    if s[-1]=='A' and s[0]=='B':
        a_b += 1
    elif s[-1]=='A':
        end_a += 1
    elif s[0]=='B':
        sta_b += 1

a_b = [a_b, a_b]
if a_b[0]>=end_a:
    cnt += end_a
    a_b[0] -= end_a
    end_a = 0
else:
    cnt += a_b
    a_b[0] = 0
    end_a -= a_b

if a_b[1]>=sta_b:
    cnt += sta_b
    a_b[1] -= sta_b
    sta_b = 0
else:
    cnt += a_b
    a_b[1] = 0
    sta_b -= a_b
cnt += min(end_a, sta_b)
cnt += min(a_b)
print(cnt)
Problem p03061 (python)

Fixed submission:
from fractions import gcd

N = int(input())
As = list(map(int, input().split()))
re_As = As[::-1]
gcds = [0]*(N)
rgcds = [0]*(N)
gcds[0] = 0
rgcds[0] = 0

for i in range(N-1):
    gcds[i+1] = gcd(As[i], gcds[i])
    rgcds[i+1] = gcd(re_As[i], rgcds[i])

rgcds = rgcds[::-1]

ans = [0]*(N+1)

for i, (s, r) in enumerate(zip(gcds, rgcds)):
    ans[i] = gcd(s, r)
    
print(max(ans))

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

lis = [0]*N
ans = 0
for k in range(N):
    g = 10**20
    for i in range(N-1):
        if i==k: continue
        for j in range(i+1, N):
            if j==k: continue
            g = min(gcd(As[i], As[j]), g)
    ans = max(ans, g)
if N==2:
    print(max(As))
else:
    print(ans)

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

lis = [0]*N
ans = 0
for k in range(N):
    g = 10**20
    for i in range(N-1):
        if i==k: continue
        for j in range(i+1, N):
            if j==k: continue
            g = min(gcd(As[i], As[j]), g)
    ans = max(ans, g)
if N==2:
    print(max(As))
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
wh = int(input())
A[wh] = int(input())
ans = 1
for i in range(max(A), 0, -1):
    if all([x % i == 0 for x in A]):
        ans = i
        break
print(ans)
Problem p03062 (python)

Fixed submission:
import math
n = int(input())
M = list(map(int, input().split()))
p = [q < 0 for q in M].count(True)
X = [abs(x) for x in M]
if p % 2 == 0:
    print(sum(X))
else:
    print(sum(X) - min(X)*2)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
M = list(map(int, input().split()))
X = [math.abs(x) for x in M]
print(sum(X) - min(X)*2)
Problem p03111 (python)

Fixed submission:
N, A, B, C = map(int, input().split())

L = [int(input()) for _ in range(N)]

ans = []
def dfs(idx, a, b, c, mp10):
    if idx==N:
        if a and b and c:
            ans.append(abs(A-a)+abs(B-b)+abs(C-c)+mp10*10)
    else:
        dfs(idx+1, a, b, c, mp10)
        dfs(idx+1, a+L[idx], b, c, mp10+1)
        dfs(idx+1, a, b+L[idx], c, mp10+1)
        dfs(idx+1, a, b, c+L[idx], mp10+1)

dfs(0, 0, 0, 0, -3)

print(min(ans))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)
Input = open('input.txt')
def input(): return Input.readline()
def mapint(): return map(int, input().split())

N, A, B, C = mapint()
Ls = [int(input()) for _ in range(N)]
ans = 10**18
def dfs(a, b, c, idx, magic):
    global ans
    if idx==N:
        if a==0 or b==0 or c==0:
            return
        magic -= 30
        magic += abs(A-a)
        magic += abs(B-b)
        magic += abs(C-c)
        ans = min(ans, magic)
        return
    nx = Ls[idx]
    dfs(a+nx, b, c, idx+1, magic+10)
    dfs(a, b+nx, c, idx+1, magic+10)
    dfs(a, b, c+nx, idx+1, magic+10)
    dfs(a, b, c, idx+1, magic)

dfs(0, 0, 0, 0, 0)
print(ans)
Problem p03138 (python)

Fixed submission:
N, K = map(int, input().split())
As = list(map(int, input().split()))
bitK = K.bit_length()
ans = [0]*bitK
for a in As:
    for i in range(bitK):
        if not (a>>i)&1:
            ans[i] += 1

ans = ans[::-1]
string = ['0']*bitK
if bitK==0:
    print(sum(As))
else:
    for i, a in enumerate(ans):
        if a>=N/2:
            string[i] = '1'
            if int(''.join(string), 2)>K:
                string[i] = '0'
    num = int(''.join(string), 2)
    print(sum([x^num for x in As]))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
As = list(map(int, input().split()))
bitK = K.bit_length()
ans = [0]*bitK
for a in As:
    for i in range(bitK):
        if not (a>>i)&1:
            ans[i] += 1

ans = ans[::-1]
string = ['0']*bitK
for i, a in enumerate(ans):
    if a>=N/2:
        string[i] = '1'
        if int(''.join(string), 2)>K:
            string[i] = '0'
num = int(''.join(string), 2)
print(sum([x^num for x in As]))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
As = list(map(int, input().split()))
bitK = K.bit_length()
ans = [0]*bitK
for a in As:
    for i in range(bitK):
        if (a>>i)&1:
            ans[i] += 1

string = ['0']*bitK
for i, a in enumerate(ans):
    if a>=N//2:
        string[i] = '1'
        if int(''.join(string), 2)>K:
            string[i] = '0'
num = int(''.join(string), 2)
print(sum([x^num for x in As]))
Problem p03262 (python)

Fixed submission:
N, X = map(int, input().split())
Xs = list(map(int, input().split()))
from fractions import gcd

lis = []
for x in Xs:
    lis.append(abs(x-X))

G = 0
for l in lis:
    G = gcd(l, G)
print(G)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
Xs = list(map(int, input().split()))
from math import gcd

lis = []
for x in Xs:
    lis.append(abs(x-X))

G = 0
for l in lis:
    G = gcd(l, G)
print(G)
Problem p03263 (python)

Fixed submission:
H, W = map(int, input().split())

query = []
for i in range(H):
    if i%2==0:
        lis = [(i, j) for i, j in enumerate(list(map(int, input().split())))]
    else:
        lis = [(i, j) for i, j in enumerate(list(map(int, input().split())))][::-1]
    query += lis

odd = 0
move = []
last = (0, 0)
for i, (w, q) in enumerate(query):
    if odd:
        move.append((last[0], last[1], i//W+1, w+1))
        if q%2==1:
            odd = 0
        else:
            last = (i//W+1, w+1)
    else:
        if q%2==1:
            odd = 1
            last = (i//W+1, w+1)

print(len(move))
for l in move:
    print(*l)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())

query = []
for i in range(H):
    if i%2==0:
        lis = [(i, j) for i, j in enumerate(list(map(int, input().split())))]
    else:
        lis = [(i, j) for i, j in enumerate(list(map(int, input().split())))][::-1]
    query += lis

odd = 0
move = []
last = (0, 0)
for i, (w, q) in enumerate(query):
    if not odd and q%2==0:
        continue
    if odd:
        move.append((*last, i//H+1, w+1))
        if q%2==1:
            odd = 0
        else:
            last = (i//H+1, w+1)
    else:
        if q%2==1:
            odd = 1
            last = (i//H+1, w+1)

print(len(move))
for l in move:
    print(*l)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())

query = []
for i in range(H):
    if i%2==0:
        lis = [(i, j) for i, j in enumerate(list(map(int, input().split())))]
    else:
        lis = [(i, j) for i, j in enumerate(list(map(int, input().split())))][::-1]
    query += lis

odd = 0
move = []
last = (0, 0)
for i, (w, q) in enumerate(query):
    if not odd and q%2==0:
        continue
    if odd:
        move.append((*last, i//H+1, w+1))
        if q%2==1:
            odd = 0
        else:
            last = (i//H+1, w+1)
    else:
        if q%2==1:
            odd = 1
            last = (i//H+1, w+1)

print(len(move))
for l in move:
    print(*l)
Problem p03274 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
Xs = list(mapint())

pos = []
neg = []

for x in Xs:
    if x>=0:
        pos.append(x)
    else:
        neg.append(-x)

neg = neg[::-1]

ans = 10**18
if len(pos)>=K:
    ans = min(ans, pos[K-1])
if len(neg)>=K:
    ans = min(ans, neg[K-1])
lenp = len(pos)
lenn = len(neg)
if lenn>0:
    for i in range(min(lenp, K)):
        if K-(i+1)<=lenn:
            ans = min(ans, pos[i]*2+neg[K-i-2])
if lenp>0:
    for i in range(min(lenn, K)):
        if K-(i+1)<=lenp:
            ans = min(ans, neg[i]*2+pos[K-i-2])
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
Xs = list(mapint())

from bisect import bisect_left
pos = []
neg = []

for x in Xs:
    if x>=0:
        pos.append(x)
    else:
        neg.append(-x)

neg = neg[::-1]

ans = 10**18
if len(pos)>=K:
    ans = min(ans, pos[K-1])
if len(neg)>=K:
    ans = min(ans, neg[K-1])
lenp = len(pos)
lenn = len(neg)
for i in range(min(lenp, K)):
    if K-(i+1)<=lenn:
        ans = min(ans, pos[i]*2+neg[K-i-2])
for i in range(min(lenn, K)):
    if K-(i+1)<=lenp:
        ans = min(ans, neg[i]*2+pos[K-i-2])
print(ans)
Problem p03355 (python)

Fixed submission:
s = str(input())
K = int(input())

lis = list(set(list(s)))
lis.sort()

ans_lis = []
for i in range(min(5, len(lis))):
    i = lis[i]
    s2 = s
    while 1:
        idx = s2.find(i)
        if idx==-1:
            break
        ans_lis += [s2[idx:idx+l+1] for l in range(min(5, len(s2)-idx))]
        s2 = s2[idx+1:]
ans_lis = list(set(ans_lis))
ans_lis.sort()
print(ans_lis[K-1])

Buggy submission (verdict: Runtime Error):
s = str(input())
K = int(input())

lis = list(set(list(s)))
lis.sort()

ans_lis = []
for i in range(min(5, len(lis))):
    i = lis[i]
    s2 = s
    while 1:
        idx = s2.find(i)
        if idx==-1:
            break
        ans_lis += [s2[idx:idx+l+1] for l in range(min(5, len(s2)-idx-1))]
        s2 = s2[idx+1:]
ans_lis = list(set(ans_lis))
ans_lis.sort()
print(ans_lis[4])
Problem p03372 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, C = mapint()
xv = [list(mapint()) for _ in range(N)]
righthand = [0]*N
lefthand = [0]*N
nowv = 0
maxv = -10**18
for i, (x, v) in enumerate(xv):
    nowv += v
    maxv = max(maxv, nowv-x)
    righthand[i] = maxv
nowv = 0
maxv = -10**18
for i, (x, v) in enumerate(xv[::-1]):
    nowv += v
    maxv = max(maxv, nowv-(C-x))
    lefthand[i] = maxv
 
xv = [(0, 0)] + xv +[(C, 0)]
righthand = [0]+righthand
lefthand = [0]+lefthand
rmax = 0
for i in range(N+1):
    rmax = max(rmax, righthand[i]-xv[i][0]+lefthand[N-i])
lmax = 0
for i in range(N):
    lmax = max(lmax, lefthand[i]-(C-xv[-i-1][0])+righthand[N-i])
print(max(rmax, lmax))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)
Input = open('input.txt')
def input(): return Input.readline()
def mapint(): return map(int, input().split())

N, C = mapint()
xv = [list(mapint()) for _ in range(N)]
righthand = [0]*N
lefthand = [0]*N
nowv = 0
maxv = -10**18
for i, (x, v) in enumerate(xv):
    nowv += v
    maxv = max(maxv, nowv-x)
    righthand[i] = maxv
nowv = 0
maxv = -10**18
for i, (x, v) in enumerate(xv[::-1]):
    nowv += v
    maxv = max(maxv, nowv-(C-x))
    lefthand[i] = maxv

xv = [(0, 0)] + xv +[(C, 0)]
righthand = [0]+righthand
lefthand = [0]+lefthand
rmax = 0
for i in range(N+1):
    rmax = max(rmax, righthand[i]-xv[i][0]+lefthand[N-i])
lmax = 0
for i in range(N):
    lmax = max(lmax, lefthand[i]-(C-xv[-i-1][0])+righthand[N-i])
print(rmax, lmax)
Problem p03393 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(input())
# while 1:
if len(S)==26:
    end = S[-1]
    lis = [end]
    for i in range(24, -1, -1):
        if ord(S[i])<ord(end):
            for s in lis:
                if ord(S[i])<ord(s):
                    S[i] = s
                    break
            S = S[:i+1]
            print(''.join(S))
            break
        else:
            lis.append(S[i])
            end = S[i]
    else:
        if S[0]=='z':
            print(-1)
        else:
            S = [chr(ord(S[0])+1)]
            print(S[0])
else:
    check = [0]*26
    for s in S:
        check[ord(s)-97] = 1
    for i in range(26):
        if not check[i]:
            S.append(chr(i+97))
            break
    print(''.join(S))

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(input())
check = [0]*26
if len(S)==26:
    else:
        end = S[-1]
        for i in range(24, -1, -1):
            if ord(S[i])<ord(end):
                S[i] = end
                print(''.join(S[:i+1]))
                break
        else:
            if S[0]=='z':
                print(-1)
            else:
                print(chr(ord(S[0])+1))
else:
    for s in S:
        check[ord(s)-97] = 1
    for i in range(26):
        if not check[i]:
            S.append(chr(i+97))
            break
    print(''.join(S))
Problem p03421 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, A, B = mapint()
from collections import deque
if A+B-1>N or N>A*B:
    print(-1)
else:
    blocks = []
    blocks.append(' '.join(map(str, range(B, 0, -1))))
    now = B+1
    rest = N-A+2

    while now:
        if now>=rest:
            break
        if now+B>rest:
            blocks.append(' '.join(map(str, range(rest, now-1, -1))))
            rest += 1
            break
        blocks.append(' '.join(map(str, range(now+B-1, now-1, -1))))
        now = now+B
        rest += 1
    blocks.append(' '.join(map(str, range(rest, N+1))))
    print(' '.join(blocks))

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, A, B = mapint()
if A+B-1>N or N>A*B:
    print(-1)
else:
    cnt = N
    blocks = [0]*B*A
    for i, b in enumerate(range(B, 0, -1)):
        blocks[i] = b
    flg = True
    loop = 0
    while flg:
        flg = False
        for i in range(A-1, 0, -1):
            blocks[i*B+loop] = cnt
            cnt -= 1
            if cnt==B:
                break
        else:
            flg = True
            loop += 1
    blocks = [i for i in blocks if i!=0]
    print(*blocks)

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, A, B = mapint()
if A+B-1>N or N>A*B:
    print(-1)
else:
    cnt = N
    blocks = list(range(B, 0, -1))
    blocks.extend([0]*B*(A-1))
    flg = True
    loop = 0
    while flg:
        flg = False
        for i in range(A-1, 0, -1):
            blocks[i*B-loop] = cnt
            cnt -= 1
            if cnt==B:
                break
        else:
            flg = True
            loop += 1
    blocks = [i for i in blocks if i!=0]
    print(*blocks)

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, A, B = mapint()
if A+B-1>N or N>A*B:
    print(-1)
else:
    cnt = N
    blocks = list(range(B, 0, -1))
    blocks.extend([0]*B*(A-1))
    flg = True
    loop = 0
    while flg:
        flg = False
        for i in range(A-1, 0, -1):
            blocks[i*B+loop] = cnt
            cnt -= 1
            if cnt==B:
                break
        else:
            flg = True
            loop += 1
    blocks = [i for i in blocks if i!=0]
    print(*blocks)
Problem p03457 (python)

Fixed submission:
N = int(input())

bt, bx, by = 0, 0, 0

for _ in range(N):
    t, x, y = map(int, input().split())
    dist = abs(x-bx)+abs(y-by)
    time = t-bt
    if time<dist or time%2!=dist%2:
        print('No')
        break
    bt, bx, by = t, x, y
else:
    print('Yes')

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

T, X, B = 0, 0, 0

for _ in range(N):
    t, x, y = map(int, input().split())
    dist = abs(x-X)+abs(y-Y)
    time = t-T
    if time<dist or time%2!=dist%2:
        print('No')
        break
    T, X, Y = t, x, y
else:
    print('Yes')
Problem p03486 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)

lens = len(s)
lent = len(t)
for i in range(lens):
    if i==lent:
        print('No')
        exit()
    if s[i]<t[i]:
        print('Yes')
        exit()
    elif s[i]>t[i]:
        print('No')
        exit()
else:
    if len(t)==len(s):
        print('No')
    else:
        print('Yes')

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)

lens = len(s)
for i in range(lens):
    if s[i]<t[i]:
        print('Yes')
        exit()
    elif s[i]>t[i]:
        print('No')
        exit()
else:
    if len(t)==len(s):
        print('No')
    else:
        print('Yes')
Problem p03673 (python)

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

from collections import deque
b = []
b = deque(b)

for i, a in enumerate(As):
    if i%2==0:
        b.append(a)
    else:
        b.appendleft(a)

if n%2==0:
    print(' '.join(b))
else:
    print(' '.join(reversed(b)))

Buggy submission (verdict: Runtime Error):
n = int(input())
As = list(map(str, input().split()))

from collections import deque
b = []
b = deque(b)

for i, a in enumerate(As):
    if i%2==0:
        b.append(a)
    else:
        b.appendleft(a)

if n%2==0:
    print(' '.join(b))
else:
    print(' '.join(b[::-1]))
Problem p03738 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

A = int(input())
B = int(input())
if A>B:
    print('GREATER')
elif A<B:
    print('LESS')
else:
    print('EQUAL')

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

A, B = mapint()
if A>B:
    print('GREATER')
elif A<B:
    print('LESS')
else:
    print('EQUAL')
Problem p03910 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
cnt = 0
s = set()
for i in range(1, N+1):
    cnt += i
    s.add(i)
    if cnt>=N:
        break
if N!=cnt:
    s.remove(cnt-N)

for i in s:
    print(i)

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
cnt = 0
s = set()
for i in range(1, N):
    cnt += i
    s.add(i)
    if cnt>=N:
        break
if N!=cnt:
    s.remove(cnt-N)

for i in s:
    print(i)
Problem p02995 (python)

Fixed submission:
import fractions
li = list(map(int,input().split()))
countC = li[1] // li[2] - (li[0]-1) // li[2]

countD = li[1] // li[3] - (li[0]-1) // li[3]

lcm = (li[2] * li[3]) // fractions.gcd(li[2], li[3])

countCD = li[1] // lcm - (li[0]-1) // lcm

re = (li[1] - li[0] + 1) - (countC +countD - countCD)

print(re)

Buggy submission (verdict: Runtime Error):
import math
li = list(map(int,input().split()))
countC = li[1] // li[2] - (li[0]-1) // li[2]

countD = li[1] // li[3] - (li[0]-1) // li[3]

lcm = (li[2] * li[3]) // math.gcd(li[2], li[3])

countCD = li[1] // lcm - (li[0]-1) // lcm

re = (li[1] - li[0] + 1) - (countC +countD - countCD)

print(re)
Problem p02741 (python)

Fixed submission:
K=int(input())
s=[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]
print(s[K-1])

Buggy submission (verdict: Runtime Error):
a

Buggy submission (verdict: Runtime Error):
K=int(input().split())
s=[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]
print(s[K-1])
Problem p02772 (python)

Fixed submission:
n = int(input())
x = sum([1 for e in [int(a) for a in input().split(" ")] if not(e % 2 == 0 and e % 3 != 0 and e % 5 != 0)])
print("APPROVED" if n == x else "DENIED")

Buggy submission (verdict: Runtime Error):
print("APPROVED" if int(input()) == xsum([1 for e in [int(a) for a in input().split(" ")] if not(e % 2 == 0 and e % 3 != 0 and e % 5 != 0)]) else "DENIED")
Problem p02898 (python)

Fixed submission:
k = int(input().split(" ")[1])
c = 0
for e_h in [int(e) for e in input().split()]:
    if(k <= e_h): c += 1
print(c)

Buggy submission (verdict: Runtime Error):
nk = [int(e) for e in input().split(" ")]
h = [int(f) for f in input().split()]
c = 0
for e_h in h: if nk[1] <= e_h: c += 1
print(c)
Problem p02899 (python)

Fixed submission:
n = int(input())
a = [(int(a), num) for a, num in zip(input().split(" "), list(range(1,n + 1)))]
a.sort()
m = len(a)
for i in range(m):
    print(a[i][1],end="")
    if(i + 1 < m):
        print(" ",end="")
print()

Buggy submission (verdict: Runtime Error):
print(" ".join(map(lambda x: str(x[1]), sorted([(int(a), num) for a, num in zip(input().split(" "), list(range(1,int(input()) + 1)))]))))