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

Fixed submission:
i = [int(input().strip()) for i in range(5)]

mod = 10
last =1
for s in range(5):
	tmp = i[s] % 10
	if tmp!=0:
		if mod > tmp:
			mod=tmp
			last=s
sum=0
for s in range(5):
  if(s!=last):
    tmp=i[s] // 10
    mod=i[s] % 10
    if mod >0:
      sum+=tmp + 1
    else:
      sum+=tmp
print(sum*10 +i[last])

Buggy submission (verdict: Runtime Error):
i = [int(input().strip()) for i in range(5)]

mod = 10
for s in range(5):
	tmp = i[s] % 10
	if tmp!=0:
		if mod > tmp:
			mod=tmp
			last=s
sum=0
for s in range(5):
  if(s!=last):
    tmp=i[s] // 10
    mod=i[s] % 10
    if mod >0:
      sum+=tmp + 1
    else:
      sum+=tmp
print(sum*10 +i[last])
Problem p03085 (python)

Fixed submission:
a = input()

if a == 'A':
  print('T')
elif a == 'T':
  print('A')
elif a == 'G':
  print('C')
elif a == 'C':
  print('G')

Buggy submission (verdict: Runtime Error):
n, q = list(map(int, input().split()))
s = input()
for i in range(q):
  l,r = list(map(int, input().split()))
  print(s[(l - 1):r].count('AC'))
Problem p02909 (python)

Fixed submission:
wether = ['Sunny','Cloudy','Rainy']
S = input()

if S == wether[0]:
  print(wether[1])
elif S == wether[1]:
  print(wether[2])
else:
  print(wether[0])

Buggy submission (verdict: Runtime Error):
wether = ['Sunny','Cloudy','Rainy']
S = input()

if S == wether[0]:
  print(wether[1])
elif S == wether[1]:
  print(wether[2])
else:
  print(wether[3])

Buggy submission (verdict: Runtime Error):
wether = ['Sunny','Cloudy','Rainy']
S = int(input())

if S == wether[0]:
  print(wether[0])
elif S == wether[1]:
  print(wether[1])
else:
  print(wether[2])
Problem p02909 (python)

Fixed submission:
S = input()

Slist = ["Sunny", "Cloudy", "Rainy" ]

if S == Slist[0]:
    TS = Slist[1]
elif S == Slist[1]:
    TS = Slist[2]
else:
    TS = Slist[0]

print(TS)

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

for i in range(M):
    A.sort(reverse=True)
    A[0] //= 2

print(sum(A))
Problem p03047 (python)

Fixed submission:
N,K = list(map(int,input().split()))
num = N - K + 1
print(num)

Buggy submission (verdict: Runtime Error):
R,G,B,N = list(map(int,input().split()))
count = 0

for r in range(N+1):
    if r*R >= N+1:
        continue
    elif r*R == N:
        count += 1
        continue

    for g in range(N+1):
        if (r*R + g*G) >= N + 1:
            break
        elif (r*R + g*G) == N:
            count += 1
            break

        for b in range(N + 1):
            n = r * R + g * G + b * B
            if n == N:
                count += 1
                break

print(count)
Problem p02917 (python)

Fixed submission:
n = int(input())

B_lst = list(map(int,input().split()))
A_lst = [0] * n

A_lst[0] = B_lst[0]
A_lst[n-1] = B_lst[n-2]

if n >= 3:
    for i in range(1,n-1):

        if B_lst[i-1] > B_lst[i]:
            A_lst[i] = B_lst[i]
        else:
            A_lst[i] = B_lst[i-1]

print(sum(A_lst))

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

B_lst = list(map(int,input().split()))
A_lst = [0] * (n+1)

for i in range(n):
    if B_lst[i] > B_lst[i-1]:
        A_lst[i] = str(B_lst[i-1])
    else:
        A_lst[i] = str(B_lst[i])

    if i == n-1:
        A_lst[i+1] = str(B_lst[i])
        break

list = ' '.join(A_lst)
print(list)
Problem p02947 (python)

Fixed submission:
import math
n = int(input())
dic = {}
def combinations_count(n,r):
    return math.factorial(n) // (math.factorial(n - r)*math.factorial(r))

for index in range(n):
    temp = ''.join(sorted(list(input())))
    #入力された文字列をa-z順にソートし、変数tempに代入
    if temp in dic:
        dic[temp] = dic[temp] + 1
        #すでに同じ文字列の入力があれば、key:tempのvalueに+1
    else:
        dic[temp] = 1
        #新しい文字列の場合は文字列とvalue＝1を辞書に追加
ans = 0

for k in dic.values():
    if k >= 2:
        ans += combinations_count(k,2)
    else:
        ans = ans
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
dic = {}　#空の辞書を定義
def combinations_count(n,r):
    return math.factorial(n) // (math.factorial(n - r)*math.factorial(r))

for index in range(n):
    temp = ''.join(sorted(list(input())))
    #入力された文字列をa-z順にソートし、変数tempに代入
    if temp in dic:
        dic[temp] = dic[temp] + 1
        #すでに同じ文字列の入力があれば、key:tempのvalueに+1
    else:
        dic[temp] = 1
        #新しい文字列の場合は文字列とvalue＝1を辞書に追加
ans = 0

for k in dic.values():
    ans += combinations_count(k,2)

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
dic = {}　#空の辞書を定義

for index in range(n):
    temp = ''.join(sorted(list(input())))
    #入力された文字列をa-z順にソートし、変数tempに代入
    if temp in dic:
        dic[temp] = dic[temp] + 1
        #すでに同じ文字列の入力があれば、key:tempのvalueに+1
    else:
        dic[temp] = 1
        #新しい文字列の場合は文字列とvalue＝1を辞書に追加
ans = 0

for k in dic.values():
    cnt = 0
    for i in range(k):
        cnt += i
    ans += cnt
print(ans)
Problem p02983 (python)

Fixed submission:
l,r = map(int,input().split())

if r - l >= 2018:
    print(0)
else:
    ans = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = min(ans,(i*j)%2019)
    print(ans)

Buggy submission (verdict: Runtime Error):
l,r = map(int,input().split())

if r - l >= 2018 :
    print(0)
else:
    ans = 2019
    for i in range(l,r-1):
        for j in range(l+1,r)
            ans = min(ans,(i*j)%2019)
    print(ans)

Buggy submission (verdict: Runtime Error):
l,r = map(int,input().split())

if r - l >= 2018 :
    print(0)
else:
    ans = 2019
    for i in range(l,r):
        for j in range(i + 1,r + 1)
            ans = min(ans,(i*j)%2019)
    print(ans)

Buggy submission (verdict: Runtime Error):
l,r = map(int,input().split())

if r - l >= 2018 :
    print(0)
else:
    ans = 2019
    for i in range(l,r):
        for j in range(l + 1,r + 1)
            ans = min(ans,(i*j)%2019)
    print(ans)

Buggy submission (verdict: Runtime Error):
l,r = map(int,input().split())

for i in range(l,r-1):
    for j in range(l+1,r):
        if i == l and j == l+1:
            ans = (i*j)%2019
        else:
            res = (i*j)%2019
            ans = min(ans,res)
print(ans)

Buggy submission (verdict: Runtime Error):
l,r = map(int,input().split())

for i in range(l,r-1):
    for j in range(l+1,r):
        if i == l and j == l+1:
            ans = (i*j)%2019
        else:
            res = (i*j)%2019
            ans = min(ans,res)
print(ans)

Buggy submission (verdict: Runtime Error):
l,r = map(int,input().split())

for i in range(l,r):
    for j in range(l+1,r):
        if i == l and j == l+1:
            ans = (i*j)%2019
        else:
            res = (i*j)%2019
            ans = min(ans,res)
print(ans)
Problem p03000 (python)

Fixed submission:
n,x = map(int,input().split())
arr = list(map(int,input().split()))
chk = 0
cnt = 1
for i in range(len(arr)):
    chk = chk + arr[i]

    if chk <= x:
        cnt += 1
    else:
        print(cnt)
        exit()

print(cnt)

Buggy submission (verdict: Runtime Error):
n,x = map(int,input().split())
arr = list(map(int,input().split()))
chk = 0

for i in range(len(arr)-1):
    if i == 0:
        chk = 0
    else:
        chk = chk + arr[i]

    if chk <= x:
        count =+ 1
    else:
        print(count)
        exit()

 print(count)
Problem p02957 (python)

Fixed submission:
A,B = map(int,input().split())
K = 0
if (A+B)%2 == 0:
  K = int((A+B) /2)
else:
  K = 'IMPOSSIBLE'
  
print(K)

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
K = 0
if (A+B)%2 == 0:
  K = (A+B) /2
else:
  K = 'IMPOSSIBLE'
  
print(int(K))
Problem p02917 (python)

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

A=[]
A.append(B[0])
for i in range(0,N-2):
    if i>=1 & i < N-2:
      A.append(min(B[i],B[i+1]))
      
A.append(B[-1])
print(sum(A))

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

B.sort()
A=[]
A.append([B[0]])

for i in range(N):
    if i>0 && i < N-1 :
        A.append(min(B[i-1],B[i],B[i+1]))
    if i == N-1:
        A.append(B[N-1])
print(sum(A))
Problem p02952 (python)

Fixed submission:
N=int(input())

n=len(str(N))//2
full=0
for i in range(n):
    full+=int('9'+'0'*i*2)

if len(str(N))%2==0:
    b=0
else:
    times=len(str(N))-1
    if times==0:
        nines=0
    else:
        nines=int('9'*times)
    b=N-nines
ans=full+b
print(ans)

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

n=len(str(N))//2
full=0
for i in range(n):
    full+=int('9'+'0'*i*2)

if len(str(N))%2==0:
    b=0
else:
    nines=int('9'*(len(str(N))-1))
    b=N-nines
ans=full+b
print(ans)
Problem p02958 (python)

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

cnt=0
for i in range(N):
    if i+1!=p[i]:
        cnt+=1
if cnt==0 or cnt==2:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
7
1 2 3 4 5 6 7
Problem p03005 (python)

Fixed submission:
N,K=map(int,input().split())
if K==1:
    print(0)
else:
    print(N-K)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
if K==1:
    print(0)
else:
    print(N-K
Problem p03061 (python)

Fixed submission:
import fractions

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

L=[0,A[0]]
R=[0,A[-1]]
for i in range(N-1):
    #l=fractions.gcd(L[i+1],A[i+1])
    #r=fractions.gcd(R[i+1],A[N-i-2])
    L.append(fractions.gcd(L[i+1],A[i+1]))
    R.append(fractions.gcd(R[i+1],A[N-i-2]))
    #print(L[i+1],A[i+1],R[i+1],A[N-i-2])
#print(L)
#print(R)
arr=[]
for i in range(N):
    a=fractions.gcd(L[i],R[N-i-1])
    arr.append(a)
    #print(i,L[i],R[N-i-1],a,arr)
print(max(arr))

Buggy submission (verdict: Runtime Error):
import math

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

A.sort()
A[1]=A[0]
ans=A[0]
for i in range(N):
    ans=math.gcd(ans,A[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

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

num=0
x=A[0]
for i in range(N):
    x=A[i]
    A[i]=max(A)
    num=max(num,reduce(math.gcd,A))
    A[i]=x
print(num)
Problem p03111 (python)

Fixed submission:
N,A,B,C=map(int,input().split())
l=[]
for _ in range(N):
    l.append(int(input()))

def dfs(counter,a,b,c):
    if counter==N:
        #lの中の適当な棒を持った時点から正味スタート
        if a>0 and b>0 and c>0:
            offset=10*3
            return abs(A-a)+abs(B-b)+abs(C-c)-offset
        else:
            #棒を持っていないものは候補外
            return 10**9
    #合成魔法
    #何もしなかった分も含めて、ちょっと足りない、ちょっと長すぎは
    #上のif内で調整
    ret0=dfs(counter+1,a,b,c)
    ret1=dfs(counter+1,a+l[counter],b,c)+10
    ret2=dfs(counter+1,a,b+l[counter],c)+10
    ret3=dfs(counter+1,a,b,c+l[counter])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))

Buggy submission (verdict: Runtime Error):
N,A,B,C=map(int,input().split())
l=[]
for _ in range(N):
    l.append(int(input()))

def dfs(counter,a,b,c):
    if a==A and b==B and c==C:
            return counter
    ret1=dfs(counter+1,a+l[counter],b,c)+10
    ret2=dfs(counter+1,a,b+l[counter],c)+10
    ret3=dfs(counter+1,a,b,c+l[counter])+10
    ret4=dfs(counter+1,a+1,b,c)+1
    ret5=dfs(counter+1,a,b+1,c)+1
    ret6=dfs(counter+1,a,b,c+1)+1
    return min(ret1,ret2,ret3,ret4,ret5,ret6)

print(dfs(0,0,0,0))
Problem p03125 (python)

Fixed submission:
A,B=map(int,input().split())
if B%A==0:
    print(A+B)
else:print(B-A)

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

while len(set(A))!=1:
#for i in range(2):
    A.sort()
    for i in range(len(A)-1):
        if A.count(0):
            A.remove(0)
            break
        A[i+1]=A[i+1]%A[0]

print(max(A))

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

while len(set(A)!=1:
#for i in range(2):
    A.sort()
    for i in range(len(A)-1):
        if A.count(0):
            A.remove(0)
            break
        A[i+1]=A[i+1]%A[0]

print(max(A))
Problem p03212 (python)

Fixed submission:
N=input()

if len(N)<3:
    print(0)
else:
    arr=set([357, 375, 537, 573, 735, 753])
    for i in range(len(N)-3):
        new=set()
        for num in arr:
            for j in range(len(str(num))+1):
                n=str(num)[:j]+'3'+str(num)[j:]
                new.add(int(n))
                n=str(num)[:j]+'5'+str(num)[j:]
                new.add(int(n))
                n=str(num)[:j]+'7'+str(num)[j:]
                new.add(int(n))
        arr |= new

    arr=list(arr)
    arr.sort()
    cnt=0
    for i in range(len(arr)):
        if arr[i]<=int(N):
            cnt+=1
        else:
            break
    print(cnt)

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

if len(N)<3:
    print(0)
else:
    arr=set([357, 375, 537, 573, 735, 753])
    for i in range(len(N)-3):
        new=set()
        for num in arr:
            for j in range(len(str(num))+1):
                n=str(num)[:j]+'3'+str(num)[j:]
                new.add(int(n))
                n=str(num)[:j]+'5'+str(num)[j:]
                new.add(int(n))
                n=str(num)[:j]+'7'+str(num)[j:]
                new.add(int(n))
        arr |= new

arr=list(arr)
arr.sort()
cnt=0
for i in range(len(arr)):
    if arr[i]<=int(N):
        cnt+=1
    else:
        break
print(cnt)
Problem p03219 (python)

Fixed submission:
X,Y=map(int,input().split())
print(X+int(Y/2))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
PY=[]
for i in range(M):
    array=list(map(int,input().strip().split()))
    PY.append(array)

PY.sort()
city=0
order=0
for i in range(M):
    newcity=PY[i][0]
    if(newcity!=city):
        city=newcity
        order=1
    strcity=str(PY[i][0])
    strorder=str(order)
    upper='0'*(6-len(strcity))+strcity
    lower='0'*(6-len(strorder))+strorder
    order=order+1
    print(upper+lower)
Problem p03262 (python)

Fixed submission:
N,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X) #len(x)=N+1
x.sort()

def gcd(a,b):
    if b%a==0:
        return a
    else:
        return gcd(b%a,a)

init=x[0]
x=[i-init for i in x]
d=x[1]
for i in range(N-1):   # 0 2 4 6 10 14   N=5
    if d==0:
        d=x[i+2]
    else:
        d=gcd(d,x[i+2])
print(d)

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X) #len(x)=N+1
x.sort()

def gcd(a,b):
    if b%a==0:
        return a
    else:
        a,b=b%a,a

init=x[0]
x=[i-init for i in x]
d=x[1]
for i in range(N-1):   # 0 2 4 6 10 14   N=5
    d=gcd(d,x[i+2])
print(d)

Buggy submission (verdict: Runtime Error):
import math

N,X=map(int,input().split())
x=[int(i) for i in input().split()]
x.append(X)
x.sort()
d=[]
for i in range(N):
    d.append(x[i+1]-x[i])
n=d[0]
for i in range(N-1):
    n=math.gcd(n,d[i+1])
print(n)
Problem p03274 (python)

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

# min( 左端に到達し右へ, 右端に到達し左へ)
ans=10**9
for i in range(N-K+1):
    l=abs(x[i])+abs(x[i]-x[i+K-1])
    r=abs(x[i+K-1])+abs(x[i]-x[i+K-1])
    ans=min(ans,min(l,r))
print(ans)

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

#ゼロに最も近い正負の要素を含むようにK個の配列を舐める
#全部負または全部正(max*min>=0)ならabs(max-min)
#正負またぐ負場合(max*min<0)、
# min(負の絶対値最大*2+正の最大,負の絶対値最大+正の最大*2)

#符号切り替わりサーチ
for i in range(N):
    if x[i]>=0:
        pos_start=i
        break

#K個の配列をスライド
ans=2*(max(x)-min(x))   #ans init. 考えられる最大プラスアルファ?
for i in range(K+1):
    start=pos_start-K+i
    end=pos_start+i
    #print('search start,end ',start,end)
    if start>=0 and end<=N:
        #print('start,end ',start,end)
        obj_arr=x[start:end]
        M=max(obj_arr)
        m=min(obj_arr)
        if M*m>=0:
            ans=min(ans,max(abs(M),abs(m)))
        else:
            ans=min(ans,min(abs(m)*2+M,abs(m)+M*2))
print(ans)
Problem p03280 (python)

Fixed submission:
A,B=map(int,input().split())
print((A-1)*(B-1))

Buggy submission (verdict: Runtime Error):
N=int(input())
num=0
for j in range(1,N+1,2):
  	cnt=0
    for i in range(1,j+1):
#        print(i)
#        print(j)
        if j%i==0 :
            cnt=cnt+1
    if cnt==8 :
#        print(cnt)
        num+=1
#    print("---")
print(num)

Buggy submission (verdict: Runtime Error):
import math

N=int(input())
cnt=0
num=0
for j in range(1,N+2,2):
    for i in range(1,j+1):
#        print(i)
#        print(j)
        if j%i==0 :
            cnt=cnt+1
    if cnt==8 :
#        print(cnt)
        num+=1
    cnt=0
#    print("---")
print(num)
Problem p03281 (python)

Fixed submission:
N=int(input())
num=0
for j in range(1,N+1,2):
    cnt=0
    for i in range(1,j+1):
#        print(i)
#        print(j)
        if j%i==0 :
            cnt=cnt+1
    if cnt==8 :
#        print(cnt)
        num+=1
    cnt=0
#    print("---")
print(num)

Buggy submission (verdict: Runtime Error):
N=int(input())
num=0
for j in range(1,N+1,2):
	cnt=0
	for i in range(1,j+1):
#        print(i)
#        print(j)
        if j%i==0 :
            cnt=cnt+1
    if cnt==8 :
#        print(cnt)
        num+=1
#    print("---")
print(num)

Buggy submission (verdict: Runtime Error):
N=int(input())
num=0
for j in range(1,N+1,2):
  cnt=0
    for i in range(1,j+1):
#        print(i)
#        print(j)
        if j%i==0 :
            cnt=cnt+1
    if cnt==8 :
#        print(cnt)
        num+=1
#    print("---")
print(num)
Problem p03309 (python)

Fixed submission:
import math

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

for i in range(N):
    A[i]-=i+1
A.sort()
a=N//2

def sad(A,a):
    sadness=0
    for i in range(N):
        sadness+=abs(A[i]-A[a])
    return sadness

if N%2==0:
    ans=min(sad(A,a),sad(A,a+1))
else:
    ans=sad(A,a)
print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

for i in range(N):
    A[i]-=i+1
A.sort()
a=N//2

def sad(A,a):
    sadness=0
    for i in range(N):
        sadness+=abs(A[i]-A[a])
    return sadness

if N//2==0:
    ans=min(sad(A,a),sad(A,a+1))
else:
    ans=sad(A,a)
print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

for i in range(N):
    A[i]-=i+1
A.sort()
a=N//2

def sad(A,a):
    sadness=0
    for i in range(N):
        sadness+=abs(A[i]-A[a])
    return sadness

print(min(sad(A,a),sad(A,a+1)))
Problem p03379 (python)

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

# Xをソート(Xsort)
# 除く数字が中央より左の場合、答えは中央右(r)の数字
# 逆も然り
Xsort=sorted(X)
l=(N-1)//2
r=l+1
th=Xsort[l]
for i in range(N):
    if X[i]<=th:
        ans=Xsort[r]
    else:
        ans=Xsort[l]
    print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
X=[*map(int,input().split())]

num=[i+1 for i in range(N)]
l=zip(num,X)
l=sorted(l,key=lambda x:x[1])
indexlist=[]
for i in range(N):
    indexlist.append(l[i][0])
for i in range(N):
    x=indexlist.index(i+1)
    if x<=N//2-1:
        ans=l[N//2][1]
    else:
        ans=l[N//2-1][1]
    print(ans)
Problem p03565 (python)

Fixed submission:
SS=list(input())
T=list(input())

SS.reverse()
T.reverse()

flag=0
for i in range(len(SS)-len(T)+1):
    if flag==0:
        for j in range(len(T)):
            if SS[i+j]==T[j] or SS[i+j]=='?':
                if j==len(T)-1:
                    flag=1
                    for k in range(len(T)):
                        SS[i+k]=T[k]
                    break
            else:
                break
            #if flag==1:
            #    break

ans=''
SS.reverse()
if flag==1:
    for i in range(len(SS)):
        if SS[i]=='?':
            SS[i]='a'
        ans+=SS[i]
else:
    ans='UNRESTORABLE'
print(ans)

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

m=2**10
gain=-10**8
for i in range(1,2**10):
    x=list(map(int,format(i,'b').zfill(10)))
    sumP=0
    for j in range(N):
        total=sum([a*b for a,b in zip(x,F[j])])
        sumP+=P[j][total]
    gain=max(gain,sumP)
print(gain)
Problem p03612 (python)

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

ans=0
flag=0
for i in range(len(p)):
    if i+1 == p[i]:
        if flag==0:
            ans+=1
            flag=1
        else: # if flag == 1
            flag=0
    else: # if i+1 != p[i] 
        flag=0

print(ans)

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

ans=0
flag=0
for i in range(len(p)):
    if i+1 == p[i]:
        if flag==0:
            ans+=1
        else: # if flag == 1
            flag=0
print(ans)
Problem p03623 (python)

Fixed submission:
x,a,b=map(float,raw_input().split())
AX=abs(a-x)
BX=abs(b-x)
if AX>BX:
    print "B"
else:
    print "A"

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

A.sort()
Auni=list(set(A))
Auni.reverse()

num=[]
for i in Auni:
    num.append(A.count(i))

edge=[0,0]
for j in range(2):
    for i in range(len(num)):
        if num[i]>=2:
            num[i]=num[i]-2
            edge[j]=Auni[i]
            break
print edge[0]*edge[1]
Problem p03633 (python)

Fixed submission:
def gcd(a,b):
    #print(a)
    #print(b)
    if b==0:
        return a
    #a=a%b
    #b=a
    return gcd(b,a%b)

N=int(input())
x=1
for i in range(N):
    t=int(input())
    x=(x*t)//gcd(x,t)
print(x)

Buggy submission (verdict: Runtime Error):
import math

N=int(input())
x=1
for i in range(N):
    t=int(input())
    x=(x*t)//math.gcd(x,t)
print(x)
Problem p03651 (python)

Fixed submission:
import fractions

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

A=list(set(A))
N=len(A)
A.sort()

g=A[0]
for i in range(N-1):
    g=fractions.gcd(g,A[i+1])

if K%g==0 and K<=A[-1]:
    ans="POSSIBLE"
else:
    ans="IMPOSSIBLE"
print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

A=list(set(A))
N=len(A)
A.sort()

g=A[0]
for i in range(N-1):
    g=math.gcd(g,A[i+1])

#tmp=0
#ans="POSSIBLE"
#for i in range(N):
#    tmp+=A[i]%g
if g==1 and K<=A[-1]:
    ans="POSSIBLE"
else:
    ans="IMPOSSIBLE"
if N==1:
    ans="POSSIBLE"
print(ans)

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

A=list(set(A))
N=len(A)
A.sort()
tmp=0
for i in range(N-1):
    tmp+=A[i+1]%A[0]
if tmp>0 and K<=A[-1]:
    pass
else:
    ans="IMPOSSIBLE"
if N==1:
    ans="POSSIBLE"
print(ans)
Problem p03657 (python)

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

A,B=map(int,raw_input().split())
ans='Impossible'
if A%3==0:
    ans='Possible'
if B%3==0:
    ans='Possible'
if (A+B)%3==0:
    ans='Possible'

print ans

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

N,K=map(int,raw_input().split())
l=map(int,raw_input().split())
l.sort()
print sum(l[len(l)-K:len(l)])
Problem p03681 (python)

Fixed submission:
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
nn = 1
mm = 1
for i in range(1, N + 1):
  nn = (nn * i) % MOD
for j in range(1, M + 1):
  mm = (mm * j) % MOD
if abs(N - M) >= 2:
  ans = 0
elif abs(N - M) == 1:
  ans = (nn * mm) % MOD
else:
  ans = (2 * nn * mm) % MOD
print(ans)

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

div=10**9+7
tmp=1
K=min(N,M)
diff=abs(N-M)
for i in range(K):
    tmp*=(i+1)%div

if diff>3:
    ans=0
elif diff==0:
    ans=2*tmp*tmp%div
elif diff==1:
    ans=tmp*(tmp+K+1+1)%div
print(ans)
Problem p03759 (python)

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

a,b,c=map(int,raw_input().split())

if c-b==b-a:
    print 'YES'
else:
    print 'NO'

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

a,b,c=int(raw_input().split())

if c-b==b-a:
    print 'YES'
else:
    print 'NO'
Problem p03773 (python)

Fixed submission:
A,B=map(int,raw_input().split())
print (A+B)%24

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

import math

n=int(raw_input().strip())
N=int(math.ceil(math.sqrt(float(n))))
a=[]
for i in range(1,N+1):
    if n%i==0:
        a.append(i)
A=max(a)
B=int(n/A)
A_keta=len(map(int,str(A)))
B_keta=len(map(int,str(B)))
F=max(A_keta,B_keta)
print F