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

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

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
for i in range(len(s)):
    if [:i]+[i:]==t:
        ans=0
    else:
        ans=1
        break
if ans==0:
    print("Yes")
else:
    print("No")
Problem p03316 (python)

Fixed submission:
n=int(input())
a=0
for i in range(len(str(n))):
    a+=int(str(n)[i])
if n % a== 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=0
for i in range(len(a)):
    a+=str(n)[i]
if n%a==0:
    print("Yes")
else:
    print("No")
Problem p03324 (python)

Fixed submission:
d,n = map(int,input().split())
for i in range (n):
    ans=100 ** d * (i+1)
if n==100:
    ans+=100 ** d
print(ans)

Buggy submission (verdict: Runtime Error):
d,n = map(int,input().split())
if n==100:
    ans=100 ** d * (i+2)
else:
    for i in range (n):
    ans=100 ** d * (i+1)
print(ans)
Problem p03351 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
if abs (a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
if !abs(a-b)>d&&!abs(b-c)>d:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
if abs(a-b)==d&&abs(b-c)==d:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
if a+b<=d and b+c<=d:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
if a+b<=d and c+d<=d:
    print("Yes")
else:
    print("No")
Problem p03352 (python)

Fixed submission:
x=int(input())
i,j=2,1
ans=[]
if x==1:
    print(1)
    quit()
while True:
    j+=1
    if i**j>x:
        i+=1
        j=2
        if i**j>x:
            break
    ans.append(i**j)
print(max(ans))

Buggy submission (verdict: Runtime Error):
x=int(input())
i,j=2,1
ans=[]
while True:
    j+=1
    if i**j>x:
        i+=1
        j=2
        if i**j>x:
            break
    ans.append(i**j)
print(max(ans))

Buggy submission (verdict: Runtime Error):
x = int(input())
 
ans=0
for i in range(1,x):
    for j in range(2,x):
        if b**p<=x:
            ans=b**p
        else:
            break
print(ans)

Buggy submission (verdict: Runtime Error):
x=int(input())
i=0
a=[]
while x>=i**2:
    i+=1
    a.append((i-1)**2)
    while x>=i**j:
        j+=1
        a.append((i-1)**j)
print(max(a))
Problem p03361 (python)

Fixed submission:
h,w=map(int,input().split())
S=[]
for i in range(h):
    s=input()
    S.append(s)
for i in range(1,h-1):
    for j in range(1,w-1):
        if S[i+1][j]==S[i][j+1]==S[i-1][j]==S[i][j-1]=="." and S[i][j]=="#":
            print("No")
            quit()
print("Yes")

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
S=[]
for i in range(h):
    s=list(map(int,input.split())
    S.append(s)
for i in range(h):
    for j in range(w):
        if S[i+1][j]==S[i][j+1]==S[i-1][j]==S[i][j-1]==".":
            print("No")
            quit()
print("Yes")

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
S=[]
for i in range(h):
    s=list(map(int,input.split()))
    S.append(s)
for i in range(h):
    for j in range(w):
        if S[i+1][j]==S[i][j+1]==S[i-1][j]==S[i][j-1]==".":
            print("No")
            quit()
print("Yes")
Problem p03370 (python)

Fixed submission:
n,x=map(int,input().split())
li=[]
for i in range(n):
    m=int(input())
    li.append(m)
x=x-sum(li)
print(n+x//min(li))

Buggy submission (verdict: Runtime Error):
n=int(input())
li=list(map(int,input().split()))
print(max(li)-min(li))
Problem p03437 (python)

Fixed submission:
x,y=map(int,input().split())
if x%y==0:
    print(-1)
else:
    print(x*(y-1))

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
if x%y==0:
    print(-1)
else:
    print(a*(b-1))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if x%y==0:
    print(-1)
else:
    print(a*(b-1))
Problem p03502 (python)

Fixed submission:
n=input()
a=0
for i in range(len(n)):
    a+=int(n[i])
if int(n)%a==0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=0
for i in range(len(str(n))):
    a+=n[i]
if n%a==0:
    print("Yes")
else:
    print("No")
Problem p03545 (python)

Fixed submission:
s=input()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])
if a+b+c+d==7:
    print(a,"+",b,"+",c,"+",d,"=",7,sep="")
elif a+b+c-d==7:
    print(a,"+",b,"+",c,"-",d,"=",7,sep="")
elif a+b-c+d==7:
    print(a,"+",b,"-",c,"+",d,"=",7,sep="")
elif a+b-c-d==7:
    print(a,"+",b,"-",c,"-",d,"=",7,sep="")
elif a-b+c+d==7:
    print(a,"-",b,"+",c,"+",d,"=",7,sep="")
elif a-b+c-d==7:
    print(a,"-",b,"+",c,"-",d,"=",7,sep="")
elif a-b-c+d==7:
    print(a,"-",b,"-",c,"+",d,"=",7,sep="")
else:
    print(a,"-",b,"-",c,"-",d,"=",7,sep="")

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
if a+b+c+d==7:
    print(a,"+",b,"+",c,"+",d,"=",7,sep="")
elif a+b+c-d==7:
    print(a,"+",b,"+",c,"-",d,"=",7,sep="")
elif a+b-c+d==7:
    print(a,"+",b,"-",c,"+",d,"=",7,sep="")
elif a+b-c-d==7:
    print(a,"+",b,"-",c,"-",d,"=",7,sep="")
elif a-b+c+d==7:
    print(a,"-",b,"+",c,"+",d,"=",7,sep="")
elif a-b+c-d==7:
    print(a,"-",b,"+",c,"-",d,"=",7,sep="")
elif a-b-c+d==7:
    print(a,"-",b,"-",c,"+",d,"=",7,sep="")
elif a-b-c-d==7:
    print(a,"-",b,"-",c,"-",d,"=",7,sep="")
Problem p03591 (python)

Fixed submission:
s=input()
if len(s)<4:
    a=1
else:
    a=s[0]+ s[1]+ s[2]+ s[3]
if a=='YAKI':
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s=input()
if len(s)<4:
    a=“a”
else:
    a=“s[0]”+ “s[1]”+ “s[2]”+ “s[3]”
if a==“YAKI”:
    print(“Yes”)
else:
    print(“No”)

Buggy submission (verdict: Runtime Error):
s=list(input())
a=s[0]+ s[1]+ s[2]+ s[3]
if a=='YAKI':
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s=input()
if s[0]==“Y” and s[1]==“A” and s[2]==“K” and s[3]==“I”:
    print(“Yes”)
else:
    print(“No”)
Problem p03694 (python)

Fixed submission:
n=int(input())
li=list(map(int,input().split()))
print(max(li)-min(li))

Buggy submission (verdict: Runtime Error):
n=int(input())
li=li(map(int,input().split()))
print(max(li)-min(li))
Problem p03712 (python)

Fixed submission:
h,w=map(int,input().split())
print("#"*(w+2))
for i in range(h):
    a=input()
    print("#"+a+"#")
print("#"*(w+2))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=input()
b=input()
print("#"*(h+w))
print("#"+a+"#")
print("#"+b+"#")
print("#"*(h+w))
Problem p03827 (python)

Fixed submission:
n=int(input())
s=input()
x=0
a=[0]
for i in range(n):
    if s[i]=="I":
        x+=1
    else:
        x-=1
    a.append(x)
print(max(a))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
x=0
a=[]
for i in range(n):
    if s[i]==I:
        x+=1
    else:
        x-=1
    a.append(x)
print(max(a))
Problem p04012 (python)

Fixed submission:
w=input()
for i in range(len(w)):
    if w.count(w[i])%2==0:
        ans="Yes"
    else:
        ans="No"
        break
print(ans)

Buggy submission (verdict: Runtime Error):
w=input()
for i in range(w):
    if w.count(w[i])%2==0:
        ans="Yes"
    else:
        ans="No"
        break
print(ans)
Problem p02602 (python)

Fixed submission:
#m-solutions2020 c
import sys
input = sys.stdin.readline


N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
for i in range(K,N):
    if A[i]>A[i-K]:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
#m-solutions2020 c
import sys,
input = sys.stdin.readline

N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
for i in range(K,N):
    if A[i]>A[i-K]:
        print('Yes')
    else:
        print('No')
Problem p02606 (python)

Fixed submission:
#AIsing2020 a

import sys,math,collections,itertools
input = sys.stdin.readline

L,R,d = list(map(int,input().split()))

if L%d ==0:
    print(R//d-L//d+1)
else:
    print(R//d-L//d)

Buggy submission (verdict: Runtime Error):
#AIsing2020 d
 
import sys,math,collections,itertools,copy
input = sys.stdin.readline
 
 
def popcount(n):
    bin_str = bin(n)
    cou1 = bin_str.count('1')
    return cou1
 
def count(nc):
    co = 0
    while nc >0:
        cou1 = popcount(nc)
        nc = nc%cou1
        co +=1
    return co
 
N = int(input())
X = list(input().rstrip())
 
for i in range(N):
    Y = copy.copy(X)
    if Y[i] == '1':
        Y[i] = '0'
    else:
        Y[i] = '1'
    s = '0b'+"".join(Y)
    a =int(s,2)
    co = count(a)
    print(co)
Problem p02630 (python)

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

N=input().rstrip()
A=list(map(int,input().split()))
Ac = collections.Counter(A)
Q = int(input())
for i in range(Q):
    B,C = list(map(int,input().split()))
    nb = Ac[B]
    Ac[C] += Ac[B]
    Ac[B] = 0

    if i==0:
        ans = 0
        for key,val in Ac.items():
            ans += key*val
    else:
        ans +=nb*C - nb*B
    
    print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**8)

N = int(input())
A = list(map(int,(input().split())))
Q = int(input())
num_list = [0]*(N+1)
s = []
for i in range(N):
    num_list[A[i]] += 1
for _ in range(Q):
    s_s = 0
    B,C = map(int,(input().split()))
    num_list[C] += num_list[B]
    num_list[B] = 0
    for j in range(N+1):
        s_s += (j)*num_list[j]
    s.append(s_s)
for i in range(Q):
    print(s[i])

Buggy submission (verdict: Runtime Error):
 = int(input())
A = list(map(int,(input().split())))
Q = int(input())
num_list = [0]*(N+1)
s = []
for i in range(N):
    num_list[A[i]] += 1
for _ in range(Q):
    s_s = 0
    B,C = map(int,(input().split()))
    num_list[C] += num_list[B]
    num_list[B] = 0
    for j in range(N+1):
        s_s += (j)*num_list[j]
    s.append(s_s)
for i in range(Q):
    print(s[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,list(input().split())))
Q = int(input())
num_list = [0]*(N+1)
s = []
for i in range(N):
    num_list[A[i]] += 1
for _ in range(Q):
    s_s = 0
    B,C = map(int,(input().split()))
    num_list[C] += num_list[B]
    num_list[B] = 0
    for j in range(N+1):
        s_s += (j)*num_list[j]
    s.append(s_s)
for i in range(Q):
    print(s[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,list(input().split())))
Q = int(input())
num_list = [0]*(N+1)
s = []
for i in range(N):
    num_list[A[i]] += 1
for i in range(Q):
    s_s = 0
    B,C = map(int,(input().split()))
    num_list[C] += num_list[B]
    num_list[B] = 0
    for j in range(N+1):
        s_s += (j)*num_list[j]
    s.append(s_s)
for i in range(Q):
    print(s[i])
Problem p02641 (python)

Fixed submission:
x,n = map(int,input().split())
if n == 0:
    print(x)
else:
    mp = set(range(-1,102))
    p = set(list(map(int,input().split())))
    lp = list(mp-p)
    sub_lp = [abs(i-x) for i in lp]
    print(lp[sub_lp.index(min(sub_lp))])

Buggy submission (verdict: Runtime Error):
x,n = map(int,input().split())
mp = set(range(1,101))
p = set(list(map(int,input().split())))
lp = list(mp-p)
sub_lp = [abs(i-x) for i in lp]
print(lp[sub_lp.index(min(sub_lp))])
Problem p02642 (python)

Fixed submission:
import collections
N = int(input())
A = sorted(list(map(int,input().split())))
cA = collections.Counter(A)

li = [1]*(max(A)+1)
for j in range(N):
    for i in range(A[j]*2,A[-1]+1,A[j]):
        li[i] = 0

for key,val in cA.items():
    if val >1:
        li[key]=0
        
sA = sum([li[i] for i in A])
print(sA)

Buggy submission (verdict: Runtime Error):
import collections
N = int(input())
A = sorted(list(map(int,input().split())))

li = [1]*(max(A)+1)
for j in range(N):
    for i in range(A[j]*2,A[-1]+1,A[j]):
        li[i] = 0
    if j == 0:
        if A[j] == A[j+1]:
            li[A[j]]= 0
    elif j == N-1:
        if A[j] == A[j-1]:
             li[A[j]]= 0
    else:
        if A[j] == A[j+1] or A[j] == A[j-1]:
             li[A[j]]= 0
sA = sum([li[i] for i in A])
print(sA)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = sorted(list(map(int,input().split())))
cnt = 0
ln = set()
for i in range(N):
    tmp = A[i]
    if i == 0 and A[i] == A[i+1]:
        cnt = 0
        ln = ln | set(range(A[i],A[-1]+1,A[i]))
    elif i == 0 and A[i] != A[i+1]:
        cnt +=1
        ln = ln | set(range(A[i],A[-1]+1,A[i]))
    else:
        if A[i] not in ln:
            cnt +=1
    ln = ln | set(range(A[i],A[-1]+1,A[i]))
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = sorted(list(map(int,input().split())))
cnt = 0
for i in range(N):
    tmp = A[i]
    if i == 0:
        if A[0]==A[1]:
            continue
    elif i == N-1:
        if A[-1]==A[-2]:
            continue
    else:
        if A[i-1]== A[i] or A[i] == A[i+1]:
            continue
    flag = 0
    for j in range(i):
        if A[j]*2 > A[i]:
            break
        else:
            #print(A[j],A[i])
            if A[i]%A[j]== 0:
                flag = 1
                break
            else:
                continue
    #print(A[i],flag)
    if flag == 0:
        #print(A[i])
        cnt +=1
print(cnt)
Problem p02646 (python)

Fixed submission:
A,V = map(int,input().split())
B,W= map(int,input().split())
T = int(input())
dist = abs(A-B)
vec = V-W
print('YES' if vec*T >= dist else 'NO')

Buggy submission (verdict: Runtime Error):
A,V = map(int,input().split())
B,W= map(int,input().split())
T = int(input()
dist = abs(A-B)
vec = V-W
print('Yes' if vec*T >= dist else 'NO')
Problem p02683 (python)

Fixed submission:
import itertools
import numpy as np
 
N,M,X = map(int,input().split())
ca = ([list(map(int,input().split())) for _ in range(N)])
ca = np.array(ca)
sumX = sum(ca)[1:]
sumcos = sum(ca)[0]
cost = sumcos
if sum(sumX>=X)<M:
    print(-1)
else:
    for j in range(1,N+1):
        for a in itertools.combinations(range(1,N+1),j):       
            x = sum(ca)[1:]
            fx = np.array([0]*M)
            c = sumcos
            for i in range(len(a)):
                x -= ca[a[i]-1][1:]
                c -= ca[a[i]-1][0]
                if sum(x>=X)<M:
                    break
                else:
                    cost = min(c,cost)
    print(cost)

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np
 
N,M,X = map(int,input().split())
ca = ([list(map(int,input().split())) for _ in range(N)])
ca = np.array(ca)
sumX = sum(ca)[1:]
sumcos = sum(ca)[0]
cost = sumcos
if sum(sumX>=X)<M:
    print(-1)
else:
    for j in range(1,N+1):
        for a in itertools.combinations(range(1,N+1),j):       
            x = sum(ca)[1:]
            fx = np.array([0]*M)
            c = sumcos
            for i in range(len(a)):
                x -= ca[a[i]-1][1:]
                c -= ca[a[i]-1][0]
                if sum(x>=X)<M:
                    break
                else:
                    cost = min(c,cost)
    print(cost)

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

N,M,X = map(int,input().split())
ca = ([list(map(int,input().split())) for _ in range(N)])
ca = np.array(ca)
combi = itertools.permutations(range(N),N)
sumX = sum(ca)[1:]
sumcos = sum(ca)[0]
cost = sumcos
if sum(sumX>=X)<M:
    print(-1)
else:
    for a in combi:
        x = sum(ca)[1:]
        fx = np.array([0]*M)
        c = sumcos
        for i in range(len(a)):
            x -= ca[a[i]][1:]
            c -= ca[a[i]][0]
            if sum(x>=X)<M:
                break
            else:
                cost = min(c,cost)
    print(cost)
Problem p02684 (python)

Fixed submission:
import sys,math,collections,itertools
input = sys.stdin.readline

N,K=list(map(int,input().split()))
A =[0]+list(map(int,input().split()))
town = 1
town_list = [1]
towntown = [0]*(N+1)
towntown[1]=1
count = 0
while True:
    town = A[town]
    count +=1
    if count == K:
        print(town)
        exit()
    if towntown[town] == 0:
        town_list.append(town)
        towntown[town] =1
    else:
        roop_town_num = town
        break
    
l_ini_index = town_list.index(roop_town_num)
len_roop = len(town_list)-l_ini_index 

if K <= l_ini_index:
    print(town_list[K])
else:
    print(town_list[((K-l_ini_index)%len_roop+l_ini_index)])

Buggy submission (verdict: Runtime Error):
import sys,math,collections,itertools
input = sys.stdin.readline

N,K=list(map(int,input().split()))
A =[0]+list(map(int,input().split()))
town = 1
town_list = [1]
while True:
    town = A[town]
    if town not in town_list:
        town_list.append(town)
    else:
        roop_town_num = town
        break
    
l_ini_index = town_list.index(roop_town_num)
len_roop = len(town_list)-l_ini_index 

if K <= l_ini_index:
    print(town_lis[K])
else:
    print(town_list[((K-l_ini_index)%len_roop+l_ini_index)])
Problem p02690 (python)

Fixed submission:
import math

X= int(input())

for A in range(-120,121):
    for B in range(-120,A+1):
        if A**5-B**5  == X:
            print(A,B)
            exit()

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

Bp = -1*math.floor(X**0.2)
Bn = 0
while True:
    Bp += 1
    A = (X+Bp**5)**0.2
    if A == int(A):
        print(int(A),Bp)
        exit()

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

Bp = 0
Bn = 0
while True:
    Bp += 1
    A = (X+Bp**5)**0.2
    if A == int(A):
        print(A,Bp)
        exit()

    Bn -= 1
    A = (X+Bn**5)**0.2
    if A == int(A):
        print(int(A),Bn)
        exit()
Problem p02691 (python)

Fixed submission:
import sys,collections
input = sys.stdin.readline
N=int(input())
A=list(map(int,input().split()))
B = []
C = []
for i,a in enumerate(A):
    B.append(i+a)
    C.append(i-a)
cnt = 0
Bc = collections.Counter(B)
Cc = collections.Counter(C)

for key,val in Bc.items():
    cnt += val*Cc[key]
print(cnt)

Buggy submission (verdict: Runtime Error):
import sys,math,collections,
input = sys.stdin.readline
N=int(input())
A=list(map(int,input().split()))
B = []
C = []
for i,a in enumerate(A):
    B.append(i+a)
    C.append(i-a)
cnt = 0
Bc = collections.Counter(B)
Cc = collections.Counter(C)

for key,val in Bc.items():
    cnt += val*Cc[key]
print(cnt)

Buggy submission (verdict: Runtime Error):
import sys,math,collections,itertools,bisect
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))

B = []
for i,a in enumerate(A):
    if a <= N-1:
        B.append([a,i])
if len(B)==0:
    print(0)
    exit()
B.sort()
cnt = 0
for i in range(N):
    for j in range(i+1,N):
        if B[i][0]+B[j][0]==abs(B[i][1]-B[j][1]):
            cnt +=1
        if B[i][0]+B[j][0]>=N:
            break
print(cnt)

Buggy submission (verdict: Runtime Error):
import sys,math,collections,itertools,bisect
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))

B = []
for i,a in enumerate(A):
    if a <=N-1:
        B.append([a,i])
B.sort()
cnt = 0
for i in range(N):
    for j in range(i+1,N):
        if B[i][0]+B[j][0]==abs(B[i][1]-B[j][1]):
            cnt +=1
        if B[i][0]+B[j][0]>=N:
            break
print(cnt)
Problem p02714 (python)

Fixed submission:
N = int(input())
S = input()
count = 0

RGBlist = [[S.count('R')],[S.count('G')],[S.count('B')]]


for i in range(1,N):
    RGBlist[0].append(RGBlist[0][-1] - (S[i-1] == 'R'))
    RGBlist[1].append(RGBlist[1][-1] - (S[i-1] == 'G'))
    RGBlist[2].append(RGBlist[2][-1] - (S[i-1] == 'B'))

for i in range(N-2):
    si = S[i]
    
    for j in range(i+1,N-1):
        sj = S[j]
        if si==sj:
            continue
        else:
            RGB = set(['R','G','B'])
            RGB -= set([si,sj])
            k=j+1
            kji=j-i
            if RGB == {'R'}:
                rgb = 0
            elif RGB =={'G'}:
                rgb = 1
            else:
                rgb = 2
            if k+kji-1 < len(S):
                count += RGBlist[rgb][k] - ({S[k+kji-1]} == RGB)
            else:
                count += RGBlist[rgb][k]
            
print(count)

Buggy submission (verdict: Runtime Error):
from collections import deque
s = input()
Q = int(input())

SS =deque(list(s))
rev_count = 0

for i in range(Q):
    que = input()
    if que[0] == '1':
        rev_count +=1
    elif que[0] == '2':
        if (rev_count + int(que[2]))%2 == 0:
            SS.append(que[4])
        else:
            SS.appendleft(que[4])

print("".join(SS) if rev_count %2 == 0 else ("".join(SS))[-1::-1])
Problem p02796 (python)

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

N = int(input())
imo = []
xlmin = 0
xlmax = 0
for _ in range(N):
    x,l = map(int,input().split())
    imo.append([x-l,x+l-1])
imo = sorted(imo,key = lambda x: x[1])
cnt = 1
ls = imo[0][1]
for i in range(1,N):
    if imo[i][0]<=ls:
        continue
    else:
        cnt += 1
        ls = imo[i][1]
print(cnt)

Buggy submission (verdict: Runtime Error):
import sys,math,collections,itertools
input = sys.stdin.readline

N = int(input())
imo = []
xlmin = 0
xlmax = 0
for _ in range(N):
    x,l = map(int,input().split())
    imo.append([x-l,x+l])
    xlmin = min(xlmin,x-l)
    xlmax = max(xlmax,x+l)

point = [0]*(xlmax-xlmin+2)

for i in range(N):
    point[imo[i][0]-xlmin+1] += 1
    point[imo[i][1]-xlmin+1] -= 1

now = 0
cnt = 0
befor = 0
for i in range(len(point)):
    before = now
    now += point[i]
    if point[i]>=1 and now >1:
        cnt += now-before

print(N-cnt)
Problem p02797 (python)

Fixed submission:
import sys,math,collections,itertools
input = sys.stdin.readline

N,K,S=list(map(int,input().split()))
if S == 10**9:
    ans = [10**9-1]*N
else:
    ans = [10**9]*N
for i in range(K):
    ans[i]=S
print(*ans)

Buggy submission (verdict: Runtime Error):
import sys,math,collections,itertools
input = sys.stdin.readline

N,K,S=list(map(int,input().split()))
ans = [0]*N
if S !=10**9-1:
    ans[K]=10**9-1
else:
    ans[K]=10**9-2
ans[0]=S

print(*ans)

Buggy submission (verdict: Runtime Error):
import sys,math,collections,itertools
input = sys.stdin.readline

N,K,S=list(map(int,input().split()))
ans = [0]*N
ans[K]=10**9+1
ans[0]=S

print(*ans)
Problem p02845 (python)

Fixed submission:
import sys,math,collections,itertools
input = sys.stdin.readline
 
N=int(input())
A=list(map(int,input().split()))
color1 = -1
color2 = -1
color3 = -1
 
m = 10**9+7
patern = 1
 
for a in A:
    if color1 == a-1 and color2 == a-1 and color3 == a-1:
        patern = (patern * 3)%m
        color1 = a
 
    elif (color1 != a-1 and color2 == a-1 and color3 == a-1):
        patern = (patern * 2)%m
        color2 = a
 
    elif (color1 == a-1 and color2 == a-1 and color3 != a-1):
        patern = (patern * 2)%m
        color1 = a
    elif (color1 == a-1 and color2 != a-1 and color3 != a-1):
        color1 = a
 
    elif (color1 != a-1 and color2 == a-1 and color3 != a-1):
        color2 = a
 
    elif (color1 != a-1 and color2 != a-1 and color3 == a-1):
        color3 = a
 
    elif (color1 != a-1 and color2 != a-1 and color3 != a-1):
        patern = 0
        break
print(patern)

Buggy submission (verdict: Runtime Error):
import sys,math,collections,itertools
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
X = [0,0,0]

m = 10**9+7
patern = 1

for a in A:
    patern *= X.count(a)
    patern %= m
    X[X.index(a)]+=1
    

print(patern % m)