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

Fixed submission:
import bisect

a=[]
s=[]
def asff(a,b,s,n):
    m=bisect.bisect(a,b)
    if m<=0:
        asf=-n*b+s[n-1]
    elif m<n:
        asf=(2*m-n)*b+s[n-1]-2*s[m-1]
    elif n<=m:
        asf=n*b-s[n-1]
    return asf

n=int(input())
a=list(map(int,input().split()))

#n=5
#stra="2 2 3 5 5"
#ans=2

#n=9
#stra="1 2 3 4 5 6 7 8 9"
#ans=0

#n=6
#stra="6 5 4 3 2 1"
#ans=18

#n=7
#stra="1 1 1 1 2 3 4"
#ans=6

#a=list(map(int,stra.split()))

for i in range(n):
    a[i]=a[i]-i-1
#print(a)
a.sort()

s=[a[0]]
for i in range(1,n):
    s.append(s[i-1]+a[i])
    
bmin=min(a)-n
bmax=max(a)+n

b1=bmin
b5=bmax+1
b2=b1+int((b5-b1)/4)
b3=b1+int((b5-b1)/2)
b4=b1+int((b5-b1)/4*3)
#b2=b1+(b5-b1)//4
#b3=b1+(b5-b1)//4*2
#b4=b1+(b5-b1)//4*3
#print("b1",b1,"b5",b5)
    
asmin=bmax*n
#m0=0
m1=bisect.bisect(a,bmin)


while b1+1<b5:
    c=[]
    c.append([asff(a,b1,s,n),b1])
    c.append([asff(a,b2,s,n),b2])
    c.append([asff(a,b3,s,n),b3])
    c.append([asff(a,b4,s,n),b4])
    c.append([asff(a,b5,s,n),b5])
    c.sort()
    asf=c[0][0]
    d=[]
    d.append(c[0][1])
    d.append(c[1][1])
    d.append(c[2][1])
    d.sort()
    b1=d[0]
    b5=d[2]
    b2=b1+int((b5-b1)/4)
    b3=b1+int((b5-b1)/2)
    b4=b1+int((b5-b1)/4*3)
    
#    print("b1",b1,"b5",b5,"d0",d[0],"asf",asf)
    if asf<asmin:
        asmin=asf

print(asmin)

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

#n=5
#stra="2 2 3 5 5"
#ans=2

#n=9
#stra="1 2 3 4 5 6 7 8 9"
#ans=0

#n=6
#stra="6 5 4 3 2 1"
#ans=18

#n=7
#stra="1 1 1 1 2 3 4"
#ans=6

#a=list(map(int,stra.split()))

for i in range(n):
    a[i]=a[i]-i-1
#print(a)
a.sort()

s=[a[0]]
for i in range(1,n):
    s.append(s[i-1]+a[i])
    
bmin=min(a)-n
bmax=max(a)+n

  
asmin=bmax*n
m0=0
for b in range(bmin,bmax+1):
    m=bisect.bisect(a,b)
    if m<=0:
        asf=-n*b+s[n-1]
    elif m<n:
        asf=(2*m-n)*b+s[n-1]-2*s[m-1]
    elif n<=m:
        asf=n*b-s[n-1]
        
#    print("b",b,"m",m,"asf",asf)
    if asf<asmin:
        asmin=asf

print(asmin)
Problem p03323 (python)

Fixed submission:
a,b=map(int,input().split())
if a<=8 and b<=8:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split()
if a<=8 and b<=8:
    print("Yay!")
else:
    print(":(")
Problem p03380 (python)

Fixed submission:

from bisect import bisect_left,bisect

n=int(input())
a=list(map(int,input().split()))

a.sort()
ai=max(a)


#if ai%2==0:
#    ai2=ai//2+1
#else:
#    ai2=ai//2
ai2=ai/2

jj=bisect(a,ai2)

if jj+1<n:
    if abs(a[jj]-ai2)>abs(a[jj+1]-ai2):
        jj=jj+1
if jj-1>=0:
    if abs(a[jj]-ai2)>abs(a[jj-1]-ai2):
        jj=jj-1
    
if jj==n-1:
    jj=jj-1
    
aj=a[jj]

print(ai,aj)

Buggy submission (verdict: Runtime Error):

from bisect import bisect_left,bisect

n=int(input())
a=list(map(int,input().split()))

a.sort()
ai=max(a)


if ai%2==0:
    ai2=ai//2-1
else:
    ai2=ai//2

jj=bisect(a,ai2)

if jj+1<n:
    if abs(a[jj]-ai2)>abs(a[jj+1]-ai2):
        jj2=jj+1
if jj-1>=0:
    if abs(a[jj]-ai2)>abs(a[jj-1]-ai2):
        jj2=jj-1
    
if jj2==n-1:
    jj2=jj2-1
    
aj=a[jj2]

print(ai,aj)

Buggy submission (verdict: Runtime Error):

from bisect import bisect_left,bisect

n=int(input())
a=list(map(int,input().split()))

a.sort()
ai=max(a)


if ai%2==0:
    ai2=ai//2-1
else:
    ai2=ai//2

jj=bisect(a,ai2)

if abs(a[jj]-ai2)>abs(a[jj-1]-ai2):
    jj=jj+1
    
if jj==n-1:
    jj=jj-1
    
aj=a[jj]

print(ai,aj)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left,bisect

n=int(input())
a=list(map(int,input().split()))

a.sort()
ai=max(a)


if ai%2==0:
    ai2=ai//2-1
else:
    ai2=ai//2

jj=bisect(a,ai2)

if abs(a[jj]-ai2)>abs(a[jj+1]-ai2):
    jj=jj+1
    
if jj==n-1:
    jj=jj-1
    
aj=a[jj]

print(ai,aj)
Problem p03503 (python)

Fixed submission:
icase=0
if icase==0:
    n=int(input())

    f=[]
    for i in range(n):
        fi=list(map(int,input().split()))
        f.append(fi)
    p=[]
    for i in range(n):
        pi=list(map(int,input().split()))
        p.append(pi)
elif icase==1: 
    n=1
    f=[[1, 1, 0, 1, 0, 0, 0, 1, 0, 1]]
    p=[[3, 4, 5, 6, 7, 8, 9, -2, -3, 4, -2]]
elif icase==2: 
    n=2
    f=[[1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]]
    p=[[0, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1],
       [0, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1]]
elif icase==3: 
    n=3
    f=[[1, 1, 1, 1, 1, 1, 0, 0, 1, 1],
       [0, 1, 0, 1, 1, 1, 1, 0, 1, 0],
       [1, 0, 1, 1, 0, 1, 0, 1, 0, 1]]
    p=[[-8, 6, -2, -8, -8, 4, 8, 7, -6, 2, 2],
       [-9, 2, 0, 1, 7, -5, 0, -2, -6, 5, 5],
       [6, -6, 7, -9, 6, -5, 8, 0, -9, -7, -7]]
    
import itertools
sumpmax=-10**11
for i in itertools.product([0,1], repeat=10):
    r=list(i)
    sump=0
    if sum(r)!=0:
        for jj in range(n):
            ci=0
            for j in range(10):
                ci=ci+r[j]*f[jj][j]
            sump=sump+p[jj][ci]
#            print(sump,r)
        sumpmax=max(sump,sumpmax)
print(sumpmax)

Buggy submission (verdict: Runtime Error):

icase=0
if icase==0:
    n=int(input())

    f=[]
    for i in range(n):
        fi=map(int,input().split())
        f.append(fi)
    p=[]
    for i in range(n):
        pi=map(int,input().split())
        p.append(pi)
elif icase==1: 
    n=1
    f=[[1, 1, 0, 1, 0, 0, 0, 1, 0, 1]]
    p=[[3, 4, 5, 6, 7, 8, 9, -2, -3, 4, -2]]
elif icase==2: 
    n=2
    f=[[1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]]
    p=[[0, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1],
       [0, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1]]
elif icase==3: 
    n=3
    f=[[1, 1, 1, 1, 1, 1, 0, 0, 1, 1],
       [0, 1, 0, 1, 1, 1, 1, 0, 1, 0],
       [1, 0, 1, 1, 0, 1, 0, 1, 0, 1]]
    p=[[-8, 6, -2, -8, -8, 4, 8, 7, -6, 2, 2],
       [-9, 2, 0, 1, 7, -5, 0, -2, -6, 5, 5],
       [6, -6, 7, -9, 6, -5, 8, 0, -9, -7, -7]]
    
import itertools
sumpmax=-10**11
for i in itertools.product([0,1], repeat=10):
    r=list(i)
    sump=0
    if sum(r)!=0:
        for jj in range(n):
            ci=0
            for j in range(10):
                ci=ci+r[j]*f[jj][j]
            sump=sump+p[jj][ci]
#            print(sump,r)
        sumpmax=max(sump,sumpmax)
print(sumpmax)
Problem p03548 (python)

Fixed submission:
icase=0
if icase==0:
    x,y,z=map(int,input().split())
    n=x//(y+z)
    if x%(y+z)>=z:
        print(n)
    else:
        print(n-1)

Buggy submission (verdict: Runtime Error):
icase=0
if icase==0:
    x,y,z=map(int,input().split())
    n=x//(y+z)
    if x%(y+z)>=z:
        print(n)
    else:
        print(n-1
Problem p03557 (python)

Fixed submission:
icase=0
if icase==0:
    n=int(input())  #数値入力 「N」だけの入力のとき
    a=list(map(int, input().split()))
    b=list(map(int, input().split()))
    c=list(map(int, input().split()))
elif icase==1:
    n=2
    a=[1,5]
    b=[2,4]
    c=[3,6]
elif icase==2:
    n=6
    a=[3, 14, 159, 2, 6, 53]
    b=[58, 9, 79, 323, 84, 6]
    c=[2643, 383, 2, 79, 50, 288]
    
a.sort()
b.sort()
c.sort()
   
icnt=0
ast=0
cst=0
for i in range(n):
    if a[n-1]<=b[i]:
        ast=n
#        print("a1:",ast-1,a[ast-1],i,b[i])
    elif a[0]>=b[i]:
        ast=0
#        print("a1:",ast-1,a[ast-1],i,b[i])
    else:
        while a[ast]<b[i] and ast<n-1:
            ast=ast+1
#            print("a2:",ast-1,a[ast-1],i,b[i])
    if b[i]<c[0]:
        cst=0 
    elif b[i]>=c[n-1]:
        cst=n 
#        print("c1:",cst,c[cst],i,b[i])
    else:
        while b[i]>=c[cst] and cst<n-1:
            cst=cst+1
#            print("c2:",cst-1,c[cst-1],i,b[i])
#    print(ast,i,n-cst)
    icnt=icnt+(ast)*(n-cst)
    
print(icnt)

Buggy submission (verdict: Runtime Error):
icase=0
if icase==0:
    n=int(input())  #数値入力 「N」だけの入力のとき
    a=[]
    b=[]
    c=[]
    for i in range(n):
       ai,bi,ci=map(int, input().split())
       a.append(ai)
       b.append(bi)
       c.append(ci)
elif icase==1:
    n=2
    a=[1,5]
    b=[2,4]
    c=[3,6]
elif icase==2:
    n=6
    a=[3, 14, 159, 2, 6, 53]
    b=[58, 9, 79, 323, 84, 6]
    c=[2643, 383, 2, 79, 50, 288]
    
a.sort()
b.sort()
c.sort()
   
icnt=0
ast=0
cst=0
for i in range(n):
    if a[n-1]<=b[i]:
        ast=n
#        print("a1:",ast-1,a[ast-1],i,b[i])
    else:
        while a[ast]<b[i] and ast<n-1:
            ast=ast+1
#            print("a2:",ast-1,a[ast-1],i,b[i])
    if b[i]<c[0]:
        cst=0 
#        print("c1:",cst,c[cst],i,b[i])
    else:
        while b[i]>=c[cst] and cst<n-1:
            cst=cst+1
#            print("c2:",cst-1,c[cst-1],i,b[i])
#    print(ast,i,n-cst)
    icnt=icnt+(ast)*(n-cst)
    
print(icnt)
Problem p03607 (python)

Fixed submission:
dicc=dict()

n=int(input())
for i in range(n):
    ai=input()
    if ai in dicc:
        dicc[ai]=1-dicc[ai]
    else:
        dicc[ai]=1
        
icnt=0    
for i in dicc.values():
    icnt=icnt+i
      
print(icnt)

Buggy submission (verdict: Runtime Error):
c=[1]*(10**9)
a=[]
n=int(input())
for i in range(n):
    ai=int(input())-1
    c[ai]=1-c[ai]
    a.append(ai)
    
icnt=0
for i in range(n):
  if c[a[i]]==0:
      icnt=icnt+1
      
print(icnt)

Buggy submission (verdict: Runtime Error):
nmax=10**9+1
c=[1]*nmax
a=[]
n=int(input())
for i in range(n):
    ai=int(input())-1
    c[ai]=1-c[ai]
    a.append(ai)
    
icnt=0
for i in range(n):
  if c[a[i]]==0:
      icnt=icnt+1
      
print(icnt)

Buggy submission (verdict: Runtime Error):
c=[1]*100000
n=int(input())
for i in range(n):
    ai=int(input())-1
    c[ai]=1-c[ai]
    
icnt=0
for i in range(100000):
  if c[i]==0:
      icnt=icnt+1
      
print(icnt)
Problem p03739 (python)

Fixed submission:
n=int(input())

a=list(map(int,input().split()))

kp=0
asum=0
flag=-1
for i in range(n):
    asum=asum+a[i]
    if flag==-1:
        if asum>=0:
            kp=kp+asum+1
            asum=-1
    else:
        if asum<=0:
            kp=kp+1-asum
            asum=1
    flag=-flag
#    print(asum)
#print("-----",kp)            
km=0
asum=0
flag=1
for i in range(n):
    asum=asum+a[i]
    if flag==-1:
        if asum>=0:
            km=km+asum+1
            asum=-1
    else:
        if asum<=0:
            km=km+1-asum
            asum=1
    flag=-flag
#    print(asum)
#print("-----",km)            

print(min(kp,km))

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

#      0  1  2  3  evn odd
# kevn +  -  +  -   +   -
# kodd -  +  -  +   -   +
def kf(a,flag):
    a0=a[0]*flag
    if a0<=0:
        kevn=1-a0
        sevn=1
    elif a0>0:
        kevn=0
        sevn=a0

    for i in range(1,n):
        ai=a[i]*flag
        if i%2==0:
            if sevn+ai<=0:
                kevn=kevn+1-(ai+sevn)
                sevn=1
            elif sevn+ai>0:
                kevn=kevn
                sevn=sevn+ai
        elif i%2==1:
            if sevn+ai<0:
                kevn=kevn
                sevn=sevn+ai
            elif sevn+ai>=0:
                kevn=kevn+1+(ai+sevn)
                sevn=-1
    return kevn

kevn1=kf(a,1,n)
kevn=kf(a,-1,n)

kevn=min(kevn,kevn1)

print(kevn)
Problem p03853 (python)

Fixed submission:
icase=0
if icase==0:
    h,w=map(int,input().split())
#    xy=[[1]*w for i in range(2*h)]
    for i in range(h):
        cij=input()
        print(cij)
        print(cij)

Buggy submission (verdict: Runtime Error):
icase=0
if icase==0:
    w,h=map(int,input().split())
#    xy=[[1]*w for i in range(2*h)]
    for i in range(h):
        cij=input()
        print(cij)
        print(cij)
Problem p02582 (python)

Fixed submission:
import sys

S=input()
ans=0
ans=S.count("R")
if ans==2 and S[1]=="S":
    print("1")
    sys.exit()
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import math
X,K,D = map(int, input().split()) 
X1=abs(X)
syou=math.floor(X1/D)
amari=math.floor(K/syou)
ans=0
if amari==0:
    ans=X1-D*K
else:
    ya=math.floor(K/amari)
    ans=X1-ya*D
    if ya%2==0:
        print(ans)
        sys.exit()
    if abs(ans+D)>abs(ans-D):
        ans=ans-D
    else:
        ans=ans+D
print(abs(ans))
Problem p02664 (python)

Fixed submission:
T=input()
T_len=len(T)
S=list(T)
if S[0]=="?":
    S[0]="D"
if S[-1]=="?":
    S[-1]="D"

for i in range(T_len):
    if S[i]=="?":
        if S[i-1]=="D" and (S[i+1]=="D" or S[i+1]=="?"):
            S[i]="P"
        else:
            S[i]="D"
str_changed = "".join(S)
print(str_changed)

Buggy submission (verdict: Runtime Error):
T=input()
T_len=len(T)
S=list(T)
if S[0]=="?":
    S[0]="D"

for i in range(T_len):
    if S[i]=="?":
        if S[i-1]=="D" and (S[i+1]=="D" or S[i+1]=="?"):
            S[i]="P"
        else:
            S[i]="D"
str_changed = "".join(S)
print(str_changed)
Problem p03497 (python)

Fixed submission:
import math
import sys
import collections
n,k = map(int, input().split())
A = list(map(int, input().split()))
count=len(A)
Adel=list(set(A))
ans=len(Adel)-k
#print(Adel)
if ans<0:
    ans=0
    print(ans)
    sys.exit()
newA=collections.Counter(A)
count=list(newA.values())
count.sort()
#print(count)
ans=sum(count[:-k])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import sys
import collections
n,k = map(int, input().split())
A = list(map(int, input().split()))
count=len(A)
Adel=list(set(A))
ans=len(Adel)-k
#print(Adel)
if ans<0:
    ans=0
    print(ans)
    sys.exit()
newA=collections.Counter(A)
ans=len(Adel)
Aans=n
for i in range(k+1):
    count=newA.most_common()[i][i]
    #print(count)
    ans=ans-1
    Aans=Aans-count
    if ans==k:
        print(n-Aans)
        sys.exit()
    #print(count)
#print(newA)
#print(A)
Problem p02573 (python)

Fixed submission:
import sys
sys.setrecursionlimit(200000+10)

N,M  = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]

class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
            # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

UF = UnionFind(N)
li = [i for i in range(N+20)]

for i in range(len(AB)):
    AB[i][0] -= 1
    AB[i][1] -= 1
    UF.Unite(AB[i][0], AB[i][1])

cnt = [UF.Count(i) for i in range(N)]
print(max(cnt))

Buggy submission (verdict: Runtime Error):
N,M  = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]

#xの木の根を求める
def root(x,li): 
    if li[x] == x:
        return x
    else:
        li[x] = root(li[x],li)
        return li[x]

#xとyが同じ集合に属するかの判定
def find(x,y,li):
    return root(x,li) == root(y,li)

#xとｙを併合
def union(x,y,li):
    x = root(x,li)
    y = root(y,li)
    if x==y:
        return
    else:
        li[x] = y

li = [i for i in range(N+20)]

for i in range(len(AB)):
    AB[i][0] -= 1
    AB[i][1] -= 1
    union(AB[i][0], AB[i][1], li)

for i in range(N):
    root(i, li)

cnt = [0 for i in range(N+20)]
for i in range(N):
    cnt[li[i]] += 1
print(max(cnt))

Buggy submission (verdict: Runtime Error):
N,M  = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]

#xの木の根を求める
def root(x,li): 
    if li[x] == x:
        return x
    else:
        li[x] = root(li[x],li)
        return li[x]

#xとyが同じ集合に属するかの判定
def find(x,y,li):
    return root(x,li) == root(y,li)

#xとｙを併合
def union(x,y,li):
    x = root(x,li)
    y = root(y,li)
    if x==y:
        return
    else:
        li[x] = y

li = [i for i in range(N)]

for i in range(len(AB)):
    AB[i][0] -= 1
    AB[i][1] -= 1
    union(AB[i][0], AB[i][1], li)

for i in range(N):
    root(i, li)

cnt = [0 for i in range(N)]
for i in range(N):
    cnt[li[i]] += 1
print(max(cnt))
Problem p02677 (python)

Fixed submission:
import math

A,B,H,M = map(int,input().split())

H = (H*360/12)+(M*30/60)
M = M*360/60

a = abs(H-M)
# print(a)
ans = math.sqrt((A**2)+(B**2)-2*A*B*math.cos(math.radians(a)))
print(ans)

Buggy submission (verdict: Runtime Error):
import math

A,B,H,M = map(int,input().split())

H = (H*360/12)+(M*30/60)
M = M*360/60

a = abs(H-M)
# print(a)
ans = math.sqrt((A**2)+(B**2)-2*A*B*math.cos(math.radians(a)))
print(ans)

mm = (A**2+B**2-(4.56425719433**2))/(2*A*B)
# print(mm)
mm = math.acos(mm)
mm = math.degrees(mm)
# print(mm)
Problem p02691 (python)

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

li1 = [i+1-A[i] for i in range(N)]
li2 = [A[i]+i+1 for i in range(N)]

cnt = [0 for i in range(2*N+1)]
for i in li2:
    if i<len(cnt)-1:
        cnt[i] += 1

ans = 0
for i in li1:
    if i>=0:
        ans += cnt[i]
print(ans)

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

li1 = [i+1-A[i] for i in range(N)]
li2 = [A[i]+i+1 for i in range(N)]

cnt = [0 for i in range(2*N+1)]
for i in li2:
    cnt[i] += 1

ans = 0
for i in li1:
    if i>=0:
        ans += cnt[i]
print(ans)
Problem p02761 (python)

Fixed submission:
import sys

N,M = map(int,input().split())
li = [-1 for i in range(3)]

if M==0 and N==1:
    print(0)
elif M==0 and N==2:
    print(10)
elif M==0 and N==3:
    print(100)
if M==0:
    sys.exit()

for i in range(M):
    s,c = map(int,input().split())


    if li[s-1]==-1 or li[s-1]==c:
        li[s-1] = c
    else:
        print(-1)
        break
else:
    ans = 0
    for i in range(N):
        mm = li[i]
        if li[i]==-1 and i!=0:
            li[i] = 0
        elif li[i]==-1 and i==0:
            li[i] = 1
        ans = ans * 10 + li[i]

    if c == 0 and s==1 and N >= 2:
        print(-1)
    elif c == 0 and s==1 and N==1:
        print(0)
    else:
        print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
li = [-1 for i in range(3)]

for i in range(M):
    s,c = map(int,input().split())


    if li[s-1]==-1 or li[s-1]==c:
        li[s-1] = c
    else:
        print(-1)
        break
else:
    ans = 0
    for i in range(N):
        mm = li[i]
        if li[i]==-1 and i!=0:
            li[i] = 0
        elif li[i]==-1 and i==0:
            li[i] = 1
        ans = ans * 10 + li[i]

    if c == 0 and s==1 and N >= 2:
        print(-1)
    elif c == 0 and s==1 and N==1:
        print(0)
    else:
        print(ans)
Problem p02924 (python)

Fixed submission:
n = int(input())

ans = ((n-1)*n)//2

print(ans)

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

ans = int((n-1)*n)/2)

print(ans)
Problem p02993 (python)

Fixed submission:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


a = list(input())

if a[0] == a[1] or a[1] == a[2] or a[2] == a[3]:
    print("Bad")
else:
    print("Good")

Buggy submission (verdict: Runtime Error):
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


s = list(input())

if a[0] == a[1] or a[1] == a[2] or a[2] == a[3]:
    print("Bad")
else:
    print("Good")
Problem p03000 (python)

Fixed submission:
#bin/usr/env python3

n, x = map(int,input().split())
length = input().split()

total_len = 0
for i in range(n):
    total_len += int(length[i])
    if total_len > x:
        print(i+1)
        break
    if i == n-1:
        print(n+1)

Buggy submission (verdict: Runtime Error):
#bin/usr/env python3

n, x = map(int,input().split())
length = input().split()

total_len = 0
for i in range(n):
    total_len += int(length[i])
    if total_len > x:
        print(i+1)
        break
    if i = n-1:
        print(n+1)
Problem p03007 (python)

Fixed submission:
#!/usr/bin/env python3

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()

    li = []
    mm1 = A[N-1]
    mm2 = A[0]
    i = 1
    while(i<N-1):
        if A[i]<=0:
            li.append([mm1,A[i]])
            mm1 -= A[i]
        else:
            li.append([mm2,A[i]])
            mm2 -= A[i]
        i += 1
    li.append([mm1,mm2])
    print(mm1-mm2)
    for i in range(N-1):
        print(*li[i])
    

        


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()

    li = []
    mm1 = A[N-1]
    mm2 = A[0]
    i = 1
    
    while(i<N-1):
        if A[i]<=0:
            li.append([mm1,A[i]])
            mm1 -= A[i]
        else:
            li.append([mm2,A[i]])
            mm2 -= A[i]
        i += 1
        li.append([mm1,mm2])
    print(mm1-mm2)
    for i in range(N-1):
        print(*li[i])

        


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

Fixed submission:
import itertools

n, m = map(int,input().split())

s = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))

li = [0,1]
ans = 0
for elm in itertools.product(li,repeat=n):
    for i in range(m):
        mm = 0
        for j in range(1,s[i][0]+1):
            if elm[s[i][j]-1]==1:
                mm += 1
        if mm%2!=p[i]:
            break
    else:
        ans += 1
        #print(elm)
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools

n, m = map(int,input().split())

s = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))

li = [0,1]
ans = 0
for elm in itertools.product(li,repeat=n):
    for i in range(n):
        mm = 0
        for j in range(len(s[i])-1):
            if elm[s[i][j]-1]==1:
                mm += 1
        if mm%2!=p[i]:
            break
    else:
        ans += 1
print(ans)
Problem p03061 (python)

Fixed submission:
#!/usr/bin/env python3

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

n = int(input())
a = list(map(int,input().split()))

memo1 = 10**9
memo2 = 10**9

lf = [0 for i in range(n)]
rgt = [0 for i in range(n)]

lf[0] = a[0]
rgt[0] = a[n-1]

for i in range(1,n):
	lf[i] = gcd(lf[i-1],a[i])
	rgt[i] = gcd(rgt[i-1],a[i*(-1)-1])


mx = 0
mx = max(mx,lf[n-2])
mx = max(mx,rgt[n-2])

for i in range(1,n-1):
	mx = max(mx,gcd(lf[i-1],rgt[i*(-1)-2]))

print(mx)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

import math

n = int(input())
a = input().split()
num1 = 10000000000
num2 = 10000000000

for i in range(n-1):
    w = math.gcd(int(a[i]),int(a[i+1]))
    if w < num1:
        num1 = w
    elif num1 <= w <= num2:
        num2 = w

if num2 == 10000000000:
    print(num1)
else:
    print(num2)
Problem p03110 (python)

Fixed submission:
#!/usr/bin/env python3

N = int(input())

data = []

for i in range(N):
    price = input().split()
    data.append(price) 

total = 0

for i in range(N):
    if data[i][1] == "JPY":
        total += int(data[i][0])
    elif data[i][1] == "BTC":
        total += 380000 * float(data[i][0])

print(total)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

N = float(input())

data = []

for i in range(N):
    price = input().split()
    data.append(price) 

total = 0

for i in range(N):
    if data[i][1] == "JPY":
        total += int(data[i][0])
    elif data[i][1] == "BTC":
        total += 380000 * float(data[i][0])

print(total)
Problem p03125 (python)

Fixed submission:
#!/usr/bin/env python3

A, B = map(int, input().split())

if B % A == 0:
    print(A + B)
else:
    print(B -A)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

A, B = map(int input().split())

if B % A == 0:
    print(A + B)
else:
    print(B -A)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

A B = map(int input().split())

if B % A == 0:
    print(A + B)
else:
    print(B -A)