Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a=int(input())
if a<1200:
  print("ABC")
else if 2800<=a:
  print("AGC")
else:
  print("ARC")


Fixed submission:
a=int(input())
if a<1200:
  print("ABC")
elif 2800<=a:
  print("AGC")
else:
  print("ARC")

Buggy python submission (verdict: Runtime Error):
=int(input())
if a<1200:
  print("ABC")
elif 2800<=a:
  print("AGC")
else:
  print("ARC")


Fixed submission:
a=int(input())
if a<1200:
  print("ABC")
elif 2800<=a:
  print("AGC")
else:
  print("ARC")

Buggy python submission (verdict: Runtime Error):
=int(input())
if a<1200:
  print("ABC")
else if 2800<=a:
  print("AGC")
else:
  print("ARC")

Fixed submission:
a=int(input())
if a<1200:
  print("ABC")
elif 2800<=a:
  print("AGC")
else:
  print("ARC")
Buggy python submission (verdict: Runtime Error):
a=str(input())
print(a.cpunt("+")-a.count("-"))

Fixed submission:
a=str(input())
print(a.count("+")-a.count("-"))
Buggy python submission (verdict: Time Limit Exceeded):
s=str(input())
k=int(input())
ans=[]
for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        ans.append(s[i:j])
#print(ans)
ans=sorted(list(set(ans)))
#print(ans)
print(ans[k-1])


Fixed submission:
s=str(input())
k=int(input())
ans=[]
for i in range(len(s)):
    for j in range(i+1,i+k+1):
        ans.append(s[i:j])
#print(ans)
ans=sorted(list(set(ans)))
#print(ans)
print(ans[k-1])
Buggy python submission (verdict: Runtime Error):


a,b,ab,x,y=map(int,input().split())
ans=0
abcnt=min(x,y)
if (a+b)//2>=ab:
    if min(a,b)>ab*2:
        ans+=max(x,y)*2*ab
    else:
        ans+=abcnt*2*ab
        if x>y:
            ans+=(x-abcnt)*a
        else:
            ans+=(y-abcnt)*b
else:
    ans+=x*a+y*b
print(ans)


Fixed submission:
h,w=map(int,input().split())
s=[]
s.append(['.']*(w+2))
for i in range(h):
    s.append( list(map(str,input())))
    

s.append(['.']*(w+2))
for i in range(1,h+1):
    s[i].insert(0,'.')
    s[i].append('.')


for i in range(1,h):
    for j in range(1,w):
        if s[i][j]=='#':
            if s[i+1][j]!='#' and s[i-1][j]!='#' and s[i][j+1]!='#' and s[i][j-1]!='#' :
                print("No")
                exit()

print("Yes")
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())

if a%2==b%2 and b%2==c%2 and a%2==c%2:
    m=max(a,b,c)
    count=(m-a)//2+(m-b)//2+(m-c)//2
else:
    count=(m-a)//2+(m-b)//2+(m-c)//2+1
print(count)

Fixed submission:
a,b,c=map(int,input().split())
m=max(a,b,c)*3
f=a+b+c
if (m-f)%2==0:
    print((m-f)//2)
else:
    print((m-f)//2+2)
Buggy python submission (verdict: Runtime Error):
s=str(input())
a=list("zyxwvutsrqponmlkjihgfedcba")
a=a[::-1]
#print(a)


if "zyxwvutsrqponmlkjihgfedcba"==s:
    print(-1)


if len(s)==26:
    s=s[::-1]#後ろから見ていく
    for i in range(len(s)):
        for j in range(i+1):
           # print(i,j,s[i+1],s[j+1])
            if s[i+1]<s[j+1]:#xyzの降順の流れが切れたところを変える
                s=s[::-1]
                print(s[:-(i+1)]+s[-(j+1)])
                exit()
else:
    for i in a:
        if i not in s:
            s+=i
            break
    print(s)




Fixed submission:
s=str(input())
a=list("zyxwvutsrqponmlkjihgfedcba")
a=a[::-1]
#print(a)


if "zyxwvutsrqponmlkjihgfedcba"==s:
    print(-1)
    exit()


if len(s)==26:
    s=s[::-1]#後ろから見ていく
    for i in range(len(s)):
        for j in range(i+1):
            #print(i,j,s[i],s[j])
            if s[i]<s[j]:#xyzの降順の流れが切れたところを変える
                s=s[::-1]
               # print(s)
                print(s[:-(i+1)]+s[-(j+1)])
                exit()
else:
    for i in a:
        if i not in s:
            s+=i
            break
    print(s)
Buggy python submission (verdict: Runtime Error):
import collections
n = int(input())
s = [str(input()) for _ in range(n)]
m = int(input())
t = [str(input()) for _ in range(m)]
s = collections.Counter(s)
t = collections.Counter(t)

for k, j in t.items():
    if k in s:
        s[k] -= j

values, counts = zip(*s.most_common())
print(max(0,counts[0))


Fixed submission:
import collections
n = int(input())
s = [str(input()) for _ in range(n)]
m = int(input())
t = [str(input()) for _ in range(m)]
s = collections.Counter(s)
t = collections.Counter(t)

for k, j in t.items():
    if k in s:
        s[k] -= j

values, counts = zip(*s.most_common())
print(max(0,counts[0]))
Buggy python submission (verdict: Runtime Error):
from collections import deque
q = deque()
h,w=map(int,input().split())
sx,sy=1,1#スタート位置
ex,ey=h,w#ゴール位置
q.append([sx-1,sy-1,0])
global finished 
finished = set()
c=[]
for i in range(h):
    c.append(list(map(str,input())))

def check(x,y):
    if 0<=x and x<h:
        if 0<=y and y<w:
            return True
    return False

count=0
def search():
    while (q):
        x,y,count=q.popleft()
        
        if check(x,y)==False or (x,y) in finished or c[x][y]=='#':
            continue
        else:
            q.append([x,y-1,count+1])
            q.append([x,y+1,count+1])
            q.append([x+1,y,count+1])
            q.append([x-1,y,count+1])
            finished.add((x,y))
            c[x][y]=count
            if x==ex-1 and y==ey-1:
                return c[x][y]+1 #通った道の合計を返す

black_count=0
for i in range(h):
    black_count+=c[i].count("#")

print(h*w-black_count-search())#全体からもともと黒の#の数と通った白い道を削除


Fixed submission:
from collections import deque
q = deque()
h,w=map(int,input().split())
sx,sy=1,1#スタート位置
ex,ey=h,w#ゴール位置
q.append([sx-1,sy-1,0])
global finished 
finished = set()
c=[]
for i in range(h):
    c.append(list(map(str,input())))

def check(x,y):
    if 0<=x and x<h:
        if 0<=y and y<w:
            return True
    return False

count=0
def search():
    while (q):
        x,y,count=q.popleft()
        
        if check(x,y)==False or (x,y) in finished or c[x][y]=='#':
            continue
        else:
            q.append([x,y-1,count+1])
            q.append([x,y+1,count+1])
            q.append([x+1,y,count+1])
            q.append([x-1,y,count+1])
            finished.add((x,y))
            c[x][y]=count
            if x==ex-1 and y==ey-1:
                return c[x][y]+1 #通った道の合計を返す
    return -1
black_count=0
for i in range(h):
    black_count+=c[i].count("#")
path=search()#通る道
if path==-1:
    print(path)
else:
    print(h*w-black_count-path)#全体からもともと黒の#の数と通った白い道を削除
Buggy python submission (verdict: Runtime Error):
s=list(str(input()))
t=list(str(input()))
s.sort()
t.sort()
#print(s,t)

for i in range(min(len(s),len(t))):
    if s[i]>t[i]:
        print("Yes")
        exit()
    elif s[i]<t[i]:
        print("No")
        exit()
if len(s)<t:
    print("Yes")
else:
    print("No")

Fixed submission:
s=list(str(input()))
t=list(str(input()))
s.sort()

t.sort(reverse=True)
#print(s,t)

for i in range(min(len(s),len(t))):
   # print(s[i],t[i])
    if s[i]<t[i]:
        print("Yes")
        exit()
    elif s[i]>t[i]:
        print("No")
        exit()
if len(s)<len(t):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
s=list(str(input()))
t=list(str(input()))
s.sort()
t.sort()
#print(s,t)

for i in range(min(len(s),len(t))):
    if s[i]<t[i]:
        print("Yes")
        exit()
    elif s[i]>t[i]:
        print("No")
        exit()
if len(s)<t:
    print("Yes")
else:
    print("No")

Fixed submission:
s=list(str(input()))
t=list(str(input()))
s.sort()

t.sort(reverse=True)
#print(s,t)

for i in range(min(len(s),len(t))):
   # print(s[i],t[i])
    if s[i]<t[i]:
        print("Yes")
        exit()
    elif s[i]>t[i]:
        print("No")
        exit()
if len(s)<len(t):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=sorted(list(map(int,input().split())))

b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
#print(a)
#print(b)
#print(c)
c_count=[]#cから行けるところの回数
b_count=[]#bから行けるところの回数

j=0
count=0
for i in range(n):#cから行けるところの回数
    for j in range(count,n):
        if b[j]<c[i]:
            count+=1
        else:
            break
    c_count.append(count)

count=0

for i in range(n):#bから行けるところの回数
    for j in range(count,n):
        if a[j]<b[i]:
            count+=1
        else:
            break
    b_count.append(count)

ans=0

for i in range(n):
    ans+=sum(b_count[0:c_count[i]])

print(ans)

#print(b_count)
#print(c_count)


Fixed submission:
n=int(input())
a=sorted(list(map(int,input().split())))

b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
#print(a)
#print(b)
#print(c)
c_count=[]#cから行けるところの回数
b_count=[]#bから行けるところの回数

j=0
count=0
for i in range(n):#cから行けるところの回数
    for j in range(count,n):
        
        if b[j]<c[i]:
 #           print("dfghj")
            count+=1
        else:
  #          print("GHJK")
            break
    c_count.append(count)

count=0

for i in range(n):#bから行けるところの回数
    for j in range(count,n):
        if a[j]<b[i]:
            count+=1
        else:
            break
    b_count.append(count)

ans=0
#print(b_count)
#print(c_count)
for i in range(1,n):
    b_count[i]+=b_count[i-1]
#print(b_count)

for i in range(n):
    if 0<=c_count[i]-1:
        ans+=b_count[c_count[i]-1]

print(ans)

#print(b_count)
#print(c_count)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=sorted(list(map(int,input().split())))

b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
#print(a)
#print(b)
#print(c)
c_count=[]#cから行けるところの回数
b_count=[]#bから行けるところの回数

j=0
count=0
for i in range(n):#cから行けるところの回数
    for j in range(count,n):
        if b[j]<c[i]:
            count+=1
    c_count.append(count)

count=0

for i in range(n):#bから行けるところの回数
    for j in range(count,n):
        if a[j]<b[i]:
            count+=1
    b_count.append(count)

ans=0

for i in range(n):
    ans+=sum(b_count[0:c_count[i]])

print(ans)

#print(b_count)
#print(c_count)


Fixed submission:
n=int(input())
a=sorted(list(map(int,input().split())))

b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
#print(a)
#print(b)
#print(c)
c_count=[]#cから行けるところの回数
b_count=[]#bから行けるところの回数

j=0
count=0
for i in range(n):#cから行けるところの回数
    for j in range(count,n):
        
        if b[j]<c[i]:
 #           print("dfghj")
            count+=1
        else:
  #          print("GHJK")
            break
    c_count.append(count)

count=0

for i in range(n):#bから行けるところの回数
    for j in range(count,n):
        if a[j]<b[i]:
            count+=1
        else:
            break
    b_count.append(count)

ans=0
#print(b_count)
#print(c_count)
for i in range(1,n):
    b_count[i]+=b_count[i-1]
#print(b_count)

for i in range(n):
    if 0<=c_count[i]-1:
        ans+=b_count[c_count[i]-1]

print(ans)

#print(b_count)
#print(c_count)
Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,f=map(int,input().split())

water=set()#入れる可能性のある水の量O(A*B)
sugar=set()#入れる可能性のある佐藤の量O(C*D)

for i in range(31):
    for j in range(31):
        water.add(100*i*a+100*j*b)

for i in range(1501):
    for j in range(1501):
        sugar.add(c*i+d*j)
water=sorted(list(water))
#print(water)
sugar=sorted(list(sugar))
#print(sugar)
ans=0
sumans=0
for i in range(1,len(water)):
    for j in range(len(sugar)):
        if water[i]+sugar[j]<=f and (sugar[j]/(water[i]//100))<=e:
            if ans<(100*sugar[j])//(water[i]+sugar[j]):
                #print(sugar[j],water[j])
                ans=(100*sugar[j])/(water[i]+sugar[j])
                sugarans=sugar[j]
                sumans=water[i]+sugar[j]
print(sumans,sugarans)


Fixed submission:
a,b,c,d,e,f=map(int,input().split())

water=set()#入れる可能性のある水の量O(A*B)
sugar=set()#入れる可能性のある佐藤の量O(C*D)

for i in range(31):
    for j in range(31):
        if 100*i*a+100*j*b<=f:
            water.add(100*i*a+100*j*b)

for i in range(1501):
    for j in range(1501):
        if c*i+d*j<=f:
            sugar.add(c*i+d*j)
water=sorted(list(water))
#print(water)
#print(sugar)
sugar=sorted(list(sugar))
#print(sugar)
ans=0
sugarans=0
sumans=0
for i in range(1,len(water)):
    for j in range(len(sugar)):
        if water[i]+sugar[j]<=f and sugar[j]<=e*(water[i]/100):
            if ans<(100*sugar[j])/(water[i]+sugar[j]):
                #print(sugar[j],water[j])
                ans=(100*sugar[j])/(water[i]+sugar[j])
                sugarans=sugar[j]
                sumans=water[i]+sugar[j]
               # print(ans)
if  sumans==0:
    print(100*a,sugarans)
else:
    print(sumans,sugarans)
Buggy python submission (verdict: Runtime Error):

n=int(input())
t=[int(input()) for _ in range(n)]
ans = t[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, t[i])
print(ans)

Fixed submission:
import fractions

n=int(input())
t=[int(input()) for _ in range(n)]
ans = t[0]
for i in range(1, n):
    ans = ans * t[i] // fractions.gcd(ans, t[i])
print(ans)

Buggy python submission (verdict: Runtime Error):

import fractions

n=int(input())
t=[int(input()) for _ in range(n)]
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, t[i])
print(ans)

Fixed submission:
import fractions

n=int(input())
t=[int(input()) for _ in range(n)]
ans = t[0]
for i in range(1, n):
    ans = ans * t[i] // fractions.gcd(ans, t[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
count4=0#4の倍数
count2=0#2の倍数だが4の倍数じゃない
count1=0
for i in range(n):
    if a[i]%4==0:
        count+=1
    elif a[i]%2==0:
        count2+=1
    else:
        count1+=1
if count2==0:
    if count1<=count4+1:
        print("Yes")
    else:
        print("No")
else:
    if count1<count4:
        print("Yes")
    else:
        print("No")

    

    
"""
#print(count2)
if 1<=count2:
    if (n-count2//2)//2<=count or n//2<=count:
        print("Yes")
    elif count2%2==0:
        if   (n-count2)//2<count :
            print("Yes ")
        else:
            print("No")
    elif count2%2==1:
        if  (n-count2)//2<=count :
            print("Yes ")
        else:
            print("No")
else:
    if n//2<=count:
        print("Yes")
    else:
        print("No")

    """
"""    7
    2 2 2 2 3 4 3

    YES になる間違い13晩のテキスト

"""


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
count4=0#4の倍数
count2=0#2の倍数だが4の倍数じゃない
count1=0
for i in range(n):
    if a[i]%4==0:
        count4+=1
    elif a[i]%2==0:
        count2+=1
    else:
        count1+=1
if count2==0:
    if count1<=count4+1:
        print("Yes")
    else:
        print("No")
else:
    if count1<=count4:
        print("Yes")
    else:
        print("No")

    

    
"""
#print(count2)
if 1<=count2:
    if (n-count2//2)//2<=count or n//2<=count:
        print("Yes")
    elif count2%2==0:
        if   (n-count2)//2<count :
            print("Yes ")
        else:
            print("No")
    elif count2%2==1:
        if  (n-count2)//2<=count :
            print("Yes ")
        else:
            print("No")
else:
    if n//2<=count:
        print("Yes")
    else:
        print("No")

    """
"""    7
    2 2 2 2 3 4 3

    YES になる間違い13晩のテキスト

"""

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input(),split()))
count=0
for i in range(n):
    if a[i]%4==0:
        count+=1

if n//2<=count:
    print("Yes")
else:
    print("No")

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
count4=0#4の倍数
count2=0#2の倍数だが4の倍数じゃない
count1=0
for i in range(n):
    if a[i]%4==0:
        count4+=1
    elif a[i]%2==0:
        count2+=1
    else:
        count1+=1
if count2==0:
    if count1<=count4+1:
        print("Yes")
    else:
        print("No")
else:
    if count1<=count4:
        print("Yes")
    else:
        print("No")

    

    
"""
#print(count2)
if 1<=count2:
    if (n-count2//2)//2<=count or n//2<=count:
        print("Yes")
    elif count2%2==0:
        if   (n-count2)//2<count :
            print("Yes ")
        else:
            print("No")
    elif count2%2==1:
        if  (n-count2)//2<=count :
            print("Yes ")
        else:
            print("No")
else:
    if n//2<=count:
        print("Yes")
    else:
        print("No")

    """
"""    7
    2 2 2 2 3 4 3

    YES になる間違い13晩のテキスト

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

ans=[[0]*w for _ in range(h)]
i=0
j=0
jugh=0
for z in range(n):
    count=0
    while count<a[z]:
        #print(i,j,z+1)
        if jugh==0:
            ans[i][j]=z+1
            j+=1
            c=0
        elif jugh==2:
            if j==0:
                jugh=0
                c=1
                ans[i][j]=z+1
                j+=1
            else:
                
                jugh=1
                c=1
                
                ans[i][j]=z+1
                j-=1
        else:
            ans[i][j]=z+1
            j-=1
            c=0

        if j==w and c==0:
            i+=1
            j-=1
            jugh=2
        if j==-1 and c==0:
            i+=1
            j+=1
            jugh=2
            
        count+=1

for i in range(h):
    for j in range(w):
        print(ans[i][j],end=" ")
    print()

Fixed submission:
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))

ans=[[0]*w for _ in range(h)]
i=0
j=0
jugh=0


if w==1:
    for i in range(n):
        for j in range(a[i]):
            print(i+1)
    exit()



for z in range(n):
    count=0
    while count<a[z]:
       # print(i,j,z+1)
        if jugh==0:
            ans[i][j]=z+1
            j+=1
            c=0
        elif jugh==2:
            if j==0:
                jugh=0
                c=1
                ans[i][j]=z+1
                j+=1
            else:
                
                jugh=1
                c=1
                
                ans[i][j]=z+1
                j-=1
        else:
            ans[i][j]=z+1
            j-=1
            c=0

        if j==w and c==0:
            i+=1
            j-=1
            jugh=2
        if j==-1 and c==0:
            i+=1
            j+=1
            jugh=2
            
        count+=1

for i in range(h):
    for j in range(w):
        print(ans[i][j],end=" ")
    print()
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
a1 = []
if max(a) < k:
    print("IMPOSSIBLE")
    exit()

for i in range(1, n):
    a1.append(abs(a[i-1]-a[i]))
a1 = sorted(a1)

for i in range(1, n-1):
    if a1[i] % a1[0] != 0:
        print("POSSIBLE")
        break
else:
    if k % a1[0] == 0 or a1[0] == 1:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Fixed submission:
from math import gcd
n, k = map(int, input().split())
a = list(map(int, input().split()))
if max(a) < k:
    print("IMPOSSIBLE")
    exit()
if k in a:
    print("POSSIBLE")
    exit()
a_gcd = a[0]
for i in range(1, n):
    a_gcd = gcd(a_gcd, a[i])

if k % a_gcd == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

a=list(map(int,input().split()))
b=[a[0]]
if n%2:#n%2==1
    for i in range(1,n):
        if i%2==1:
            b.append(a[i])
        else:
            b.insert(0,a[i])
else:
    for i in range(1,n):
        if i%2==0:
            b.append(a[i])
        else:
            b.insert(0,a[i])
"""
for i in range(n):
    b.append(a[i])
    b.reverse()
"""
for i in range(n):
    print(b[i],end=" ")

Fixed submission:
n=int(input())

a=list(map(int,input().split()))
b=[0]*n
cen=n//2
if n%2:#n%2==1
    for i in range(0,n):
        if i%2==1:
            b[cen+(i+1)//2]=a[i]
        else:
            b[cen-(i+1)//2]=a[i]
else:
    for i in range(0,n):
        if i%2==1:
            b[cen-(i+1)//2]=a[i]
        else:
            b[cen+(i+1)//2]=a[i]
"""
for i in range(n):
    b.append(a[i])
    b.reverse()
"""
for i in range(n):
    print(b[i],end=" ")

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

a=list(map(int,input().split()))
b=[]

for i in range(n):
    b.append(a[i])
    b.reverse()

for i in range(n):
    print(b[i],end=" ")

Fixed submission:
n=int(input())

a=list(map(int,input().split()))
b=[0]*n
cen=n//2
if n%2:#n%2==1
    for i in range(0,n):
        if i%2==1:
            b[cen+(i+1)//2]=a[i]
        else:
            b[cen-(i+1)//2]=a[i]
else:
    for i in range(0,n):
        if i%2==1:
            b[cen-(i+1)//2]=a[i]
        else:
            b[cen+(i+1)//2]=a[i]
"""
for i in range(n):
    b.append(a[i])
    b.reverse()
"""
for i in range(n):
    print(b[i],end=" ")
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=1
now=a[0]
start=1
while now==a[start]:
    start+=1
if a[0]<a[start]:#増加
    jugh=1
else:#現象
    jugh=2
#print(start,jugh)
i=start
while i<n:
    if jugh==0:
        while now==a[start]:
            start+=1
        if now<a[start]:#増加
            jugh=1
        else:#現象
            jugh=2
    if jugh==1:
        if a[i-1]>a[i]:
            jugh=0
            ans+=1
            now=a[i]
            start=i+1
            #print(a[i-1],a[i])
                
    else:
        if a[i-1]<a[i]:
            jugh=0
            ans+=1
            now=a[i]
            start=i+1
            #print(a[i-1],a[i])
            
    i+=1   

print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=1
now=a[0]
start=1

if n==1:
    print(1)
    exit()

while now==a[start]:
    start+=1
if a[0]<a[start]:#増加
    jugh=1
else:#現象
    jugh=2
#print(start,jugh)
i=start
while i<n:
    if jugh==0:
        while now==a[start]:
            start+=1
        if now<a[start]:#増加
            jugh=1
        else:#現象
            jugh=2
    if jugh==1:
        if a[i-1]>a[i]:
            jugh=0
            ans+=1
            now=a[i]
            start=i+1
            #print(a[i-1],a[i])
                
    else:
        if a[i-1]<a[i]:
            jugh=0
            ans+=1
            now=a[i]
            start=i+1
            #print(a[i-1],a[i])
            
    i+=1   

print(ans)
Buggy python submission (verdict: Runtime Error):
s=list(map(str,input()))
#print(s)
ans=0
for i in range(len(s)):
    if s[i]=='A':
        sa=i
    if s[i]=='Z':
        #print("VBHJ")
        ans=max(ans,i-sa+1)

print(ans)

Fixed submission:
s=list(map(str,input()))
#print(s)
for i in range(len(s)):
    if s[i]=='A':
        sa=i
        break

for i in range(len(s)-1,-1,-1):
    if s[i]=='Z':
        zg=i
        break

print(zg-sa+1)
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())

ans=abs(x)-abs(y)

if ans==0:
    if x==y:
        print(ans)
    else:
        print(1)
elif ans<0:
    if x<0 and y<0 :
        print(ans+2)
    else:
        print(ans)
else:
    if x<=0 and y=<0:
        print(abs(ans))
    elif 0<x and 0<y:
        print(abs(ans)+2)
    else: 
        print(abs(ans)+1)



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

ans=abs(x)-abs(y)
#print(ans)
if ans==0:
    if x==y:
        print(ans)
    else:
        print(1)
elif ans<0:
   # print("SDFGH")
    if x<0 and y<0 :
        print(abs(ans)+2)
    elif 0<=x and 0<=y:
        print(abs(ans))
    else:
        print(abs(ans)+1)
else:
    if x<=0 and y<=0:
        print(abs(ans))
    elif 0<x and 0<y:
        print(abs(ans)+2)
    else: 
        
        print(abs(ans)+1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
t=list(map(int,input().split()))
m=int(input())
px=[list(map(int,input().split())) for _ in range(m)]

ans=sum(t)-t[0]-t[1]

for i in range(m):
    
    print(ans+sum(px[i]))



Fixed submission:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
px=[list(map(int,input().split())) for _ in range(m)]

ans=sum(t)

for i in range(m):
    print(ans-t[px[i][0]-1]+px[i][1])