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

Fixed submission:
#inserting X
s=input()
length=len(s)
string=""
for i in range(length):
    if s[i]!="x":
        string=string+s[i]
    else:
        continue


flag=True
length2=len(string)
if length2>=2:
    for i in range(length2//2):
        if string[i]!=string[-(i+1)]:
            flag=False
            break
if flag:
    s="x"+s+"X"
    length=len(s)
    checklist=[]
    count=0
    for i in range(length):
        if s[i]=="x":
            count+=1
        else:
            checklist.append(count)
            count=0
    checklist[0]-=1
    ans=0
    for i in range(len(checklist)//2):
        ans+=abs(checklist[i]-checklist[-(i+1)])
    print(ans)
    
else:
    print("-1")

Buggy submission (verdict: Runtime Error):
#inserting X
s=input()
length=len(s)
string=""
for i in range(length):
    if s[i]!="x":
        string=string+s[i]
    else:
        continue

flag=True
length2=len(string)
if length2>=2:
    for i in range(length//2):
        if string[i]!=string[-(i+1)]:
            flag=False
            break
if flag:
    s="x"+s+"X"
    length=len(s)
    checklist=[]
    count=0
    for i in range(length):
        if s[i]=="x":
            count+=1
        else:
            checklist.append(count)
            count=0
    checklist[0]-=1
    ans=0
    for i in range(len(checklist)//2):
        ans+=max(checklist[i],checklist[-(i+1)])
    print(ans)
    
    
else:
    print("-1")
Problem p03576 (python)

Fixed submission:
#atcoder -take a rest-(easy)

def main():
    N,K = map(int,input().split())
    que = []
    que_x =  []
    que_y = []
    for i in range(N):
        x,y = map(int,input().split())
        que_x.append(x)
        que_y.append(y)
        que.append((x,y))
    que_x.sort()
    que_y.sort()
    ans = 10**100
    for i in range(N):
        for j in range(i,N):
            for _i in range(N):
                for _j in range(_i,N):
                    h,w = que_x[j]-que_x[i],que_y[_j] -que_y[_i]
                    cnt = 0
                    for x,y in que:
                        if que_x[i]<=x<=que_x[j] and que_y[_i]<=y<=que_y[_j]:
                            cnt += 1
                    if cnt >=K:
                        ans = min(ans,h*w)
    print(ans)
    return




if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
lists=[]
for i in range(n):
    x,y=map(int,input().split())
    lists.append((x,y))
anslist=[]
for i in range(n):
    for j in range(i+1,n):
        for k in range(n):
            for l in range(k+1,n):       
                a=lists[i][0]
                b=lists[j][0]
                c=lists[k][1]
                d=lists[l][1]
                counter=0
                for s in range(n):
                    p,q=lists[s][0],lists[s][1]
                    if min(a,b)<=p<=max(a,b) and min(d,c)<=q<=max(c,d):
                        counter+=1
                    if counter>=K:
                        anslist.append(abs(a-b)*abs(c-d))
print(min(anslist))
Problem p03600 (python)

Fixed submission:
n=int(input())

mat=[[0 for i in range(n)] for j in range(n)]
data=[[0 for i in range(n)] for j in range(n)]
for _ in range(n):
    x=list(map(int,input().split()))
    for j in range(n):
        mat[_][j]=x[j]
        data[_][j]=x[j]
def warshall_floyd(d):
    #d[i][j]=i番目の頂点からj番目の頂点までの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

newmat=warshall_floyd(mat)
if newmat==data:
    ans=0
    for i in range(n):
        for j in range(i+1,n):
            ans+=data[i][j]*int(all(data[i][j]<data[i][k]+data[k][j] for k in range(i))&all(data[i][j]<data[i][k]+data[k][j] for k in range(i+1,j))&all(data[i][j]<data[i][k]+data[k][j] for k in range(j+1,n)))     
    print(ans)      
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
#restoring read network
ans=0
import numpy as np
from scipy.sparse import csr_matrix 
from scipy.sparse.csgraph import floyd_warshall
n=int(input())
mat=np.array([[0 for i in range(n)] for j in range(n)],dtype=np.int)
data=np.array([[0 for i in range(n)] for j in range(n)],dtype=np.int)
for _ in range(n):
    x=list(map(int,input().split()))
    for j in range(n):
        mat[_][j]=x[j]
        data[_][j]=x[j]
        
csr=csr_matrix(mat)
csr=floyd_warshall(csr)
if np.array_equal(csr,data):
    ans=0
    for i in range(n):
        for j in range(i+1,n):
            cnt=0
            for k in range(n):
                if data[i][j]>=data[i][k]+data[k][j]:
                    cnt+=1
            if cnt==2:
                ans+=data[i][j]                
    print(ans)            
else:
    print(-1)
Problem p03627 (python)

Fixed submission:
#第二問　make a rectangle
import collections
n=int(input())
lists=list(map(int,input().split()))
A=dict(collections.Counter(lists))
dictdict=[]


for j in A.keys():
    for _ in range(A[j]//2):
        dictdict.append(j)

dictdict=sorted(dictdict,reverse=True)
if len(dictdict)>=2:
    print(dictdict[0]*dictdict[1])
else:
    print(0)

Buggy submission (verdict: Runtime Error):
#第二問　make a rectangle
import collections
n=int(input())
lists=list(map(int,input().split()))
A=dict(collections.Counter(lists))
dictdict=[]


for j in A.keys():
    for _ in range(A[j]//2):
        dictdict.append(j)

dictdict=sorted(dictdict,reverse=True)
print(dictdict[0]*dictdict[1])
Problem p03633 (python)

Fixed submission:
#早くmathを導入してほしい
from fractions import gcd
n=int(input())
glm=1
for i in range(n):
    nums=int(input())
    glm=int(glm*nums//gcd(nums,glm))
print(glm)

Buggy submission (verdict: Runtime Error):
import fractions
n=int(input())
glm=1
for i in range(n):
    nums=int(input())
    glm=int(glm*nums/fractions.gcd(nums,glm))
print(glm)

Buggy submission (verdict: Runtime Error):
import fractions
n=int(input())
lists=[]
glmlists=[]
for s in range(n):
    s=int(input())
    lists.append(s)
lists.append(1)
glm=lists[0]
cnt=0
while cnt<n:
    gcd=fractions.gcd(glm,lists[cnt+1])
    glm=int(glm*lists[cnt+1]/gcd)
    glmlists.append(glm)
    cnt+=1    
print(glmlists[-1])

Buggy submission (verdict: Runtime Error):
import fractions
n=int(input())
lists=[]
for s in range(n):
    s=int(input())
    lists.append(s)
    
lists.append(1)

glm=lists[0]

cnt=0

while cnt<n:
	gcd=fractions.gcd(glm,lists[cnt+1])
    glm=int(glm*lists[cnt+1]/gcd)
    cnt+=1
    
print(glm)

Buggy submission (verdict: Runtime Error):
import fractions
n=int(input())
lists=[]
for s in range(n):
    s=int(input())
    lists.append(s)
lists.append(1)
glm=lists[0]
cnt=0
while cnt<n:
    gcd=fractions.gcd(glm,lists[cnt+1])
    glm=int(glm*lists[cnt+1]/gcd)
    cnt+=1    
print(glm)

Buggy submission (verdict: Runtime Error):
import fractions
n=int(input())
lists=[]
for s in range(n):
    s=int(input())
    lists.append(s)
lists.append(1)
print(lists)
glm=lists[0]
cnt=0
while cnt<n:
    gcd=fractions.gcd(glm,lists[cnt+1])
    glm=int(glm*lists[cnt+1]/gcd)
    cnt+=1    
print(glm)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
lists=[]
for s in range(n):
    s=int(input())
    lists.append(s)
lists.append(1)
glm=lists[0]
cnt=0
while cnt<n:
    gcd=math.gcd(glm,lists[cnt+1])
    glm=int(glm*lists[cnt+1]/gcd)
    cnt+=1    
print(glm)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
lists=[]
for s in range(n):
    s=int(input())
    lists.append(s)
lists.append(1)
print(lists)
glm=lists[0]
cnt=0
while cnt<n:
    gcd=math.gcd(glm,lists[cnt+1])
    glm=int(glm*lists[cnt+1]/gcd)
    cnt+=1    
print(glm)
Problem p03646 (python)

Fixed submission:
#Decrease (const)
K = int(input())
# 適当に構成する
N = 50
u, v = divmod(K, 50)
P = [u+i for i in range(N)]
for i in range(1, v+1):
    P[-i] += 1
print(N)
print(*P)

Buggy submission (verdict: Runtime Error):
k=int(input())
lists=[49 for i in range(50)]
T=k//50
for j in range(50):
    lists[j]+=T
print(50)

sums=0
for i in range(50):
    sums+=math.floor((lists[i]+k)/(51))
dis=k-sums
lists[0]=lists[0]-51*dis
print(*lists)
Problem p03696 (python)

Fixed submission:
#insertion
n=int(input())
s=input()
count=1
Llist=[]
Rlist=[]
s=s+"X"
for i  in range(n):
    if s[i]==s[i+1]:
        count+=1
    else:
        if s[i]=="(":
            Llist.append(count)
        else:
            Rlist.append(count)
        count=1
#LのがRよりもつよい
if s[0]==")":
    Llist.insert(0,0)
if s[-2]=="(":
    Rlist.append(0)

Lsum=0
Rsum=0
for i in range(len(Llist)):
    Lsum+=Llist[i]
    Rsum+=Rlist[i]
    if Lsum>=Rsum:
        pass
    elif Lsum<Rsum:
        Llist[0]+=(Rsum-Lsum)
        Lsum+=(Rsum-Lsum)
if Lsum!=Rsum:
    Rlist[-1]+=(Lsum-Rsum)
anstr=""
for i in range(len(Llist)):
    a,b=Llist[i],Rlist[i]
    anstr+="("*a
    anstr+=")"*b
print(anstr)

Buggy submission (verdict: Runtime Error):
#insertion
n=int(input())
s=input()
count=1
countlist=[]
s=s+"X"
for i  in range(n):
    if s[i]==s[i+1]:
        count+=1
    else:
        if s[i]=="(":
            countlist.append((count,"L"))
        else:
            countlist.append((count,"R"))
        count=1

if len(countlist)%2==0 and countlist[0][1]=="L":
    pass
elif len(countlist)%2!=0 and countlist[0][1]=="L":
    countlist.append((countlist[-1][0],"R"))
elif len(countlist)%2==0 and countlist[0][1]=="R":
    countlist.append(countlist[-1][0],"R")
    countlist=[(countlist[0][0],"L")]+countlist
elif len(countlist)%2!=0 and countlist[0][1]=="R":
    countlist=[(countlist[0][0],"L")]+countlist

ans=""
for i in range(0,len(countlist),2):
    x=max(countlist[i][0],countlist[i+1][0])
    ans=ans+"("*x+")"*x
print(ans)
Problem p03713 (python)

Fixed submission:
h,w=map(int,input().split())
if h%3==0 or w%3==0:
    print(0)
if h%3!=0 and w%3!=0:
    ansh=h*w
    for j in range(1,h):
        area1=w*j
        number=w//2
        area2=(h-j)*number
        area3=(h-j)*(w-number)
        check=max(abs(area1-area2),abs(area1-area3),abs(area2-area3))
        if check<ansh:
            ansh=check
        else:
            continue  
    answ=w*h
    for j in range(1,w):
        area1=h*j
        number=h//2
        area2=(w-j)*number
        area3=(w-j)*(h-number)
        check=max(abs(area1-area2),abs(area1-area3),abs(area2-area3))
        if check<answ:
            answ=check
        else:
             continue
    print(min(ansh,answ,w,h))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
if h%3==0:
    print(0)
if w%3==0:
    print(0)
else:
    ansh=h*w
    for j in range(1,h):
        area1=w*j
        number=w//2
        area2=(h-j)*number
        area3=(h-j)*(w-number)
        check=max(abs(area1-area2),abs(area1-area3),abs(area2-area3))
        if check<ansh:
            ansh=check
        else:
            continue  
    answ=w*h
    for j in range(1,w):
        area1=h*j
        number=h//2
        area2=(w-j)*number
        area3=(w-j)*(h-number)
        check=max(abs(area1-area2),abs(area1-area3),abs(area2-area3))
        if check<answ:
            answ=check
        else:
            continue
print(min(ansh,answ))
Problem p03714 (python)

Fixed submission:
# 3 N numbers
import heapq
N = int(input())
a = list(map(int, input().split()))
S = sum(a[:N])
b = a[:N]
heapq.heapify(b)
dpmax = [S for i in range(N+1)]
# dpmax[x] = 前半　ｘ + N このうちmax N　このわを記録
for i in range(N, 2*N):
    heapq.heappush(b, a[i])
    d = heapq.heappop(b)
    S += a[i]-d
    dpmax[i-N+1] = S

c = a[-N:]
for i in range(N):
    c[i] = -c[i]
T = sum(c)
heapq.heapify(c)
dpmin = [-T for i in range(N+1)]

# dpmin[x]= 後半　x + N このうち　min Nこのわを記録する
for i in range(N, 2*N):
    heapq.heappush(c, -a[-1-i])
    d = heapq.heappop(c)
    T += -a[-1-i]-d
    dpmin[i+1-N] = -T

ans = -1000000000000000000000000000000
for i in range(N+1):
    ans = max(ans, dpmax[i]-dpmin[N-i])
print(ans)

Buggy submission (verdict: Runtime Error):
#3N numbers
n=int(input())
lists=list(map(int,input().split()))
second=lists.copy()
second=second[::-1]
for i in range(3*n):
    second[i]=-second[i]    
MAX=sum(lists[:n])
MIN=-sum(second[:n])
MAXlist=[0 for i in range(n+1)]
MINlist=[0 for i in range(n+1)]
MAXlist[0]=MAX
MINlist[0]=MIN
ANS=-10**100
import heapq
a=lists[:n]
b=second[:n]
heapq.heapify(a)  # リストを優先度付きキューへ
for j in range(n,2*n):
    heapq.heappush(a,lists[j])  # 要素の挿入    
    heapq.heappush(b,second[j])
    mini=heapq.heappop(a)  # 最小値の取り出し
    mini2=heapq.heappop(b)
    MAX-=mini
    MIN+=mini2
    MAX+=lists[j]
    MIN-=second[j]
    MAXlist[j+1-n]=MAX
    MINlist[j+1-n]=MIN
MINlist=MINlist[::-1]
for i in range(n+1):
    ANS=max(ANS,MAXlist[i]-MINlist[i])
print(ANS)
Problem p03739 (python)

Fixed submission:
#sequence
n=int(input())
lists=list(map(int,input().split()))
a=0
sum1=0
#奇数番目の項が-,偶数番目の項が＋の場合の最小値
for i in range(n):
    sum1+=lists[i]
    if i%2==0:
        if sum1>=0:
            a+=(sum1+1)
            sum1=-1
        elif sum1<0:
            pass
    elif  i%2!=0:
        if sum1<=0:
            a+=(1-sum1)
            sum1=1
        elif sum1>0:
            pass

b=0
#奇数番目の項が＋、偶数番目の項が−の場合の最小値
sum2=0
for i in range(n):
    sum2+=lists[i]
    if i%2!=0:
        if sum2>=0:
            b+=(sum2+1)
            sum2=-1
        elif sum2<0:
            pass
    elif  i%2==0:
        if sum2<=0:
            b+=(1-sum2)
            sum2=1
        elif sum2>0:
            pass
print(min(a,b))

Buggy submission (verdict: Runtime Error):
n=int(input())
N=list(map(int,input().split()))
emptylists=[]
number=0
for i in range(n):
	number+=N[i]
    emptylists.append(number)
ans1=0
use=0
for i in range(n):
    #偶数番が正、奇数番が負の時
    if i%2==0:
        #奇数番め
        if emptylists[i]+use<0:
            continue
        if emptylists[i]+use>=0:
            ans1+=emptylists[i]+1  
            use=use-emptylists[i]-1
        
    if i%2!=0:
        #偶数番め
        if emptylists[i]+use>0:
            continue
        if emptylists[i]+use<=0:
            ans1+=1-emptylists[i]-use
            use=use+1-emptylists[i]
ans2=0
uses=0
for i in range(n):
    #偶数番が負、奇数番が正の時
    if i%2!=0:
        #ぐう数番め
        if emptylists[i]<0:
            continue
        if emptylists[i]>=0:
            ans2+=emptylists[i]+1  
            uses=uses-emptylists[i]-1       
    if i%2==0:
        #き数番め
        if emptylists[i]>0:
            continue
        if emptylists[i]<=0:
            ans2+=1-emptylists[i]-uses
            uses=uses+1-emptylists[i]
print(min(ans1,ans2))
Problem p03779 (python)

Fixed submission:
x=int(input())
i=0
while i<=10**5:
    if int(i*(i-1)/2)<x<=int(i*(i+1)/2):
        print(i)
        break
    else:
        i+=1

Buggy submission (verdict: Runtime Error):
x=int(input())
for i in range(10**5):
	if int(i*(i-1)/2)<x<=int(i*(i+1)/2):
    	print(i)
        break

Buggy submission (verdict: Runtime Error):
 x=int(input())
for i in range(10**5):
    if int(i*(i-1)/2)<x<=int(i*(i+1)/2):
        print(i)
        break
Problem p03837 (python)

Fixed submission:
# cadidates of no shortest paths
n, m = map(int, input().split())

d = [[float("inf") for i in range(n + 1)] for i in range(n + 1)]
edge_data=[]
connect={i:[] for i in range(1,n+1)}
for i in range(m):
    x, y, z = map(int, input().split())
    # 有向グラフか無向グラフかによってここで場合わけが生じる
    d[x][y] = z
    d[y][x] = z
    connect[x].append(y)
    connect[y].append(x)    
    edge_data.append((x,y,z))
for i in range(n + 1):
    d[i][i] = 0  # 自身のところに行くコストは０


def warshall_floyd(d):
    # d[i][j]=i番目の頂点からj番目の頂点までの最短距離
    for k in range(1, n + 1):
        for i in range(1, n + 1):
            for j in range(1, n + 1):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

warshall_floyd(d)

#最短距離を求めた
cnt=0
for some in edge_data:
    x,y,z=some[0],some[1],some[2]
    if d[x][y]<z:
        cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
# cadidates of no shortest paths
n, m = map(int, input().split())

d = [[float("inf") for i in range(n + 1)] for i in range(n + 1)]
edge_data=[]
connect={i:[] for i in range(1,n+1)}
for i in range(m):
    x, y, z = map(int, input().split())
    # 有向グラフか無向グラフかによってここで場合わけが生じる
    d[x][y] = z
    d[y][x] = z
    connect[x].append(y)
    connect[y].append(x)    
    edge_data.append((x,y,z))
for i in range(n + 1):
    d[i][i] = 0  # 自身のところに行くコストは０


def warshall_floyd(d):
    # d[i][j]=i番目の頂点からj番目の頂点までの最短距離
    for k in range(1, n + 1):
        for i in range(1, n + 1):
            for j in range(1, n + 1):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

warshall_floyd(d)

#最短距離を求めた
cnt=0
for some in edge_data:
    x,y,zsome[0],some[1],some[2]
    if d[x][y]<z:
        cnt+=1
print(cnt)
Problem p03964 (python)

Fixed submission:
n=int(input())
lists=[]
import math
for i in range(n):
    a,t=map(int,input().split())
    lists.append([a,t])
x=1
y=1
for i in range(n):
    j=max((x-1)//lists[i][0]+1,(y-1)//lists[i][1]+1)
    x=lists[i][0]*j
    y=lists[i][1]*j
print(x+y)

Buggy submission (verdict: Runtime Error):
#greedy方法
import fractions
n=int(input())
lists=[]
for x in range(n):
    x,y=map(int,input().split())
    lists.append([x,y])
lists.append([1,1])
a=lists[0][0]
b=lists[0][1]
k=0
cnt=0
while cnt<n:
    k=max(fractions.ceil(a/lists[cnt+1][0]),fractions.ceil(b/lists[cnt+1][1]))
    a=lists[cnt+1][0]*k
    b=lists[cnt+1][1]*k   
    cnt+=1    
print(a+int(a*(min(lists[n-1][0],lists[n-1][1])/max(lists[n-1][0],lists[n-1][1])) ))
Problem p03965 (python)

Fixed submission:
#D-atcoderくんと変なジャンケン
s=input()+"g"+"p"
import collections
S=dict(collections.Counter(s))
a=S["p"]-1
b=S["g"]-1
x=((a+b)//2)
print(x-a)

Buggy submission (verdict: Runtime Error):
#D-atcoderくんと変なジャンケン
s=input()
import collections
S=dict(collections.Counter(s))
a=S["p"]
b=S["g"]
x=((a+b)//2)
print(x-a)
Problem p04046 (python)

Fixed submission:
# D　イロハちゃんと升目
cnt=0
h,w,a,b=map(int,input().split())
def find_power(n):
    # 0!からn!までのびっくりを出してくれる関数
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(10**9+7)
    return powlist

def find_inv_power(n):
    #0!からn!までの逆元を10**9+7で割ったあまりリストを作る関数
    powlist=find_power(n)
    check=powlist[-1]
    first=1
    uselist=[0]*(n+1)
    secondlist=[0]*30
    secondlist[0]=check
    secondlist[1]=check**2
    for i in range(28):
        secondlist[i+2]=(secondlist[i+1]**2)%(10**9+7)
    a=format(10**9+5,"b")
    for j in range(30):
        if a[29-j]=="1":
            first=(first*secondlist[j])%(10**9+7)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(10**9+7)
    return uselist

powlist=find_power(h+w+1)
invlist=find_inv_power(h+w+1)
def combi(n,r):
    a=powlist
    b=invlist
    if n<r:
        return 0
    elif n>=r:
        return (a[n]*b[r]*b[n-r])%(10**9+7)

for i in range(h-a):
    cnt+=(combi(b+i-1,i)*combi(w+h-2-b-i,h-1-i))%(10**9+7)
print(cnt%(10**9+7))

Buggy submission (verdict: Runtime Error):
from math import gamma
cnt=0
h,w,a,b=map(int,input().split())
for k in range(0,h-a):
    cnt+= (int((gamma(b+k)*gamma(h+w-k-b-1))/(gamma(k+1)*gamma(b)*gamma(w-b)*gamma(h-k))))//(10^9+7)
print(cnt)
Problem p02628 (python)

Fixed submission:
n, k = input().split(" ")
n = int(n)
k = int(k)
a = [int(x) for x in input().split(" ")]
a.sort()
ans = 0
for i in range(k):
 ans += int(a[i])
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = input().split(" ")
n = int(n)
k = int(k)
a = input.split(" ")
a = sorted(a)
ans = 0
for i in range(k):
 ans += int(a[i])
print(ans)
Problem p02639 (python)

Fixed submission:
r = 1
for i in input().split(' '):
 r ^= int(i)
print(r)

Buggy submission (verdict: Runtime Error):
r = 1
for i in range(input().split(' ')):
 r ^= int(i)
print(r)
Problem p02640 (python)

Fixed submission:
x, y = input().split(" ")
x = int(x)
y = int(y)
print("Yes" if 2*x <= y and y <= 4*x and y%2 == 0 else "No")

Buggy submission (verdict: Runtime Error):
x, y = input().split(" ")
x = int(x)
 y = int(y)
print("Yes" if 2*x <= y and y <= 4*x and y%2 == 0 else "No")
Problem p02865 (python)

Fixed submission:
print((int(input())-1)//2)

Buggy submission (verdict: Runtime Error):
print(int(input()-1)//2)
Problem p02957 (python)

Fixed submission:
a, b = [int(i) for i in input().split(" ")]
print("IMPOSSIBLE" if (a+b)%2 else (a+b)//2)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
q = 0
for i in range(n):
 for j in range(i+1, n):
  t = a[i]
  a[i] = a[j]
  a[j] = t
  f = 1  
  lst = - 1100
  for k in a:
   f &= k > lst
   lst = k
  q |= f
  t = a[i]
  a[i] = a[j]
  a[j] = t
print("YES" if q else "NO")
Problem p02958 (python)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
q = 0
for i in range(n):
 for j in range(i, n):
  t = a[i]
  a[i] = a[j]
  a[j] = t
  f = 1  
  lst = - 1100
  for k in a:
   f &= k > lst
   lst = k
  q |= f
  t = a[i]
  a[i] = a[j]
  a[j] = t
print("YES" if q else "NO")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for in input().split()]
t = 0
for i in range(n):
 for j in range(i+1,n):
  t += a[i] > a[j]
print("YES" if t < 2 else "NO")
Problem p03145 (python)

Fixed submission:
a, b, c = [int(i) for i in input().split()]
if a >= b and a >= c:
 print(c*b//2)
elif b >= c and b >= a:
 print(a*c//2)
else:
 print(a*b//2)

Buggy submission (verdict: Runtime Error):
a, b, c = [int(i) for i in input().split()]
if a >= b and a >= c:
 print(c*b//2)
else if b >= c and b >= a:
 print(a*c//2)
else:
 print(a*b//2)

Buggy submission (verdict: Runtime Error):
a, b, c = [int(i) for i in input().split()]
if a >= b and a >= c:
 print(c*b//2)
else if b >= c and b >= a:
 print(a*c//2)
else
 print(a*b//2)
Problem p02957 (python)

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

sum = a + b
if sum % 2 == 1:
  print("IMPOSSIBLE")
else:
  print(sum // 2)

Buggy submission (verdict: Runtime Error):
N = int(input())
mnstr = list(map(int, input().split()))
yusha = list(map(int, input().split()))
sum = 0
killed = 0

for i in range(N):
  killedtemp1 = min(mnstr[i], yusha[i])#iの勇者が倒したモンスターiの数
  yusha[i] = max(0, yusha[i]-mnstr[i])
  killedtemp2 = min(mnstr[i+1], yusha[i])#iの勇者が倒したモンスターi+1の数
  mnstr[i+1] = mnstr[i+1] - killedtemp2
  killed += killedtemp1 + killedtemp2
  
print(killed)
Problem p02981 (python)

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

print(min(A*N, B))

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())

Lmod = L%2019
Rmod = R%2019

i = Lmod
j = i + 1

for k in range(L, R+1):
  if (k%2019) == 0:
    print(0)
    break
  elif k < R:
	continue
  else:
	print((i*j)%2019)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())

Lmod = L%2019
Rmod = R%2019

i = Lmod
j = i + 1

for k in range(L, R+1):
  if (k%2019) == 0:
    print(0)
    break
  elif (k < R):
  	continue
  else:
    print((i*j)%2019)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())

Lmod = L%2019
Rmod = R%2019

i = Lmod
j = i + 1

print((i*j)%2019)
Problem p02999 (python)

Fixed submission:
X, A = map(int, input().split())

if X < A:
  print(0)
else:
  print(10)

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

if X < A:
  print(0)
else:
  print(10)
Problem p03071 (python)

Fixed submission:
x, y = map(int, input().split())

print(max(x, y) + max(max(x, y)-1, min(x,y)))

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())

print(max(x, y) + max(max(x, y)-1, min(x,y))

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())

print(max(x, y) + max(max(x, y)-1, min(x,y))