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

Fixed submission:
n=int(input())
d=[int(input()) for _ in range(n)]
from collections import deque
d.sort()
a=deque(d)

tmpl=a.popleft()
tmpr=tmpl
ans=0
i=0

while len(a)>0:
    #0 大きいほうから
    if i%4==0:
        tmp=a.pop()
        ans+=abs(tmpl-tmp)
        tmpl=tmp

    #1 大きいほうから
    elif i%4==1:
        tmp=a.pop()
        ans+=abs(tmpr-tmp)
        tmpr=tmp

    #2 小さいほうから
    elif i%4==2:
        tmp=a.popleft()
        ans+=abs(tmpl-tmp)
        tmpl=tmp


    #3 小さいほうから
    elif i%4==3:
        tmp=a.popleft()
        ans+=abs(tmpr-tmp)
        tmpr=tmp

    i+=1

res=ans
import copy
d.sort(reverse=True)
a= deque(copy.deepcopy(d))

tmpl=a.popleft()
tmpr=tmpl
ans=0
i=0

while len(a)>0:
    #0 大きいほうから
    if i%4==0:
        tmp=a.pop()
        ans+=abs(tmpl-tmp)
        tmpl=tmp

    #1 大きいほうから
    elif i%4==1:
        tmp=a.pop()
        ans+=abs(tmpr-tmp)
        tmpr=tmp

    #2 小さいほうから
    elif i%4==2:
        tmp=a.popleft()
        ans+=abs(tmpl-tmp)
        tmpl=tmp


    #3 小さいほうから
    elif i%4==3:
        tmp=a.popleft()
        ans+=abs(tmpr-tmp)
        tmpr=tmp

    i+=1

print(max(ans,res))

Buggy submission (verdict: Runtime Error):
n=int(input())
d=[int(input()) for _ in range(n)]
from collections import deque
d.sort()
a=deque(d)

tmpl=a.popleft()
tmpr=tmpl
ans=0
i=0

while len(a)>0:
    #0 大きいほうから
    if i%4==0:
        tmp=a.pop()
        ans+=abs(tmpl-tmp)
        tmpl=tmp

    #1 大きいほうから
    elif i%4==1:
        tmp=a.pop()
        ans+=abs(tmpr-tmp)
        tmpr=tmp

    #2 小さいほうから
    elif i%4==2:
        tmp=a.popleft()
        ans+=abs(tmpl-tmp)
        tmpl=tmp


    #3 小さいほうから
    elif i%4==3:
        tmp=a.popleft()
        ans+=abs(tmpr-tmp)
        tmpr=tmp

    i+=1

res=ans

d.sort(reverse=True)
a= deque(copy.deepcopy(d))

tmpl=a.popleft()
tmpr=tmpl
ans=0
i=0

while len(a)>0:
    #0 大きいほうから
    if i%4==0:
        tmp=a.pop()
        ans+=abs(tmpl-tmp)
        tmpl=tmp

    #1 大きいほうから
    elif i%4==1:
        tmp=a.pop()
        ans+=abs(tmpr-tmp)
        tmpr=tmp

    #2 小さいほうから
    elif i%4==2:
        tmp=a.popleft()
        ans+=abs(tmpl-tmp)
        tmpl=tmp


    #3 小さいほうから
    elif i%4==3:
        tmp=a.popleft()
        ans+=abs(tmpr-tmp)
        tmpr=tmp

    i+=1

print(max(ans,res))
Problem p03238 (python)

Fixed submission:
n=int(input())
if n==1:
    print("Hello World")
else:
    a=int(input())
    b=int(input())
    print(a+b)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n==1:
    print("Hello World")
else:
    a,b=map(int,input().split())
    print(a+b)

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

zahyo=[]

for _ in range(n):
    zahyo.append(list(map(int,input().split())))

for x in range(101):
    for y in range(101):

        flag=0
        saisho=10**9+1
        H=0
        for item in zahyo:
            if item[2]==0:
                saisho=min(saisho,abs(x-item[0])+abs(y-item[1]))
            else:
                if H==0:
                    H=item[2]+abs(item[0]-x)+abs(item[1]-y)
                else:
                    H_temp=item[2]+abs(item[0]-x)+abs(item[1]-y)
                    if H_temp!=H:
                        flag=1
                        break
        if flag==0 and H<=saisho:
            print(x,y,H)
Problem p03240 (python)

Fixed submission:
n=int(input())

hxy=[]
for _ in range(n):
    x,y,h=map(int,input().split())
    hxy.append([h,x,y])

hxy.sort()

for cx in range(101):
    for cy in range(101):
        flag=0
        temp=hxy[-1]
        H=temp[0]+abs(temp[1]-cx)+abs(temp[2]-cy)

        for item in hxy:
            h=item[0]
            x=item[1]
            y=item[2]
            if h!=max(H-abs(x-cx)-abs(y-cy),0):
                flag=1
                break
        
        if flag==0:
            print(cx,cy,H)
            exit()

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

zahyo=[]

for _ in range(n):
    zahyo.append(tuple(map(int,input().split())))

zahyo.sort(key=lamda x:x[2])

for x in range(101):
    for y in range(101):


        H=zahyo[0][2]+abs(zahyo[0][0]-x)+abs(zahyo[0][1]-y)
        flag=0
        saisho=10**9+1
        H=0
        for item in zahyo[1:]:
                if item[2]==0:
                    if H>abs(item[0]-x)+abs(item[1]-y):
                        flag=1
                        break
                else:
                    if H!=item[2]+abs(item[0]-x)+abs(item[1]-y):
                        flag=1
                        break
        if flag==0:
            print(x,y,H)
Problem p03241 (python)

Fixed submission:
n,m=map(int,input().split())

def make_divisors(n,m):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if i>=m:
                divisors.append(i)
            if i != n // i:
                if n//i>=m:
                    divisors.append(n//i)

    divisors.sort()
    return divisors

test=make_divisors(m,n)
print(m//min(test))

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

for _ in range(m)
    if m%n==0:
        print(m//n)
        exit()
    n+=1
Problem p03246 (python)

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

odd=[[0,0] for _ in range(10**5+1)]
even=[[0,0] for _ in range(10**5+1)]
ev=0
od=0


for i,v in enumerate(vv):
    if i%2==0:
        ev+=1
        even[v-1][1]=v-1
        even[v-1][0]+=1
    else:
        od+=1
        odd[v-1][1]=v-1
        odd[v-1][0]+=1


even.sort()
odd.sort()

#print(odd)
#print(even)


if even[-1][1]!=odd[-1][1]:
    print(ev-even[-1][0]+od-odd[-1][0])
else:
    print(min(ev-even[-2][0]+od-odd[-1][0],ev-even[-1][0]+od-odd[-2][0]))

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

odd=[[0,0] for _ in range(5+1)]
even=[[0,0] for _ in range(5+1)]
ev=0
od=0


for i,v in enumerate(vv):
    if i%2==0:
        ev+=1
        even[v-1][1]=v-1
        even[v-1][0]+=1
    else:
        od+=1
        odd[v-1][1]=v-1
        odd[v-1][0]+=1


even.sort()
odd.sort()

#print(odd)
#print(even)


if even[-1][1]!=odd[-1][1]:
    print(ev-even[-1][0]+od-odd[-1][0])
else:
    print(min(ev-even[-2][0]+od-odd[-1][0],ev-even[-1][0]+od-odd[-2][0]))
Problem p03262 (python)

Fixed submission:
n,start=map(int,input().split())
town=list(map(int,input().split()))

kyori=[]

for item in town:
    kyori.append(abs(item-start))
import fractions
temp=kyori[0]

for item in kyori:
    temp=fractions.gcd(item, temp)

print(temp)

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

kyori=[]

for item in town:
    kyori.append(abs(item-start))

import math
temp=kyori[0]

for item in kyori:
    temp=math.gcd(item, temp)

print(temp)
Problem p03304 (python)

Fixed submission:
n,m,d=map(int,input().split())

#1~nの数字
#m個
#隣り合う数字がdの個数

if d==0:
    print(1.0*(m-1)/n)
else:
    print(1.0*(m-1)*2*(n-d)/n/n)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())

maze=[list(input()) for _ in range(h)]

group=[[0]*w for _ in range(h)]

group_no=0
color_cnt=[]

for y in range(h):
    for x in range(w):
        if group[y][x]==0:
            stack=[(y,x)]
            group_no+=1

            color_cnt_tmp=[0,0]

            while len(stack)>0:
                tmp=stack.pop()
                group[tmp[0]][tmp[1]]=group_no
                print(tmp)
                if maze[tmp[0]][tmp[1]]=="#":
                    color_cnt_tmp[0]+=1
                else:
                    color_cnt_tmp[1]+=1

                for (ny,nx) in [(0,1),(1,0),(-1,0),(0,-1)]:
                    my=ny+tmp[0]
                    mx=nx+tmp[1]
                    if 0<=my<h and 0<=mx<w:
                        if group[my][mx]==0:
                            if maze[tmp[0]][tmp[1]]!=maze[my][mx]:
                                stack.append((my,mx))
                                group[my][mx]=group_no
            color_cnt.append(color_cnt_tmp)

ans=0
for (b,w) in color_cnt:
    ans+=b*w

print(ans)
Problem p03324 (python)

Fixed submission:
d,n=map(int,input().split())

if d==0:
  cnt=0
  i=1
  while 1:
    if i%100!=0:
      cnt+=1
    if cnt==n:
      print(i)
      exit()
    i+=1
else:
  cnt=0
  i=1
  waru=100**d
  while 1:
    if i%waru==0 and (i//waru)%100 !=0 :
      cnt+=1
    if cnt==n:
      print(i)
      exit()
    i+=1

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

if d==0:
  cnt=0
  i=1
  while 1:
    if i%100!=0:
      cnt+=1
    if cnt==n:
      print(i)
      exit()
    i+=1
elif
  cnt=0
  i=1
  waru=100**d
  while 1:
    if i%waru==0 and (i//waru)%100 !=0 :
      cnt+=1
    if cnt==n:
      print(i)
      exit()
    i+=1

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

if d==0:
  cnt=0
  i=1
  while 1:
    if i%100!=0:
      cnt+=1
    if cnt==n:
      print(i)
      exit()
    i+=1
else:
  cnt=0
  i=1
  waru=100**d
  while 1:
    if i%waru==0 and (i*100)%!=0:
      cnt+=1
    if cnt==n:
      print(i)
      exit()
    i+=1
Problem p03340 (python)

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

ll=0
rr=0
llrr=0

result=0

for ll in range(n):

    while rr<n and a[rr]&llrr==0:
        llrr+=a[rr]
        rr+=1
    result+=rr-ll
    llrr=llrr^a[ll]

print(result)

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

ll=0
rr=0
llrr=0

result=0

for ll in range(n):

    while rr<n and a[rr]&llrr==0:
        rr+=1
        b+=a[rr]
    result+=r-list
    b=b^a[ll]

print(result)
Problem p03380 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)

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

if n==2:
    print(aa[0],aa[1])
    exit()

aa.sort()

nn=max(aa)

c=0
tmp=10**9

for a in aa:
    if abs(nn/2.0-a)<tmp:
        tmp=abs(nn/2.0-a)
        c=a

print(nn,c)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)

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

if n==2:
    print(aa[0],aa[1])
    exit()

aa.sort()

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 10**9+7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

import bisect
ans=0
(a,b)=(0,0)

for item in aa[:n//2+1]:
    i=bisect.bisect_left(aa,item*2)
    tmp=cmb(aa[min(n-1,i)],item,p)
    #print(aa[min(n-1,i)],item,tmp)
    if ans<tmp:
        ans=tmp
        (a,b)=(aa[min(n-1,i)],item)
    

print(a,b)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)


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

a.sort()
nn=a[-1]

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 998244353
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
#cmb(n-1, pair, p)

result=0
for i in range(1,len(a)):
    if a[i-1]<nn//2 and a[i]>=nn//2:
        if a[i]==nn:
            print(nn,a[i-1])
            exit()
        if cmb(nn,a[i-1],1)>cmb(nn,a[i],1):
            print(nn,a[i-1])
        else:
            print(nn,a[i])

        exit()

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

a.sort()
nn=a[-1]

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 998244353
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
#cmb(n-1, pair, p)

result=0
for i in range(1,len(a)):
    if a[i-1]<nn//2 and a[i]>=nn//2:
        if a[i]==nn:
            print(nn,a[i-1])
            exit()
        if cmb(nn,a[i-1],1)>cmb(nn,a[i],1):
            print(nn,a[i-1])
        else:
            print(nn,a[i])

        exit()
Problem p03436 (python)

Fixed submission:
h,w=map(int,input().split())
sx,sy=0,0
gx,gy=w-1,h-1

maze=[]
white=0
for _ in range(h):
    temp=input()
    t=[]
    for s in temp:
        t.append(s)
        if s==".":
            white+=1
    maze.append(t)

maze[sy][sx]=1

from collections import deque
fifo = deque()
fifo.append([sy,sx])

result=-1

while len(fifo)>0:
    temp=fifo.popleft()
    y,x=temp[0],temp[1]

    if y==gy and x==gx:
        result=maze[y][x]

    if y>0:
        if maze[y-1][x]==".":
            fifo.append([y-1,x])
            maze[y-1][x]=maze[y][x]+1
    if y<h-1:
        if maze[y+1][x]==".":
            fifo.append([y+1,x])
            maze[y+1][x]=maze[y][x]+1
    if x>0:
        if maze[y][x-1]==".":
            fifo.append([y,x-1])
            maze[y][x-1]=maze[y][x]+1
    if x<w-1:
        if maze[y][x+1]==".":
            fifo.append([y,x+1])
            maze[y][x+1]=maze[y][x]+1



if result==-1:
    print(result)
else:
    print(white-result)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())

s=[list(input()) for _ in range(h)]

black_cnt=0
for ss in s:
    black_cnt+=ss.count("#")

from collections import deque
stack=deque([(0,0)])
s[0][0]=1

while len(stack)>0:
    #print(stack)
    tmp=stack.popleft()
    if tmp[0]==h-1 and tmp[1]==w-1:
        break

    for (my,mx) in [(1,0),(0,1),(-1,0),(0,-1)]:
        ny=tmp[0]+my
        nx=tmp[1]+mx
        #print(ny,nx)
        if 0<=ny and ny<h and 0<=nx and nx<w:
            #print(ny,nx)
            if s[ny][nx]==".":
                #print(ny,nx,tmp[0],tmp[1],stack)
                s[ny][nx]=s[tmp[0]][tmp[1]]+1
                stack.append((ny,nx))

#for item in s:
 #   print(item)

print(h*w-s[-1][-1]-black_cnt)
Problem p03438 (python)

Fixed submission:
n=int(input())

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

#a.sort()
#b.sort()

if a==b:
    print("Yes")
    exit()

suma=sum(a)
sumb=sum(b)


#sum(a)+2*k=sum(b)+k
#k=(sum(a)-sum(b))

k=sumb-suma
#
#1 1 1 6
#2 2 2 3

cnta=0
cntb=0
for i in range(n):
    if a[i]>b[i]:
        cntb+=a[i]-b[i]
    elif a[i]<b[i]:
        cnta+=(-1)*((a[i]-b[i])//2)
#print(k,cntb,cnta)
if cntb<=k and cnta<=k:
    print("Yes")
else:
    print("No")

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

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

a.sort()
b.sort()

#sum(a)+2*k=sum(b)+k
#k=(sum(a)-sum(b))

k=suma-sumb
#
#1 1 1 6
#2 2 2 3

cnt=0
for i in range(n):
    if a[i]>b[i]:
        cnt+=b[i]-a[i]
    elif a[i]<b[i]:
        cnt+=(-1)*((a[i]-b[i])//2)

if cnt>=k:
    print("Yes")
else:
    print("No")
Problem p03546 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)

h,w=map(int,input().split())

#change[i][j]はiをjに変えるコスト
change=[list(map(int, input().split())) for i in range(10)]
test_case=[list(map(int, input().split())) for i in range(h)]
cost=[0]*10

for i in range(10):
    cost[i]=change[i][1]
#print(cost)
def DEF(start,backed,weight,non_used):
    global cost,change
    #print(backed,non_used)
    if non_used==[]:
        return 0

    for item in non_used:
        if weight+change[backed][item]+change[item][1]<cost[start]:
            cost[start]=weight+change[backed][item]+change[item][1]
        if weight+change[backed][item]<cost[start]:
            non_used2=[]
            for t in non_used:
                if t!=item:
                    non_used2.append(t)

            DEF(start,item,weight+change[backed][item],non_used2)

for item in range(10):
    if item!=1:

        temp=[]
        for i in range(10):
            if item!=i and i!=1:
                temp.append(i)
        #print("######",item,temp)
        DEF(item,item,0,temp)

result=0
for item in test_case:
    for item2 in item:
        if item2!=1 and item2!=-1:
            result+=cost[item2]

print(result)

Buggy submission (verdict: Runtime Error):
3 5
0 4 3 6 2 7 2 5 3 3
4 0 5 3 7 5 3 7 2 7
5 7 0 7 2 9 3 2 9 1
3 6 2 0 2 4 6 4 2 3
3 5 7 4 0 6 9 7 6 7
9 8 5 2 2 0 4 7 6 5
5 4 6 3 2 3 0 5 4 3
3 6 2 3 4 2 4 0 8 9
4 6 5 4 3 5 3 2 0 8
2 1 3 4 5 7 8 6 4 0
3 5 2 6 1
2 5 3 2 1
6 9 2 5 6
Problem p03550 (python)

Fixed submission:
n,z,w=map(int,input().split())
card=list(map(int,input().split()))

if n==1:
  print(abs(card[0]-w))
else:
  print(max(abs(card[-2]-card[-1]),abs(card[-1]-w)))

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

if n==1:
  print(abs(card[0]-w))
else:
  print(max(abs(n[-2]-n[-1]),abs(n[-1]-w)))
Problem p03565 (python)

Fixed submission:
s=list(input())
t=input()

for i in range(len(s)-len(t)+1):
    flag=0
    i=len(s)-len(t)-i
    #print(i)
    for j in range(len(t)):
        if t[j]!=s[i+j] and s[i+j]!="?":
            flag=1
            #print(j,t[j],s[i+j])
    if flag==0:
        for j in range(len(t)):
            s[i+j]=t[j]
        result=""
        for item in s:
            result=result+str(item)
        result=result.replace("?","a")
        print(result)
        exit()
print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
#https://atcoder.jp/contests/abc076/tasks/abc076_c

s=input()
t=input()

for i in range(len(s)-len(t)+1):
    flag=0
    n= len(s)-i-len(t)
    temp=s[n:n+len(t)]
    for j in range(len(t)):
        if temp[j]!=t[j] and temp[j]!="?":
            flag=1
    if flag==0:
        break

if flag==1:
    print("UNRESTORABLE")
    exit()
temp=s[:n]+t+s[n+len(t):]
print(temp.replace("?","a"))
Problem p03626 (python)

Fixed submission:
n=int(input())
s1=input()
s2=input()

mod=1000000007

x=0
cnt=1
while x<n:
    if x==0:
        if s1[x]==s2[x]:
            cnt*=3%mod
            x+=1
        else:
            cnt*=6%mod
            x+=2
    else:
        if s1[x-1]==s2[x-1]:
            #x-1:AA 
            #x  :BB CC
            if s1[x]==s2[x]:
                cnt*=2%mod
                x+=1
            #x-1:AA 
            #x  :BC  CB
            #    BC  CB
            else:
                cnt*=2%mod
                x+=2
        else:
            #x-1:AB
            #   :CC
            if s1[x]==s2[x]:
                cnt*=1%mod
                x+=1
            #x-1:AB
            #x  :BA CA BC 
            else:
                cnt*=3%mod
                x+=2

print(cnt%mod)

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

mod=1000000007

x=0
cnt=1
while x<3:
    if x==0:
        if s1[x]==s2[x]:
            cnt*=3%mod
            x+=1
        else:
            cnt*=6%mod
            x+=2
    else:
        if s1[x-1]==s2[x-1]:
            #x-1:AA 
            #x  :BB CC
            if s1[x]==s2[x]:
                cnt*=2%mod
                x+=1
            #x-1:AA 
            #x  :BC  CB
            #    BC  CB
            else:
                cnt*=2%mod
                x+=2
        else:
            #x-1:AB
            #   :CC
            if s1[x]==s2[x]:
                cnt*=1%mod
                x+=1
            #x-1:AB
            #x  :BA CA BC 
            else:
                cnt*=3%mod
                x+=2

print(cnt%mod)
Problem p03651 (python)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
import fractions
a.sort()
#9,4,3>7
#9-(9-4-3)
#9 ;6 3 >5
if k in a:
    print("POSSIBLE")
    exit()

if k>a[-1]:
    print("IMPOSSIBLE")
    exit()

if a[0]==1:
    print("POSSIBLE")
    exit()

flag=0
gg = fractions.gcd(a[0], a[1])

for item in a[1:]:
    if item%gg!=0:
        flag=1

if flag==1:
    print("POSSIBLE")
    exit()
else:
    if k%gg==0:
        print("POSSIBLE")
        exit()
    else:
        print("IMPOSSIBLE")
        exit()

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

a.sort()
#9,4,3>7
#9-(9-4-3)


#9 ;6 3 >5
if k in a:
    print("POSSIBLE")
    exit()

if k>a[-1]:
    print("IMPOSSIBLE")
    exit()

if a[0]==1:
    print("POSSIBLE")
    exit()

flag=0
for item in a[1:]:
    if item%a[0]!=0:
        flag=1

if flag==1:
    print("POSSIBLE")
    exit()
else:
    if k%item[0]==0:
        print("POSSIBLE")
        exit()
    else:
        print("IMPOSSIBLE")
        exit()
Problem p03994 (python)

Fixed submission:
s=input()
k=int(input())

result=""
for ss in s:
    if ss=="a":
        result+="a"
    else:
        if k>= 123 - ord(ss):
            k-=123-ord(ss)
            result+="a"
        else:
            result+=ss


if k>0:
    k=k%(123-97)
    temp=chr((((ord(result[-1])-97)+k)%(123-97))+97)
    print(result[:-1]+temp)
else:
    print(result)

#print(ord("a")):97
#print(ord("b")):98
#print(ord("z")):122
#97ならそのまま
#aにするには123-ord()をすればいい

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())

result=""
for ss in s:
    if ss=="a":
        result+="a"
    else:
        if k>= 123 - ord(ss):
            k-=123-ord(ss)
            result+="a"
        else:
            result+=ss


if k>0:
    k=k%(123-97)
    temp=chr((((ord(result[-1])-97)+k)%(123-97))+97)
    
print(result[:-1]+temp)

#print(ord("a")):97
#print(ord("b")):98
#print(ord("z")):122
#97ならそのまま
#aにするには123-ord()をすればいい

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())

result=""
for ss in s:
    if ss=="a":
        result+="a"
    else:
        if k>= 123 - ord(ss):
            k-=123-ord(ss)
            result+="a"
        else:
            result+=ss



print(result[:-1]+chr(ord(result[-1])+k))

#print(ord("a")):97
#print(ord("b")):98
#print(ord("z")):122
#97ならそのまま
#aにするには123-ord()をすればいい
Problem p04032 (python)

Fixed submission:
s=input()

#長さ2
#xx
#長さ3
#xxy←長さ2に内包,yxx,xyx
#長さ5:xyxzx　←長さ３に内包

if len(s)==2:
    if s[0]==s[1]:
        print(1,2)
        exit()

for i in range(len(s)-2):
    if s[i]==s[i+1]:
        print(i+1,i+1+1)
        exit()
    elif s[i]==s[i+2]:
        print(i+1,i+2+1)
        exit()

print(-1,-1)

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

#長さ2
#xx
#長さ3
#xxy←長さ2に内包,yxx,xyx
#長さ5:xyxzx　←長さ３に内包

if len(s)==2:
    if s[i]+s[i+1]:
        print(1,2)
        exit()

for i in range(len(s)-2):
    if s[i]==s[i+1]:
        print(i+1,i+1+1)
        exit()
    elif s[i]==s[i+2]:
        print(i+1,i+2+1)
        exit()

print(-1,-1)
Problem p02642 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
m = max(a) + 10
li = [0]*m 
for x in a:
    li[x] += 1
ans = 0
for i in range(1,m):
    if li[i]: 
        if li[i]==1: 
            ans += 1 
        for j in range(i,m,i): 
            li[j] = 0
print(ans)

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

D = [0] * (10**6 + 1)
A.sort()
for i in range(N):
    D[A[i]] += 1
    
ans = 0
for i in range(1, 10**6+1):
    if D[i]:
        if D[i]==1:
            ans += 1
        for j in range(i,m,i):
            D[j] = 0
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
m = max(a)
li = [0]*m 
for x in a:
    li[x] += 1
ans = 0
for i in range(1,m):
    if li[i]: 
        if li[i]==1: 
            ans += 1 
        for j in range(i,m,i): 
            li[j] = 0
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
m = max(a)
li = [0]*m 
for x in a:
    li[x] += 1
ans = 0
for i in range(1,m):
    if li[i]: 
        if li[i]==1: 
            ans += 1 
        for j in range(i,m,i): 
            li[j] = 0
Problem p02713 (python)

Fixed submission:
from math import gcd
ans = 0
n = int(input())

for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            l = gcd(i,j)
            ans += gcd(k,l)
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
K = int(input())
 
c = 0
for i in range(1,K+1):
    for j in range(1,K+1):
      k = gcd(i,j)
        for l in range(1,K+1):
            a = gcd(k, l)
            c += a
 
print(c)