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

Fixed submission:
from collections import deque

N, M = map(int, input().split())
AB = []
for i in range(M):
    ab = list(map(int, input().split()))
    AB.append(ab)
# print(AB)

graph = [[] for _ in range(N)]
for a, b in AB:
    graph[a-1].append(b)
    graph[b-1].append(a)
# print(graph) -> [[], [2], [1, 3, 4], [2, 4], [3, 2]]

que = deque([1])
ans = [0 for _ in range(N)]

while que:
    x = deque.popleft(que)
    for i in graph[x-1]:
        if ans[i-1] != 0:
            continue
        ans[i-1] = x
        que.append(i)
for a in ans[1:]:
    if a == 0:
        print('No')
        break
else:
    print('Yes')
    print('\n'.join(map(str, ans[1:])))

Buggy submission (verdict: Runtime Error):
import numpy as np

N, M = map(int, input().split())
ans_list = np.zeros(N-1, dtype=int)
AB = []
flag = 0
ans_num_1 = []
for i in range(M):
    ab = list(map(int, input().split()))
    AB.append(ab)
    if 1 in ab:
        for j in ab:
            if j != 1:
                ans_num_1.append(j)
                ans_list[j-2] = 1
        AB.remove(ab)
if 0 not in ans_list:
    flag = 1
    print("Yes")
# print(ans_list)
while(flag != 1):
    if flag == 0:
        for ab in AB:
            for ans_num in ans_num_1:
                if ans_num in ab:
                    for j in ab:
                        if ans_num != j:
                            ans_list[j-2] = ans_num
                    AB.remove(ab)
            
        if 0 not in ans_list:
            flag = 1
            print("Yes")
if flag == 1:
    for ans in ans_list:
        print(ans)
Problem p02687 (python)

Fixed submission:
S = input()
if S == 'ABC':
    print('ARC')
else:
    print('ABC')

Buggy submission (verdict: Runtime Error):
import itertools


X = int(input())
ans_A = 0
ans_B = 0
for i, j in itertools.combinations(range(0, 1000), 2):
    j *= -1
    if i**5 - j**5 == X:
        ans_A = i
        ans_B = j
        break
if ans_A == 0 and ans_B == 0:
    for i, j in itertools.combinations(range(0, 1000), 2):
        if i**5 - j**5 == X:
            ans_A = i
            ans_B = j
            break
print(ans_A, ans_B)
Problem p02618 (python)

Fixed submission:
for i in range(365):
  print(1)

Buggy submission (verdict: Runtime Error):
D = int(input())
c = [int(x) for x in input().split()]
s = []
for i in range(D):
    s.append([int(x) for x in input().split()])
kotae = 0
for k in range(26):
    ans = 0
    nissuu = [0] * 26
    for i in range(D):
        t = (i+k) % 26 + 1
        for j in range(26):
            if j == t-1:
                nissuu[j] = 0
            else:
                nissuu[j] += 1
            ans -= c[j]*nissuu[j]
        ans += s[i][t-1]
    if kotae <= ans:
        kotae = ans
        key = k
for i in range(D):
    print((i+key) % 26 + 1)

Buggy submission (verdict: Runtime Error):
D = int(input())
c = [int(x) for x in input().split()]
s = []
for i in range(D):
    s.append([int(x) for x in input().split()])
kotae = 0
k2 = 0
for k in range(26):
    ans = 0
    nissuu = [0] * 26
    for i in range(D):
        t = (i+k) % 26 + 1
        for j in range(26):
            if j == t-1:
                nissuu[j] = 0
            else:
                nissuu[j] += 1
            ans -= c[j]*nissuu[j]
        ans += s[i][t-1]
    if kotae <= ans:
        kotae = ans
        key = k
for i in range(D):
    print((i+key) % 26 + 1)

Buggy submission (verdict: Runtime Error):
D = int(input())
c = [int(x) for x in input().split()]
s = []
for i in range(D):
    s.append([int(x) for x in input().split()])
kotae = 0
nissuu = [0] * 26
k2 = 0
for k in range(26):
    ans = 0
    print(k)
    for i in range(D):
        t = (i+k) % 26 + 1
        for j in range(26):
            if j == t-1:
                nissuu[j] = 0
            else:
                nissuu[j] += 1
            ans -= c[j]*nissuu[j]
        ans += s[i][t-1]
    if kotae <= ans:
        kotae = ans
        key = k
for i in range(D):
    print((i+key) % 26 + 1)
Problem p02660 (python)

Fixed submission:
n = int(input())
a = []
b = []
if n == 1:
    print(0)
    exit()
if True:
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
kosuu = 1
mae = a[0]
for i in range(1,len(a)):
    if mae == a[i]:
        kosuu += 1
    else:
        mae = a[i]
        b.append(kosuu)
        kosuu = 1
b.append(kosuu)
ans = 0
for i in range(len(b)):
    for j in range(2,100):
        if b[i] < j*(j+1)//2:
            ans += j-1
            break
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
b = []
if True:
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
kosuu = 1
mae = a[0]
for i in range(1,len(a)):
    if mae == a[i]:
        kosuu += 1
    else:
        mae = a[i]
        b.append(kosuu)
        kosuu = 1
b.append(kosuu)
ans = 0
for i in range(len(b)):
    for j in range(2,100):
        if b[i] < j*(j+1)//2:
            ans += j-1
            break
print(ans)
Problem p02713 (python)

Fixed submission:
import math
ans = 0
N = int(input())
if N <= 5:
  for i in range(N):
    for j in range(N):
        for k in range(N):
            ans += math.gcd(math.gcd(i+1,j+1),math.gcd(j+1,k+1))
else:
    for i in range(N):
        ans += i+1
    for i in range(N-1):
        for j in range(i+1,N):
            ans += 6*math.gcd(i+1,j+1)
    for i in range(N-2):
        for j in range(i+1,N-1):
            for k in range(j+1,N):
                ans += 6*math.gcd(math.gcd(i+1,j+1),math.gcd(j+1,k+1))
print(ans)

Buggy submission (verdict: Runtime Error):
import math
ans = 0
N = int(input())
for i in range(N):
    for j in range(N):
        for k in range(N):
            ans += math.gcd(i,j,k)
print(ans)
Problem p02716 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2000000000)
N = int(input())
import math
l = [int(x) for x in input().split()]
tobi = [0]*(math.ceil(N/2))
tobi[0] = l[0]
for i in range(1,math.ceil(N/2)):
    tobi[i] = tobi[i-1] + l[i*2]
from functools import lru_cache
@lru_cache(maxsize=1000000000)
def motomeru(x,y):
    if y == 0 or x == 0 or x == 1:
        return 0
    elif x % 2 == 0:
        return max(motomeru(x-2,y-1)+l[x-1],tobi[math.floor((x-1)/2)])
    else:
        return max(motomeru(x-2,y-1)+l[x-1],motomeru(x-1,y))
print(motomeru(N,N//2))

Buggy submission (verdict: Runtime Error):
N,K = [int(x) for x in input().split()]
count = [0]*(K+1)
ans = 0
mod = 1000000007
for i in range(K,0,-1):
    kosuu = pow(K//i,N,mod)
    if K // i >= 2:
        for j in range(K//i,1,-1):
            kosuu -= count[j*i]
    ans += i*kosuu
    count[i] = kosuu
print(ans%mod)

Buggy submission (verdict: Runtime Error):
N = int(input())
import math
l = [int(x) for x in input().split()]
tobi = [0]*(math.ceil(N/2))
tobi[0] = l[0]
for i in range(1,math.ceil(N/2)):
    tobi[i] = tobi[i-1] + l[i*2]
from functools import lru_cache
@lru_cache(maxsize=1000000000)
def motomeru(x,y):
    if y == 0 or x == 0 or x == 1:
        return 0
    elif x % 2 == 0:
        return max(motomeru(x-2,y-1)+l[x-1],tobi[math.floor((x-1)/2)])
    else:
        return max(motomeru(x-2,y-1)+l[x-1],motomeru(x-1,y))
print(motomeru(N,N//2))

Buggy submission (verdict: Runtime Error):
N = int(input())
import math
l = [int(x) for x in input().split()]
tobi = [0]*(math.ceil(N/2))
tobi[0] = l[0]
for i in range(1,math.ceil(N/2)):
    tobi[i] = tobi[i-1] + l[i*2]
def motomeru(x,y):
    if y == 0 or x == 0 or x == 1:
        return 0
    elif x % 2 == 0:
        return max(motomeru(x-2,y-1)+l[x-1],tobi[math.floor((x-1)/2)])
    else:
        return max(motomeru(x-2,y-1)+l[x-1],motomeru(x-1,y))
print(motomeru(N,N//2))
Problem p02727 (python)

Fixed submission:
from collections import deque
x,y,a,b,c = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
r = [int(x) for x in input().split()]
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
d = deque(r)
aka = x-1
midori = y-1
ps = p[:x]
qs = q[:y]
li = ps + qs
li.sort(reverse=True)
i = 0
z = d.popleft()
while li[x+y-1-i] < z:
  li[x+y-1-i] = z
  i += 1
  if not d:
    break
  z = d.popleft()
ans = 0
for i in range(x+y):
  ans += li[i]
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
x,y,a,b,c = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
r = [int(x) for x in input().split()]
#入力を受け取った
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
d = deque(r)
#ソートした。rはdequeにした
aka = x-1#赤いリンゴのうち、交換するか調べるもの
midori = y-1#緑リンゴ同上
while True:
  siraberu = d.popleft()#無職リンゴのうち一番美味しいものを取り出す
  if min(p[aka],q[midori]) < siraberu:#調べるリンゴのうちのまずい方がsiraberuよりまずいか
    if p[aka] <= q[midori]:#調べる赤リンゴの方がまずいとき
      p[aka] = siraberu#交換
      aka = aka - 1#調べるものを一個ずらす
    else:
      q[midori] = siraberu
      midori = midori - 1
  if aka == -1:
    aka = 0
  elif midori == -1:
    midori = 0
  else:
    break
pd = deque(p)
qd = deque(q)
ans = 0
for i in range(x):
  ans = ans + pd.popleft()
for i in range(y):
  ans = ans + qd.popleft()
print(ans)
Problem p02756 (python)

Fixed submission:
from collections import deque
a = input()
c = input()
d = []
alist = list(a)
adeque = deque(a)
count = 0
for i in range(int(c)):
  e = input().split()
  d.append(e)
for i in range(int(c)):
  if d[i][0]=="1":
    count = count + 1
  else:
    if d[i][1] == "1" and count % 2 == 0:
      adeque.appendleft(d[i][2])
    elif d[i][1] == "2" and count % 2 == 1:
      adeque.appendleft(d[i][2])
    else:
      adeque.append(d[i][2])
alist = list(adeque)
if count % 2 == 1:
  l = len(alist)
  for x in range(int(l//2)):
    alist[x],alist[l-x-1] = alist[l-x-1],alist[x]
answer = "".join(alist)
print(answer)

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
d=[]
alist = list(a)
for i in range(int(c)):
  e = input().split()
  d.append(e)
for i in range(int(c)):
  if d[i][0]=="1":
    l = len(alist)
    for x in range(int(l//2)):
      alist[x],alist[l-x-1] = alist[l-x-1],alist[x]
  else:
    if d[i][1] == "1":
      alist = [d[i][2]] + alist
    else:
      alist = alist + [d[i][2]]
le = len(alist)
answer =""
for i in range(le):
  answer = answer + alist[i]
print(answer)
Problem p02768 (python)

Fixed submission:
n,a,b = [int(x) for x in input().split()]
mod = 10**9 + 7
def comb(x,y):
    child = 1
    mother = 1
    for i in range(y):
        child = child * (x-i)%mod
        mother = mother * (i+1)%mod
    return child * pow(mother,mod-2,mod) % mod
ans = pow(2,n,mod) - 1
ans -= comb(n,a)
ans %= mod
ans -= comb(n,b)
ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b = [int(x) for x in input().split()]
mod = 10**9 + 7
import math
#再起限界突破
import sys
sys.setrecursionlimit(1000000000)
#メモ化再帰
from functools import lru_cache
@lru_cache(maxsize=1000000000)
def action(k):
    if k == 1:
        return 1
    else:
        return k * action(k-1) % mod
ans = pow(2,n,mod)  - action(n)/action(n-a)/action(a) - action(n)/(action(n-b)*action(b)) - 1
print(int(ans%mod))

Buggy submission (verdict: Runtime Error):
n,a,b = [int(x) for x in input().split()]
mod = 10**9 + 7
import math
#再起限界突破
import sys
sys.setrecursionlimit(1000000000)
def action(k):
    if k == 1:
        return 1
    else:
        return k * action(k-1)
ans = pow(2,n,mod)  - action(n)/action(n-a)/action(a) - action(n)/(action(n-b)*action(b)) - 1
print(int(ans%mod))

Buggy submission (verdict: Runtime Error):
n,a,b = [int(x) for x in input().split()]
mod = 10**9 + 7
import math
#再起限界突破
import sys
sys.setrecursionlimit(2000000000)
#メモ化再帰
from functools import lru_cache
@lru_cache(maxsize=2000000000)
def action(k):
    if k == 1:
        return 1
    else:
        return k * action(k-1)
ans = pow(2,n,mod)  - action(n)/action(n-a)/action(a) - action(n)/(action(n-b)*action(b)) - 1
print(int(ans%mod))
Problem p02900 (python)

Fixed submission:
a,b = [int(x) for x in input().split()]
import fractions
g = fractions.gcd(a,b)
ans = 1
mama = int(g ** (1/2))
flag = 0
for i in range(2,mama+2):
    while True:
        if g%i != 0:
            break
        else:
            g = g/i
            flag = 1
    if flag == 1:
        ans += 1
    flag = 0
if g != 1:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
a,b = [int(x) for x in input().split()]
import fractions
g = fractions.gcd(a,b)
ans = 1
mama = int(g ** (1/2))
for i in range(2,mama+2):
    while True:
        if g%i != 0:
            break
        else:
            g = g/i
            flag = 1
    if flag == 1:
        ans += 1
    flag = 0
if g != 1:
    ans += 1
print(ans)
Problem p03274 (python)

Fixed submission:
N,K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
ans = 100000000000
for i in range(N-K+1):
  le = l[i]
  ri = l[i+K-1]
  ans = min(ans,abs(le)+abs(ri-le),abs(ri)+abs(ri-le))
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
lm = []
lp = []
while l:
    x = l.pop(0)
    if x >= 0:
        lp.append(x)
    else:
        lm.append(-x)
ans = 100000000000
if lm and lp:
  for i in range(min(len(lp),K)):
    if K - i - 1 > 0:
      ans = min(ans,2*lp[i] + lm[-(K-i-1)],lp[i] + 2*lm[-(K-i-1)])
    else:
      ans = min(ans,lp[i])
elif lp:
  ans = lp[K-1]
else:
  ans = lm[1-K]
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
lm = []
lp = []
while l:
    x = l.pop(0)
    if x >= 0:
        lp.append(x)
    else:
        lm.append(-x)
ans = 100000000000
if lm and lp:
  for i in range(min(len(lp),K)):
    ans = min(ans,2*lp[i] + lm[-(K-i-1)],lp[i] + 2*lm[-(K-i-1)])
elif lp:
  ans = lp[K-1]
else:
  ans = lm[1-K]
print(ans)
Problem p03282 (python)

Fixed submission:
a = input()
k = int(input())
b = list(a)
if k == 1:
    print(b[0])
    exit()
else:
    for i in range(k):
        if int(b[i]) != 1:
            print(b[i])
            exit()
print(1)

Buggy submission (verdict: Runtime Error):
a = input()
k = int(input())
b = list(a)
if k == 1:
    print(b[0])
else:
    for i in range(100):
        if int(b[i]) != 1:
            print(b[i])
            break
Problem p03435 (python)

Fixed submission:
l = []
for i in range(3):
    ll = [int(x) for x in input().split()]
    l.append(ll)
if l[0][0] - l[0][1] != l[1][0] - l[1][1] or l[2][0] - l[2][1] != l[1][0] - l[1][1]:
    print("No")
    exit()
if l[0][2] - l[0][1] != l[1][2] - l[1][1] or l[2][2] - l[2][1] != l[1][2] - l[1][1]:
    print("No")
    exit()
if l[0][0] - l[1][0] != l[0][1] - l[1][1] or l[0][2] - l[1][2] != l[0][1] - l[1][1]:
    print("No")
    exit()
if l[2][0] - l[1][0] != l[2][1] - l[1][1] or l[2][2] - l[1][2] != l[2][1] - l[1][1]:
    print("No")
    exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
N = int(input())
ll = []
for i in range(3):
    l = [int(x) for x in input().split()]
    ll.append(l)
if l[0][0] - l[0][1] != l[1][0] - l[1][1] or l[2][0] - l[2][1] != l[1][0] - l[1][1]:
    print("No")
    exit()
if l[0][2] - l[0][1] != l[1][2] - l[1][1] or l[2][2] - l[2][1] != l[1][2] - l[1][1]:
    print("No")
    exit()
if l[0][0] - l[1][0] != l[0][1] - l[1][1] or l[0][2] - l[1][2] != l[0][1] - l[1][1]:
    print("No")
    exit()
if l[2][0] - l[1][0] != l[2][1] - l[1][1] or l[2][2] - l[1][2] != l[2][1] - l[1][1]:
    print("No")
    exit()
print("Yes")
Problem p03946 (python)

Fixed submission:
N,T = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ans = []
mi = 10**9
for i in range(N):
    mi = min(mi,a[i])
    ans.append(a[i]-mi)
print(ans.count(max(ans)))

Buggy submission (verdict: Runtime Error):
N,T = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ind = 0
rieki = []
while True:
    ma = max(a[ind+1:N])
    kioku = ind+1
    ind = a.index(ma)
    if kioku != ind:
        mi = min(a[kioku:ind])
        rieki.append(ma-mi)
    if ind == N-1:
        break
print(rieki.count(max(rieki)))
Problem p03999 (python)

Fixed submission:
import copy
a = list(input())
n = len(a)-1
ans = 0
if n == 0:
  print(int(a[0]))
else:
  for i in range(2 ** n):
    l=[]
    l = copy.copy(a)
    dokoka = [0]*(n)
    for j in range(n):
        if ((i >> j)&1):
            dokoka[j] = 1
    x = l.pop(0)
    while True:
      d = dokoka.pop(0)
      if d == 0:
          x += l.pop(0)
      else:
          ans += int(x)
          x = l.pop(0)
      if not dokoka:
          ans += int(x)
          break
  print(ans)

Buggy submission (verdict: Runtime Error):
import copy
a = list(input())
n = len(a)-1
ans = 0
for i in range(2 ** n):
    l=[]
    l = copy.copy(a)
    dokoka = [0]*(n)
    for j in range(n):
        if ((i >> j)&1):
            dokoka[j] = 1
    x = l.pop(0)
    while True:
      d = dokoka.pop(0)
      if d == 0:
          x += l.pop(0)
      else:
          ans += int(x)
          x = l.pop(0)
      if not dokoka:
          ans += int(x)
          break
print(ans)
Problem p02548 (python)

Fixed submission:
import sys

input = sys.stdin.readline

n = int(input())
ans = 0

for a in range(1,n+1):
    ans += (n-1) // a
    
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import sympy
import math

input = sys.stdin.readline

n = int(input())
ans = 0

for a in range(1,n+1):
    ans += (n-1) // a
    
print(ans)
Problem p02609 (python)

Fixed submission:
import sys
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("202007_2nd/D_input.txt")
else:
    f=sys.stdin
#from 2nd count
def cnt_func(num):
    cnt=0
    while num:
        num%=bin(num).count("1")
        cnt+=1
    return cnt+1
n=int(f.readline().strip())
s=f.readline().strip()
input_val=int(s,2)
input_one_count=s.count("1")
#Base value
zero_first=input_val%(input_one_count+1)
one_first=input_val%(input_one_count-1) if input_one_count>1 else 0
ans=0
for idx,emt in enumerate(s):
    p=n-idx-1
    if emt=="0": #inverted to "1"
        ans=cnt_func((zero_first+(pow(2,p,input_one_count+1)))%(input_one_count+1))
    else: #inverted to "0"
        if input_one_count>1:
            ans=cnt_func((one_first-(pow(2,p,input_one_count-1)))%(input_one_count-1))
        else:
            ans=0
    print(ans)
f.close()

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

import sys
import math

def saiki(n,saiki_one_count,do_count):
    do_count += 1
    mod = n % saiki_one_count
    if mod == 0:
        return do_count
    saiki_one_count = bin(mod).count("1")
    return saiki(mod,saiki_one_count,do_count)
def main():
    input = sys.stdin.readline
    N = int(input())
    x = input()
    x_list = list(x)[:-1]
    x_list = [int(value) for value in x_list]
    one_count = x_list.count(1)
    sum_x = 0
    for i in range(len(x_list)):
        if x_list[N -1 - i] == 1:
            sum_x += 2 ** i
    zero_convert = sum_x%(one_count+1)
    one_convert = sum_x%(one_count+1)

    for i in range(len(x_list)):
        current_sum_x = 0
        current_one_count = 0
        if x_list[i] == 0:
            current_one_count = one_count + 1
            current_sum_x = zero_convert + pow(2,N-i-1,current_one_count)
        else:
            current_one_count = one_count - 1
            current_sum_x = one_convert + pow(2,N-i-1,current_one_count)
        do_count = saiki(current_sum_x,current_one_count,0)
        print(do_count)
    return


if __name__ == '__main__':
    main()

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

import sys
import math

def saiki(n,saiki_one_count,do_count):
    do_count += 1
    mod = n % saiki_one_count
    if mod == 0:
        return do_count
    saiki_one_count = bin(mod).count("1")
    return saiki(mod,saiki_one_count,do_count)
def main():
    input = sys.stdin.readline
    N = int(input())
    x = input()
    x_list = list(x)[:-1]
    x_list = [int(value) for value in x_list]
    one_count = x_list.count(1)
    sum_x = 0
    for i in range(len(x_list)):
        if x_list[N -1 - i] == 1:
            sum_x += 2 ** i

    for i in range(len(x_list)):
        current_sum_x = 0
        current_one_count = 0
        if x_list[i] == 0:
            current_one_count = one_count + 1
            current_sum_x = sum_x + 2 ** (N - 1 - i)
        else:
            current_one_count = one_count - 1
            current_sum_x = sum_x - 2 ** (N - 1 - i)
        do_count = saiki(current_sum_x,current_one_count,0)
        print(do_count)
    return


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

Fixed submission:
import sys
import heapq


input = sys.stdin.readline
n = int(input())
result = n*(n-1)//2
print(result)

Buggy submission (verdict: Runtime Error):
import sys
import heapq


input = sys.stdin.readline
n = int(input())
n_list = list(range(1,n))
print(sum(n_list))
Problem p03393 (python)

Fixed submission:
import sys

input = sys.stdin.readline
S =  input()
S = S.replace("\n","")
s_list = list(S)
alpha_list = [chr(i) for i in range(97, 97+26)]
flag_list = [False for _ in range(26)]


if len(s_list) == 26:
    for i in range(25, 0, -1):
        if s_list[i - 1] < s_list[i]:
            c = 'ω'
            for j in range(i, 26):
                if s_list[i - 1] < s_list[j]:
                    c = min(c, s_list[j])
            print(S[:i-1] + c)
            exit(0)
    print(-1)

else:
    for i,alpha in enumerate(alpha_list):
        if alpha in s_list:
            flag_list[i] = True
    for i,flag in enumerate(flag_list):
        if not flag:
            print(S + alpha_list[i])
            break

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline
S =  input()
S = S.replace("\n","")
s_list = list(S)
alpha_list = [chr(i) for i in range(97, 97+26)]
flag_list = [False for _ in range(23)]


if len(s_list) == 26:
    for i in range(25, 0, -1):
        if s_list[i - 1] < s_list[i]:
            c = 'ω'
            for j in range(i, 26):
                if s_list[i - 1] < s_list[j]:
                    c = min(c, s_list[j])
            print(S[:i-1] + c)
            exit(0)
    print(-1)

else:
    for i,alpha in enumerate(alpha_list):
        if alpha in s_list:
            flag_list[i] = True
    for i,flag in enumerate(flag_list):
        if not flag:
            print(S + alpha_list[i])
            break

Buggy submission (verdict: Runtime Error):
import sys
import heapq
from decimal import Decimal

input = sys.stdin.readline
S =  input()
S = S.replace("\n","")
s_list = list(S)
alpha_list = [chr(i) for i in range(97, 97+26)]
flag_list = [False for _ in range(23)]


if len(s_list) == 26:
    for i in range(25, 0, -1):
        if s_list[i - 1] < s_list[i]:
            c = 'ω'
            for j in range(i, 26):
                if s_list[i - 1] < s_list[j]:
                    c = min(c, s_list[j])
            print(S[:i-1] + c)
            exit()
    print(-1)

else:
    for i,alpha in enumerate(alpha_list):
        if alpha in s_list:
            flag_list[i] = True
    for i,flag in enumerate(flag_list):
        if not flag:
            print(S + alpha_list[i])
            break

Buggy submission (verdict: Runtime Error):
import sys
import heapq
from decimal import Decimal

input = sys.stdin.readline
S =  input()
S = S.replace("\n","")
s_list = list(S)
alpha_list = [chr(i) for i in range(97, 97+26)]
flag_list = [False for _ in range(23)]


if len(s_list) == 26:
    for i in range(25, 0, -1):
        if s_list[i - 1] < s_list[i]:
            c = 'ω'
            for j in range(i, 26):
                if s_list[i - 1] < s_list[j]:
                    c = min(c, s_list[j])
            print(s_list[:i-1] + c)
            exit()
    print(-1)

else:
    for i,alpha in enumerate(alpha_list):
        if alpha in s_list:
            flag_list[i] = True
    for i,flag in enumerate(flag_list):
        if not flag:
            print(S + alpha_list[i])
            break